From 5468c26b6d9eacceaec644e6353f06677fc66102 Mon Sep 17 00:00:00 2001 From: Rafael Barreto Date: Thu, 20 May 2010 18:36:00 +0000 Subject: [PATCH] crouching in the air git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4946 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/physics.cpp | 20 ++++++++++++++------ source/src/rendermodel.cpp | 3 ++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/source/src/physics.cpp b/source/src/physics.cpp index c9bbbdbc..739a5620 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -270,7 +270,7 @@ VAR(recoilbackfade, 0, 100, 1000); void resizephysent(physent *pl, int moveres, int curtime, float min, float max) { - if(pl->eyeheightvel==0.0f) return; +// if(pl->eyeheightvel==0.0f) return; const bool water = hdr.waterlevel>pl->o.z; const float speed = curtime*pl->maxspeed/(water ? 2000.0f : 1000.0f); @@ -278,8 +278,10 @@ void resizephysent(physent *pl, int moveres, int curtime, float min, float max) loopi(moveres) { - pl->eyeheight += h; - pl->o.z += h; + if ( pl->onfloor || pl->onladder ) { + pl->eyeheight += h; + pl->o.z += h; + } if(!collide(pl)) { pl->eyeheight -= h; // collided, revert mini-step @@ -360,8 +362,11 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) int move = pl->onladder && !pl->onfloor && pl->move == -1 ? 0 : pl->move; // movement on ladder water = hdr.waterlevel>pl->o.z-0.5f; + float chspeed = 0.4f; + if(!(pl->onfloor || pl->onladder)) chspeed = 1.0f; + const bool crouching = pl->crouching || pl->eyeheight < pl->maxeyeheight; - const float speed = curtime/(water ? 2000.0f : 1000.0f)*pl->maxspeed*(crouching ? 0.4f : 1.0f)*(specfly ? 2.0f : 1.0f); + const float speed = curtime/(water ? 2000.0f : 1000.0f)*pl->maxspeed*(crouching ? chspeed : 1.0f)*(specfly ? 2.0f : 1.0f); const float friction = water ? 20.0f : (pl->onfloor || editfly || specfly ? 6.0f : (pl->onladder ? 1.5f : 30.0f)); const float fpsfric = max(friction/curtime*20.0f, 1.0f); @@ -609,7 +614,8 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) // apply volume-resize when crouching if(pl->type==ENT_PLAYER) { - if(pl==player1 && !(intermission || player1->onladder || (pl->trycrouch && !player1->onfloor && player1->timeinair > 50))) updatecrouch(player1, player1->trycrouch); +// if(pl==player1 && !(intermission || player1->onladder || (pl->trycrouch && !player1->onfloor && player1->timeinair > 50))) updatecrouch(player1, player1->trycrouch); + if(pl==player1 && !intermission) updatecrouch(player1, player1->trycrouch); const float croucheyeheight = pl->maxeyeheight*3.0f/4.0f; resizephysent(pl, moveres, curtime, croucheyeheight, pl->maxeyeheight); } @@ -713,7 +719,9 @@ void updatecrouch(playerent *p, bool on) if(p->crouching == on) return; const float crouchspeed = 0.6f; p->crouching = on; - p->eyeheightvel = on ? -crouchspeed : crouchspeed; + if ( p->onfloor || p->onladder ) { + p->eyeheightvel = on ? -crouchspeed : crouchspeed; + } if(p==player1) audiomgr.playsoundc(on ? S_CROUCH : S_UNCROUCH); } diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 6320a9a9..1bdcecba 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -608,7 +608,8 @@ void renderclient(playerent *d, const char *mdlname, const char *vwepname, int t else if(d->state==CS_EDITING) { anim = ANIM_JUMP|ANIM_END; } else if(d->state==CS_LAGGED) { anim = ANIM_SALUTE|ANIM_LOOP|ANIM_TRANSLUCENT; } else if(lastmillis-d->lastpain<300) { anim = d->crouching ? ANIM_CROUCH_PAIN : ANIM_PAIN; speed = 300.0f/4; varseed += d->lastpain; basetime = d->lastpain; } - else if(!d->onfloor && d->timeinair>50) { anim = ANIM_JUMP|ANIM_END; } +// else if(!d->onfloor && d->timeinair>50) { anim = ANIM_JUMP|ANIM_END; } + else if(!d->onfloor && d->timeinair>50) { anim = (d->crouching ? ANIM_CROUCH_WALK : ANIM_JUMP)|ANIM_END; } else if(d->weaponsel==d->lastattackweapon && lastmillis-d->lastaction<300 && d->lastpain < d->lastaction) { anim = d->crouching ? ANIM_CROUCH_ATTACK : ANIM_ATTACK; speed = 300.0f/8; basetime = d->lastaction; } else if(!d->move && !d->strafe) { anim = (d->crouching ? ANIM_CROUCH_IDLE : ANIM_IDLE)|ANIM_LOOP; } else { anim = (d->crouching ? ANIM_CROUCH_WALK : ANIM_RUN)|ANIM_LOOP; speed = 1860/d->maxspeed; }