From ba3c01738cba3a842b2fe02f6b0f4e5fec454179 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 23 Nov 2013 15:31:34 +0000 Subject: Play sounds when getting hit. --- src/game/base/ship.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/game/base') 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"); + } + } } } } -- cgit v1.2.3