]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_physics.qc
Merge branch 'master' into mirceakitsune/multijump
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_physics.qc
index c136ef7b0a6e40f6ed96a5c69def085613599e0a..11d0cbf25301d70bf169f2ab1a7d680fa4913223 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)
@@ -87,7 +111,7 @@ void PlayerJump (void)
                self.velocity_z = max(cvar("sv_jumpvelocity") * cvar("sv_jumpspeedcap_min"), self.velocity_z);
        if(cvar_string("sv_jumpspeedcap_max") != "") {
                if(trace_fraction < 1 && trace_plane_normal_z < 0.98 && cvar("sv_jumpspeedcap_max_disable_on_ramps")) {
-                       // don't do jump speedcaps on ramps to preserve old nexuiz ramjump style
+                       // don't do jump speedcaps on ramps to preserve old xonotic ramjump style
                        //print("Trace plane normal z: ", ftos(trace_plane_normal_z), ", disabling speed cap!\n");
                }
                else
@@ -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
@@ -542,7 +569,6 @@ void PM_AirAccelerate(vector wishdir, float wishspeed)
 .vector v_angle_old;
 .string lastclassname;
 
-void Nixnex_GiveCurrentWeapon();
 .float() PlayerPhysplug;
 
 string specialcommand = "xwxwxsxsxaxdxaxdx1x ";
@@ -689,6 +715,8 @@ void SV_PlayerPhysics()
                bot_think();
        }
        
+       MUTATOR_CALLHOOK(PlayerPhysics);
+
        self.items &~= IT_USING_JETPACK;
 
        if(self.classname == "player")