From b0f4544bbc853108b4b57c27b7a73f1d56652e3c Mon Sep 17 00:00:00 2001 From: div0 Date: Sat, 9 May 2009 15:34:28 +0000 Subject: [PATCH] make sv_doublejump safer by blocking jumping for up to 0.1s after jumping git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6694 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/cl_physics.qc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/data/qcsrc/server/cl_physics.qc b/data/qcsrc/server/cl_physics.qc index de04727b3..2a377c775 100644 --- a/data/qcsrc/server/cl_physics.qc +++ b/data/qcsrc/server/cl_physics.qc @@ -30,6 +30,7 @@ float sv_warsowbunny_backtosideratio; #define SHTEST_THRESHOLD 1.1 .float shtest_next; .float shtest_accumulator; +.float doublejump_nextjumptime; /* ============= @@ -55,7 +56,6 @@ void PlayerJump (void) return; } - if (!(self.flags & FL_ONGROUND)) return; @@ -65,6 +65,10 @@ void PlayerJump (void) if(self.health <= g_bloodloss) return; + + if(sv_doublejump) + if(time < self.doublejump_nextjumptime) + return; if(g_runematch) { @@ -99,6 +103,17 @@ void PlayerJump (void) if(g_jump_grunt) PlayerSound(playersound_jump, CHAN_PLAYER, VOICETYPE_PLAYERSOUND); + + if(sv_doublejump) + { + // we're moving upwards at self.velocity_z + // only allow jumping after we got 3 units upwards + // so we for sure leave the FL_ONGROUND check + // + // but as this sucks because of factoring in gravity, we'll just do it + // for 4 units, and constant velocity + self.doublejump_nextjumptime = time + 4 / max(40, self.velocity_z); // max 0.1s blocking of jumps + } } void CheckWaterJump() -- 2.39.2