tinnitus fx

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2142 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2008-06-02 19:00:55 +00:00
parent 59e6a9b48e
commit becb40d75c
2 changed files with 14 additions and 11 deletions
+12 -11
View File
@@ -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()
+2
View File
@@ -24,6 +24,8 @@ enum
S_FOOTSTEPS, S_FOOTSTEPSCROUCH,
S_MENUSELECT, S_MENUENTER,
S_UNDERWATER,
S_TINNITUS,
S_AFFIRMATIVE,
S_ALLRIGHTSIR,
S_COMEONMOVE,