]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator_multijump.qc
Merge branch 'master' into terencehill/menu_listbox_changes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_multijump.qc
index 57014f1816c171b776a232af9a233e8f8dfb7d6b..dd879e5de4bc4858c3bf19c14c0f561843c13b0d 100644 (file)
@@ -1,3 +1,9 @@
+#ifdef SVQC
+       #include "../_all.qh"
+       #include "mutator.qh"
+       #include "../antilag.qh"
+#endif
+
 .float multijump_count;
 .float multijump_ready;
 
@@ -40,23 +46,20 @@ void PM_multijump()
 
        if(IS_ONGROUND(self))
        {
-               if (PHYS_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_count = 0;
        }
 }
 
 float PM_multijump_checkjump()
 {
-       if(!PHYS_MULTIJUMP) { return FALSE; }
+       if(!PHYS_MULTIJUMP) { return false; }
 
        if (!IS_JUMP_HELD(self) && !IS_ONGROUND(self)) // jump button pressed this frame and we are in midair
-               self.multijump_ready = TRUE;  // this is necessary to check that we released the jump button and pressed it again
+               self.multijump_ready = true;  // this is necessary to check that we released the jump button and pressed it again
        else
-               self.multijump_ready = FALSE;
+               self.multijump_ready = false;
 
-       if(!player_multijump && self.multijump_ready && self.multijump_count < PHYS_MULTIJUMP && self.velocity_z > PHYS_MULTIJUMP_SPEED)
+       if(!player_multijump && self.multijump_ready && (self.multijump_count < PHYS_MULTIJUMP || PHYS_MULTIJUMP == -1) && self.velocity_z > PHYS_MULTIJUMP_SPEED)
        {
                if (PHYS_MULTIJUMP)
                {
@@ -64,36 +67,44 @@ float PM_multijump_checkjump()
                        {
                                if (self.velocity_z < PHYS_JUMPVELOCITY)
                                {
-                                       player_multijump = TRUE;
+                                       player_multijump = true;
                                        self.velocity_z = 0;
                                }
                        }
                        else
-                               player_multijump = TRUE;
+                               player_multijump = true;
 
                        if(player_multijump)
                        {
-                               if(PHYS_INPUT_MOVEVALUES(self)_x != 0 || PHYS_INPUT_MOVEVALUES(self)_y != 0) // don't remove all speed if player isnt pressing any movement keys
+                               if(self.movement_x != 0 || self.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys
                                {
-                                       float curspeed = vlen(vec2(self.velocity));
+                                       float curspeed;
                                        vector wishvel, wishdir;
 
-                                       makevectors(PHYS_INPUT_ANGLES(self)_y * '0 1 0');
-                                       wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self)_x + v_right * PHYS_INPUT_MOVEVALUES(self)_y;
+#ifdef SVQC
+                                       curspeed = max(
+                                               vlen(vec2(self.velocity)), // current xy speed
+                                               vlen(vec2(antilag_takebackavgvelocity(self, max(self.lastteleporttime + sys_frametime, time - 0.25), time))) // average xy topspeed over the last 0.25 secs
+                                       );
+#elif defined(CSQC)
+                                       curspeed = vlen(vec2(self.velocity));
+#endif
+
+                                       makevectors(self.v_angle_y * '0 1 0');
+                                       wishvel = v_forward * self.movement_x + v_right * self.movement_y;
                                        wishdir = normalize(wishvel);
 
                                        self.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump
                                        self.velocity_y = wishdir_y * curspeed;
                                        // keep velocity_z unchanged!
                                }
-                               if (PHYS_MULTIJUMP > 0)
-                                       self.multijump_count += 1;
+                               self.multijump_count += 1;
                        }
                }
-               self.multijump_ready = FALSE; // require releasing and pressing the jump button again for the next jump
+               self.multijump_ready = false; // require releasing and pressing the jump button again for the next jump
        }
 
-       return FALSE;
+       return false;
 }
 
 #ifdef SVQC
@@ -102,7 +113,7 @@ MUTATOR_HOOKFUNCTION(multijump_PlayerPhysics)
        multijump_UpdateStats();
        PM_multijump();
 
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(multijump_PlayerJump)
@@ -113,13 +124,13 @@ MUTATOR_HOOKFUNCTION(multijump_PlayerJump)
 MUTATOR_HOOKFUNCTION(multijump_BuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":multijump");
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(multijump_BuildMutatorsPrettyString)
 {
        ret_string = strcat(ret_string, ", Multi jump");
-       return FALSE;
+       return false;
 }
 
 MUTATOR_DEFINITION(mutator_multijump)
@@ -134,6 +145,6 @@ MUTATOR_DEFINITION(mutator_multijump)
                multijump_AddStats();
        }
 
-       return FALSE;
+       return false;
 }
 #endif