return lerp(e.(antilag_times[i0]), e.(antilag_origins[i0]), e.(antilag_times[i1]), e.(antilag_origins[i1]), t);\r
}\r
\r
+vector antilag_takebackavgvelocity(entity e, float t0, float t1)\r
+{\r
+ vector o0, o1;\r
+ if(t0 >= t1)\r
+ return '0 0 0';\r
+ o0 = antilag_takebackorigin(e, t0);\r
+ o1 = antilag_takebackorigin(e, t1);\r
+ return (o1 - o0) * (1 / (t1 - t0));\r
+}\r
+\r
void antilag_takeback(entity e, float t)\r
{\r
e.antilag_saved_origin = e.origin;\r
.float wasFlying;\r
.float spectatorspeed;\r
\r
+.float multijump_count;\r
+.float multijump_ready;\r
+.float prevjumpbutton;\r
+\r
/*\r
=============\r
PlayerJump\r
void PlayerJump (void)\r
{\r
float mjumpheight;\r
+ float doublejump;\r
+\r
+ doublejump = FALSE;\r
+ if (cvar("sv_doublejump"))\r
+ {\r
+ tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);\r
+ if (trace_fraction < 1 && trace_plane_normal_z > 0.7)\r
+ doublejump = TRUE;\r
+ }\r
\r
mjumpheight = cvar("sv_jumpvelocity");\r
if (self.waterlevel >= WATERLEVEL_SWIMMING)\r
return;\r
}\r
\r
- if (!(self.flags & FL_ONGROUND))\r
- return;\r
+ if (cvar("g_multijump"))\r
+ {\r
+ if (self.prevjumpbutton == FALSE && !(self.flags & FL_ONGROUND)) // jump button pressed this frame and we are in midair\r
+ self.multijump_ready = TRUE; // this is necessary to check that we released the jump button and pressed it again\r
+ else\r
+ self.multijump_ready = FALSE;\r
+ }\r
+\r
+ if(!doublejump && self.multijump_ready && self.multijump_count < cvar("g_multijump") && self.velocity_z > cvar("g_multijump_speed"))\r
+ {\r
+ // doublejump = FALSE; // checked above in the if\r
+ if (cvar("g_multijump") > 0)\r
+ {\r
+ if (cvar("g_multijump_add") == 0) // in this case we make the z velocity == jumpvelocity\r
+ {\r
+ if (self.velocity_z < mjumpheight)\r
+ {\r
+ doublejump = TRUE;\r
+ self.velocity_z = 0;\r
+ }\r
+ }\r
+ else\r
+ doublejump = TRUE;\r
+\r
+ if(doublejump)\r
+ {\r
+ if(self.movement_x != 0 || self.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys\r
+ {\r
+ float curspeed;\r
+ vector wishvel, wishdir;\r
+\r
+ curspeed = max(\r
+ vlen(vec2(self.velocity)), // current xy speed\r
+ vlen(vec2(antilag_takebackavgvelocity(self, max(self.lastteleporttime + sys_frametime, time - 0.25), time))) // average xy topspeed over the last 0.25 secs\r
+ );\r
+ makevectors(self.v_angle_y * '0 1 0');\r
+ wishvel = v_forward * self.movement_x + v_right * self.movement_y;\r
+ wishdir = normalize(wishvel);\r
+\r
+ self.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump\r
+ self.velocity_y = wishdir_y * curspeed;\r
+ // keep velocity_z unchanged!\r
+ }\r
+ self.multijump_count += 1;\r
+ }\r
+ }\r
+ self.multijump_ready = FALSE; // require releasing and pressing the jump button again for the next jump\r
+ }\r
+\r
+ if (!doublejump)\r
+ if (!(self.flags & FL_ONGROUND))\r
+ return;\r
\r
if(!sv_pogostick)\r
if (!(self.flags & FL_JUMPRELEASED))\r
\r
if(self.classname == "player")\r
{\r
- if(sv_doublejump && time - self.jumppadusetime > 2 * sys_frametime)\r
+ if(self.flags & FL_ONGROUND)\r
{\r
- tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);\r
- self.flags &~= FL_ONGROUND;\r
- if(trace_fraction < 1 && trace_plane_normal_z > 0.7)\r
- self.flags |= FL_ONGROUND;\r
+ if (cvar("g_multijump") > 0)\r
+ self.multijump_count = 0;\r
+ else\r
+ self.multijump_count = -2; // the cvar value for infinite jumps is -1, so this needs to be smaller\r
}\r
\r
if (self.BUTTON_JUMP)\r