From cc585999b0a946ad3f626227f2b4f71912fa0961 Mon Sep 17 00:00:00 2001 From: driAn Date: Fri, 4 Jan 2008 20:26:37 +0000 Subject: [PATCH] crouch footstep fixes, weapon fixes git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1563 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 5 ++- source/src/menus.cpp | 7 +++-- source/src/protos.h | 1 - source/src/renderhud.cpp | 20 +++--------- source/src/sound.cpp | 65 +++++++++++++++++++-------------------- source/src/weapon.cpp | 8 +++-- 6 files changed, 49 insertions(+), 57 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 6f27529a..3f295ae2 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -30,7 +30,6 @@ extern int framesinmap; char *getclientmap() { return clientmap; } extern bool c2sinit, senditemstoserver; -extern int dblend; void setskin(playerent *pl, uint skin) { @@ -123,10 +122,12 @@ void newteam(char *name) } void newskin(int skin) { player1->nextskin = skin; } +int curteam() { return team_int(player1->team); } COMMANDN(team, newteam, ARG_1STR); COMMANDN(name, newname, ARG_1STR); COMMANDN(skin, newskin, ARG_1INT); +COMMAND(curteam, ARG_1EXP); void deathstate(playerent *pl) { @@ -139,7 +140,6 @@ void deathstate(playerent *pl) if(pl == player1) { - dblend = 0; showscores(true); setscope(false); if(editmode) toggleedit(); @@ -378,7 +378,6 @@ void dodamage(int damage, playerent *pl, playerent *actor, bool gib, bool local) if(pl==player1) { - //damageblend(damage); updatedmgindicator(actor->o); pl->damageroll(damage); } diff --git a/source/src/menus.cpp b/source/src/menus.cpp index ec9dbc73..3a5becd4 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -192,6 +192,8 @@ struct mitemtextinput : mitemtext setdefaultvalue(); modified = false; } + + virtual void select() { }; void setdefaultvalue() { @@ -299,6 +301,7 @@ struct mitemslider : mitem maxvaluewidth = max(text_width(curval), maxvaluewidth); } value = oldvalue; + displaycurvalue(); } }; @@ -468,7 +471,7 @@ void menuitemtextinput(char *text, char *value, char *action, char *hoveraction) void menuitemslider(char *text, char *min_, char *max_, char *value, char *step, char *display, char *action) { if(!lastmenu) return; - lastmenu->items.add(new mitemslider(lastmenu, newstring(text), atoi(min_), atoi(max_), atoi(step), value[0] ? newstring(value) : NULL, display[0] ? newstring(display) : NULL, action[0] ? newstring(action) : NULL, NULL)); + lastmenu->items.add(new mitemslider(lastmenu, newstring(text), atoi(min_), atoi(max_), atoi(step), newstring(value), display[0] ? newstring(display) : NULL, action[0] ? newstring(action) : NULL, NULL)); } void menuitemkeyinput(char *text, char *bindcmd) @@ -480,7 +483,7 @@ void menuitemkeyinput(char *text, char *bindcmd) void menuitemcheckbox(char *text, char *value, char *action) { if(!lastmenu) return; - lastmenu->items.add(new mitemcheckbox(lastmenu, newstring(text), newstring(value), newstring(action), NULL)); + lastmenu->items.add(new mitemcheckbox(lastmenu, newstring(text), newstring(value), action[0] ? newstring(action) : NULL, NULL)); } void menumdl(char *mdl, char *anim, char *rotspeed, char *scale) diff --git a/source/src/protos.h b/source/src/protos.h index 89e2e52a..e8200469 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -365,7 +365,6 @@ extern void pruneundos(int maxremain = 0); // renderhud extern void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater); -extern void damageblend(int n); extern void loadingscreen(const char *fmt = NULL, ...); extern void hudoutf(const char *s, ...); extern void show_out_of_renderloop_progress(float bar1, const char *text1, float bar2 = 0, const char *text2 = NULL); diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index a58ae78c..86420e93 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -52,10 +52,6 @@ void drawvoteicon(float x, float y, int col, int row, bool noblend) } VARP(crosshairsize, 0, 15, 50); - -int dblend = 0; -void damageblend(int n) { dblend += n; } - VARP(hidestats, 0, 1, 1); VARP(crosshairfx, 0, 1, 1); VARP(hideradar, 0, 0, 1); @@ -358,19 +354,12 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glOrtho(0, VIRTW, VIRTH, 0, -1, 1); glEnable(GL_BLEND); - if(dblend || underwater) + if(underwater) { glDepthMask(GL_FALSE); - if(dblend) - { - glBlendFunc(GL_ZERO, GL_SRC_COLOR); - glColor3f(1.0f, 0.1f, 0.1f); - } - else - { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4ub(hdr.watercolor[0], hdr.watercolor[1], hdr.watercolor[2], 102); - } + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4ub(hdr.watercolor[0], hdr.watercolor[1], hdr.watercolor[2], 102); glBegin(GL_QUADS); glVertex2i(0, 0); glVertex2i(VIRTW, 0); @@ -378,7 +367,6 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glVertex2i(0, VIRTH); glEnd(); glDepthMask(GL_TRUE); - dblend = max(0, dblend-curtime/3); } glEnable(GL_TEXTURE_2D); diff --git a/source/src/sound.cpp b/source/src/sound.cpp index 96ae943e..cdc65dc5 100644 --- a/source/src/sound.cpp +++ b/source/src/sound.cpp @@ -265,8 +265,6 @@ void checkmapsounds() } VAR(footsteps, 0, 1, 1); -VAR(footstepradius, 0, 16, 25); -VAR(footstepalign, 5, 15, 4000); int findsoundloc(int sound, physent *p) { @@ -274,6 +272,31 @@ int findsoundloc(int sound, physent *p) return -1; } +void updateplayerfootsteps(playerent *p, int sound) +{ + const int footstepradius = 16, footstepalign = 15; + int idx = findsoundloc(sound, p); + bool inuse = (idx >= 0 && soundlocs[idx].inuse); + + if(camera1->o.dist(p->o) < footstepradius && footsteps) + { + if(!inuse) // start sound + { + // sync to model animation + int basetime = -((int)(size_t)p&0xFFF); + int time = lastmillis-basetime; + int speed = int(1860/p->maxspeed); + // TODO: share with model code + if(time%speed < footstepalign) playsound(sound, p); + } + } + else if(inuse) // stop sound + { + Mix_HaltChannel(idx); + soundlocs[idx].sleep(); + } +} + void checkplayerloopsounds() { int fsl = findsoundloc(S_FOOTSTEPS, player1); @@ -285,27 +308,8 @@ void checkplayerloopsounds() { playerent *p = players[i]; if(!p) continue; - - int idx = findsoundloc(S_FOOTSTEPS, p); - bool inuse = (idx >= 0 && soundlocs[idx].inuse); - - if(camera1->o.dist(p->o) < footstepradius && footsteps) - { - if(!inuse) // start sound - { - // sync to model animation - int basetime = -((int)(size_t)p&0xFFF); - int time = lastmillis-basetime; - int speed = int(1860/p->maxspeed); - // TODO: share with model code - if(time%speed < footstepalign) playsound(S_FOOTSTEPS, p); - } - } - else if(inuse) // stop sound - { - Mix_HaltChannel(idx); - soundlocs[idx].sleep(); - } + updateplayerfootsteps(p, S_FOOTSTEPS); + updateplayerfootsteps(p, S_FOOTSTEPSCROUCH); } } @@ -337,21 +341,16 @@ void updatechanvol(int chan, int svol, soundloc *sl) } if(sl->pse) // control looping physent sound volume { - if(sl->pse->type == ENT_PLAYER || sl->pse->type == ENT_BOT) + int s; + if(sl->slot == &gamesounds[(s=S_FOOTSTEPS)] || sl->slot == &gamesounds[(s=S_FOOTSTEPSCROUCH)]) // control footsteps { - if(sl->slot == &gamesounds[S_FOOTSTEPS]) // control footsteps + if(sl->pse->type == ENT_PLAYER || sl->pse->type == ENT_BOT) { playerent *p = (playerent *)sl->pse; - bool nofootsteps = !footsteps || p->state != CS_ALIVE || lastmillis-p->lastpain < 300 || (!p->onfloor && p->timeinair>50) || (!p->move && !p->strafe) || p->crouching; + bool nofootsteps = !footsteps || p->state != CS_ALIVE || lastmillis-p->lastpain < 300 || (!p->onfloor && p->timeinair>50) || (!p->move && !p->strafe) || (s==S_FOOTSTEPS && p->crouching) || (s==S_FOOTSTEPSCROUCH && !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) @@ -409,7 +408,7 @@ void updatevol() if(FSOUND_IsPlaying(i)) #endif updatechanvol(i, soundlocs[i].slot->vol, &sl); - else sl.sleep(); + else if(!sl.slot->loop) sl.sleep(); } #ifndef USE_MIXER diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 520de196..61565405 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -718,7 +718,11 @@ struct grenades : weapon 0); playsound(S_GRENADEPULL); } - else if(inhandnade && attackmillis>info.attackdelay && (!owner->attacking || !inhandnade->isalive(lastmillis))) thrownade(); + else if(inhandnade && attackmillis>info.attackdelay && (!owner->attacking || !inhandnade->isalive(lastmillis))) + { + vec n(0,0,0); + thrownade(owner->o, n, inhandnade); + } return true; } @@ -792,7 +796,7 @@ struct grenades : weapon bool selectable() { return weapon::selectable() && !inhand() && mag; } void reset() { throwmillis = 0; } - void onselecting() { reset(); } + void onselecting() { reset(); playsound(S_GUNCHANGE); } //void onammopicked() { reset(); } void onownerdies() {