diff --git a/source/src/clientextras.cpp b/source/src/clientextras.cpp index ae5744b7..38b314b2 100644 --- a/source/src/clientextras.cpp +++ b/source/src/clientextras.cpp @@ -5,7 +5,7 @@ void renderclient(playerent *d, char *mdlname, char *vwepname) { int varseed = (int)(size_t)d; - int anim = ANIM_PAIN; + int anim = ANIM_IDLE|ANIM_LOOP; float speed = 100.0f; float mz = d->o.z-d->eyeheight; int basetime = -((int)(size_t)d&0xFFF); @@ -21,7 +21,7 @@ void renderclient(playerent *d, char *mdlname, char *vwepname) if(t<0 || t>20000) return; if(t>(r-1)*100-50) { - anim = ANIM_LYING_DEAD|ANIM_NOINTERP; + anim = ANIM_LYING_DEAD|ANIM_NOINTERP|ANIM_LOOP; if(t>(r+10)*100) { t -= (r+10)*100; @@ -32,8 +32,11 @@ void renderclient(playerent *d, char *mdlname, char *vwepname) } else if(d->state==CS_EDITING) { anim = ANIM_TAUNT|ANIM_LOOP; } else if(d->state==CS_LAGGED) { anim = ANIM_CROUCH_ATTACK|ANIM_LOOP; } + else if(lastmillis-d->lastpain<300) { anim = ANIM_PAIN; basetime = d->lastpain; } + else if(!d->onfloor && d->timeinair>0) { anim = ANIM_JUMP|ANIM_END; } + else if(d->gunselect==d->lastattackgun && lastmillis-d->lastactiongunselect)) + { anim = ANIM_ATTACK; basetime = d->lastaction; } else if(!d->move && !d->strafe) { anim = ANIM_IDLE|ANIM_LOOP; } - else if(!d->onfloor && d->timeinair>100) { anim = ANIM_JUMP; } else { anim = ANIM_RUN|ANIM_LOOP; speed = 1860/d->maxspeed; }; rendermodel(mdlname, anim, 0, 1.5f, d->o.x, mz, d->o.y, d->yaw+90, d->pitch/4, speed, basetime, d, vwepname); }; diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 01d3a705..1f3df5bb 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -254,6 +254,8 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) e.y = getint(p)/DMF; e.z = getint(p)/DMF; if(gun==GUN_SHOTGUN) createrays(s, e); + d->lastaction = lastmillis; + d->lastattackgun = gun; shootv(gun, s, e, d, false, getint(p)); break; }; @@ -265,7 +267,12 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) int damage = getint(p); int ls = getint(p); if(target==clientnum) { if(ls==player1->lifesequence) selfdamage(damage, cn, d, gib); } - else playsound(S_PAIN1+rnd(5), &getclient(target)->o); + else + { + playerent *victim = getclient(target); + playsound(S_PAIN1+rnd(5), &victim->o); + victim->lastpain = lastmillis; + }; gib = false; break; } diff --git a/source/src/cube.h b/source/src/cube.h index ec787e23..c12be843 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -328,7 +328,7 @@ struct playerent : dynent int health, armour; //armourtype, quadmillis; int akimbomillis; int gunselect, gunwait; - int lastaction, lastattackgun, lastmove; + int lastaction, lastattackgun, lastmove, lastpain; bool attacking; int ammo[NUMGUNS]; int mag[NUMGUNS]; @@ -348,7 +348,7 @@ struct playerent : dynent CPrevLocation PrevLocations; // Previous stored locations of this player - playerent() : plag(0), ping(0), lifesequence(0), frags(0), flagscore(0), + playerent() : plag(0), ping(0), lifesequence(0), frags(0), flagscore(0), lastpain(0), shots(0), reloading(false), primary(GUN_ASSAULT), nextprimary(GUN_ASSAULT), skin(0), nextskin(0), inhandnade(NULL) { diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 2b724a9d..d7d20b5e 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -251,6 +251,7 @@ void newprojectile(vec &from, vec &to, float speed, bool local, playerent *owner void hit(int target, int damage, playerent *d, playerent *at, bool gib=false) { + d->lastpain = lastmillis; if(d==player1) selfdamage(damage, at==player1 ? -1 : -2, at, gib); // Added by Rick: Let bots take damage else if(d->type==ENT_BOT)