From: Mircea Kitsune Date: Sun, 21 Mar 2010 18:02:24 +0000 (+0200) Subject: My first GIT commit :) Implements UT2k4 style air-jumping (jumping again in mid air... X-Git-Tag: xonotic-v0.1.0preview~361^2~11^2~10 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=07e8b303c05dcd49270ec80a27ba93c14554042f;p=xonotic%2Fxonotic-data.pk3dir.git My first GIT commit :) Implements UT2k4 style air-jumping (jumping again in mid air). Has configurable jump limit, delay and necessary vertical speed. --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index d8c11a268..165c53ddd 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -812,6 +812,10 @@ set g_bloodloss 0 "amount of health below which blood loss occurs" set g_footsteps 0 "serverside footstep sounds" +set g_multijump 0 "Number of multiple jumps to allow (jumping again in the air), -1 allows for infinite jumps" +set g_multijump_delay 0.25 "Delay between multiple jumps" +set g_multijump_speed 30 "Minimum vertical speed a player must have in order to jump again" + // effects r_picmipsprites 0 // Xonotic uses sprites that should never be picmipped (team mate, typing, waypoints) r_mipsprites 1 diff --git a/qcsrc/server/cl_physics.qc b/qcsrc/server/cl_physics.qc index 4c2280099..eef772476 100644 --- a/qcsrc/server/cl_physics.qc +++ b/qcsrc/server/cl_physics.qc @@ -29,6 +29,10 @@ float sv_warsowbunny_backtosideratio; .float wasFlying; .float spectatorspeed; +.float multijump_count; +.float multijump_delay; +.float multijump_ready; + /* ============= PlayerJump @@ -53,7 +57,27 @@ void PlayerJump (void) return; } - if (!(self.flags & FL_ONGROUND)) + if (cvar("g_multijump")) + { + if ((self.flags & FL_JUMPRELEASED) && !(self.flags & FL_ONGROUND)) + self.multijump_ready = TRUE; // this is necessary to check that we released the jump button and pressed it again + else if (self.flags & FL_ONGROUND) + { + if (cvar("g_multijump") > 0) + self.multijump_count = 0; + else + self.multijump_count = -2; // the cvar value for infinite jumps is -1, so this needs to be smaller + self.multijump_ready = FALSE; + } + } + + if(self.multijump_ready && time > self.multijump_delay && self.multijump_count < cvar("g_multijump") && self.velocity_z > cvar("g_multijump_speed")) + { + if (cvar("g_multijump") > 0) + self.multijump_count += 1; + self.multijump_ready = FALSE; // require releasing and pressing the jump button again for the next jump + } + else if (!(self.flags & FL_ONGROUND)) return; if(!sv_pogostick) @@ -114,6 +138,9 @@ void PlayerJump (void) self.flags &~= FL_ONGROUND; self.flags &~= FL_JUMPRELEASED; + if (cvar("g_multijump")) + self.multijump_delay = time + cvar("g_multijump_delay"); + if (self.crouch) setanim(self, self.anim_duckjump, FALSE, TRUE, TRUE); else