Play damage sound on player death (#7679)

Also run CSM 'on_damage_taken' callback.
Improve function logic and remove 'return'.
This commit is contained in:
Paramat 2018-08-28 23:23:04 +01:00 committed by GitHub
parent 34f940dcca
commit dcd1a15545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2492,22 +2492,23 @@ void Game::handleClientEvent_None(ClientEvent *event, CameraOrientation *cam)
void Game::handleClientEvent_PlayerDamage(ClientEvent *event, CameraOrientation *cam) void Game::handleClientEvent_PlayerDamage(ClientEvent *event, CameraOrientation *cam)
{ {
if (client->getHP() == 0)
return;
if (client->moddingEnabled()) { if (client->moddingEnabled()) {
client->getScript()->on_damage_taken(event->player_damage.amount); client->getScript()->on_damage_taken(event->player_damage.amount);
} }
runData.damage_flash += 95.0 + 3.2 * event->player_damage.amount; // 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); 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_timer = 1.5f;
player->hurt_tilt_strength = player->hurt_tilt_strength =
rangelim(event->player_damage.amount / 4, 1.0f, 4.0f); rangelim(event->player_damage.amount / 4.0f, 1.0f, 4.0f);
}
// Play damage sound
client->getEventManager()->put(new SimpleTriggerEvent(MtEvent::PLAYER_DAMAGE)); client->getEventManager()->put(new SimpleTriggerEvent(MtEvent::PLAYER_DAMAGE));
} }