From becb40d75c07cffdd370a455116970bb0f8e114b Mon Sep 17 00:00:00 2001 From: driAn Date: Mon, 2 Jun 2008 19:00:55 +0000 Subject: [PATCH] tinnitus fx git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2142 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/sound.cpp | 23 ++++++++++++----------- source/src/sound.h | 2 ++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/source/src/sound.cpp b/source/src/sound.cpp index 526eb6ce..f8a850f5 100644 --- a/source/src/sound.cpp +++ b/source/src/sound.cpp @@ -814,17 +814,13 @@ void updateplayerfootsteps(playerent *p, int sound) else if(loc) loc->reset(); // out of range, stop it } -void updateplayerunderwater(playerent *p) +void updateloopsound(int sound, bool active, float vol = 1.0f) { - if(!p) return; - bool water = p->inwater; - location *l = findsoundloc(S_UNDERWATER, p); - if(p==player1) - { - if(!l && water) playsound(S_UNDERWATER, p, NULL, NULL, SP_HIGH); // start - else if(l && !water) l->reset(); // stop - } - // put other water sounds here + if(camera1->type != ENT_PLAYER) return; + location *l = findsoundloc(sound, camera1); + if(!l && active) playsound(sound, NULL, NULL, NULL, SP_HIGH); + else if(l && !active) l->reset(); + if(l && vol != 1.0f) l->gain(vol); } void checkplayerloopsounds() @@ -840,8 +836,13 @@ void checkplayerloopsounds() updateplayerfootsteps(p, S_FOOTSTEPSCROUCH); } + bool alive = player1->state!=CS_DEAD; // water - updateplayerunderwater(player1); + updateloopsound(S_UNDERWATER, alive && player1->inwater); + // tinnitus + bool tinnitus = alive && player1->eardamagemillis>0 && lastmillis<=player1->eardamagemillis; + float tinnitusvol = tinnitus ? 1.0f-(player1->eardamagemillis-lastmillis/250.0f) : 1.0f; + updateloopsound(S_TINNITUS, tinnitus, tinnitusvol); } void updatevol() diff --git a/source/src/sound.h b/source/src/sound.h index a8c93a8c..e8184faf 100644 --- a/source/src/sound.h +++ b/source/src/sound.h @@ -24,6 +24,8 @@ enum S_FOOTSTEPS, S_FOOTSTEPSCROUCH, S_MENUSELECT, S_MENUENTER, S_UNDERWATER, + S_TINNITUS, + S_AFFIRMATIVE, S_ALLRIGHTSIR, S_COMEONMOVE,