]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a couple of useful options to multijump
authorMario <zacjardine@y7mail.com>
Sun, 30 Aug 2015 12:32:48 +0000 (22:32 +1000)
committerMario <zacjardine@y7mail.com>
Sun, 30 Aug 2015 12:32:48 +0000 (22:32 +1000)
defaultXonotic.cfg
mutators.cfg
qcsrc/client/main.qc
qcsrc/common/stats.qh
qcsrc/server/autocvars.qh
qcsrc/server/mutators/mutator_multijump.qc

index 6a81e3507cc4558196eb7ec92bfbff97aa6ab438..bdeeafab139ecf4d5871251d56fba74c4397378b 100644 (file)
@@ -510,10 +510,6 @@ set g_bloodloss 0   "amount of health below which blood loss occurs"
 
 set g_footsteps 1      "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_add 0  "0 = make the current z velocity equal to jumpvelocity, 1 = add jumpvelocity to the current z velocity"
-set g_multijump_speed -999999  "Minimum vertical speed a player must have in order to jump again"
-
 set g_throughfloor_debug 0 "enable debugging messages for throughfloor calculations"
 set g_throughfloor_damage_max_stddev 2 "Maximum standard deviation for splash damage"
 set g_throughfloor_force_max_stddev 10 "Maximum standard deviation for splash force"
index 10a41a06935c10103656b70dffa4d243a683a7c4..0623ba37589fa43b9e9ea7143a981b5cb5760e0b 100644 (file)
@@ -388,3 +388,12 @@ set g_rm_laser_force "400" "laser force, divided by laser count"
 // ================
 set g_breakablehook 0 "enable breakable hook mutator (hook can be damaged, and returns damage to the owner when broken)"
 set g_breakablehook_owner 0 "allow owner to break their own hook"
+
+
+// ===========
+//  multijump
+// ===========
+seta cl_multijump 1 "allow multijump mutator"
+set g_multijump 0      "Number of multiple jumps to allow (jumping again in the air), -1 allows for infinite jumps"
+set g_multijump_add 0  "0 = make the current z velocity equal to jumpvelocity, 1 = add jumpvelocity to the current z velocity"
+set g_multijump_speed -999999  "Minimum vertical speed a player must have in order to jump again"
index a5085e893da413c6db62620736aabb7fef9d6fec..9b0c49a955cdc354f03ad446486b0bd2babfacdc 100644 (file)
@@ -125,6 +125,8 @@ void CSQC_Init(void)
        registercvar("cl_jumpspeedcap_min", "");
        registercvar("cl_jumpspeedcap_max", "");
 
+       registercvar("cl_multijump", "1");
+
        gametype = 0;
 
        // hud_fields uses strunzone on the titles!
index 74aa0e75fad498f4cb543430af2e119212fa93cd..eff0eff804ef1f07621f138f78f03266e8096a62 100644 (file)
@@ -217,8 +217,8 @@ const int STAT_CTF_FLAGSTATUS         = 124;
 // 163 empty?
 // 164 empty?
 // 165 empty?
-// 166 empty?
-// 167 empty?
+const int STAT_MULTIJUMP_DODGING                      = 166;
+const int STAT_MULTIJUMP_MAXSPEED                     = 167;
 const int STAT_GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND   = 168;
 const int STAT_BUGRIGS_REVERSE_STOPPING               = 169;
 const int STAT_BUGRIGS_REVERSE_SPINNING               = 170;
index 3783ee41953598cb2e6f5ae22810a1fc74c40582..42a48e98550a6259ec559f6980769c34065e757d 100644 (file)
@@ -410,6 +410,8 @@ float autocvar_g_movement_highspeed = 1;
 int autocvar_g_multijump;
 float autocvar_g_multijump_add;
 float autocvar_g_multijump_speed;
+float autocvar_g_multijump_maxspeed;
+float autocvar_g_multijump_dodging = 1;
 string autocvar_g_mutatormsg;
 float autocvar_g_nexball_basketball_bouncefactor;
 float autocvar_g_nexball_basketball_bouncestop;
index dd879e5de4bc4858c3bf19c14c0f561843c13b0d..a5bb70b8e2ed44b988fcf2d586841a3553db8dce 100644 (file)
@@ -4,31 +4,40 @@
        #include "../antilag.qh"
 #endif
 
-.float multijump_count;
-.float multijump_ready;
+.int multijump_count;
+.bool multijump_ready;
+.bool cvar_cl_multijump;
 
 #ifdef CSQC
 
 #define PHYS_MULTIJUMP                                 getstati(STAT_MULTIJUMP)
 #define PHYS_MULTIJUMP_SPEED           getstatf(STAT_MULTIJUMP_SPEED)
 #define PHYS_MULTIJUMP_ADD                     getstati(STAT_MULTIJUMP_ADD)
+#define PHYS_MULTIJUMP_MAXSPEED        getstatf(STAT_MULTIJUMP_MAXSPEED)
+#define PHYS_MULTIJUMP_DODGING                 getstati(STAT_MULTIJUMP_DODGING)
 
 #elif defined(SVQC)
 
 #define PHYS_MULTIJUMP                                 autocvar_g_multijump
 #define PHYS_MULTIJUMP_SPEED           autocvar_g_multijump_speed
 #define PHYS_MULTIJUMP_ADD                     autocvar_g_multijump_add
