3 #include "../../../../server/antilag.qh"
5 #include "../../../physics.qh"
9 .bool cvar_cl_multijump;
11 #define PHYS_MULTIJUMP STAT(MULTIJUMP, self)
12 #define PHYS_MULTIJUMP_SPEED STAT(MULTIJUMP_SPEED, self)
13 #define PHYS_MULTIJUMP_ADD STAT(MULTIJUMP_ADD, self)
14 #define PHYS_MULTIJUMP_MAXSPEED STAT(MULTIJUMP_MAXSPEED, self)
15 #define PHYS_MULTIJUMP_DODGING STAT(MULTIJUMP_DODGING, self)
19 if(!PHYS_MULTIJUMP) { return; }
23 self.multijump_count = 0;
27 bool PM_multijump_checkjump()
29 if(!PHYS_MULTIJUMP) { return false; }
32 bool client_multijump = self.cvar_cl_multijump;
34 bool client_multijump = cvar("cl_multijump");
36 if(cvar("cl_multijump") > 1)
40 if (!IS_JUMP_HELD(self) && !IS_ONGROUND(self) && client_multijump) // jump button pressed this frame and we are in midair
41 self.multijump_ready = true; // this is necessary to check that we released the jump button and pressed it again
43 self.multijump_ready = false;
45 int phys_multijump = PHYS_MULTIJUMP;
48 phys_multijump = (PHYS_MULTIJUMP) ? -1 : 0;
51 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))
55 if (!PHYS_MULTIJUMP_ADD) // in this case we make the z velocity == jumpvelocity
57 if (self.velocity_z < PHYS_JUMPVELOCITY)
59 player_multijump = true;
64 player_multijump = true;
68 if(PHYS_MULTIJUMP_DODGING)
69 if(self.movement_x != 0 || self.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys
72 vector wishvel, wishdir;
76 vlen(vec2(self.velocity)), // current xy speed
77 vlen(vec2(antilag_takebackavgvelocity(self, max(self.lastteleporttime + sys_frametime, time - 0.25), time))) // average xy topspeed over the last 0.25 secs
80 curspeed = vlen(vec2(self.velocity));
83 makevectors(self.v_angle_y * '0 1 0');
84 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
85 wishdir = normalize(wishvel);
87 self.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump
88 self.velocity_y = wishdir_y * curspeed;
89 // keep velocity_z unchanged!
91 if (PHYS_MULTIJUMP > 0)
93 self.multijump_count += 1;
97 self.multijump_ready = false; // require releasing and pressing the jump button again for the next jump
104 REGISTER_MUTATOR(multijump, cvar("g_multijump"));
106 MUTATOR_HOOKFUNCTION(multijump, PlayerPhysics)
113 MUTATOR_HOOKFUNCTION(multijump, PlayerJump)
115 return PM_multijump_checkjump();
118 MUTATOR_HOOKFUNCTION(multijump, GetCvars)
120 GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_multijump, "cl_multijump");
124 MUTATOR_HOOKFUNCTION(multijump, BuildMutatorsString)
126 ret_string = strcat(ret_string, ":multijump");
130 MUTATOR_HOOKFUNCTION(multijump, BuildMutatorsPrettyString)
132 ret_string = strcat(ret_string, ", Multi jump");