From 91677d98e9af905557e82aeb8af9250e6c811f73 Mon Sep 17 00:00:00 2001 From: Rafael Barreto Date: Thu, 20 May 2010 19:41:26 +0000 Subject: [PATCH] fixing git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4951 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/entity.h | 6 +++--- source/src/physics.cpp | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/src/entity.h b/source/src/entity.h index 32a816d4..e5fed23f 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -101,7 +101,7 @@ public: int timeinair; // used for fake gravity float radius, eyeheight, maxeyeheight, aboveeye; // bounding box size bool inwater; - bool onfloor, onladder, jumpnext, crouching, trycrouch, cancollide, stuck; + bool onfloor, onladder, jumpnext, crouching, crouchedinair, trycrouch, cancollide, stuck; int lastjump; int lastsplash; char move, strafe; @@ -109,7 +109,7 @@ public: float eyeheightvel; physent() : o(0, 0, 0), deltapos(0, 0, 0), newpos(0, 0, 0), yaw(270), pitch(0), roll(0), pitchvel(0), - crouching(false), trycrouch(false), cancollide(true), stuck(false), lastjump(0), lastsplash(0), state(CS_ALIVE) + crouching(false), crouchedinair(false), trycrouch(false), cancollide(true), stuck(false), lastjump(0), lastsplash(0), state(CS_ALIVE) { reset(); } @@ -127,7 +127,7 @@ public: vel.x = vel.y = vel.z = eyeheightvel = 0.0f; move = strafe = 0; timeinair = lastjump = lastsplash = 0; - onfloor = onladder = inwater = jumpnext = crouching = trycrouch = stuck = false; + onfloor = onladder = inwater = jumpnext = crouching = crouchedinair = trycrouch = stuck = false; } virtual void oncollision() {} diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 2ac2a669..7ce8dae2 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -444,12 +444,15 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) pl->lastjump = lastmillis; } pl->timeinair = 0; + pl->crouchedinair = false; } else { pl->timeinair += curtime; - if (pl->trycrouch && !pl->crouching) pl->vel.z += 0.8f; - if (!pl->trycrouch && pl->crouching) pl->vel.z -= 0.8f; + if (pl->trycrouch && !pl->crouching && !pl->crouchedinair) { + pl->vel.z += 0.6f; + pl->crouchedinair = true; + } } }