]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
My first GIT commit :) Implements UT2k4 style air-jumping (jumping again in mid air...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 21 Mar 2010 18:02:24 +0000 (20:02 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 21 Mar 2010 18:02:24 +0000 (20:02 +0200)
defaultXonotic.cfg
qcsrc/server/cl_physics.qc

index d8c11a2683dde044f2519db7d1ffb21b91fd5e48..165c53dddf668079f3b0c3e98a2afd8f0b185057 100644 (file)
@@ -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
index 4c2280099dc2f0b08e5e86de9466c898c733913b..eef7724768cb53c1daf97b960c86f9c37fd2929c 100644 (file)
@@ -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