aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPilzAdam <pilzadam@minetest.net>2013-04-17 20:13:47 +0200
committerPilzAdam <pilzadam@minetest.net>2013-06-12 20:27:06 +0000
commit2cdf0ff4abaa045545440c8694b47371766a7b64 (patch)
tree1b01148e29b36a63d40449d17d83edb875fcb87d /src
parent773471750dbea73431934ac3736c23564da986b5 (diff)
downloadminetest-2cdf0ff4abaa045545440c8694b47371766a7b64.tar.gz
minetest-2cdf0ff4abaa045545440c8694b47371766a7b64.tar.bz2
minetest-2cdf0ff4abaa045545440c8694b47371766a7b64.zip
Play player_damage.ogg when recieving damage and additionally play player_falling_damage.ogg when recieving falling damage
Diffstat (limited to 'src')
-rw-r--r--src/environment.cpp6
-rw-r--r--src/game.cpp17
2 files changed, 22 insertions, 1 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index ab6a6d3d3..af05371ca 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -40,6 +40,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef SERVER
#include "clientmap.h"
#include "localplayer.h"
+#include "event.h"
#endif
#include "daynightratio.h"
#include "map.h"
@@ -2190,8 +2191,11 @@ void ClientEnvironment::step(float dtime)
{
f32 damage_f = (speed - tolerance)/BS * post_factor;
u16 damage = (u16)(damage_f+0.5);
- if(damage != 0)
+ if(damage != 0){
damageLocalPlayer(damage, true);
+ MtEvent *e = new SimpleTriggerEvent("PlayerFallingDamage");
+ m_gamedef->event()->put(e);
+ }
}
}
diff --git a/src/game.cpp b/src/game.cpp
index 2d43d05b8..baf161e88 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -729,6 +729,18 @@ public:
sm->m_sound->playSound(sm->m_ndef->get(nde->n).sound_dug, false);
}
+ static void playerDamage(MtEvent *e, void *data)
+ {
+ SoundMaker *sm = (SoundMaker*)data;
+ sm->m_sound->playSound(SimpleSoundSpec("player_damage", 0.5), false);
+ }
+
+ static void playerFallingDamage(MtEvent *e, void *data)
+ {
+ SoundMaker *sm = (SoundMaker*)data;
+ sm->m_sound->playSound(SimpleSoundSpec("player_falling_damage", 0.5), false);
+ }
+
void registerReceiver(MtEventManager *mgr)
{
mgr->reg("ViewBobbingStep", SoundMaker::viewBobbingStep, this);
@@ -737,6 +749,8 @@ public:
mgr->reg("CameraPunchLeft", SoundMaker::cameraPunchLeft, this);
mgr->reg("CameraPunchRight", SoundMaker::cameraPunchRight, this);
mgr->reg("NodeDug", SoundMaker::nodeDug, this);
+ mgr->reg("PlayerDamage", SoundMaker::playerDamage, this);
+ mgr->reg("PlayerFallingDamage", SoundMaker::playerFallingDamage, this);
}
void step(float dtime)
@@ -2202,6 +2216,9 @@ void the_game(
player->hurt_tilt_timer = 1.5;
player->hurt_tilt_strength = event.player_damage.amount/2;
player->hurt_tilt_strength = rangelim(player->hurt_tilt_strength, 2.0, 10.0);
+
+ MtEvent *e = new SimpleTriggerEvent("PlayerDamage");
+ gamedef->event()->put(e);
}
else if(event.type == CE_PLAYER_FORCE_MOVE)
{