Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-11-23 15:31:34 +0000
committerStijn Buys <ingar@osirion.org>2013-11-23 15:31:34 +0000
commitba3c01738cba3a842b2fe02f6b0f4e5fec454179 (patch)
tree0814236c44c48e21eade3732006305f66ca9d5a4
parent93bb759aeb71537a98386693918b28b37961a103 (diff)
Play sounds when getting hit.
-rw-r--r--src/client/soundext.cc22
-rw-r--r--src/game/base/ship.cc15
2 files changed, 32 insertions, 5 deletions
diff --git a/src/client/soundext.cc b/src/client/soundext.cc
index 09c83d8..dd86a70 100644
--- a/src/client/soundext.cc
+++ b/src/client/soundext.cc
@@ -295,6 +295,18 @@ void SoundExt::frame(float elapsed)
pitch = 1.0f;
gain = 0.0f; // loop buffer gain
+ } else if (controlable->state() == core::Entity::Docked) {
+
+ if (state_engineloopbuffer) {
+ audio::stop(state_engineloopsource);
+ state_engineloopbuffer = 0;
+ }
+ if (state_engineeventbuffer) {
+ audio::stop(state_engineeventsource);
+ state_engineeventbuffer = 0;
+ }
+ gain = 0.0f; // loop buffer gain
+
} else {
if ((state_engineeventbuffer == state_impulsestartbuffer) || (state_engineeventbuffer == state_impulseloopbuffer)) {
@@ -310,11 +322,13 @@ void SoundExt::frame(float elapsed)
}
}
- audio::update_source(state_engineloopsource,
- controlable->location() - controlable->axis().forward() * r ,velocity, pitch, gain);
+ if (state_engineloopbuffer) {
+ audio::update_source(state_engineloopsource, controlable->location() - controlable->axis().forward() * r ,velocity, pitch, gain);
+ }
- audio::update_source(state_engineeventsource,
- controlable->location() - controlable->axis().forward() * r , velocity);
+ if (state_engineeventbuffer) {
+ audio::update_source(state_engineeventsource, controlable->location() - controlable->axis().forward() * r , velocity);
+ }
} else if (entity()->type() == core::Entity::Dynamic) {
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");
+ }
+ }
}
}
}