panting sound when player is low on energy

This commit is contained in:
darkrose 2015-06-06 21:48:52 +10:00
parent 387057b3c6
commit 0081718a7c
5 changed files with 19 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

@ -744,7 +744,8 @@ LocalPlayer::LocalPlayer():
cold_effectf(0.0),
m_sneak_node(32767,32767,32767),
m_sneak_node_exists(false),
m_can_use_energy(true)
m_can_use_energy(true),
m_low_energy_effect(0)
{
m_energy = 10.0;
m_character = g_settings->get("character_definition");
@ -1107,8 +1108,22 @@ void LocalPlayer::applyControl(float dtime)
}else if (m_energy < -0.1) {
m_can_use_energy = false;
m_energy = -0.1;
if (g_sound) {
if (m_character == "")
m_character = std::string(PLAYER_DEFAULT_CHARDEF);
Strfnd f(m_character);
std::string gender = f.next(":");
std::string snd("low-energy-");
snd += gender;
m_low_energy_effect = g_sound->playSound(snd,true);
}
}else if (m_energy > 1.8) {
m_can_use_energy = true;
if (g_sound && m_low_energy_effect) {
g_sound->stopSound(m_low_energy_effect);
m_low_energy_effect = 0;
}
}
if (energy_effectf > 0.0)

View File

@ -540,6 +540,7 @@ private:
content_t m_old_node_below_type;
float m_energy;
bool m_can_use_energy;
int m_low_energy_effect;
};
#endif // !SERVER

View File

@ -120,6 +120,8 @@ void init_sounds(ISoundManager *sound)
// special
sound->loadSound("wield","wield_item.ogg");
sound->loadSound("low-energy-F","low_energy_F.ogg");
sound->loadSound("low-energy-M","low_energy_M.ogg");
// menu backgrounds
sound->loadSound("bg-mainmenu","bg_mainmenu.ogg");