summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorParamat <paramat@users.noreply.github.com>2018-08-28 23:23:04 +0100
committerGitHub <noreply@github.com>2018-08-28 23:23:04 +0100
commitdcd1a15545c3a8e6ec9bdabd1358f808a1214314 (patch)
tree3c88ec17385c5190ad173ab79af1c19029c2f49e /src/game.cpp
parent34f940dccae53ac62177d2555c63688fce90519d (diff)
downloadminetest-dcd1a15545c3a8e6ec9bdabd1358f808a1214314.tar.gz
minetest-dcd1a15545c3a8e6ec9bdabd1358f808a1214314.tar.bz2
minetest-dcd1a15545c3a8e6ec9bdabd1358f808a1214314.zip
Play damage sound on player death (#7679)
Also run CSM 'on_damage_taken' callback. Improve function logic and remove 'return'.
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 005241495..fbfbdd547 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -2492,22 +2492,23 @@ void Game::handleClientEvent_None(ClientEvent *event, CameraOrientation *cam)
void Game::handleClientEvent_PlayerDamage(ClientEvent *event, CameraOrientation *cam)
{
- if (client->getHP() == 0)
- return;
-
if (client->moddingEnabled()) {
client->getScript()->on_damage_taken(event->player_damage.amount);
}
- runData.damage_flash += 95.0 + 3.2 * event->player_damage.amount;
- runData.damage_flash = MYMIN(runData.damage_flash, 127.0f);
+ // Damage flash and hurt tilt are not used at death
+ if (client->getHP() > 0) {
+ runData.damage_flash += 95.0f + 3.2f * event->player_damage.amount;
+ runData.damage_flash = MYMIN(runData.damage_flash, 127.0f);
- LocalPlayer *player = client->getEnv().getLocalPlayer();
+ LocalPlayer *player = client->getEnv().getLocalPlayer();
- player->hurt_tilt_timer = 1.5;
- player->hurt_tilt_strength =
- rangelim(event->player_damage.amount / 4, 1.0f, 4.0f);
+ player->hurt_tilt_timer = 1.5f;
+ player->hurt_tilt_strength =
+ rangelim(event->player_damage.amount / 4.0f, 1.0f, 4.0f);
+ }
+ // Play damage sound
client->getEventManager()->put(new SimpleTriggerEvent(MtEvent::PLAYER_DAMAGE));
}