diff --git a/source/src/entity.h b/source/src/entity.h index 4cb42a8b..dc0f312d 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -101,13 +101,14 @@ struct physent float radius, eyeheight, maxeyeheight, aboveeye; // bounding box size bool inwater; bool onfloor, onladder, jumpnext, crouching, trycrouch, cancollide, stuck; + int lastjump; int lastsplash; char move, strafe; uchar state, type; 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), lastsplash(0), state(CS_ALIVE) + crouching(false), trycrouch(false), cancollide(true), stuck(false), lastjump(0), lastsplash(0), state(CS_ALIVE) { reset(); } @@ -124,7 +125,7 @@ struct physent { vel.x = vel.y = vel.z = eyeheightvel = 0.0f; move = strafe = 0; - timeinair = lastsplash = 0; + timeinair = lastjump = lastsplash = 0; onfloor = onladder = inwater = jumpnext = crouching = trycrouch = stuck = false; } diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 879f3a89..2259edfb 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -427,9 +427,19 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) if(pl->jumpnext) { pl->jumpnext = false; - pl->vel.z = 2.0f; // physics impulse upwards - if(water) { pl->vel.x /= 8; pl->vel.y /= 8; } // dampen velocity change even harder, gives correct water feel + pl->vel.z = 2.0f; // physics impulse upwards + bool doublejump = pl->lastjump && lastmillis-pl->lastjump < 250 && pl->strafe != 0; + if(doublejump) // more velocity on double jump + { + pl->vel.mul(1.25f); + } + if(water) // dampen velocity change even harder, gives correct water feel + { + pl->vel.x /= 8.0f; + pl->vel.y /= 8.0f; + } else if(pl==player1 || pl->type!=ENT_PLAYER) audiomgr.playsoundc(S_JUMP, pl); + pl->lastjump = lastmillis; } pl->timeinair = 0; }