From 196d47d34e17a4563117c416a5913adbf37bd0ae Mon Sep 17 00:00:00 2001 From: ac-stef Date: Sat, 26 Sep 2015 15:32:27 +0200 Subject: [PATCH] limit max speed by consecutive doublejumps Instead of applying 25% bonus speed with every executed doublejump (with potentially unlimited top speed), limit the reachable max speed to 125% of regular full speed. This limits regular gameplay only marginally but removes a lot of cheat potential. --- source/src/physics.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/src/physics.cpp b/source/src/physics.cpp index f340470f..d72d16f3 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -465,6 +465,8 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) d.x += (float)(pl->strafe*cosf(RAD*(pl->yaw-180))); d.y += (float)(pl->strafe*sinf(RAD*(pl->yaw-180))); + float curfullspeed = d.magnitudexy(); + pl->vel.mul(fpsfric-1.0f); // slowly apply friction and direction to velocity, gives a smooth movement pl->vel.add(d); pl->vel.div(fpsfric); @@ -519,9 +521,9 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) bool doublejump = pl->lastjump && lastmillis-pl->lastjump < 250 && pl->strafe != 0 && pl->lastjumpheight != 0 && pl->lastjumpheight != pl->o.z; pl->lastjumpheight = pl->o.z; pl->vel.z = 2.0f; // physics impulse upwards - if(doublejump) // more velocity on double jump + if(doublejump && curfullspeed > 0.1f) // more velocity on double jump { - pl->vel.mul(1.25f); + pl->vel.mul(1.25f / max(pl->vel.magnitudexy() / curfullspeed, 1.0f)); } if(water) // dampen velocity change even harder, gives correct water feel {