From 82352713688e37e0ee2077b21e3eeb1b6e143578 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Mon, 3 Sep 2007 18:35:08 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1289 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/entity.h | 6 +++--- source/src/hudgun.cpp | 12 +++++------- source/src/weapon.cpp | 17 +++++++---------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/source/src/entity.h b/source/src/entity.h index afef9592..08a8d803 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -310,7 +310,7 @@ struct playerent : dynent, playerstate bool attacking; string name, team; int shots; //keeps track of shots from auto weapons - bool reloading, weaponchanging; + int reloading, weaponchanging; int nextweapon; // weapon we switch to int skin, nextskin; // skin after respawning @@ -322,7 +322,7 @@ struct playerent : dynent, playerstate poshist history; // Previous stored locations of this player playerent() : clientnum(-1), plag(0), ping(0), lifesequence(0), frags(0), flagscore(0), lastpain(0), lastteamkill(0), clientrole(CR_DEFAULT), - shots(0), reloading(false), + shots(0), reloading(0), skin(0), nextskin(0), inhandnade(NULL) { name[0] = team[0] = 0; @@ -351,7 +351,7 @@ struct playerent : dynent, playerstate lastattackgun = -1; akimbomillis = 0; attacking = false; - weaponchanging = false; + weaponchanging = 0; } }; diff --git a/source/src/hudgun.cpp b/source/src/hudgun.cpp index e1c64e94..d2f42d74 100644 --- a/source/src/hudgun.cpp +++ b/source/src/hudgun.cpp @@ -19,10 +19,6 @@ struct weaponmove void calcmove(vec base, int basetime) { - int timediff = NADE_THROWING ? lastmillis-player1->thrownademillis : lastmillis-basetime; - int animtime = NADE_THROWING ? NADE_THROW_TIME : min(player1->gunwait[player1->gunselect], attackdelay(player1->gunselect)); - int rtime = reloadtime(player1->gunselect); - kick = k_rot = 0.0f; pos = player1->o; anim = ANIM_GUN_IDLE; @@ -42,19 +38,21 @@ struct weaponmove if(player1->weaponchanging) { anim = ANIM_GUN_RELOAD; - float percent_done = (float)(timediff)*100.0f/(float) WEAPONCHANGE_TIME; + float percent_done = (float)(lastmillis - player1->weaponchanging)*100.0f/(float) WEAPONCHANGE_TIME; if(percent_done>=100 || percent_done<0) percent_done = 100; k_rot = -(sinf((float)(percent_done*2/100.0f*90.0f)*PI/180.0f)*90); } else if(player1->reloading) { anim = ANIM_GUN_RELOAD; - float percent_done = (float)(timediff)*100.0f/(float)rtime; + float percent_done = (float)(lastmillis - player1->reloading)*100.0f/(float)reloadtime(player1->gunselect); if(percent_done>=100 || percent_done<0) percent_done = 100; k_rot = -(sinf((float)(percent_done*2/100.0f*90.0f)*PI/180.0f)*90); } else { + int timediff = lastmillis-basetime, + animtime = min(player1->gunwait[player1->gunselect], attackdelay(player1->gunselect)); vec sway = base; float percent_done = 0.0f; float k_back = 0.0f; @@ -69,7 +67,7 @@ struct weaponmove if(player1->lastaction && player1->lastattackgun==player1->gunselect) { - if(NADE_THROWING && timedifflastactiongunselect!=GUN_KNIFE && player1->gunselect!=GUN_GRENADE ? ANIM_LOOP : 0); } diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index b0d8f462..e152cb92 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -20,12 +20,11 @@ void updatelastaction(playerent *d, int millis = 0, bool akimbo = false) void checkweaponswitch() { if(!player1->weaponchanging) return; - int timeprogress = lastmillis-player1->lastaction; + int timeprogress = lastmillis-player1->weaponchanging; if(timeprogress>WEAPONCHANGE_TIME) { addmsg(SV_WEAPCHANGE, "ri", player1->gunselect); - player1->weaponchanging = false; - updatelastaction(player1); + player1->weaponchanging = 0; } else if(timeprogress>WEAPONCHANGE_TIME/2) { @@ -38,9 +37,8 @@ void checkweaponswitch() void weaponswitch(int gun) { - player1->weaponchanging = true; + player1->weaponchanging = lastmillis; player1->thrownademillis = 0; - updatelastaction(player1, 0, true); player1->nextweapon = gun; playsound(S_GUNCHANGE); } @@ -110,7 +108,7 @@ void reload(playerent *d) if(d == player1) setscope(false); updatelastaction(d, 0, true); - d->reloading = true; + d->reloading = lastmillis; d->gunwait[d->gunselect] += guns[d->gunselect].reloadtime; int numbullets = (has_akimbo(d) ? 2 : 1)*guns[d->gunselect].magsize - d->mag[d->gunselect]; @@ -733,15 +731,14 @@ void shoot(playerent *d, vec &targ) if(d->thrownademillis && attacktime >= NADE_THROW_TIME) { - d->weaponchanging = true; + d->weaponchanging = lastmillis-1-WEAPONCHANGE_TIME/2; d->nextweapon = d->mag[GUN_GRENADE] ? GUN_GRENADE : d->primary; d->thrownademillis = 0; - updatelastaction(d, -1-WEAPONCHANGE_TIME/2); } if(d->weaponchanging || attacktimegunwait[d->gunselect]) return; d->gunwait[d->gunselect] = 0; - d->reloading = false; + d->reloading = 0; if(d->attacking && !d->inhandnade) // activate { @@ -765,7 +762,7 @@ void shoot(playerent *d, vec &targ) if(autoreload && d == player1 && !d->mag[d->gunselect] && lastmillis-d->lastaction>guns[d->gunselect].attackdelay) { reload(d); return; } if(d->weaponchanging || attacktimegunwait[d->gunselect]) return; d->gunwait[d->gunselect] = 0; - d->reloading = false; + d->reloading = 0; if(!d->attacking) { d->shots = 0; return; } updatelastaction(d);