diff options
author | Stijn Buys <ingar@osirion.org> | 2013-11-23 15:31:34 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2013-11-23 15:31:34 +0000 |
commit | ba3c01738cba3a842b2fe02f6b0f4e5fec454179 (patch) | |
tree | 0814236c44c48e21eade3732006305f66ca9d5a4 /src/game | |
parent | 93bb759aeb71537a98386693918b28b37961a103 (diff) |
Play sounds when getting hit.
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/base/ship.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc index 03c44aa..6a7ac56 100644 --- a/src/game/base/ship.cc +++ b/src/game/base/ship.cc @@ -713,7 +713,7 @@ void Ship::hit(core::Entity *other) explode(); if (owner()) { - // broadcast death message + // broadcast death message std::string message("^B"); message.append(owner()->name()); @@ -760,6 +760,19 @@ void Ship::hit(core::Entity *other) if (assassin) { assassin->sound("game/target_hit"); } + + // send got hit sound to owner + if (owner()) { + const float chance = math::randomf(100.0f); + + if (chance < 33.0f) { + owner()->sound("game/hit01"); + } else if (chance < 66.0f) { + owner()->sound("game/hit02"); + } else { + owner()->sound("game/hit03"); + } + } } } } |