+#define PHYS_MULTIJUMP_MAXSPEED        autocvar_g_multijump_maxspeed
+#define PHYS_MULTIJUMP_DODGING                 autocvar_g_multijump_dodging
 
 
 .float stat_multijump;
 .float stat_multijump_speed;
 .float stat_multijump_add;
+.float stat_multijump_maxspeed;
+.float stat_multijump_dodging;
 
 void multijump_UpdateStats()
 {
        self.stat_multijump = PHYS_MULTIJUMP;
        self.stat_multijump_speed = PHYS_MULTIJUMP_SPEED;
        self.stat_multijump_add = PHYS_MULTIJUMP_ADD;
+       self.stat_multijump_maxspeed = PHYS_MULTIJUMP_MAXSPEED;
+       self.stat_multijump_dodging = PHYS_MULTIJUMP_DODGING;
 }
 
 void multijump_AddStats()
@@ -36,6 +45,8 @@ void multijump_AddStats()
        addstat(STAT_MULTIJUMP, AS_INT, stat_multijump);
        addstat(STAT_MULTIJUMP_SPEED, AS_FLOAT, stat_multijump_speed);
        addstat(STAT_MULTIJUMP_ADD, AS_INT, stat_multijump_add);
+       addstat(STAT_MULTIJUMP_MAXSPEED, AS_FLOAT, stat_multijump_maxspeed);
+       addstat(STAT_MULTIJUMP_DODGING, AS_INT, stat_multijump_dodging);
 }
 
 #endif
@@ -50,16 +61,31 @@ void PM_multijump()
        }
 }
 
-float PM_multijump_checkjump()
+bool PM_multijump_checkjump()
 {
        if(!PHYS_MULTIJUMP) { return false; }
 
-       if (!IS_JUMP_HELD(self) && !IS_ONGROUND(self)) // jump button pressed this frame and we are in midair
+#ifdef SVQC
+       bool client_multijump = self.cvar_cl_multijump;
+#elif defined(CSQC)
+       bool client_multijump = cvar("cl_multijump");
+
+       if(cvar("cl_multijump") > 1)
+               return false; // nope
+#endif
+
+       if (!IS_JUMP_HELD(self) && !IS_ONGROUND(self) && client_multijump) // 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
        else
                self.multijump_ready = false;
 
-       if(!player_multijump && self.multijump_ready && (self.multijump_count < PHYS_MULTIJUMP || PHYS_MULTIJUMP == -1) && self.velocity_z > PHYS_MULTIJUMP_SPEED)
+       int phys_multijump = PHYS_MULTIJUMP;
+
+#ifdef CSQC
+       phys_multijump = (PHYS_MULTIJUMP) ? -1 : 0;
+#endif
+
+       if(!player_multijump && self.multijump_ready && (self.multijump_count < phys_multijump || phys_multijump == -1) && self.velocity_z > PHYS_MULTIJUMP_SPEED && (!PHYS_MULTIJUMP_MAXSPEED || vlen(self.velocity) <= PHYS_MULTIJUMP_MAXSPEED))
        {
                if (PHYS_MULTIJUMP)
                {
@@ -76,19 +102,20 @@ float PM_multijump_checkjump()
 
                        if(player_multijump)
                        {
+                               if(PHYS_MULTIJUMP_DODGING)
                                if(self.movement_x != 0 || self.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys
                                {
                                        float curspeed;
                                        vector wishvel, wishdir;
 
-#ifdef SVQC
+/*#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)
+#elif defined(CSQC)*/
                                        curspeed = vlen(vec2(self.velocity));
-#endif
+//#endif
 
                                        makevectors(self.v_angle_y * '0 1 0');
                                        wishvel = v_forward * self.movement_x + v_right * self.movement_y;
@@ -98,7 +125,10 @@ float PM_multijump_checkjump()
                                        self.velocity_y = wishdir_y * curspeed;
                                        // keep velocity_z unchanged!
                                }
-                               self.multijump_count += 1;
+                               if (PHYS_MULTIJUMP > 0)
+                               {
+                                       self.multijump_count += 1;
+                               }
                        }
                }
                self.multijump_ready = false; // require releasing and pressing the jump button again for the next jump
@@ -121,6 +151,12 @@ MUTATOR_HOOKFUNCTION(multijump_PlayerJump)
        return PM_multijump_checkjump();
 }
 
+MUTATOR_HOOKFUNCTION(multijump_GetCvars)
+{
+       GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_multijump, "cl_multijump");
+       return false;
+}
+
 MUTATOR_HOOKFUNCTION(multijump_BuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":multijump");
@@ -137,6 +173,7 @@ MUTATOR_DEFINITION(mutator_multijump)
 {
        MUTATOR_HOOK(PlayerPhysics, multijump_PlayerPhysics, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerJump, multijump_PlayerJump, CBC_ORDER_ANY);
+       MUTATOR_HOOK(GetCvars, multijump_GetCvars, CBC_ORDER_ANY);
        MUTATOR_HOOK(BuildMutatorsString, multijump_BuildMutatorsString, CBC_ORDER_ANY);
        MUTATOR_HOOK(BuildMutatorsPrettyString, multijump_BuildMutatorsPrettyString, CBC_ORDER_ANY);