11 .float spectatorspeed;
16 .string lastclassname;
18 .float() PlayerPhysplug;
19 float AdjustAirAccelQW(float accelqw, float factor);
22 .float stat_dodging_frozen;
23 .float stat_sv_airaccel_qw;
24 .float stat_sv_airstrafeaccel_qw;
25 .float stat_sv_airspeedlimit_nonqw;
26 .float stat_sv_maxspeed;
27 .float stat_movement_highspeed;
29 .float stat_jetpack_accel_side;
30 .float stat_jetpack_accel_up;
31 .float stat_jetpack_antigravity;
32 .float stat_jetpack_fuel;
33 .float stat_jetpack_maxspeed_up;
34 .float stat_jetpack_maxspeed_side;
36 void Physics_AddStats()
38 // g_movementspeed hack
39 addstat(STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW, AS_FLOAT, stat_sv_airspeedlimit_nonqw);
40 addstat(STAT_MOVEVARS_MAXSPEED, AS_FLOAT, stat_sv_maxspeed);
41 addstat(STAT_MOVEVARS_AIRACCEL_QW, AS_FLOAT, stat_sv_airaccel_qw);
42 addstat(STAT_MOVEVARS_AIRSTRAFEACCEL_QW, AS_FLOAT, stat_sv_airstrafeaccel_qw);
43 addstat(STAT_MOVEVARS_HIGHSPEED, AS_FLOAT, stat_movement_highspeed);
46 addstat(STAT_DODGING_FROZEN, AS_INT, stat_dodging_frozen);
49 addstat(STAT_JETPACK_ACCEL_SIDE, AS_FLOAT, stat_jetpack_accel_side);
50 addstat(STAT_JETPACK_ACCEL_UP, AS_FLOAT, stat_jetpack_accel_up);
51 addstat(STAT_JETPACK_ANTIGRAVITY, AS_FLOAT, stat_jetpack_antigravity);
52 addstat(STAT_JETPACK_FUEL, AS_FLOAT, stat_jetpack_fuel);
53 addstat(STAT_JETPACK_MAXSPEED_UP, AS_FLOAT, stat_jetpack_maxspeed_up);
54 addstat(STAT_JETPACK_MAXSPEED_SIDE, AS_FLOAT, stat_jetpack_maxspeed_side);
58 // Client/server mappings
62 #define PHYS_INPUT_ANGLES(s) input_angles
63 #define PHYS_INPUT_BUTTONS(s) input_buttons
65 #define PHYS_INPUT_TIMELENGTH input_timelength
67 #define PHYS_INPUT_MOVEVALUES(s) input_movevalues
69 #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE
70 #define GAMEPLAYFIX_NOGRAVITYONGROUND moveflags & MOVEFLAG_NOGRAVITYONGROUND
71 #define GAMEPLAYFIX_Q2AIRACCELERATE moveflags & MOVEFLAG_Q2AIRACCELERATE
73 #define IS_DUCKED(s) (s.pmove_flags & PMF_DUCKED)
74 #define SET_DUCKED(s) s.pmove_flags |= PMF_DUCKED
75 #define UNSET_DUCKED(s) s.pmove_flags &= ~PMF_DUCKED
77 #define IS_JUMP_HELD(s) (s.pmove_flags & PMF_JUMP_HELD)
78 #define SET_JUMP_HELD(s) s.pmove_flags |= PMF_JUMP_HELD
79 #define UNSET_JUMP_HELD(s) s.pmove_flags &= ~PMF_JUMP_HELD
81 #define IS_ONGROUND(s) (s.pmove_flags & PMF_ONGROUND)
82 #define SET_ONGROUND(s) s.pmove_flags |= PMF_ONGROUND
83 #define UNSET_ONGROUND(s) s.pmove_flags &= ~PMF_ONGROUND
85 #define ITEMS(s) getstati(STAT_ITEMS, 0, 24)
86 #define PHYS_AMMO_FUEL(s) getstatf(STAT_FUEL)
87 #define PHYS_FROZEN(s) getstati(STAT_FROZEN)
89 #define PHYS_ACCELERATE getstatf(STAT_MOVEVARS_ACCELERATE)
90 #define PHYS_AIRACCEL_QW(s) getstatf(STAT_MOVEVARS_AIRACCEL_QW)
91 #define PHYS_AIRACCEL_QW_STRETCHFACTOR(s) getstatf(STAT_MOVEVARS_AIRACCEL_QW_STRETCHFACTOR)
92 #define PHYS_AIRACCEL_SIDEWAYS_FRICTION getstatf(STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION)
93 #define PHYS_AIRACCELERATE getstatf(STAT_MOVEVARS_AIRACCELERATE)
94 #define PHYS_AIRCONTROL getstatf(STAT_MOVEVARS_AIRCONTROL)
95 #define PHYS_AIRCONTROL_PENALTY getstatf(STAT_MOVEVARS_AIRCONTROL_PENALTY)
96 #define PHYS_AIRCONTROL_POWER getstatf(STAT_MOVEVARS_AIRCONTROL_POWER)
97 #define PHYS_AIRSPEEDLIMIT_NONQW(s) getstatf(STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW)
98 #define PHYS_AIRSTOPACCELERATE getstatf(STAT_MOVEVARS_AIRSTOPACCELERATE)
99 #define PHYS_AIRSTRAFEACCEL_QW(s) getstatf(STAT_MOVEVARS_AIRSTRAFEACCEL_QW)
100 #define PHYS_AIRSTRAFEACCELERATE getstatf(STAT_MOVEVARS_AIRSTRAFEACCELERATE)
101 #define PHYS_ENTGRAVITY(s) getstatf(STAT_MOVEVARS_ENTGRAVITY)
102 #define PHYS_FRICTION getstatf(STAT_MOVEVARS_FRICTION)
103 #define PHYS_GRAVITY getstatf(STAT_MOVEVARS_GRAVITY)
104 #define PHYS_HIGHSPEED getstatf(STAT_MOVEVARS_HIGHSPEED)
105 #define PHYS_JUMPVELOCITY getstatf(STAT_MOVEVARS_JUMPVELOCITY)
106 #define PHYS_MAXAIRSPEED getstatf(STAT_MOVEVARS_MAXAIRSPEED)
107 #define PHYS_MAXAIRSTRAFESPEED getstatf(STAT_MOVEVARS_MAXAIRSTRAFESPEED)
108 #define PHYS_MAXSPEED(s) getstatf(STAT_MOVEVARS_MAXSPEED)
109 #define PHYS_STEPHEIGHT getstatf(STAT_MOVEVARS_STEPHEIGHT)
110 #define PHYS_STOPSPEED getstatf(STAT_MOVEVARS_STOPSPEED)
111 #define PHYS_WARSOWBUNNY_ACCEL getstatf(STAT_MOVEVARS_WARSOWBUNNY_ACCEL)
112 #define PHYS_WARSOWBUNNY_BACKTOSIDERATIO getstatf(STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO)
113 #define PHYS_WARSOWBUNNY_AIRFORWARDACCEL getstatf(STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL)
114 #define PHYS_WARSOWBUNNY_TOPSPEED getstatf(STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED)
115 #define PHYS_WARSOWBUNNY_TURNACCEL getstatf(STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL)
117 #define PHYS_JETPACK_ACCEL_UP getstatf(STAT_JETPACK_ACCEL_UP)
118 #define PHYS_JETPACK_ACCEL_SIDE getstatf(STAT_JETPACK_ACCEL_SIDE)
119 #define PHYS_JETPACK_ANTIGRAVITY getstatf(STAT_JETPACK_ANTIGRAVITY)
120 #define PHYS_JETPACK_FUEL getstatf(STAT_JETPACK_FUEL)
121 #define PHYS_JETPACK_MAXSPEED_UP getstatf(STAT_JETPACK_MAXSPEED_UP)
122 #define PHYS_JETPACK_MAXSPEED_SIDE getstatf(STAT_JETPACK_MAXSPEED_SIDE)
124 #define PHYS_BUTTON_HOOK(s) (input_buttons & 32)
126 #define PHYS_DODGING_FROZEN getstati(STAT_DODGING_FROZEN)
130 #define PHYS_INPUT_ANGLES(s) s.v_angle
132 #define PHYS_INPUT_BUTTONS(s) (s.BUTTON_ATCK + 2 * s.BUTTON_JUMP + 4 * s.BUTTON_ATCK2 + 8 * s.BUTTON_ZOOM + 16 * s.BUTTON_CROUCH + 32 * s.BUTTON_HOOK + 64 * s.BUTTON_USE + 128 * (s.movement_x < 0) + 256 * (s.movement_x > 0) + 512 * (s.movement_y < 0) + 1024 * (s.movement_y > 0))
134 #define PHYS_INPUT_TIMELENGTH frametime
136 #define PHYS_INPUT_MOVEVALUES(s) s.movement
138 #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE autocvar_sv_gameplayfix_gravityunaffectedbyticrate
139 #define GAMEPLAYFIX_NOGRAVITYONGROUND cvar("sv_gameplayfix_nogravityonground")
140 #define GAMEPLAYFIX_Q2AIRACCELERATE autocvar_sv_gameplayfix_q2airaccelerate
142 #define IS_DUCKED(s) s.crouch
143 #define SET_DUCKED(s) s.crouch = TRUE
144 #define UNSET_DUCKED(s) s.crouch = FALSE
146 #define IS_JUMP_HELD(s) (s.flags & FL_JUMPRELEASED == 0)
147 #define SET_JUMP_HELD(s) s.flags &= ~FL_JUMPRELEASED
148 #define UNSET_JUMP_HELD(s) s.flags |= FL_JUMPRELEASED
150 #define IS_ONGROUND(s) (s.flags & FL_ONGROUND)
151 #define SET_ONGROUND(s) s.flags |= FL_ONGROUND
152 #define UNSET_ONGROUND(s) s.flags &= ~FL_ONGROUND
154 #define ITEMS(s) s.items
155 #define PHYS_AMMO_FUEL(s) s.ammo_fuel
156 #define PHYS_FROZEN(s) s.frozen
158 #define PHYS_ACCELERATE autocvar_sv_accelerate
159 #define PHYS_AIRACCEL_QW(s) s.stat_sv_airaccel_qw
160 #define PHYS_AIRACCEL_QW_STRETCHFACTOR(s) autocvar_sv_airaccel_qw_stretchfactor
161 #define PHYS_AIRACCEL_SIDEWAYS_FRICTION autocvar_sv_airaccel_sideways_friction
162 #define PHYS_AIRACCELERATE autocvar_sv_airaccelerate
163 #define PHYS_AIRCONTROL autocvar_sv_aircontrol
164 #define PHYS_AIRCONTROL_PENALTY autocvar_sv_aircontrol_penalty
165 #define PHYS_AIRCONTROL_POWER autocvar_sv_aircontrol_power
166 #define PHYS_AIRSPEEDLIMIT_NONQW(s) s.stat_sv_airspeedlimit_nonqw
167 #define PHYS_AIRSTOPACCELERATE autocvar_sv_airstopaccelerate
168 #define PHYS_AIRSTRAFEACCEL_QW(s) s.stat_sv_airstrafeaccel_qw
169 #define PHYS_AIRSTRAFEACCELERATE autocvar_sv_airstrafeaccelerate
170 #define PHYS_ENTGRAVITY(s) s.gravity
171 #define PHYS_FRICTION autocvar_sv_friction
172 #define PHYS_GRAVITY autocvar_sv_gravity
173 #define PHYS_HIGHSPEED autocvar_g_movement_highspeed
174 #define PHYS_JUMPVELOCITY autocvar_sv_jumpvelocity
175 #define PHYS_MAXAIRSPEED autocvar_sv_maxairspeed
176 #define PHYS_MAXAIRSTRAFESPEED autocvar_sv_maxairstrafespeed
177 #define PHYS_MAXSPEED(s) s.stat_sv_maxspeed
178 #define PHYS_STEPHEIGHT autocvar_sv_stepheight
179 #define PHYS_STOPSPEED autocvar_sv_stopspeed
180 #define PHYS_WARSOWBUNNY_ACCEL autocvar_sv_warsowbunny_accel
181 #define PHYS_WARSOWBUNNY_BACKTOSIDERATIO autocvar_sv_warsowbunny_backtosideratio
182 #define PHYS_WARSOWBUNNY_AIRFORWARDACCEL autocvar_sv_warsowbunny_airforwardaccel
183 #define PHYS_WARSOWBUNNY_TOPSPEED autocvar_sv_warsowbunny_topspeed
184 #define PHYS_WARSOWBUNNY_TURNACCEL autocvar_sv_warsowbunny_turnaccel
186 #define PHYS_JETPACK_ACCEL_UP autocvar_g_jetpack_acceleration_up
187 #define PHYS_JETPACK_ACCEL_SIDE autocvar_g_jetpack_acceleration_side
188 #define PHYS_JETPACK_ANTIGRAVITY autocvar_g_jetpack_antigravity
189 #define PHYS_JETPACK_FUEL autocvar_g_jetpack_fuel
190 #define PHYS_JETPACK_MAXSPEED_UP autocvar_g_jetpack_maxspeed_up
191 #define PHYS_JETPACK_MAXSPEED_SIDE autocvar_g_jetpack_maxspeed_side
193 #define PHYS_BUTTON_HOOK(s) s.BUTTON_HOOK
195 #define PHYS_DODGING_FROZEN autocvar_sv_dodging_frozen
198 void Physics_UpdateStats(float maxspd_mod)
200 self.stat_sv_airaccel_qw = AdjustAirAccelQW(autocvar_sv_airaccel_qw, maxspd_mod);
201 if (autocvar_sv_airstrafeaccel_qw)
202 self.stat_sv_airstrafeaccel_qw = AdjustAirAccelQW(autocvar_sv_airstrafeaccel_qw, maxspd_mod);
204 self.stat_sv_airstrafeaccel_qw = 0;
205 self.stat_sv_airspeedlimit_nonqw = autocvar_sv_airspeedlimit_nonqw * maxspd_mod;
206 self.stat_sv_maxspeed = autocvar_sv_maxspeed * maxspd_mod; // also slow walking
207 self.stat_movement_highspeed = PHYS_HIGHSPEED; // TODO: remove this!
209 self.stat_jetpack_antigravity = PHYS_JETPACK_ANTIGRAVITY;
210 self.stat_jetpack_accel_up = PHYS_JETPACK_ACCEL_UP;
211 self.stat_jetpack_accel_side = PHYS_JETPACK_ACCEL_SIDE;
212 self.stat_jetpack_maxspeed_side = PHYS_JETPACK_MAXSPEED_SIDE;
213 self.stat_jetpack_maxspeed_up = PHYS_JETPACK_MAXSPEED_UP;
214 self.stat_jetpack_fuel = PHYS_JETPACK_FUEL;
218 float IsMoveInDirection(vector mv, float angle) // key mix factor
220 if (mv_x == 0 && mv_y == 0)
221 return 0; // avoid division by zero
222 angle -= RAD2DEG * atan2(mv_y, mv_x);
223 angle = remainder(angle, 360) / 45;
224 return angle > 1 ? 0 : angle < -1 ? 0 : 1 - fabs(angle);
227 float GeomLerp(float a, float lerp, float b)
229 return a == 0 ? (lerp < 1 ? 0 : b)
230 : b == 0 ? (lerp > 0 ? 0 : a)
231 : a * pow(fabs(b / a), lerp);
235 float pmove_waterjumptime; // weird engine flag we shouldn't really use but have to for now
238 const float unstick_count = 27;
239 vector unstick_offsets[unstick_count] =
241 // 1 no nudge (just return the original if this test passes)
244 ' 0.000 0.000 0.125', '0.000 0.000 -0.125',
245 '-0.125 0.000 0.000', '0.125 0.000 0.000',
246 ' 0.000 -0.125 0.000', '0.000 0.125 0.000',
247 // 4 diagonal flat nudges
248 '-0.125 -0.125 0.000', '0.125 -0.125 0.000',
249 '-0.125 0.125 0.000', '0.125 0.125 0.000',
250 // 8 diagonal upward nudges
251 '-0.125 0.000 0.125', '0.125 0.000 0.125',
252 ' 0.000 -0.125 0.125', '0.000 0.125 0.125',
253 '-0.125 -0.125 0.125', '0.125 -0.125 0.125',
254 '-0.125 0.125 0.125', '0.125 0.125 0.125',
255 // 8 diagonal downward nudges
256 '-0.125 0.000 -0.125', '0.125 0.000 -0.125',
257 ' 0.000 -0.125 -0.125', '0.000 0.125 -0.125',
258 '-0.125 -0.125 -0.125', '0.125 -0.125 -0.125',
259 '-0.125 0.125 -0.125', '0.125 0.125 -0.125',
262 void CSQC_ClientMovement_Unstick()
265 for (i = 0; i < unstick_count; i++)
267 vector neworigin = unstick_offsets[i] + self.origin;
268 tracebox(neworigin, PL_CROUCH_MIN, PL_CROUCH_MAX, neworigin, MOVE_NORMAL, self);
269 if (!trace_startsolid)
271 self.origin = neworigin;
278 void CSQC_ClientMovement_UpdateStatus()
280 // make sure player is not stuck
281 CSQC_ClientMovement_Unstick();
284 if (PHYS_INPUT_BUTTONS(self) & 16)
286 // wants to crouch, this always works..
287 if (!IS_DUCKED(self))
292 // wants to stand, if currently crouching we need to check for a
296 tracebox(self.origin, PL_MIN, PL_MAX, self.origin, MOVE_NORMAL, self);
297 if (!trace_startsolid)
303 vector origin1 = self.origin + '0 0 1';
304 vector origin2 = self.origin - '0 0 1';
306 tracebox(origin1, self.mins, self.maxs, origin2, MOVE_NORMAL, self);
307 if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
311 // this code actually "predicts" an impact; so let's clip velocity first
312 float f = dotproduct(self.velocity, trace_plane_normal);
313 if (f < 0) // only if moving downwards actually
314 self.velocity -= f * trace_plane_normal;
317 UNSET_ONGROUND(self);
319 // set watertype/waterlevel
320 origin1 = self.origin;
321 origin1_z += self.mins_z + 1;
322 self.waterlevel = WATERLEVEL_NONE;
324 self.watertype = (pointcontents(origin1) == CONTENT_WATER);
328 self.waterlevel = WATERLEVEL_WETFEET;
329 origin1_z = self.origin_z + (self.mins_z + self.maxs_z) * 0.5;
330 if(pointcontents(origin1) == CONTENT_WATER)
332 self.waterlevel = WATERLEVEL_SWIMMING;
333 origin1_z = self.origin_z + 22;
334 if(pointcontents(origin1) == CONTENT_WATER)
335 self.waterlevel = WATERLEVEL_SUBMERGED;
339 if(IS_ONGROUND(self) || self.velocity_z <= 0 || pmove_waterjumptime <= 0)
340 pmove_waterjumptime = 0;
343 void CSQC_ClientMovement_Move()
345 float t = PHYS_INPUT_TIMELENGTH;
346 vector primalvelocity = self.velocity;
347 CSQC_ClientMovement_UpdateStatus();
349 for (bump = 0; bump < 8 && self.velocity * self.velocity > 0; bump++)
351 vector neworigin = self.origin + t * self.velocity;
352 tracebox(self.origin, self.mins, self.maxs, neworigin, MOVE_NORMAL, self);
353 float old_trace1_fraction = trace_fraction;
354 vector old_trace1_endpos = trace_endpos;
355 vector old_trace1_plane_normal = trace_plane_normal;
356 if (trace_fraction < 1 && trace_plane_normal_z == 0)
358 // may be a step or wall, try stepping up
359 // first move forward at a higher level
360 vector currentorigin2 = self.origin;
361 currentorigin2_z += PHYS_STEPHEIGHT;
362 vector neworigin2 = neworigin;
363 neworigin2_z = self.origin_z + PHYS_STEPHEIGHT;
364 tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self);
365 if (!trace_startsolid)
367 // then move down from there
368 currentorigin2 = trace_endpos;
369 neworigin2 = trace_endpos;
370 neworigin2_z = self.origin_z;
371 float old_trace2_fraction = trace_fraction;
372 vector old_trace2_plane_normal = trace_plane_normal;
373 tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self);
374 //Con_Printf("%f %f %f %f : %f %f %f %f : %f %f %f %f\n", trace.fraction, trace.endpos[0], trace.endpos[1], trace.endpos[2], trace2.fraction, trace2.endpos[0], trace2.endpos[1], trace2.endpos[2], trace3.fraction, trace3.endpos[0], trace3.endpos[1], trace3.endpos[2]);
375 // accept the new trace if it made some progress
376 if (fabs(trace_endpos_x - old_trace1_endpos_x) >= 0.03125 || fabs(trace_endpos_y - old_trace1_endpos_y) >= 0.03125)
378 trace_fraction = old_trace2_fraction;
379 trace_endpos = trace_endpos;
380 trace_plane_normal = old_trace2_plane_normal;
384 trace_fraction = old_trace1_fraction;
385 trace_endpos = old_trace1_endpos;
386 trace_plane_normal = old_trace1_plane_normal;
391 // check if it moved at all
392 if (trace_fraction >= 0.001)
393 self.origin = trace_endpos;
395 // check if it moved all the way
396 if (trace_fraction == 1)
399 // this is only really needed for nogravityonground combined with gravityunaffectedbyticrate
400 // <LordHavoc> I'm pretty sure I commented it out solely because it seemed redundant
401 // this got commented out in a change that supposedly makes the code match QW better
402 // so if this is broken, maybe put it in an if (cls.protocol != PROTOCOL_QUAKEWORLD) block
403 if (trace_plane_normal_z > 0.7)
406 t -= t * trace_fraction;
408 float f = dotproduct(self.velocity, trace_plane_normal);
409 self.velocity -= f * trace_plane_normal;
411 if (pmove_waterjumptime > 0)
412 self.velocity = primalvelocity;
416 void CPM_PM_Aircontrol(vector wishdir, float wishspeed)
420 // this doesn't play well with analog input
421 if (PHYS_INPUT_MOVEVALUES(self).x == 0 || PHYS_INPUT_MOVEVALUES(self).y != 0)
422 return; // can't control movement if not moving forward or backward
425 k = 32 * (2 * IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), 0) - 1);
430 k *= bound(0, wishspeed / PHYS_MAXAIRSPEED, 1);
432 float zspeed = self.velocity_z;
434 float xyspeed = vlen(self.velocity);
435 self.velocity = normalize(self.velocity);
437 float dot = self.velocity * wishdir;
439 if (dot > 0) // we can't change direction while slowing down
441 k *= pow(dot, PHYS_AIRCONTROL_POWER)*PHYS_INPUT_TIMELENGTH;
442 xyspeed = max(0, xyspeed - PHYS_AIRCONTROL_PENALTY * sqrt(max(0, 1 - dot*dot)) * k/32);
443 k *= PHYS_AIRCONTROL;
444 self.velocity = normalize(self.velocity * xyspeed + wishdir * k);
447 self.velocity = self.velocity * xyspeed;
448 self.velocity_z = zspeed;
451 float AdjustAirAccelQW(float accelqw, float factor)
453 return copysign(bound(0.000001, 1 - (1 - fabs(accelqw)) * factor, 1), accelqw);
456 // example config for alternate speed clamping:
457 // sv_airaccel_qw 0.8
458 // sv_airaccel_sideways_friction 0
459 // prvm_globalset server speedclamp_mode 1
461 void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float accel, float accelqw, float stretchfactor, float sidefric, float speedlimit)
463 float speedclamp = stretchfactor > 0 ? stretchfactor
464 : accelqw < 0 ? 1 // full clamping, no stretch
467 accelqw = fabs(accelqw);
469 if (GAMEPLAYFIX_Q2AIRACCELERATE)
470 wishspeed0 = wishspeed; // don't need to emulate this Q1 bug
472 float vel_straight = self.velocity * wishdir;
473 float vel_z = self.velocity_z;
474 vector vel_xy = vec2(self.velocity);
475 vector vel_perpend = vel_xy - vel_straight * wishdir;
477 float step = accel * PHYS_INPUT_TIMELENGTH * wishspeed0;
479 float vel_xy_current = vlen(vel_xy);
481 accelqw = AdjustAirAccelQW(accelqw, (speedlimit - bound(wishspeed, vel_xy_current, speedlimit)) / max(1, speedlimit - wishspeed));
482 float vel_xy_forward = vel_xy_current + bound(0, wishspeed - vel_xy_current, step) * accelqw + step * (1 - accelqw);
483 float vel_xy_backward = vel_xy_current - bound(0, wishspeed + vel_xy_current, step) * accelqw - step * (1 - accelqw);
484 vel_xy_backward = max(0, vel_xy_backward); // not that it REALLY occurs that this would cause wrong behaviour afterwards
485 vel_straight = vel_straight + bound(0, wishspeed - vel_straight, step) * accelqw + step * (1 - accelqw);
487 if (sidefric < 0 && (vel_perpend*vel_perpend))
488 // negative: only apply so much sideways friction to stay below the speed you could get by "braking"
490 float f = max(0, 1 + PHYS_INPUT_TIMELENGTH * wishspeed * sidefric);
491 float fmin = (vel_xy_backward * vel_xy_backward - vel_straight * vel_straight) / (vel_perpend * vel_perpend);
493 // vel_xy_backward*vel_xy_backward - vel_straight*vel_straight > vel_perpend*vel_perpend
494 // vel_xy_backward*vel_xy_backward > vel_straight*vel_straight + vel_perpend*vel_perpend
495 // vel_xy_backward*vel_xy_backward > vel_xy * vel_xy
496 // obviously, this cannot be
502 vel_perpend *= max(fmin, f);
506 vel_perpend *= max(0, 1 - PHYS_INPUT_TIMELENGTH * wishspeed * sidefric);
508 vel_xy = vel_straight * wishdir + vel_perpend;
512 float vel_xy_preclamp;
513 vel_xy_preclamp = vlen(vel_xy);
514 if (vel_xy_preclamp > 0) // prevent division by zero
516 vel_xy_current += (vel_xy_forward - vel_xy_current) * speedclamp;
517 if (vel_xy_current < vel_xy_preclamp)
518 vel_xy *= (vel_xy_current / vel_xy_preclamp);
522 self.velocity = vel_xy + vel_z * '0 0 1';
525 void PM_AirAccelerate(vector wishdir, float wishspeed)
530 vector curvel = self.velocity;
532 float curspeed = vlen(curvel);
534 if (wishspeed > curspeed * 1.01)
535 wishspeed = min(wishspeed, curspeed + PHYS_WARSOWBUNNY_AIRFORWARDACCEL * PHYS_MAXSPEED(self) * PHYS_INPUT_TIMELENGTH);
538 float f = max(0, (PHYS_WARSOWBUNNY_TOPSPEED - curspeed) / (PHYS_WARSOWBUNNY_TOPSPEED - PHYS_MAXSPEED(self)));
539 wishspeed = max(curspeed, PHYS_MAXSPEED(self)) + PHYS_WARSOWBUNNY_ACCEL * f * PHYS_MAXSPEED(self) * PHYS_INPUT_TIMELENGTH;
541 vector wishvel = wishdir * wishspeed;
542 vector acceldir = wishvel - curvel;
543 float addspeed = vlen(acceldir);
544 acceldir = normalize(acceldir);
546 float accelspeed = min(addspeed, PHYS_WARSOWBUNNY_TURNACCEL * PHYS_MAXSPEED(self) * PHYS_INPUT_TIMELENGTH);
548 if (PHYS_WARSOWBUNNY_BACKTOSIDERATIO < 1)
550 vector curdir = normalize(curvel);
551 float dot = acceldir * curdir;
553 acceldir -= (1 - PHYS_WARSOWBUNNY_BACKTOSIDERATIO) * dot * curdir;
556 self.velocity += accelspeed * acceldir;
564 When you press the jump key
567 void PlayerJump (void)
570 if (PHYS_FROZEN(self))
571 return; // no jumping in freezetag when frozen
573 if (self.player_blocked)
574 return; // no jumping while blocked
576 float doublejump = FALSE;
577 float mjumpheight = PHYS_JUMPVELOCITY;
579 player_multijump = doublejump;
580 player_jumpheight = mjumpheight;
581 if (MUTATOR_CALLHOOK(PlayerJump))
584 doublejump = player_multijump;
585 mjumpheight = player_jumpheight;
587 if (autocvar_sv_doublejump)
589 tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
590 if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
594 // we MUST clip velocity here!
596 f = self.velocity * trace_plane_normal;
598 self.velocity -= f * trace_plane_normal;
602 if (self.waterlevel >= WATERLEVEL_SWIMMING)
604 self.velocity_z = self.stat_sv_maxspeed * 0.7;
609 if (!IS_ONGROUND(self))
612 if (self.cvar_cl_movement_track_canjump)
613 if (!(self.flags & FL_JUMPRELEASED))
616 // sv_jumpspeedcap_min/sv_jumpspeedcap_max act as baseline
617 // velocity bounds. Final velocity is bound between (jumpheight *
618 // min + jumpheight) and (jumpheight * max + jumpheight);
620 if (autocvar_sv_jumpspeedcap_min != "")
622 float minjumpspeed = mjumpheight * stof(autocvar_sv_jumpspeedcap_min);
624 if (self.velocity_z < minjumpspeed)
625 mjumpheight += minjumpspeed - self.velocity_z;
628 if (autocvar_sv_jumpspeedcap_max != "")
630 // don't do jump speedcaps on ramps to preserve old xonotic ramjump style
631 tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
633 if (!(trace_fraction < 1 && trace_plane_normal_z < 0.98 && autocvar_sv_jumpspeedcap_max_disable_on_ramps))
635 float maxjumpspeed = mjumpheight * stof(autocvar_sv_jumpspeedcap_max);
637 if (self.velocity_z > maxjumpspeed)
638 mjumpheight -= self.velocity_z - maxjumpspeed;
642 if (!(self.lastflags & FL_ONGROUND))
644 if (autocvar_speedmeter)
645 dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
646 if (self.lastground < time - 0.3)
648 self.velocity_x *= (1 - autocvar_sv_friction_on_land);
649 self.velocity_y *= (1 - autocvar_sv_friction_on_land);
651 if (self.jumppadcount > 1)
652 dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
653 self.jumppadcount = 0;
656 self.oldvelocity_z = self.velocity_z += mjumpheight;
658 UNSET_ONGROUND(self);
659 self.flags &= ~FL_JUMPRELEASED;
661 animdecide_setaction(self, ANIMACTION_JUMP, TRUE);
663 if (autocvar_g_jump_grunt)
664 PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
666 self.restart_jump = -1; // restart jump anim next time
667 // value -1 is used to not use the teleport bit (workaround for tiny hitch when re-jumping)
671 void CheckWaterJump()
673 // check for a jump-out-of-water
674 makevectors(PHYS_INPUT_ANGLES(self));
675 vector start = self.origin;
678 normalize(v_forward);
679 vector end = start + v_forward*24;
680 traceline (start, end, TRUE, self);
681 if (trace_fraction < 1)
683 start_z = start_z + self.maxs_z - 8;
684 end = start + v_forward*24;
685 self.movedir = trace_plane_normal * -50;
686 traceline(start, end, TRUE, self);
687 if (trace_fraction == 1)
688 { // open at eye level
689 self.velocity_z = 225;
691 self.flags |= FL_WATERJUMP;
692 self.flags &= ~FL_JUMPRELEASED;
693 self.teleport_time = time + 2; // safety net
699 void CheckPlayerJump()
702 if (self.BUTTON_JUMP)
705 self.flags |= FL_JUMPRELEASED;
708 if (self.waterlevel == WATERLEVEL_SWIMMING)
712 float racecar_angle(float forward, float down)
720 float ret = vectoyaw('0 1 0' * down + '1 0 0' * forward);
722 float angle_mult = forward / (800 + forward);
725 return ret * angle_mult + 360 * (1 - angle_mult);
727 return ret * angle_mult;
730 void RaceCarPhysics()
733 // using this move type for "big rigs"
734 // the engine does not push the entity!
738 vector angles_save = self.angles;
739 float accel = bound(-1, PHYS_INPUT_MOVEVALUES(self).x / self.stat_sv_maxspeed, 1);
740 float steer = bound(-1, PHYS_INPUT_MOVEVALUES(self).y / self.stat_sv_maxspeed, 1);
742 if (g_bugrigs_reverse_speeding)
746 // back accel is DIGITAL
747 // to prevent speedhack
757 makevectors(self.angles); // new forward direction!
759 if (IS_ONGROUND(self) || g_bugrigs_air_steering)
761 float myspeed = self.velocity * v_forward;
762 float upspeed = self.velocity * v_up;
764 // responsiveness factor for steering and acceleration
765 float f = 1 / (1 + pow(max(-myspeed, myspeed) / g_bugrigs_speed_ref, g_bugrigs_speed_pow));
766 //MAXIMA: f(v) := 1 / (1 + (v / g_bugrigs_speed_ref) ^ g_bugrigs_speed_pow);
769 if (myspeed < 0 && g_bugrigs_reverse_spinning)
770 steerfactor = -myspeed * g_bugrigs_steer;
772 steerfactor = -myspeed * f * g_bugrigs_steer;
775 if (myspeed < 0 && g_bugrigs_reverse_speeding)
776 accelfactor = g_bugrigs_accel;
778 accelfactor = f * g_bugrigs_accel;
779 //MAXIMA: accel(v) := f(v) * g_bugrigs_accel;
785 myspeed = max(0, myspeed - PHYS_INPUT_TIMELENGTH * (g_bugrigs_friction_floor - g_bugrigs_friction_brake * accel));
789 if (!g_bugrigs_reverse_speeding)
790 myspeed = min(0, myspeed + PHYS_INPUT_TIMELENGTH * g_bugrigs_friction_floor);
797 myspeed = max(0, myspeed - PHYS_INPUT_TIMELENGTH * g_bugrigs_friction_floor);
801 if (g_bugrigs_reverse_stopping)
804 myspeed = min(0, myspeed + PHYS_INPUT_TIMELENGTH * (g_bugrigs_friction_floor + g_bugrigs_friction_brake * accel));
807 // terminal velocity = velocity at which 50 == accelfactor, that is, 1549 units/sec
808 //MAXIMA: friction(v) := g_bugrigs_friction_floor;
810 self.angles_y += steer * PHYS_INPUT_TIMELENGTH * steerfactor; // apply steering
811 makevectors(self.angles); // new forward direction!
813 myspeed += accel * accelfactor * PHYS_INPUT_TIMELENGTH;
815 rigvel = myspeed * v_forward + '0 0 1' * upspeed;
819 float myspeed = vlen(self.velocity);
821 // responsiveness factor for steering and acceleration
822 float f = 1 / (1 + pow(max(0, myspeed / g_bugrigs_speed_ref), g_bugrigs_speed_pow));
823 float steerfactor = -myspeed * f;
824 self.angles_y += steer * PHYS_INPUT_TIMELENGTH * steerfactor; // apply steering
826 rigvel = self.velocity;
827 makevectors(self.angles); // new forward direction!
830 rigvel *= max(0, 1 - vlen(rigvel) * g_bugrigs_friction_air * PHYS_INPUT_TIMELENGTH);
831 //MAXIMA: airfriction(v) := v * v * g_bugrigs_friction_air;
832 //MAXIMA: total_acceleration(v) := accel(v) - friction(v) - airfriction(v);
833 //MAXIMA: solve(total_acceleration(v) = 0, v);
835 if (g_bugrigs_planar_movement)
837 vector rigvel_xy, neworigin, up;
840 rigvel_z -= PHYS_INPUT_TIMELENGTH * PHYS_GRAVITY; // 4x gravity plays better
841 rigvel_xy = vec2(rigvel);
843 if (g_bugrigs_planar_movement_car_jumping)
846 mt = MOVE_NOMONSTERS;
848 tracebox(self.origin, self.mins, self.maxs, self.origin + '0 0 1024', mt, self);
849 up = trace_endpos - self.origin;
851 // BUG RIGS: align the move to the surface instead of doing collision testing
853 tracebox(trace_endpos, self.mins, self.maxs, trace_endpos + rigvel_xy * PHYS_INPUT_TIMELENGTH, mt, self);
856 tracebox(trace_endpos, self.mins, self.maxs, trace_endpos - up + '0 0 1' * rigvel_z * PHYS_INPUT_TIMELENGTH, mt, self);
858 if (trace_fraction < 0.5)
861 neworigin = self.origin;
864 neworigin = trace_endpos;
866 if (trace_fraction < 1)
868 // now set angles_x so that the car points parallel to the surface
869 self.angles = vectoangles(
870 '1 0 0' * v_forward_x * trace_plane_normal_z
872 '0 1 0' * v_forward_y * trace_plane_normal_z
874 '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y)
880 // now set angles_x so that the car points forward, but is tilted in velocity direction
881 UNSET_ONGROUND(self);
884 self.velocity = (neworigin - self.origin) * (1.0 / PHYS_INPUT_TIMELENGTH);
885 self.movetype = MOVETYPE_NOCLIP;
889 rigvel_z -= PHYS_INPUT_TIMELENGTH * PHYS_GRAVITY; // 4x gravity plays better
890 self.velocity = rigvel;
891 self.movetype = MOVETYPE_FLY;
895 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4', MOVE_NORMAL, self);
896 if (trace_fraction != 1)
898 self.angles = vectoangles2(
899 '1 0 0' * v_forward_x * trace_plane_normal_z
901 '0 1 0' * v_forward_y * trace_plane_normal_z
903 '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y),
911 vel_local_x = v_forward * self.velocity;
912 vel_local_y = v_right * self.velocity;
913 vel_local_z = v_up * self.velocity;
915 self.angles_x = racecar_angle(vel_local_x, vel_local_z);
916 self.angles_z = racecar_angle(-vel_local_y, vel_local_z);
920 vector vf1, vu1, smoothangles;
921 makevectors(self.angles);
922 float f = bound(0, PHYS_INPUT_TIMELENGTH * g_bugrigs_angle_smoothing, 1);
927 makevectors(angles_save);
928 vf1 = vf1 + v_forward * (1 - f);
929 vu1 = vu1 + v_up * (1 - f);
930 smoothangles = vectoangles2(vf1, vu1);
931 self.angles_x = -smoothangles_x;
932 self.angles_z = smoothangles_z;
936 string specialcommand = "xwxwxsxsxaxdxaxdx1x ";
937 .float specialcommand_pos;
938 void SpecialCommand()
944 if (!CheatImpulse(99))
945 print("A hollow voice says \"Plugh\".\n");
951 float speedaward_speed;
952 string speedaward_holder;
953 string speedaward_uid;
955 void race_send_speedaward(float msg)
958 // send the best speed of the round
959 WriteByte(msg, SVC_TEMPENTITY);
960 WriteByte(msg, TE_CSQC_RACE);
961 WriteByte(msg, RACE_NET_SPEED_AWARD);
962 WriteInt24_t(msg, floor(speedaward_speed+0.5));
963 WriteString(msg, speedaward_holder);
968 float speedaward_alltimebest;
969 string speedaward_alltimebest_holder;
970 string speedaward_alltimebest_uid;
972 void race_send_speedaward_alltimebest(float msg)
975 // send the best speed
976 WriteByte(msg, SVC_TEMPENTITY);
977 WriteByte(msg, TE_CSQC_RACE);
978 WriteByte(msg, RACE_NET_SPEED_AWARD_BEST);
979 WriteInt24_t(msg, floor(speedaward_alltimebest+0.5));
980 WriteString(msg, speedaward_alltimebest_holder);
984 float PM_check_keepaway(void)
987 return (self.ballcarried && g_keepaway) ? autocvar_g_keepaway_ballcarrier_highspeed : 1;
993 void PM_check_race_movetime(void)
996 self.race_movetime_frac += PHYS_INPUT_TIMELENGTH;
997 float f = floor(self.race_movetime_frac);
998 self.race_movetime_frac -= f;
999 self.race_movetime_count += f;
1000 self.race_movetime = self.race_movetime_frac + self.race_movetime_count;
1004 float PM_check_specialcommand(float buttons)
1010 else if (buttons == 1)
1012 else if (buttons == 2)
1014 else if (buttons == 128)
1016 else if (buttons == 256)
1018 else if (buttons == 512)
1020 else if (buttons == 1024)
1025 if (c == substring(specialcommand, self.specialcommand_pos, 1))
1027 self.specialcommand_pos += 1;
1028 if (self.specialcommand_pos >= strlen(specialcommand))
1030 self.specialcommand_pos = 0;
1035 else if (self.specialcommand_pos && (c != substring(specialcommand, self.specialcommand_pos - 1, 1)))
1036 self.specialcommand_pos = 0;
1041 void PM_check_nickspam(void)
1044 if (time >= self.nickspamtime)
1046 if (self.nickspamcount >= autocvar_g_nick_flood_penalty_yellow)
1048 // slight annoyance for nick change scripts
1049 PHYS_INPUT_MOVEVALUES(self) = -1 * PHYS_INPUT_MOVEVALUES(self);
1050 self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = self.BUTTON_ZOOM = self.BUTTON_CROUCH = self.BUTTON_HOOK = self.BUTTON_USE = 0;
1052 if (self.nickspamcount >= autocvar_g_nick_flood_penalty_red) // if you are persistent and the slight annoyance above does not stop you, I'll show you!
1054 PHYS_INPUT_ANGLES(self)_x = random() * 360;
1055 PHYS_INPUT_ANGLES(self)_y = random() * 360;
1056 // at least I'm not forcing retardedview by also assigning to angles_z
1057 self.fixangle = TRUE;
1063 void PM_check_punch()
1066 if (self.punchangle != '0 0 0')
1068 float f = vlen(self.punchangle) - 10 * PHYS_INPUT_TIMELENGTH;
1070 self.punchangle = normalize(self.punchangle) * f;
1072 self.punchangle = '0 0 0';
1075 if (self.punchvector != '0 0 0')
1077 float f = vlen(self.punchvector) - 30 * PHYS_INPUT_TIMELENGTH;
1079 self.punchvector = normalize(self.punchvector) * f;
1081 self.punchvector = '0 0 0';
1086 void PM_check_spider(void)
1089 if (time >= self.spider_slowness)
1091 self.stat_sv_maxspeed *= 0.5; // half speed while slow from spider
1092 self.stat_sv_airspeedlimit_nonqw *= 0.5;
1096 // predict frozen movement, as frozen players CAN move in some cases
1097 void PM_check_frozen(void)
1099 if (!PHYS_FROZEN(self))
1101 if (PHYS_DODGING_FROZEN
1103 && IS_REAL_CLIENT(self)
1107 PHYS_INPUT_MOVEVALUES(self)_x = bound(-5, PHYS_INPUT_MOVEVALUES(self).x, 5);
1108 PHYS_INPUT_MOVEVALUES(self)_y = bound(-5, PHYS_INPUT_MOVEVALUES(self).y, 5);
1109 PHYS_INPUT_MOVEVALUES(self)_z = bound(-5, PHYS_INPUT_MOVEVALUES(self).z, 5);
1112 PHYS_INPUT_MOVEVALUES(self) = '0 0 0';
1114 vector midpoint = ((self.absmin + self.absmax) * 0.5);
1115 if (pointcontents(midpoint) == CONTENT_WATER)
1117 self.velocity = self.velocity * 0.5;
1119 if (pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
1120 self.velocity_z = 200;
1124 void PM_check_blocked(void)
1127 if (!self.player_blocked)
1129 PHYS_INPUT_MOVEVALUES(self) = '0 0 0';
1130 self.disableclientprediction = 1;
1135 float speedaward_lastsent;
1136 float speedaward_lastupdate;
1137 string GetMapname(void);
1139 void PM_check_race(void)
1142 if not(g_cts || g_race)
1144 if (vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed)
1146 speedaward_speed = vlen(self.velocity - self.velocity_z * '0 0 1');
1147 speedaward_holder = self.netname;
1148 speedaward_uid = self.crypto_idfp;
1149 speedaward_lastupdate = time;
1151 if (speedaward_speed > speedaward_lastsent && time - speedaward_lastupdate > 1)
1153 string rr = (g_cts) ? CTS_RECORD : RACE_RECORD;
1154 race_send_speedaward(MSG_ALL);
1155 speedaward_lastsent = speedaward_speed;
1156 if (speedaward_speed > speedaward_alltimebest && speedaward_uid != "")
1158 speedaward_alltimebest = speedaward_speed;
1159 speedaward_alltimebest_holder = speedaward_holder;
1160 speedaward_alltimebest_uid = speedaward_uid;
1161 db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/speed"), ftos(speedaward_alltimebest));
1162 db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/crypto_idfp"), speedaward_alltimebest_uid);
1163 race_send_speedaward_alltimebest(MSG_ALL);
1169 void PM_check_vortex(void)
1172 float xyspeed = vlen(vec2(self.velocity));
1173 if (self.weapon == WEP_NEX && autocvar_g_balance_nex_charge && autocvar_g_balance_nex_charge_velocity_rate && xyspeed > autocvar_g_balance_nex_charge_minspeed)
1175 // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed
1176 xyspeed = min(xyspeed, autocvar_g_balance_nex_charge_maxspeed);
1177 float f = (xyspeed - autocvar_g_balance_nex_charge_minspeed) / (autocvar_g_balance_nex_charge_maxspeed - autocvar_g_balance_nex_charge_minspeed);
1178 // add the extra charge
1179 self.nex_charge = min(1, self.nex_charge + autocvar_g_balance_nex_charge_velocity_rate * f * PHYS_INPUT_TIMELENGTH);
1184 void PM_fly(float maxspd_mod)
1186 // noclipping or flying
1187 UNSET_ONGROUND(self);
1189 self.velocity = self.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION);
1190 makevectors(PHYS_INPUT_ANGLES(self));
1191 //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z;
1192 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1193 + v_right * PHYS_INPUT_MOVEVALUES(self).y
1194 + '0 0 1' * PHYS_INPUT_MOVEVALUES(self).z;
1196 vector wishdir = normalize(wishvel);
1197 float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(self) * maxspd_mod);
1198 if (time >= self.teleport_time)
1199 PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
1202 void PM_swim(float maxspd_mod)
1205 UNSET_ONGROUND(self);
1207 makevectors(PHYS_INPUT_ANGLES(self));
1208 //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z;
1209 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1210 + v_right * PHYS_INPUT_MOVEVALUES(self).y
1211 + '0 0 1' * PHYS_INPUT_MOVEVALUES(self).z;
1212 if (wishvel == '0 0 0')
1213 wishvel = '0 0 -60'; // drift towards bottom
1215 vector wishdir = normalize(wishvel);
1216 float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(self) * maxspd_mod);
1217 wishspeed = wishspeed * 0.7;
1220 self.velocity *= (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION);
1223 float addspeed = wishspeed - self.velocity * wishdir;
1226 float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed);
1227 self.velocity += accelspeed * wishdir;
1229 CSQC_ClientMovement_Move();
1233 // water acceleration
1234 PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
1238 void PM_ladder(float maxspd_mod)
1241 // on a spawnfunc_func_ladder or swimming in spawnfunc_func_water
1242 UNSET_ONGROUND(self);
1245 g = PHYS_GRAVITY * PHYS_INPUT_TIMELENGTH;
1246 if (PHYS_ENTGRAVITY(self))
1247 g *= PHYS_ENTGRAVITY(self);
1248 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1251 self.velocity_z += g;
1254 self.velocity = self.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION);
1255 makevectors(PHYS_INPUT_ANGLES(self));
1256 //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z;
1257 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1258 + v_right * PHYS_INPUT_MOVEVALUES(self).y
1259 + '0 0 1' * PHYS_INPUT_MOVEVALUES(self).z;
1260 self.velocity_z += g;
1261 if (self.ladder_entity.classname == "func_water")
1263 float f = vlen(wishvel);
1264 if (f > self.ladder_entity.speed)
1265 wishvel *= (self.ladder_entity.speed / f);
1267 self.watertype = self.ladder_entity.skin;
1268 f = self.ladder_entity.origin_z + self.ladder_entity.maxs_z;
1269 if ((self.origin_z + self.view_ofs_z) < f)
1270 self.waterlevel = WATERLEVEL_SUBMERGED;
1271 else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f)
1272 self.waterlevel = WATERLEVEL_SWIMMING;
1273 else if ((self.origin_z + self.mins_z + 1) < f)
1274 self.waterlevel = WATERLEVEL_WETFEET;
1277 self.waterlevel = WATERLEVEL_NONE;
1278 self.watertype = CONTENT_EMPTY;
1282 vector wishdir = normalize(wishvel);
1283 float wishspeed = min(vlen(wishvel), self.stat_sv_maxspeed * maxspd_mod);
1284 if (time >= self.teleport_time)
1285 // water acceleration
1286 PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE*maxspd_mod, 1, 0, 0, 0);
1290 void PM_jetpack(float maxspd_mod)
1292 //makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
1293 makevectors(PHYS_INPUT_ANGLES(self));
1294 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1295 + v_right * PHYS_INPUT_MOVEVALUES(self).y;
1296 // add remaining speed as Z component
1297 float maxairspd = PHYS_MAXAIRSPEED * max(1, maxspd_mod);
1298 // fix speedhacks :P
1299 wishvel = normalize(wishvel) * min(1, vlen(wishvel) / maxairspd);
1300 // add the unused velocity as up component
1303 // if (self.BUTTON_JUMP)
1304 wishvel_z = sqrt(max(0, 1 - wishvel * wishvel));
1306 // it is now normalized, so...
1307 float a_side = PHYS_JETPACK_ACCEL_SIDE;
1308 float a_up = PHYS_JETPACK_ACCEL_UP;
1309 float a_add = PHYS_JETPACK_ANTIGRAVITY * PHYS_GRAVITY;
1311 wishvel_x *= a_side;
1312 wishvel_y *= a_side;
1317 //////////////////////////////////////////////////////////////////////////////////////
1318 // finding the maximum over all vectors of above form
1319 // with wishvel having an absolute value of 1
1320 //////////////////////////////////////////////////////////////////////////////////////
1321 // we're finding the maximum over
1322 // f(a_side, a_up, a_add, z) := a_side * (1 - z^2) + (a_add + a_up * z)^2;
1323 // for z in the range from -1 to 1
1324 //////////////////////////////////////////////////////////////////////////////////////
1325 // maximum is EITHER attained at the single extreme point:
1326 float a_diff = a_side * a_side - a_up * a_up;
1330 f = a_add * a_up / a_diff; // this is the zero of diff(f(a_side, a_up, a_add, z), z)
1331 if (f > -1 && f < 1) // can it be attained?
1333 best = (a_diff + a_add * a_add) * (a_diff + a_up * a_up) / a_diff;
1334 //print("middle\n");
1337 // OR attained at z = 1:
1338 f = (a_up + a_add) * (a_up + a_add);
1344 // OR attained at z = -1:
1345 f = (a_up - a_add) * (a_up - a_add);
1349 //print("bottom\n");
1352 //////////////////////////////////////////////////////////////////////////////////////
1354 //print("best possible acceleration: ", ftos(best), "\n");
1357 fxy = bound(0, 1 - (self.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / PHYS_JETPACK_MAXSPEED_SIDE, 1);
1358 if (wishvel_z - PHYS_GRAVITY > 0)
1359 fz = bound(0, 1 - self.velocity_z / PHYS_JETPACK_MAXSPEED_UP, 1);
1361 fz = bound(0, 1 + self.velocity_z / PHYS_JETPACK_MAXSPEED_UP, 1);
1364 fvel = vlen(wishvel);
1367 wishvel_z = (wishvel_z - PHYS_GRAVITY) * fz + PHYS_GRAVITY;
1369 fvel = min(1, vlen(wishvel) / best);
1370 if (PHYS_JETPACK_FUEL && !(ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO))
1371 f = min(1, PHYS_AMMO_FUEL(self) / (PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel));
1375 //print("this acceleration: ", ftos(vlen(wishvel) * f), "\n");
1377 if (f > 0 && wishvel != '0 0 0')
1379 self.velocity = self.velocity + wishvel * f * PHYS_INPUT_TIMELENGTH;
1380 UNSET_ONGROUND(self);
1383 if (!(ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO))
1384 self.ammo_fuel -= PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel * f;
1386 self.items |= IT_USING_JETPACK;
1388 // jetpack also inhibits health regeneration, but only for 1 second
1389 self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen);
1394 void PM_walk(float buttons_prev, float maxspd_mod)
1397 // we get here if we ran out of ammo
1398 if ((ITEMS(self) & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32) && self.ammo_fuel < 0.01)
1399 sprint(self, "You don't have any fuel for the ^2Jetpack\n");
1402 makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
1403 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1404 + v_right * PHYS_INPUT_MOVEVALUES(self).y;
1407 if (!(self.lastflags & FL_ONGROUND))
1409 if (autocvar_speedmeter)
1410 dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
1411 if (self.lastground < time - 0.3)
1412 self.velocity *= (1 - autocvar_sv_friction_on_land);
1413 if (self.jumppadcount > 1)
1414 dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
1415 self.jumppadcount = 0;
1419 vector v = self.velocity;
1424 f = 1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION * ((f < PHYS_STOPSPEED) ? (PHYS_STOPSPEED / f) : 1);
1428 Mathematical analysis time!
1430 Our goal is to invert this mess.
1432 For the two cases we get:
1433 v = v0 * (1 - PHYS_INPUT_TIMELENGTH * (PHYS_STOPSPEED / v0) * PHYS_FRICTION)
1434 = v0 - PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED * PHYS_FRICTION
1435 v0 = v + PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED * PHYS_FRICTION
1437 v = v0 * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
1438 v0 = v / (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
1440 These cases would be chosen ONLY if:
1442 v + PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED * PHYS_FRICTION < PHYS_STOPSPEED
1443 v < PHYS_STOPSPEED * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
1445 v0 >= PHYS_STOPSPEED
1446 v / (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION) >= PHYS_STOPSPEED
1447 v >= PHYS_STOPSPEED * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
1452 vector wishdir = normalize(wishvel);
1453 float wishspeed = vlen(wishvel);
1454 wishspeed = min(wishspeed, PHYS_MAXSPEED(self) * maxspd_mod);
1455 if (IS_DUCKED(self))
1458 if (time >= self.teleport_time)
1459 PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
1463 float addspeed = wishspeed - dotproduct(self.velocity, wishdir);
1466 float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed);
1467 self.velocity += accelspeed * wishdir;
1469 float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
1470 if (!(GAMEPLAYFIX_NOGRAVITYONGROUND))
1471 self.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1);
1472 if (self.velocity * self.velocity)
1473 CSQC_ClientMovement_Move();
1474 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1475 if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
1476 self.velocity_z -= g * 0.5;
1480 void PM_air(float buttons_prev, float maxspd_mod)
1483 // we get here if we ran out of ammo
1484 if ((ITEMS(self) & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32) && PHYS_AMMO_FUEL(self) < 0.01)
1485 sprint(self, "You don't have any fuel for the ^2Jetpack\n");
1487 float maxairspd, airaccel;
1488 maxairspd = PHYS_MAXAIRSPEED * min(maxspd_mod, 1);
1489 airaccel = PHYS_AIRACCELERATE * min(maxspd_mod, 1);
1491 makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
1492 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1493 + v_right * PHYS_INPUT_MOVEVALUES(self).y;
1495 vector wishdir = normalize(wishvel);
1496 float wishspeed = vlen(wishvel);
1497 float wishspeed0 = min(wishspeed, PHYS_MAXSPEED(self) * maxspd_mod);
1498 wishspeed = min(wishspeed, maxairspd);
1499 if (IS_DUCKED(self))
1502 if (time >= self.teleport_time)
1504 if (pmove_waterjumptime <= 0)
1507 float airaccelqw = PHYS_AIRACCEL_QW(self);
1508 float accelerating = (self.velocity * wishdir > 0);
1509 float wishspeed2 = wishspeed;
1512 if (PHYS_AIRSTOPACCELERATE)
1514 vector curdir = normalize(vec2(self.velocity));
1515 airaccel += (PHYS_AIRSTOPACCELERATE*maxspd_mod - airaccel) * max(0, -(curdir * wishdir));
1517 // note that for straight forward jumping:
1518 // step = accel * PHYS_INPUT_TIMELENGTH * wishspeed0;
1519 // accel = bound(0, wishspeed - vel_xy_current, step) * accelqw + step * (1 - accelqw);
1521 // dv/dt = accel * maxspeed (when slow)
1522 // dv/dt = accel * maxspeed * (1 - accelqw) (when fast)
1523 // log dv/dt = logaccel + logmaxspeed (when slow)
1524 // log dv/dt = logaccel + logmaxspeed + log(1 - accelqw) (when fast)
1525 float strafity = IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), -90) + IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), +90); // if one is nonzero, other is always zero
1526 if (PHYS_MAXAIRSTRAFESPEED)
1527 wishspeed = min(wishspeed, GeomLerp(PHYS_MAXAIRSPEED*maxspd_mod, strafity, PHYS_MAXAIRSTRAFESPEED*maxspd_mod));
1528 if (PHYS_AIRSTRAFEACCELERATE)
1529 airaccel = GeomLerp(airaccel, strafity, PHYS_AIRSTRAFEACCELERATE*maxspd_mod);
1530 if (PHYS_AIRSTRAFEACCEL_QW(self))
1531 airaccelqw = copysign(1-GeomLerp(1-fabs(PHYS_AIRACCEL_QW(self)), strafity, 1-fabs(PHYS_AIRSTRAFEACCEL_QW(self))), ((strafity > 0.5) ? PHYS_AIRSTRAFEACCEL_QW(self) : PHYS_AIRACCEL_QW(self)));
1534 if (PHYS_WARSOWBUNNY_TURNACCEL && accelerating && PHYS_INPUT_MOVEVALUES(self).y == 0 && PHYS_INPUT_MOVEVALUES(self).x != 0)
1535 PM_AirAccelerate(wishdir, wishspeed);
1537 PM_Accelerate(wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, PHYS_AIRACCEL_QW_STRETCHFACTOR(self), PHYS_AIRACCEL_SIDEWAYS_FRICTION / maxairspd, PHYS_AIRSPEEDLIMIT_NONQW(self));
1539 if (PHYS_AIRCONTROL)
1540 CPM_PM_Aircontrol(wishdir, wishspeed2);
1543 float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
1544 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1545 self.velocity_z -= g * 0.5;
1547 self.velocity_z -= g;
1548 CSQC_ClientMovement_Move();
1549 if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
1550 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1551 self.velocity_z -= g * 0.5;
1555 // used for calculating airshots
1556 float PM_is_flying()
1558 if (IS_ONGROUND(self))
1560 if (self.waterlevel >= WATERLEVEL_SWIMMING)
1562 traceline(self.origin, self.origin - '0 0 48', MOVE_NORMAL, self);
1563 return trace_fraction >= 1;
1569 //Con_Printf(" %f", PHYS_INPUT_TIMELENGTH);
1570 if (!(PHYS_INPUT_BUTTONS(self) & 2)) // !jump
1571 UNSET_JUMP_HELD(self); // canjump = true
1572 pmove_waterjumptime -= PHYS_INPUT_TIMELENGTH;
1573 CSQC_ClientMovement_UpdateStatus();
1577 WarpZone_PlayerPhysics_FixVAngle();
1579 float maxspeed_mod = 1;
1580 maxspeed_mod *= PM_check_keepaway();
1581 maxspeed_mod *= PHYS_HIGHSPEED;
1584 Physics_UpdateStats(maxspeed_mod);
1586 if (self.PlayerPhysplug)
1587 if (self.PlayerPhysplug())
1591 PM_check_race_movetime();
1593 anticheat_physics();
1595 float buttons = PHYS_INPUT_BUTTONS(self);
1597 if (PM_check_specialcommand(buttons))
1602 if (buttons != self.buttons_old || PHYS_INPUT_MOVEVALUES(self) != self.movement_old || PHYS_INPUT_ANGLES(self) != self.v_angle_old)
1603 self.parm_idlesince = time;
1606 float buttons_prev = self.buttons_old;
1607 self.buttons_old = buttons;
1608 self.movement_old = PHYS_INPUT_MOVEVALUES(self);
1609 self.v_angle_old = PHYS_INPUT_ANGLES(self);
1611 PM_check_nickspam();
1615 if (IS_BOT_CLIENT(self))
1617 if (playerdemo_read())
1622 self.items &= ~IT_USING_JETPACK;
1624 if (IS_PLAYER(self))
1628 if (self.race_penalty)
1629 if (time > self.race_penalty)
1630 self.race_penalty = 0;
1633 float not_allowed_to_move = 0;
1635 if (self.race_penalty)
1636 not_allowed_to_move = 1;
1639 if (!autocvar_sv_ready_restart_after_countdown)
1640 if (time < game_starttime)
1641 not_allowed_to_move = 1;
1644 if (not_allowed_to_move)
1646 self.velocity = '0 0 0';
1647 self.movetype = MOVETYPE_NONE;
1649 self.disableclientprediction = 2;
1653 else if (self.disableclientprediction == 2)
1655 if (self.movetype == MOVETYPE_NONE)
1656 self.movetype = MOVETYPE_WALK;
1657 self.disableclientprediction = 0;
1663 if (self.movetype == MOVETYPE_NONE)
1668 // when we get here, disableclientprediction cannot be 2
1669 self.disableclientprediction = 0;
1670 if (time < self.ladder_time)
1671 self.disableclientprediction = 1;
1679 MUTATOR_CALLHOOK(PlayerPhysics);
1687 if (self.in_swamp) {
1688 maxspeed_mod *= self.swamp_slowdown; //cvar("g_balance_swamp_moverate");
1693 // conveyors: first fix velocity
1694 if (self.conveyor.state)
1695 self.velocity -= self.conveyor.movedir;
1699 if (!IS_PLAYER(self))
1701 maxspeed_mod *= autocvar_sv_spectator_speed_multiplier;
1702 if (!self.spectatorspeed)
1703 self.spectatorspeed = maxspeed_mod;
1704 if (self.impulse && self.impulse <= 19 || (self.impulse >= 200 && self.impulse <= 209) || (self.impulse >= 220 && self.impulse <= 229))
1706 if (self.lastclassname != "player")
1708 if (self.impulse == 10 || self.impulse == 15 || self.impulse == 18 || (self.impulse >= 200 && self.impulse <= 209))
1709 self.spectatorspeed = bound(1, self.spectatorspeed + 0.5, 5);
1710 else if (self.impulse == 11)
1711 self.spectatorspeed = maxspeed_mod;
1712 else if (self.impulse == 12 || self.impulse == 16 || self.impulse == 19 || (self.impulse >= 220 && self.impulse <= 229))
1713 self.spectatorspeed = bound(1, self.spectatorspeed - 0.5, 5);
1714 else if (self.impulse >= 1 && self.impulse <= 9)
1715 self.spectatorspeed = 1 + 0.5 * (self.impulse - 1);
1716 } // otherwise just clear
1719 maxspeed_mod *= self.spectatorspeed;
1724 // if dead, behave differently
1725 // in CSQC, physics don't handle dead player
1731 if (!self.fixangle && !g_bugrigs)
1732 self.angles = '0 1 0' * PHYS_INPUT_ANGLES(self).y;
1736 if (IS_ONGROUND(self))
1737 if (IS_PLAYER(self)) // no fall sounds for observers thank you very much
1741 if (self.waterlevel < WATERLEVEL_SWIMMING)
1742 if (time >= self.ladder_time)
1745 self.nextstep = time + 0.3 + random() * 0.1;
1746 trace_dphitq3surfaceflags = 0;
1747 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
1748 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS))
1750 if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
1751 GlobalSound(globalsound_metalfall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
1753 GlobalSound(globalsound_fall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
1763 if (IS_PLAYER(self))
1768 if (self.flags & /* FL_WATERJUMP */ 2048)
1770 self.velocity_x = self.movedir_x;
1771 self.velocity_y = self.movedir_y;
1772 if (time > self.teleport_time || self.waterlevel == WATERLEVEL_NONE)
1774 self.flags &= ~/* FL_WATERJUMP */ 2048;
1775 self.teleport_time = 0;
1780 else if (g_bugrigs && IS_PLAYER(self))
1784 else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY || self.movetype == MOVETYPE_FLY_WORLDONLY)
1785 PM_fly(maxspeed_mod);
1787 else if (self.waterlevel >= WATERLEVEL_SWIMMING)
1788 PM_swim(maxspeed_mod);
1790 else if (time < self.ladder_time)
1791 PM_ladder(maxspeed_mod);
1793 else if ((ITEMS(self) & IT_JETPACK) && PHYS_BUTTON_HOOK(self) && (!PHYS_JETPACK_FUEL || PHYS_AMMO_FUEL(self) >= 0.01 || (ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO)) && !PHYS_FROZEN(self))
1794 PM_jetpack(maxspeed_mod);
1799 // jump if on ground with jump button pressed but only if it has been
1800 // released at least once since the last jump
1801 if (PHYS_INPUT_BUTTONS(self) & 2)
1803 if (IS_ONGROUND(self) && (!IS_JUMP_HELD(self) || !cvar("cl_movement_track_canjump")))
1805 self.velocity_z += PHYS_JUMPVELOCITY;
1806 UNSET_ONGROUND(self);
1807 SET_JUMP_HELD(self); // canjump = false
1811 UNSET_JUMP_HELD(self); // canjump = true
1813 if (IS_ONGROUND(self))
1814 PM_walk(buttons_prev, maxspeed_mod);
1816 PM_air(buttons_prev, maxspeed_mod);
1820 if (!IS_OBSERVER(self))
1826 if (IS_ONGROUND(self))
1827 self.lastground = time;
1830 // conveyors: then break velocity again
1831 if (self.conveyor.state)
1832 self.velocity += self.conveyor.movedir;
1835 self.lastflags = self.flags;
1836 self.lastclassname = self.classname;
1839 void CSQC_ClientMovement_PlayerMove_Frame()
1841 // if a move is more than 50ms, do it as two moves (matching qwsv)
1842 //Con_Printf("%i ", self.cmd.msec);
1843 if (PHYS_INPUT_TIMELENGTH > 0.0005)
1845 if (PHYS_INPUT_TIMELENGTH > 0.05)
1847 PHYS_INPUT_TIMELENGTH /= 2;
1853 // we REALLY need this handling to happen, even if the move is not executed
1854 if (!(PHYS_INPUT_BUTTONS(self) & 2)) // !jump
1855 UNSET_JUMP_HELD(self); // canjump = true
1858 #undef PHYS_INPUT_ANGLES
1859 #undef PHYS_INPUT_BUTTONS
1861 #undef PHYS_INPUT_TIMELENGTH
1863 #undef PHYS_INPUT_MOVEVALUES
1865 #undef GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE
1866 #undef GAMEPLAYFIX_NOGRAVITYONGROUND
1867 #undef GAMEPLAYFIX_Q2AIRACCELERATE
1874 #undef SET_JUMP_HELD
1875 #undef UNSET_JUMP_HELD
1879 #undef UNSET_ONGROUND
1881 #undef PHYS_ACCELERATE
1882 #undef PHYS_AIRACCEL_QW
1883 #undef PHYS_AIRACCEL_QW_STRETCHFACTOR
1884 #undef PHYS_AIRACCEL_SIDEWAYS_FRICTION
1885 #undef PHYS_AIRACCELERATE
1886 #undef PHYS_AIRCONTROL
1887 #undef PHYS_AIRCONTROL_PENALTY
1888 #undef PHYS_AIRCONTROL_POWER
1889 #undef PHYS_AIRSPEEDLIMIT_NONQW
1890 #undef PHYS_AIRSTOPACCELERATE
1891 #undef PHYS_AIRSTRAFEACCEL_QW
1892 #undef PHYS_AIRSTRAFEACCELERATE
1893 #undef PHYS_EDGEFRICTION
1894 #undef PHYS_ENTGRAVITY
1895 #undef PHYS_FRICTION
1897 #undef PHYS_HIGHSPEED
1898 #undef PHYS_JUMPVELOCITY
1899 #undef PHYS_MAXAIRSPEED
1900 #undef PHYS_MAXAIRSTRAFESPEED
1901 #undef PHYS_MAXSPEED
1902 #undef PHYS_STEPHEIGHT
1903 #undef PHYS_STOPSPEED
1904 #undef PHYS_WARSOWBUNNY_ACCEL
1905 #undef PHYS_WARSOWBUNNY_BACKTOSIDERATIO
1906 #undef PHYS_WARSOWBUNNY_AIRFORWARDACCEL
1907 #undef PHYS_WARSOWBUNNY_TOPSPEED
1908 #undef PHYS_WARSOWBUNNY_TURNACCEL
1912 void SV_PlayerPhysics(void)