]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/multijump/multijump.qc
Merge branch 'divVerent/simpler-clipped-rectangle' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / multijump / multijump.qc
index 780836d4986166d4c6f6cce4457dbc2a0e90d1a0..40bc9a33e96d57c469a5fa27e1dcef40a30e14d6 100644 (file)
@@ -1,4 +1,7 @@
-#ifdef IMPLEMENTATION
+#include "multijump.qh"
+
+#ifdef GAMEQC
+
 #ifdef SVQC
        #include <server/antilag.qh>
 #endif
@@ -6,7 +9,7 @@
 
 
 #if defined(SVQC)
-REGISTER_MUTATOR(multijump, cvar("g_multijump"));
+REGISTER_MUTATOR(multijump, autocvar_g_multijump);
 #elif defined(CSQC)
 REGISTER_MUTATOR(multijump, true);
 #endif
@@ -17,17 +20,19 @@ REGISTER_MUTATOR(multijump, true);
 #define PHYS_MULTIJUMP_MAXSPEED(s)             STAT(MULTIJUMP_MAXSPEED, s)
 #define PHYS_MULTIJUMP_DODGING(s)              STAT(MULTIJUMP_DODGING, s)
 #define PHYS_MULTIJUMP_COUNT(s)                STAT(MULTIJUMP_COUNT, s)
+#define PHYS_MULTIJUMP_CLIENTDEFAULT(s)        STAT(MULTIJUMP_CLIENT, s)
 
 .bool multijump_ready;
 
 #ifdef CSQC
-bool autocvar_cl_multijump = true;
+int cvar_cl_multijump;
+int autocvar_cl_multijump = -1;
 
        #define PHYS_MULTIJUMP_CLIENT(s)        autocvar_cl_multijump
 #elif defined(SVQC)
-.bool cvar_cl_multijump;
+.int cvar_cl_multijump;
 
-       #define PHYS_MULTIJUMP_CLIENT(s)        (s).cvar_cl_multijump
+       #define PHYS_MULTIJUMP_CLIENT(s)        CS(s).cvar_cl_multijump
 #endif
 
 MUTATOR_HOOKFUNCTION(multijump, PlayerPhysics)
@@ -50,6 +55,8 @@ MUTATOR_HOOKFUNCTION(multijump, PlayerJump)
        if(!PHYS_MULTIJUMP(player)) { return; }
 
        int client_multijump = PHYS_MULTIJUMP_CLIENT(player);
+       if(client_multijump == -1)
+               client_multijump = PHYS_MULTIJUMP_CLIENTDEFAULT(player);
        if(client_multijump > 1)
                return; // nope
 
@@ -60,7 +67,7 @@ MUTATOR_HOOKFUNCTION(multijump, PlayerJump)
 
        int phys_multijump = PHYS_MULTIJUMP(player);
 
-       if(!M_ARGV(2, bool) && player.multijump_ready && (PHYS_MULTIJUMP_COUNT(player) < phys_multijump || phys_multijump == -1) && player.velocity_z > PHYS_MULTIJUMP_SPEED(player) && 
+       if(!M_ARGV(2, bool) && player.multijump_ready && (PHYS_MULTIJUMP_COUNT(player) < phys_multijump || phys_multijump == -1) && player.velocity_z > PHYS_MULTIJUMP_SPEED(player) &&
                (!PHYS_MULTIJUMP_MAXSPEED(player) || vdist(player.velocity, <=, PHYS_MULTIJUMP_MAXSPEED(player))))
        {
                if (PHYS_MULTIJUMP(player))
@@ -79,7 +86,7 @@ MUTATOR_HOOKFUNCTION(multijump, PlayerJump)
                        if(M_ARGV(2, bool))
                        {
                                if(PHYS_MULTIJUMP_DODGING(player))
-                               if(player.movement_x != 0 || player.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys
+                               if(PHYS_CS(player).movement_x != 0 || PHYS_CS(player).movement_y != 0) // don't remove all speed if player isnt pressing any movement keys
                                {
                                        float curspeed;
                                        vector wishvel, wishdir;
@@ -94,7 +101,7 @@ MUTATOR_HOOKFUNCTION(multijump, PlayerJump)
 //#endif
 
                                        makevectors(player.v_angle_y * '0 1 0');
-                                       wishvel = v_forward * player.movement_x + v_right * player.movement_y;
+                                       wishvel = v_forward * PHYS_CS(player).movement_x + v_right * PHYS_CS(player).movement_y;
                                        wishdir = normalize(wishvel);
 
                                        player.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump
@@ -111,9 +118,9 @@ MUTATOR_HOOKFUNCTION(multijump, PlayerJump)
        }
 }
 
-#ifdef SVQC
+REPLICATE(cvar_cl_multijump, int, "cl_multijump");
 
-REPLICATE(cvar_cl_multijump, bool, "cl_multijump");
+#ifdef SVQC
 
 MUTATOR_HOOKFUNCTION(multijump, BuildMutatorsString)
 {
@@ -126,4 +133,5 @@ MUTATOR_HOOKFUNCTION(multijump, BuildMutatorsPrettyString)
 }
 
 #endif
+
 #endif