Skip to content

Commit 2cdf0ff

Browse files
committedJun 12, 2013
Play player_damage.ogg when recieving damage and additionally play player_falling_damage.ogg when recieving falling damage
1 parent 7734717 commit 2cdf0ff

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed
 

‎src/environment.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
4040
#ifndef SERVER
4141
#include "clientmap.h"
4242
#include "localplayer.h"
43+
#include "event.h"
4344
#endif
4445
#include "daynightratio.h"
4546
#include "map.h"
@@ -2190,8 +2191,11 @@ void ClientEnvironment::step(float dtime)
21902191
{
21912192
f32 damage_f = (speed - tolerance)/BS * post_factor;
21922193
u16 damage = (u16)(damage_f+0.5);
2193-
if(damage != 0)
2194+
if(damage != 0){
21942195
damageLocalPlayer(damage, true);
2196+
MtEvent *e = new SimpleTriggerEvent("PlayerFallingDamage");
2197+
m_gamedef->event()->put(e);
2198+
}
21952199
}
21962200
}
21972201

‎src/game.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,18 @@ class SoundMaker
729729
sm->m_sound->playSound(sm->m_ndef->get(nde->n).sound_dug, false);
730730
}
731731

732+
static void playerDamage(MtEvent *e, void *data)
733+
{
734+
SoundMaker *sm = (SoundMaker*)data;
735+
sm->m_sound->playSound(SimpleSoundSpec("player_damage", 0.5), false);
736+
}
737+
738+
static void playerFallingDamage(MtEvent *e, void *data)
739+
{
740+
SoundMaker *sm = (SoundMaker*)data;
741+
sm->m_sound->playSound(SimpleSoundSpec("player_falling_damage", 0.5), false);
742+
}
743+
732744
void registerReceiver(MtEventManager *mgr)
733745
{
734746
mgr->reg("ViewBobbingStep", SoundMaker::viewBobbingStep, this);
@@ -737,6 +749,8 @@ class SoundMaker
737749
mgr->reg("CameraPunchLeft", SoundMaker::cameraPunchLeft, this);
738750
mgr->reg("CameraPunchRight", SoundMaker::cameraPunchRight, this);
739751
mgr->reg("NodeDug", SoundMaker::nodeDug, this);
752+
mgr->reg("PlayerDamage", SoundMaker::playerDamage, this);
753+
mgr->reg("PlayerFallingDamage", SoundMaker::playerFallingDamage, this);
740754
}
741755

742756
void step(float dtime)
@@ -2202,6 +2216,9 @@ void the_game(
22022216
player->hurt_tilt_timer = 1.5;
22032217
player->hurt_tilt_strength = event.player_damage.amount/2;
22042218
player->hurt_tilt_strength = rangelim(player->hurt_tilt_strength, 2.0, 10.0);
2219+
2220+
MtEvent *e = new SimpleTriggerEvent("PlayerDamage");
2221+
gamedef->event()->put(e);
22052222
}
22062223
else if(event.type == CE_PLAYER_FORCE_MOVE)
22072224
{

0 commit comments

Comments
 (0)
Please sign in to comment.