]> 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 92d4ef7a2872322b3a6e5679ead5b1e4294ab82f..dd879e5de4bc4858c3bf19c14c0f561843c13b0d 100644 (file)
@@ -1,16 +1,20 @@
+#ifdef SVQC
+       #include "../_all.qh"
+       #include "mutator.qh"
+       #include "../antilag.qh"
+#endif
+
 .float multijump_count;
 .float multijump_ready;
 
 #ifdef CSQC
 
-#define PHYS_MOVE_MULTIJUMP                    pm_multijump
 #define PHYS_MULTIJUMP                                 getstati(STAT_MULTIJUMP)
 #define PHYS_MULTIJUMP_SPEED           getstatf(STAT_MULTIJUMP_SPEED)
 #define PHYS_MULTIJUMP_ADD                     getstati(STAT_MULTIJUMP_ADD)
 
 #elif defined(SVQC)
 
-#define PHYS_MOVE_MULTIJUMP                    player_multijump
 #define PHYS_MULTIJUMP                                 autocvar_g_multijump
 #define PHYS_MULTIJUMP_SPEED           autocvar_g_multijump_speed
 #define PHYS_MULTIJUMP_ADD                     autocvar_g_multijump_add
@@ -42,76 +46,74 @@ 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;
        }
-
-#ifdef SVQC
-       multijump_UpdateStats();
-#endif
 }
 
 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(!PHYS_MOVE_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_MOVE_MULTIJUMP)
+               if (PHYS_MULTIJUMP)
                {
                        if (!PHYS_MULTIJUMP_ADD) // in this case we make the z velocity == jumpvelocity
                        {
                                if (self.velocity_z < PHYS_JUMPVELOCITY)
                                {
-                                       PHYS_MOVE_MULTIJUMP = TRUE;
+                                       player_multijump = true;
                                        self.velocity_z = 0;
                                }
                        }
                        else
-                               PHYS_MOVE_MULTIJUMP = TRUE;
+                               player_multijump = true;
 
-                       if(PHYS_MOVE_MULTIJUMP)
+                       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;
 
-                                       /*curspeed = max(
+#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
-                                       );*/
-                                       makevectors(PHYS_INPUT_ANGLES(self)_y * '0 1 0');
-                                       wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self)_x + v_right * PHYS_INPUT_MOVEVALUES(self)_y;
+                                       );
+#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
 MUTATOR_HOOKFUNCTION(multijump_PlayerPhysics)
 {
+       multijump_UpdateStats();
        PM_multijump();
 
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(multijump_PlayerJump)
@@ -122,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)
@@ -143,6 +145,6 @@ MUTATOR_DEFINITION(mutator_multijump)
                multijump_AddStats();
        }
 
-       return FALSE;
+       return false;
 }
 #endif