1 .float multijump_count;
2 .float multijump_ready;
4 MUTATOR_HOOKFUNCTION(multijump_PlayerPhysics)
6 if(self.flags & FL_ONGROUND)
8 if (autocvar_g_multijump > 0)
9 self.multijump_count = 0;
11 self.multijump_count = -2; // the cvar value for infinite jumps is -1, so this needs to be smaller
17 MUTATOR_HOOKFUNCTION(multijump_PlayerJump)
19 if (self.flags & FL_JUMPRELEASED && !(self.flags & FL_ONGROUND)) // jump button pressed this frame and we are in midair
20 self.multijump_ready = TRUE; // this is necessary to check that we released the jump button and pressed it again
22 self.multijump_ready = FALSE;
24 if(!player_multijump && self.multijump_ready && self.multijump_count < autocvar_g_multijump && self.velocity_z > autocvar_g_multijump_speed)
26 if (autocvar_g_multijump)
28 if (autocvar_g_multijump_add == 0) // in this case we make the z velocity == jumpvelocity
30 if (self.velocity_z < autocvar_sv_jumpvelocity)
32 player_multijump = TRUE;
37 player_multijump = TRUE;
41 if(self.movement_x != 0 || self.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys
44 vector wishvel, wishdir;
47 vlen(vec2(self.velocity)), // current xy speed
48 vlen(vec2(antilag_takebackavgvelocity(self, max(self.lastteleporttime + sys_frametime, time - 0.25), time))) // average xy topspeed over the last 0.25 secs
50 makevectors(self.v_angle_y * '0 1 0');
51 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
52 wishdir = normalize(wishvel);
54 self.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump
55 self.velocity_y = wishdir_y * curspeed;
56 // keep velocity_z unchanged!
58 if (autocvar_g_multijump > 0)
59 self.multijump_count += 1;
62 self.multijump_ready = FALSE; // require releasing and pressing the jump button again for the next jump
68 MUTATOR_HOOKFUNCTION(multijump_BuildMutatorsString)
70 ret_string = strcat(ret_string, ":multijump");
74 MUTATOR_HOOKFUNCTION(multijump_BuildMutatorsPrettyString)
76 ret_string = strcat(ret_string, ", Multi jump");
80 MUTATOR_DEFINITION(mutator_multijump)
82 MUTATOR_HOOK(PlayerPhysics, multijump_PlayerPhysics, CBC_ORDER_ANY);
83 MUTATOR_HOOK(PlayerJump, multijump_PlayerJump, CBC_ORDER_ANY);
84 MUTATOR_HOOK(BuildMutatorsString, multijump_BuildMutatorsString, CBC_ORDER_ANY);
85 MUTATOR_HOOK(BuildMutatorsPrettyString, multijump_BuildMutatorsPrettyString, CBC_ORDER_ANY);