From 51ccb6bc25f5d74c533eb3f092803fdb2db136fd Mon Sep 17 00:00:00 2001 From: driAn Date: Fri, 4 Jan 2008 14:33:54 +0000 Subject: [PATCH] crouch footsteps git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1558 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/renderhud.cpp | 6 ++---- source/src/sound.cpp | 23 ++++++++++++++--------- source/src/sound.h | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index ebcb385f..a58ae78c 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -153,8 +153,7 @@ void drawdmgindicator() { if(!damageindicatorsize) return; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - static Texture *tex = NULL; - if(!tex) tex = textureload("packages/misc/damageindicator.png"); + glDisable(GL_TEXTURE_2D); float size = (float)damageindicatorsize; loopi(4) { @@ -167,15 +166,14 @@ void drawdmgindicator() glTranslatef(0, (float)-damageindicatordist, 0); glScalef(max(0.0f, 1.0f-t), max(0.0f, 1.0f-t), 0); - glDisable(GL_TEXTURE_2D); glBegin(GL_TRIANGLES); glVertex3f(size/2.0f, size/2.0f, 0.0f); glVertex3f(-size/2.0f, size/2.0f, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f); glEnd(); - glEnable(GL_TEXTURE_2D); glPopMatrix(); } + glEnable(GL_TEXTURE_2D); } void drawequipicons() diff --git a/source/src/sound.cpp b/source/src/sound.cpp index 5384dd12..96ae943e 100644 --- a/source/src/sound.cpp +++ b/source/src/sound.cpp @@ -276,11 +276,11 @@ int findsoundloc(int sound, physent *p) void checkplayerloopsounds() { - if(findsoundloc(S_FOOTSTEPS, player1) == -1) - { - conoutf("play %d", lastmillis); - playsound(S_FOOTSTEPS, player1); - } + int fsl = findsoundloc(S_FOOTSTEPS, player1); + int csl = findsoundloc(S_FOOTSTEPSCROUCH, player1); + if(fsl == -1) playsound(S_FOOTSTEPS, player1); + if(csl == -1 || (!soundlocs[csl].inuse && player1->crouching)) playsound(S_FOOTSTEPSCROUCH, player1); + loopv(players) { playerent *p = players[i]; @@ -337,16 +337,21 @@ void updatechanvol(int chan, int svol, soundloc *sl) } if(sl->pse) // control looping physent sound volume { - if(sl->slot == &gamesounds[S_FOOTSTEPS]) // control footsteps + if(sl->pse->type == ENT_PLAYER || sl->pse->type == ENT_BOT) { - if(sl->pse->type == ENT_PLAYER || sl->pse->type == ENT_BOT) + if(sl->slot == &gamesounds[S_FOOTSTEPS]) // control footsteps { playerent *p = (playerent *)sl->pse; - ASSERT(p); - bool nofootsteps = !footsteps || p->state != CS_ALIVE || lastmillis-p->lastpain < 300 || (!p->onfloor && p->timeinair>50) || (!p->move && !p->strafe); + bool nofootsteps = !footsteps || p->state != CS_ALIVE || lastmillis-p->lastpain < 300 || (!p->onfloor && p->timeinair>50) || (!p->move && !p->strafe) || p->crouching; if(nofootsteps) vol = 0; // fade out instead? else if(p==player1) vol = vol*3/5; // dampen local footsteps } + else if(sl->slot == &gamesounds[S_FOOTSTEPSCROUCH]) // control crouching + { + playerent *p = (playerent *)sl->pse; + if(!p->crouching) vol = 0; + else if(p==player1) vol = vol*3/5; + } } } if(stereo && (v.x != 0 || v.y != 0) && dist>0) diff --git a/source/src/sound.h b/source/src/sound.h index a75b5659..de04a92e 100644 --- a/source/src/sound.h +++ b/source/src/sound.h @@ -21,7 +21,7 @@ enum S_GRENADEPULL, S_GRENADETHROW, S_RAKIMBO, S_GUNCHANGE, S_GIB, S_HEADSHOT, S_CALLVOTE, S_VOTEPASS, S_VOTEFAIL, - S_FOOTSTEPS, + S_FOOTSTEPS, S_FOOTSTEPSCROUCH, S_NULL };