11 .float spectatorspeed;
16 .string lastclassname;
18 .float() PlayerPhysplug;
21 .float stat_dodging_frozen;
22 .float stat_sv_airaccel_qw;
23 .float stat_sv_airstrafeaccel_qw;
24 .float stat_sv_airspeedlimit_nonqw;
25 .float stat_sv_maxspeed;
26 .float stat_movement_highspeed;
28 .float stat_jetpack_accel_side;
29 .float stat_jetpack_accel_up;
30 .float stat_jetpack_antigravity;
31 .float stat_jetpack_fuel;
32 .float stat_jetpack_maxspeed_up;
33 .float stat_jetpack_maxspeed_side;
35 void Physics_AddStats()
37 // g_movementspeed hack
38 addstat(STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW, AS_FLOAT, stat_sv_airspeedlimit_nonqw);
39 addstat(STAT_MOVEVARS_MAXSPEED, AS_FLOAT, stat_sv_maxspeed);
40 addstat(STAT_MOVEVARS_AIRACCEL_QW, AS_FLOAT, stat_sv_airaccel_qw);
41 addstat(STAT_MOVEVARS_AIRSTRAFEACCEL_QW, AS_FLOAT, stat_sv_airstrafeaccel_qw);
42 addstat(STAT_MOVEVARS_HIGHSPEED, AS_FLOAT, stat_movement_highspeed);
45 addstat(STAT_DODGING_FROZEN, AS_INT, stat_dodging_frozen);
48 addstat(STAT_JETPACK_ACCEL_SIDE, AS_FLOAT, stat_jetpack_accel_side);
49 addstat(STAT_JETPACK_ACCEL_UP, AS_FLOAT, stat_jetpack_accel_up);
50 addstat(STAT_JETPACK_ANTIGRAVITY, AS_FLOAT, stat_jetpack_antigravity);
51 addstat(STAT_JETPACK_FUEL, AS_FLOAT, stat_jetpack_fuel);
52 addstat(STAT_JETPACK_MAXSPEED_UP, AS_FLOAT, stat_jetpack_maxspeed_up);
53 addstat(STAT_JETPACK_MAXSPEED_SIDE, AS_FLOAT, stat_jetpack_maxspeed_side);
57 // Client/server mappings
61 #define PHYS_INPUT_ANGLES(s) input_angles
62 #define PHYS_INPUT_BUTTONS(s) input_buttons
64 #define PHYS_INPUT_TIMELENGTH input_timelength
66 #define PHYS_INPUT_MOVEVALUES(s) input_movevalues
68 #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE
69 #define GAMEPLAYFIX_NOGRAVITYONGROUND moveflags & MOVEFLAG_NOGRAVITYONGROUND
70 #define GAMEPLAYFIX_Q2AIRACCELERATE moveflags & MOVEFLAG_Q2AIRACCELERATE
72 #define IS_DUCKED(s) (s.pmove_flags & PMF_DUCKED)
73 #define SET_DUCKED(s) s.pmove_flags |= PMF_DUCKED
74 #define UNSET_DUCKED(s) s.pmove_flags &= ~PMF_DUCKED
76 #define IS_JUMP_HELD(s) (s.pmove_flags & PMF_JUMP_HELD)
77 #define SET_JUMP_HELD(s) s.pmove_flags |= PMF_JUMP_HELD
78 #define UNSET_JUMP_HELD(s) s.pmove_flags &= ~PMF_JUMP_HELD
80 #define IS_ONGROUND(s) (s.pmove_flags & PMF_ONGROUND)
81 #define SET_ONGROUND(s) s.pmove_flags |= PMF_ONGROUND
82 #define UNSET_ONGROUND(s) s.pmove_flags &= ~PMF_ONGROUND
84 #define ITEMS(s) getstati(STAT_ITEMS, 0, 24)
85 #define PHYS_AMMO_FUEL(s) getstatf(STAT_FUEL)
86 #define PHYS_FROZEN(s) getstati(STAT_FROZEN)
88 #define PHYS_ACCELERATE getstatf(STAT_MOVEVARS_ACCELERATE)
89 #define PHYS_AIRACCEL_QW(s) getstatf(STAT_MOVEVARS_AIRACCEL_QW)
90 #define PHYS_AIRACCEL_QW_STRETCHFACTOR(s) getstatf(STAT_MOVEVARS_AIRACCEL_QW_STRETCHFACTOR)
91 #define PHYS_AIRACCEL_SIDEWAYS_FRICTION getstatf(STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION)
92 #define PHYS_AIRACCELERATE getstatf(STAT_MOVEVARS_AIRACCELERATE)
93 #define PHYS_AIRCONTROL getstatf(STAT_MOVEVARS_AIRCONTROL)
94 #define PHYS_AIRCONTROL_PENALTY getstatf(STAT_MOVEVARS_AIRCONTROL_PENALTY)
95 #define PHYS_AIRCONTROL_POWER getstatf(STAT_MOVEVARS_AIRCONTROL_POWER)
96 #define PHYS_AIRSPEEDLIMIT_NONQW(s) getstatf(STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW)
97 #define PHYS_AIRSTOPACCELERATE getstatf(STAT_MOVEVARS_AIRSTOPACCELERATE)
98 #define PHYS_AIRSTRAFEACCEL_QW(s) getstatf(STAT_MOVEVARS_AIRSTRAFEACCEL_QW)
99 #define PHYS_AIRSTRAFEACCELERATE getstatf(STAT_MOVEVARS_AIRSTRAFEACCELERATE)
100 #define PHYS_ENTGRAVITY(s) getstatf(STAT_MOVEVARS_ENTGRAVITY)
101 #define PHYS_FRICTION getstatf(STAT_MOVEVARS_FRICTION)
102 #define PHYS_GRAVITY getstatf(STAT_MOVEVARS_GRAVITY)
103 #define PHYS_HIGHSPEED getstatf(STAT_MOVEVARS_HIGHSPEED)
104 #define PHYS_JUMPVELOCITY getstatf(STAT_MOVEVARS_JUMPVELOCITY)
105 #define PHYS_MAXAIRSPEED getstatf(STAT_MOVEVARS_MAXAIRSPEED)
106 #define PHYS_MAXAIRSTRAFESPEED getstatf(STAT_MOVEVARS_MAXAIRSTRAFESPEED)
107 #define PHYS_MAXSPEED(s) getstatf(STAT_MOVEVARS_MAXSPEED)
108 #define PHYS_STEPHEIGHT getstatf(STAT_MOVEVARS_STEPHEIGHT)
109 #define PHYS_STOPSPEED getstatf(STAT_MOVEVARS_STOPSPEED)
110 #define PHYS_WARSOWBUNNY_ACCEL getstatf(STAT_MOVEVARS_WARSOWBUNNY_ACCEL)
111 #define PHYS_WARSOWBUNNY_BACKTOSIDERATIO getstatf(STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO)
112 #define PHYS_WARSOWBUNNY_AIRFORWARDACCEL getstatf(STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL)
113 #define PHYS_WARSOWBUNNY_TOPSPEED getstatf(STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED)
114 #define PHYS_WARSOWBUNNY_TURNACCEL getstatf(STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL)
116 #define PHYS_JETPACK_ACCEL_UP getstatf(STAT_JETPACK_ACCEL_UP)
117 #define PHYS_JETPACK_ACCEL_SIDE getstatf(STAT_JETPACK_ACCEL_SIDE)
118 #define PHYS_JETPACK_ANTIGRAVITY getstatf(STAT_JETPACK_ANTIGRAVITY)
119 #define PHYS_JETPACK_FUEL getstatf(STAT_JETPACK_FUEL)
120 #define PHYS_JETPACK_MAXSPEED_UP getstatf(STAT_JETPACK_MAXSPEED_UP)
121 #define PHYS_JETPACK_MAXSPEED_SIDE getstatf(STAT_JETPACK_MAXSPEED_SIDE)
123 #define PHYS_BUTTON_HOOK(s) (input_buttons & 32)
125 #define PHYS_DODGING_FROZEN getstati(STAT_DODGING_FROZEN)
129 #define PHYS_INPUT_ANGLES(s) s.v_angle
131 #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))
133 #define PHYS_INPUT_TIMELENGTH frametime
135 #define PHYS_INPUT_MOVEVALUES(s) s.movement
137 #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE autocvar_sv_gameplayfix_gravityunaffectedbyticrate
138 #define GAMEPLAYFIX_NOGRAVITYONGROUND cvar("sv_gameplayfix_nogravityonground")
139 #define GAMEPLAYFIX_Q2AIRACCELERATE autocvar_sv_gameplayfix_q2airaccelerate
141 #define IS_DUCKED(s) s.crouch
142 #define SET_DUCKED(s) s.crouch = TRUE
143 #define UNSET_DUCKED(s) s.crouch = FALSE
145 #define IS_JUMP_HELD(s) (s.flags & FL_JUMPRELEASED == 0)
146 #define SET_JUMP_HELD(s) s.flags &= ~FL_JUMPRELEASED
147 #define UNSET_JUMP_HELD(s) s.flags |= FL_JUMPRELEASED
149 #define IS_ONGROUND(s) (s.flags & FL_ONGROUND)
150 #define SET_ONGROUND(s) s.flags |= FL_ONGROUND
151 #define UNSET_ONGROUND(s) s.flags &= ~FL_ONGROUND
153 #define ITEMS(s) s.items
154 #define PHYS_AMMO_FUEL(s) s.ammo_fuel
155 #define PHYS_FROZEN(s) s.frozen
157 #define PHYS_ACCELERATE autocvar_sv_accelerate
158 #define PHYS_AIRACCEL_QW(s) s.stat_sv_airaccel_qw
159 #define PHYS_AIRACCEL_QW_STRETCHFACTOR(s) autocvar_sv_airaccel_qw_stretchfactor
160 #define PHYS_AIRACCEL_SIDEWAYS_FRICTION autocvar_sv_airaccel_sideways_friction
161 #define PHYS_AIRACCELERATE autocvar_sv_airaccelerate
162 #define PHYS_AIRCONTROL autocvar_sv_aircontrol
163 #define PHYS_AIRCONTROL_PENALTY autocvar_sv_aircontrol_penalty
164 #define PHYS_AIRCONTROL_POWER autocvar_sv_aircontrol_power
165 #define PHYS_AIRSPEEDLIMIT_NONQW(s) s.stat_sv_airspeedlimit_nonqw
166 #define PHYS_AIRSTOPACCELERATE autocvar_sv_airstopaccelerate
167 #define PHYS_AIRSTRAFEACCEL_QW(s) s.stat_sv_airstrafeaccel_qw
168 #define PHYS_AIRSTRAFEACCELERATE autocvar_sv_airstrafeaccelerate
169 #define PHYS_ENTGRAVITY(s) s.gravity
170 #define PHYS_FRICTION autocvar_sv_friction
171 #define PHYS_GRAVITY autocvar_sv_gravity
172 #define PHYS_HIGHSPEED autocvar_g_movement_highspeed
173 #define PHYS_JUMPVELOCITY autocvar_sv_jumpvelocity
174 #define PHYS_MAXAIRSPEED autocvar_sv_maxairspeed
175 #define PHYS_MAXAIRSTRAFESPEED autocvar_sv_maxairstrafespeed
176 #define PHYS_MAXSPEED(s) s.stat_sv_maxspeed
177 #define PHYS_STEPHEIGHT autocvar_sv_stepheight
178 #define PHYS_STOPSPEED autocvar_sv_stopspeed
179 #define PHYS_WARSOWBUNNY_ACCEL autocvar_sv_warsowbunny_accel
180 #define PHYS_WARSOWBUNNY_BACKTOSIDERATIO autocvar_sv_warsowbunny_backtosideratio
181 #define PHYS_WARSOWBUNNY_AIRFORWARDACCEL autocvar_sv_warsowbunny_airforwardaccel
182 #define PHYS_WARSOWBUNNY_TOPSPEED autocvar_sv_warsowbunny_topspeed
183 #define PHYS_WARSOWBUNNY_TURNACCEL autocvar_sv_warsowbunny_turnaccel
185 #define PHYS_JETPACK_ACCEL_UP autocvar_g_jetpack_acceleration_up
186 #define PHYS_JETPACK_ACCEL_SIDE autocvar_g_jetpack_acceleration_side
187 #define PHYS_JETPACK_ANTIGRAVITY autocvar_g_jetpack_antigravity
188 #define PHYS_JETPACK_FUEL autocvar_g_jetpack_fuel
189 #define PHYS_JETPACK_MAXSPEED_UP autocvar_g_jetpack_maxspeed_up
190 #define PHYS_JETPACK_MAXSPEED_SIDE autocvar_g_jetpack_maxspeed_side
192 #define PHYS_BUTTON_HOOK(s) s.BUTTON_HOOK
194 #define PHYS_DODGING_FROZEN autocvar_sv_dodging_frozen
198 float IsMoveInDirection(vector mv, float angle) // key mix factor
200 if (mv_x == 0 && mv_y == 0)
201 return 0; // avoid division by zero
202 angle -= RAD2DEG * atan2(mv_y, mv_x);
203 angle = remainder(angle, 360) / 45;
204 return angle > 1 ? 0 : angle < -1 ? 0 : 1 - fabs(angle);
207 float GeomLerp(float a, float lerp, float b)
209 return a == 0 ? (lerp < 1 ? 0 : b)
210 : b == 0 ? (lerp > 0 ? 0 : a)
211 : a * pow(fabs(b / a), lerp);
215 float pmove_waterjumptime; // weird engine flag we shouldn't really use but have to for now
218 const float unstick_count = 27;
219 vector unstick_offsets[unstick_count] =
221 // 1 no nudge (just return the original if this test passes)
224 ' 0.000 0.000 0.125', '0.000 0.000 -0.125',
225 '-0.125 0.000 0.000', '0.125 0.000 0.000',
226 ' 0.000 -0.125 0.000', '0.000 0.125 0.000',
227 // 4 diagonal flat nudges
228 '-0.125 -0.125 0.000', '0.125 -0.125 0.000',
229 '-0.125 0.125 0.000', '0.125 0.125 0.000',
230 // 8 diagonal upward nudges
231 '-0.125 0.000 0.125', '0.125 0.000 0.125',
232 ' 0.000 -0.125 0.125', '0.000 0.125 0.125',
233 '-0.125 -0.125 0.125', '0.125 -0.125 0.125',
234 '-0.125 0.125 0.125', '0.125 0.125 0.125',
235 // 8 diagonal downward nudges
236 '-0.125 0.000 -0.125', '0.125 0.000 -0.125',
237 ' 0.000 -0.125 -0.125', '0.000 0.125 -0.125',
238 '-0.125 -0.125 -0.125', '0.125 -0.125 -0.125',
239 '-0.125 0.125 -0.125', '0.125 0.125 -0.125',
242 void CSQC_ClientMovement_Unstick()
245 for (i = 0; i < unstick_count; i++)
247 vector neworigin = unstick_offsets[i] + self.origin;
248 tracebox(neworigin, PL_CROUCH_MIN, PL_CROUCH_MAX, neworigin, MOVE_NORMAL, self);
249 if (!trace_startsolid)
251 self.origin = neworigin;
258 void CSQC_ClientMovement_UpdateStatus()
260 // make sure player is not stuck
261 CSQC_ClientMovement_Unstick();
264 if (PHYS_INPUT_BUTTONS(self) & 16)
266 // wants to crouch, this always works..
267 if (!IS_DUCKED(self))
272 // wants to stand, if currently crouching we need to check for a
276 tracebox(self.origin, PL_MIN, PL_MAX, self.origin, MOVE_NORMAL, self);
277 if (!trace_startsolid)
283 vector origin1 = self.origin + '0 0 1';
284 vector origin2 = self.origin - '0 0 1';
286 tracebox(origin1, self.mins, self.maxs, origin2, MOVE_NORMAL, self);
287 if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
291 // this code actually "predicts" an impact; so let's clip velocity first
292 float f = dotproduct(self.velocity, trace_plane_normal);
293 if (f < 0) // only if moving downwards actually
294 self.velocity -= f * trace_plane_normal;
297 UNSET_ONGROUND(self);
299 // set watertype/waterlevel
300 origin1 = self.origin;
301 origin1_z += self.mins_z + 1;
302 self.waterlevel = WATERLEVEL_NONE;
304 self.watertype = (pointcontents(origin1) == CONTENT_WATER);
308 self.waterlevel = WATERLEVEL_WETFEET;
309 origin1_z = self.origin_z + (self.mins_z + self.maxs_z) * 0.5;
310 if(pointcontents(origin1) == CONTENT_WATER)
312 self.waterlevel = WATERLEVEL_SWIMMING;
313 origin1_z = self.origin_z + 22;
314 if(pointcontents(origin1) == CONTENT_WATER)
315 self.waterlevel = WATERLEVEL_SUBMERGED;
319 if(IS_ONGROUND(self) || self.velocity_z <= 0 || pmove_waterjumptime <= 0)
320 pmove_waterjumptime = 0;
323 void CSQC_ClientMovement_Move()
325 float t = PHYS_INPUT_TIMELENGTH;
326 vector primalvelocity = self.velocity;
327 CSQC_ClientMovement_UpdateStatus();
329 for (bump = 0; bump < 8 && self.velocity * self.velocity > 0; bump++)
331 vector neworigin = self.origin + t * self.velocity;
332 tracebox(self.origin, self.mins, self.maxs, neworigin, MOVE_NORMAL, self);
333 float old_trace1_fraction = trace_fraction;
334 vector old_trace1_endpos = trace_endpos;
335 vector old_trace1_plane_normal = trace_plane_normal;
336 if (trace_fraction < 1 && trace_plane_normal_z == 0)
338 // may be a step or wall, try stepping up
339 // first move forward at a higher level
340 vector currentorigin2 = self.origin;
341 currentorigin2_z += PHYS_STEPHEIGHT;
342 vector neworigin2 = neworigin;
343 neworigin2_z = self.origin_z + PHYS_STEPHEIGHT;
344 tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self);
345 if (!trace_startsolid)
347 // then move down from there
348 currentorigin2 = trace_endpos;
349 neworigin2 = trace_endpos;
350 neworigin2_z = self.origin_z;
351 float old_trace2_fraction = trace_fraction;
352 vector old_trace2_plane_normal = trace_plane_normal;
353 tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self);
354 //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]);
355 // accept the new trace if it made some progress
356 if (fabs(trace_endpos_x - old_trace1_endpos_x) >= 0.03125 || fabs(trace_endpos_y - old_trace1_endpos_y) >= 0.03125)
358 trace_fraction = old_trace2_fraction;
359 trace_endpos = trace_endpos;
360 trace_plane_normal = old_trace2_plane_normal;
364 trace_fraction = old_trace1_fraction;
365 trace_endpos = old_trace1_endpos;
366 trace_plane_normal = old_trace1_plane_normal;
371 // check if it moved at all
372 if (trace_fraction >= 0.001)
373 self.origin = trace_endpos;
375 // check if it moved all the way
376 if (trace_fraction == 1)
379 // this is only really needed for nogravityonground combined with gravityunaffectedbyticrate
380 // <LordHavoc> I'm pretty sure I commented it out solely because it seemed redundant
381 // this got commented out in a change that supposedly makes the code match QW better
382 // so if this is broken, maybe put it in an if (cls.protocol != PROTOCOL_QUAKEWORLD) block
383 if (trace_plane_normal_z > 0.7)
386 t -= t * trace_fraction;
388 float f = dotproduct(self.velocity, trace_plane_normal);
389 self.velocity -= f * trace_plane_normal;
391 if (pmove_waterjumptime > 0)
392 self.velocity = primalvelocity;
396 void CPM_PM_Aircontrol(vector wishdir, float wishspeed)
400 // this doesn't play well with analog input
401 if (PHYS_INPUT_MOVEVALUES(self).x == 0 || PHYS_INPUT_MOVEVALUES(self).y != 0)
402 return; // can't control movement if not moving forward or backward
405 k = 32 * (2 * IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), 0) - 1);
410 k *= bound(0, wishspeed / PHYS_MAXAIRSPEED, 1);
412 float zspeed = self.velocity_z;
414 float xyspeed = vlen(self.velocity);
415 self.velocity = normalize(self.velocity);
417 float dot = self.velocity * wishdir;
419 if (dot > 0) // we can't change direction while slowing down
421 k *= pow(dot, PHYS_AIRCONTROL_POWER)*PHYS_INPUT_TIMELENGTH;
422 xyspeed = max(0, xyspeed - PHYS_AIRCONTROL_PENALTY * sqrt(max(0, 1 - dot*dot)) * k/32);
423 k *= PHYS_AIRCONTROL;
424 self.velocity = normalize(self.velocity * xyspeed + wishdir * k);
427 self.velocity = self.velocity * xyspeed;
428 self.velocity_z = zspeed;
431 float AdjustAirAccelQW(float accelqw, float factor)
433 return copysign(bound(0.000001, 1 - (1 - fabs(accelqw)) * factor, 1), accelqw);
436 // example config for alternate speed clamping:
437 // sv_airaccel_qw 0.8
438 // sv_airaccel_sideways_friction 0
439 // prvm_globalset server speedclamp_mode 1
441 void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float accel, float accelqw, float stretchfactor, float sidefric, float speedlimit)
443 float speedclamp = stretchfactor > 0 ? stretchfactor
444 : accelqw < 0 ? 1 // full clamping, no stretch
447 accelqw = fabs(accelqw);
449 if (GAMEPLAYFIX_Q2AIRACCELERATE)
450 wishspeed0 = wishspeed; // don't need to emulate this Q1 bug
452 float vel_straight = self.velocity * wishdir;
453 float vel_z = self.velocity_z;
454 vector vel_xy = vec2(self.velocity);
455 vector vel_perpend = vel_xy - vel_straight * wishdir;
457 float step = accel * PHYS_INPUT_TIMELENGTH * wishspeed0;
459 float vel_xy_current = vlen(vel_xy);
461 accelqw = AdjustAirAccelQW(accelqw, (speedlimit - bound(wishspeed, vel_xy_current, speedlimit)) / max(1, speedlimit - wishspeed));
462 float vel_xy_forward = vel_xy_current + bound(0, wishspeed - vel_xy_current, step) * accelqw + step * (1 - accelqw);
463 float vel_xy_backward = vel_xy_current - bound(0, wishspeed + vel_xy_current, step) * accelqw - step * (1 - accelqw);
464 vel_xy_backward = max(0, vel_xy_backward); // not that it REALLY occurs that this would cause wrong behaviour afterwards
465 vel_straight = vel_straight + bound(0, wishspeed - vel_straight, step) * accelqw + step * (1 - accelqw);
467 if (sidefric < 0 && (vel_perpend*vel_perpend))
468 // negative: only apply so much sideways friction to stay below the speed you could get by "braking"
470 float f = max(0, 1 + PHYS_INPUT_TIMELENGTH * wishspeed * sidefric);
471 float fmin = (vel_xy_backward * vel_xy_backward - vel_straight * vel_straight) / (vel_perpend * vel_perpend);
473 // vel_xy_backward*vel_xy_backward - vel_straight*vel_straight > vel_perpend*vel_perpend
474 // vel_xy_backward*vel_xy_backward > vel_straight*vel_straight + vel_perpend*vel_perpend
475 // vel_xy_backward*vel_xy_backward > vel_xy * vel_xy
476 // obviously, this cannot be
482 vel_perpend *= max(fmin, f);
486 vel_perpend *= max(0, 1 - PHYS_INPUT_TIMELENGTH * wishspeed * sidefric);
488 vel_xy = vel_straight * wishdir + vel_perpend;
492 float vel_xy_preclamp;
493 vel_xy_preclamp = vlen(vel_xy);
494 if (vel_xy_preclamp > 0) // prevent division by zero
496 vel_xy_current += (vel_xy_forward - vel_xy_current) * speedclamp;
497 if (vel_xy_current < vel_xy_preclamp)
498 vel_xy *= (vel_xy_current / vel_xy_preclamp);
502 self.velocity = vel_xy + vel_z * '0 0 1';
505 void PM_AirAccelerate(vector wishdir, float wishspeed)
510 vector curvel = self.velocity;
512 float curspeed = vlen(curvel);
514 if (wishspeed > curspeed * 1.01)
515 wishspeed = min(wishspeed, curspeed + PHYS_WARSOWBUNNY_AIRFORWARDACCEL * PHYS_MAXSPEED(self) * PHYS_INPUT_TIMELENGTH);
518 float f = max(0, (PHYS_WARSOWBUNNY_TOPSPEED - curspeed) / (PHYS_WARSOWBUNNY_TOPSPEED - PHYS_MAXSPEED(self)));
519 wishspeed = max(curspeed, PHYS_MAXSPEED(self)) + PHYS_WARSOWBUNNY_ACCEL * f * PHYS_MAXSPEED(self) * PHYS_INPUT_TIMELENGTH;
521 vector wishvel = wishdir * wishspeed;
522 vector acceldir = wishvel - curvel;
523 float addspeed = vlen(acceldir);
524 acceldir = normalize(acceldir);
526 float accelspeed = min(addspeed, PHYS_WARSOWBUNNY_TURNACCEL * PHYS_MAXSPEED(self) * PHYS_INPUT_TIMELENGTH);
528 if (PHYS_WARSOWBUNNY_BACKTOSIDERATIO < 1)
530 vector curdir = normalize(curvel);
531 float dot = acceldir * curdir;
533 acceldir -= (1 - PHYS_WARSOWBUNNY_BACKTOSIDERATIO) * dot * curdir;
536 self.velocity += accelspeed * acceldir;
544 When you press the jump key
547 void PlayerJump (void)
550 if (PHYS_FROZEN(self))
551 return; // no jumping in freezetag when frozen
553 if (self.player_blocked)
554 return; // no jumping while blocked
556 float doublejump = FALSE;
557 float mjumpheight = autocvar_sv_jumpvelocity;
559 player_multijump = doublejump;
560 player_jumpheight = mjumpheight;
561 if (MUTATOR_CALLHOOK(PlayerJump))
564 doublejump = player_multijump;
565 mjumpheight = player_jumpheight;
567 if (autocvar_sv_doublejump)
569 tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
570 if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
574 // we MUST clip velocity here!
576 f = self.velocity * trace_plane_normal;
578 self.velocity -= f * trace_plane_normal;
582 if (self.waterlevel >= WATERLEVEL_SWIMMING)
584 self.velocity_z = self.stat_sv_maxspeed * 0.7;
589 if (!(self.flags & FL_ONGROUND))
592 if (self.cvar_cl_movement_track_canjump)
593 if (!(self.flags & FL_JUMPRELEASED))
596 // sv_jumpspeedcap_min/sv_jumpspeedcap_max act as baseline
597 // velocity bounds. Final velocity is bound between (jumpheight *
598 // min + jumpheight) and (jumpheight * max + jumpheight);
600 if (autocvar_sv_jumpspeedcap_min != "")
602 float minjumpspeed = mjumpheight * stof(autocvar_sv_jumpspeedcap_min);
604 if (self.velocity_z < minjumpspeed)
605 mjumpheight += minjumpspeed - self.velocity_z;
608 if (autocvar_sv_jumpspeedcap_max != "")
610 // don't do jump speedcaps on ramps to preserve old xonotic ramjump style
611 tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
613 if (!(trace_fraction < 1 && trace_plane_normal_z < 0.98 && autocvar_sv_jumpspeedcap_max_disable_on_ramps))
615 float maxjumpspeed = mjumpheight * stof(autocvar_sv_jumpspeedcap_max);
617 if (self.velocity_z > maxjumpspeed)
618 mjumpheight -= self.velocity_z - maxjumpspeed;
622 if (!(self.lastflags & FL_ONGROUND))
624 if (autocvar_speedmeter)
625 dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
626 if (self.lastground < time - 0.3)
628 self.velocity_x *= (1 - autocvar_sv_friction_on_land);
629 self.velocity_y *= (1 - autocvar_sv_friction_on_land);
631 if (self.jumppadcount > 1)
632 dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
633 self.jumppadcount = 0;
636 self.oldvelocity_z = self.velocity_z += mjumpheight;
638 self.flags &= ~FL_ONGROUND;
639 self.flags &= ~FL_JUMPRELEASED;
641 animdecide_setaction(self, ANIMACTION_JUMP, TRUE);
643 if (autocvar_g_jump_grunt)
644 PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
646 self.restart_jump = -1; // restart jump anim next time
647 // value -1 is used to not use the teleport bit (workaround for tiny hitch when re-jumping)
651 void CheckWaterJump()
653 // check for a jump-out-of-water
654 makevectors(PHYS_INPUT_ANGLES(self));
655 vector start = self.origin;
658 normalize(v_forward);
659 vector end = start + v_forward*24;
660 traceline (start, end, TRUE, self);
661 if (trace_fraction < 1)
663 start_z = start_z + self.maxs_z - 8;
664 end = start + v_forward*24;
665 self.movedir = trace_plane_normal * -50;
666 traceline(start, end, TRUE, self);
667 if (trace_fraction == 1)
668 { // open at eye level
669 self.velocity_z = 225;
671 self.flags |= FL_WATERJUMP;
672 self.flags &= ~FL_JUMPRELEASED;
673 self.teleport_time = time + 2; // safety net
679 void CheckPlayerJump()
682 if (self.BUTTON_JUMP)
685 self.flags |= FL_JUMPRELEASED;
688 if (self.waterlevel == WATERLEVEL_SWIMMING)
692 float racecar_angle(float forward, float down)
700 float ret = vectoyaw('0 1 0' * down + '1 0 0' * forward);
702 float angle_mult = forward / (800 + forward);
705 return ret * angle_mult + 360 * (1 - angle_mult);
707 return ret * angle_mult;
710 void RaceCarPhysics()
713 // using this move type for "big rigs"
714 // the engine does not push the entity!
718 vector angles_save = self.angles;
719 float accel = bound(-1, PHYS_INPUT_MOVEVALUES(self).x / self.stat_sv_maxspeed, 1);
720 float steer = bound(-1, PHYS_INPUT_MOVEVALUES(self).y / self.stat_sv_maxspeed, 1);
722 if (g_bugrigs_reverse_speeding)
726 // back accel is DIGITAL
727 // to prevent speedhack
737 makevectors(self.angles); // new forward direction!
739 if (self.flags & FL_ONGROUND || g_bugrigs_air_steering)
741 float myspeed = self.velocity * v_forward;
742 float upspeed = self.velocity * v_up;
744 // responsiveness factor for steering and acceleration
745 float f = 1 / (1 + pow(max(-myspeed, myspeed) / g_bugrigs_speed_ref, g_bugrigs_speed_pow));
746 //MAXIMA: f(v) := 1 / (1 + (v / g_bugrigs_speed_ref) ^ g_bugrigs_speed_pow);
749 if (myspeed < 0 && g_bugrigs_reverse_spinning)
750 steerfactor = -myspeed * g_bugrigs_steer;
752 steerfactor = -myspeed * f * g_bugrigs_steer;
755 if (myspeed < 0 && g_bugrigs_reverse_speeding)
756 accelfactor = g_bugrigs_accel;
758 accelfactor = f * g_bugrigs_accel;
759 //MAXIMA: accel(v) := f(v) * g_bugrigs_accel;
765 myspeed = max(0, myspeed - PHYS_INPUT_TIMELENGTH * (g_bugrigs_friction_floor - g_bugrigs_friction_brake * accel));
769 if (!g_bugrigs_reverse_speeding)
770 myspeed = min(0, myspeed + PHYS_INPUT_TIMELENGTH * g_bugrigs_friction_floor);
777 myspeed = max(0, myspeed - PHYS_INPUT_TIMELENGTH * g_bugrigs_friction_floor);
781 if (g_bugrigs_reverse_stopping)
784 myspeed = min(0, myspeed + PHYS_INPUT_TIMELENGTH * (g_bugrigs_friction_floor + g_bugrigs_friction_brake * accel));
787 // terminal velocity = velocity at which 50 == accelfactor, that is, 1549 units/sec
788 //MAXIMA: friction(v) := g_bugrigs_friction_floor;
790 self.angles_y += steer * PHYS_INPUT_TIMELENGTH * steerfactor; // apply steering
791 makevectors(self.angles); // new forward direction!
793 myspeed += accel * accelfactor * PHYS_INPUT_TIMELENGTH;
795 rigvel = myspeed * v_forward + '0 0 1' * upspeed;
799 float myspeed = vlen(self.velocity);
801 // responsiveness factor for steering and acceleration
802 float f = 1 / (1 + pow(max(0, myspeed / g_bugrigs_speed_ref), g_bugrigs_speed_pow));
803 float steerfactor = -myspeed * f;
804 self.angles_y += steer * PHYS_INPUT_TIMELENGTH * steerfactor; // apply steering
806 rigvel = self.velocity;
807 makevectors(self.angles); // new forward direction!
810 rigvel *= max(0, 1 - vlen(rigvel) * g_bugrigs_friction_air * PHYS_INPUT_TIMELENGTH);
811 //MAXIMA: airfriction(v) := v * v * g_bugrigs_friction_air;
812 //MAXIMA: total_acceleration(v) := accel(v) - friction(v) - airfriction(v);
813 //MAXIMA: solve(total_acceleration(v) = 0, v);
815 if (g_bugrigs_planar_movement)
817 vector rigvel_xy, neworigin, up;
820 rigvel_z -= PHYS_INPUT_TIMELENGTH * PHYS_GRAVITY; // 4x gravity plays better
821 rigvel_xy = vec2(rigvel);
823 if (g_bugrigs_planar_movement_car_jumping)
826 mt = MOVE_NOMONSTERS;
828 tracebox(self.origin, self.mins, self.maxs, self.origin + '0 0 1024', mt, self);
829 up = trace_endpos - self.origin;
831 // BUG RIGS: align the move to the surface instead of doing collision testing
833 tracebox(trace_endpos, self.mins, self.maxs, trace_endpos + rigvel_xy * PHYS_INPUT_TIMELENGTH, mt, self);
836 tracebox(trace_endpos, self.mins, self.maxs, trace_endpos - up + '0 0 1' * rigvel_z * PHYS_INPUT_TIMELENGTH, mt, self);
838 if (trace_fraction < 0.5)
841 neworigin = self.origin;
844 neworigin = trace_endpos;
846 if (trace_fraction < 1)
848 // now set angles_x so that the car points parallel to the surface
849 self.angles = vectoangles(
850 '1 0 0' * v_forward_x * trace_plane_normal_z
852 '0 1 0' * v_forward_y * trace_plane_normal_z
854 '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y)
856 self.flags |= FL_ONGROUND;
860 // now set angles_x so that the car points forward, but is tilted in velocity direction
861 self.flags &= ~FL_ONGROUND;
864 self.velocity = (neworigin - self.origin) * (1.0 / PHYS_INPUT_TIMELENGTH);
865 self.movetype = MOVETYPE_NOCLIP;
869 rigvel_z -= PHYS_INPUT_TIMELENGTH * PHYS_GRAVITY; // 4x gravity plays better
870 self.velocity = rigvel;
871 self.movetype = MOVETYPE_FLY;
875 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4', MOVE_NORMAL, self);
876 if (trace_fraction != 1)
878 self.angles = vectoangles2(
879 '1 0 0' * v_forward_x * trace_plane_normal_z
881 '0 1 0' * v_forward_y * trace_plane_normal_z
883 '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y),
891 vel_local_x = v_forward * self.velocity;
892 vel_local_y = v_right * self.velocity;
893 vel_local_z = v_up * self.velocity;
895 self.angles_x = racecar_angle(vel_local_x, vel_local_z);
896 self.angles_z = racecar_angle(-vel_local_y, vel_local_z);
900 vector vf1, vu1, smoothangles;
901 makevectors(self.angles);
902 float f = bound(0, PHYS_INPUT_TIMELENGTH * g_bugrigs_angle_smoothing, 1);
907 makevectors(angles_save);
908 vf1 = vf1 + v_forward * (1 - f);
909 vu1 = vu1 + v_up * (1 - f);
910 smoothangles = vectoangles2(vf1, vu1);
911 self.angles_x = -smoothangles_x;
912 self.angles_z = smoothangles_z;
916 string specialcommand = "xwxwxsxsxaxdxaxdx1x ";
917 .float specialcommand_pos;
918 void SpecialCommand()
924 if (!CheatImpulse(99))
925 print("A hollow voice says \"Plugh\".\n");
931 float speedaward_speed;
932 string speedaward_holder;
933 string speedaward_uid;
935 void race_send_speedaward(float msg)
938 // send the best speed of the round
939 WriteByte(msg, SVC_TEMPENTITY);
940 WriteByte(msg, TE_CSQC_RACE);
941 WriteByte(msg, RACE_NET_SPEED_AWARD);
942 WriteInt24_t(msg, floor(speedaward_speed+0.5));
943 WriteString(msg, speedaward_holder);
948 float speedaward_alltimebest;
949 string speedaward_alltimebest_holder;
950 string speedaward_alltimebest_uid;
952 void race_send_speedaward_alltimebest(float msg)
955 // send the best speed
956 WriteByte(msg, SVC_TEMPENTITY);
957 WriteByte(msg, TE_CSQC_RACE);
958 WriteByte(msg, RACE_NET_SPEED_AWARD_BEST);
959 WriteInt24_t(msg, floor(speedaward_alltimebest+0.5));
960 WriteString(msg, speedaward_alltimebest_holder);
964 float PM_check_keepaway(void)
967 return (self.ballcarried && g_keepaway) ? autocvar_g_keepaway_ballcarrier_highspeed : 1;
973 void PM_check_race_movetime(void)
976 self.race_movetime_frac += PHYS_INPUT_TIMELENGTH;
977 float f = floor(self.race_movetime_frac);
978 self.race_movetime_frac -= f;
979 self.race_movetime_count += f;
980 self.race_movetime = self.race_movetime_frac + self.race_movetime_count;
984 float PM_check_specialcommand(float buttons)
990 else if (buttons == 1)
992 else if (buttons == 2)
994 else if (buttons == 128)
996 else if (buttons == 256)
998 else if (buttons == 512)
1000 else if (buttons == 1024)
1005 if (c == substring(specialcommand, self.specialcommand_pos, 1))
1007 self.specialcommand_pos += 1;
1008 if (self.specialcommand_pos >= strlen(specialcommand))
1010 self.specialcommand_pos = 0;
1015 else if (self.specialcommand_pos && (c != substring(specialcommand, self.specialcommand_pos - 1, 1)))
1016 self.specialcommand_pos = 0;
1021 void PM_check_nickspam(void)
1024 if (time >= self.nickspamtime)
1026 if (self.nickspamcount >= autocvar_g_nick_flood_penalty_yellow)
1028 // slight annoyance for nick change scripts
1029 PHYS_INPUT_MOVEVALUES(self) = -1 * PHYS_INPUT_MOVEVALUES(self);
1030 self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = self.BUTTON_ZOOM = self.BUTTON_CROUCH = self.BUTTON_HOOK = self.BUTTON_USE = 0;
1032 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!
1034 PHYS_INPUT_ANGLES(self)_x = random() * 360;
1035 PHYS_INPUT_ANGLES(self)_y = random() * 360;
1036 // at least I'm not forcing retardedview by also assigning to angles_z
1037 self.fixangle = TRUE;
1043 void PM_check_punch()
1046 if (self.punchangle != '0 0 0')
1048 float f = vlen(self.punchangle) - 10 * PHYS_INPUT_TIMELENGTH;
1050 self.punchangle = normalize(self.punchangle) * f;
1052 self.punchangle = '0 0 0';
1055 if (self.punchvector != '0 0 0')
1057 float f = vlen(self.punchvector) - 30 * PHYS_INPUT_TIMELENGTH;
1059 self.punchvector = normalize(self.punchvector) * f;
1061 self.punchvector = '0 0 0';
1066 void PM_check_spider(void)
1069 if (time >= self.spider_slowness)
1071 self.stat_sv_maxspeed *= 0.5; // half speed while slow from spider
1072 self.stat_sv_airspeedlimit_nonqw *= 0.5;
1076 // predict frozen movement, as frozen players CAN move in some cases
1077 void PM_check_frozen(void)
1079 if (!PHYS_FROZEN(self))
1081 if (PHYS_DODGING_FROZEN
1083 && IS_REAL_CLIENT(self)
1087 PHYS_INPUT_MOVEVALUES(self)_x = bound(-5, PHYS_INPUT_MOVEVALUES(self).x, 5);
1088 PHYS_INPUT_MOVEVALUES(self)_y = bound(-5, PHYS_INPUT_MOVEVALUES(self).y, 5);
1089 PHYS_INPUT_MOVEVALUES(self)_z = bound(-5, PHYS_INPUT_MOVEVALUES(self).z, 5);
1092 PHYS_INPUT_MOVEVALUES(self) = '0 0 0';
1094 vector midpoint = ((self.absmin + self.absmax) * 0.5);
1095 if (pointcontents(midpoint) == CONTENT_WATER)
1097 self.velocity = self.velocity * 0.5;
1099 if (pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
1100 self.velocity_z = 200;
1104 void PM_check_blocked(void)
1107 if (!self.player_blocked)
1109 PHYS_INPUT_MOVEVALUES(self) = '0 0 0';
1110 self.disableclientprediction = 1;
1115 float speedaward_lastsent;
1116 float speedaward_lastupdate;
1117 string GetMapname(void);
1119 void PM_check_race(void)
1122 if not(g_cts || g_race)
1124 if (vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed)
1126 speedaward_speed = vlen(self.velocity - self.velocity_z * '0 0 1');
1127 speedaward_holder = self.netname;
1128 speedaward_uid = self.crypto_idfp;
1129 speedaward_lastupdate = time;
1131 if (speedaward_speed > speedaward_lastsent && time - speedaward_lastupdate > 1)
1133 string rr = (g_cts) ? CTS_RECORD : RACE_RECORD;
1134 race_send_speedaward(MSG_ALL);
1135 speedaward_lastsent = speedaward_speed;
1136 if (speedaward_speed > speedaward_alltimebest && speedaward_uid != "")
1138 speedaward_alltimebest = speedaward_speed;
1139 speedaward_alltimebest_holder = speedaward_holder;
1140 speedaward_alltimebest_uid = speedaward_uid;
1141 db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/speed"), ftos(speedaward_alltimebest));
1142 db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/crypto_idfp"), speedaward_alltimebest_uid);
1143 race_send_speedaward_alltimebest(MSG_ALL);
1149 void PM_check_vortex(void)
1152 float xyspeed = vlen(vec2(self.velocity));
1153 if (self.weapon == WEP_NEX && autocvar_g_balance_nex_charge && autocvar_g_balance_nex_charge_velocity_rate && xyspeed > autocvar_g_balance_nex_charge_minspeed)
1155 // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed
1156 xyspeed = min(xyspeed, autocvar_g_balance_nex_charge_maxspeed);
1157 float f = (xyspeed - autocvar_g_balance_nex_charge_minspeed) / (autocvar_g_balance_nex_charge_maxspeed - autocvar_g_balance_nex_charge_minspeed);
1158 // add the extra charge
1159 self.nex_charge = min(1, self.nex_charge + autocvar_g_balance_nex_charge_velocity_rate * f * PHYS_INPUT_TIMELENGTH);
1164 void PM_fly(float maxspd_mod)
1166 // noclipping or flying
1167 self.flags &= ~FL_ONGROUND;
1169 self.velocity = self.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION);
1170 makevectors(PHYS_INPUT_ANGLES(self));
1171 //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z;
1172 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1173 + v_right * PHYS_INPUT_MOVEVALUES(self).y
1174 + '0 0 1' * PHYS_INPUT_MOVEVALUES(self).z;
1176 vector wishdir = normalize(wishvel);
1177 float wishspeed = vlen(wishvel);
1178 if (wishspeed > PHYS_MAXSPEED(self) * maxspd_mod)
1179 wishspeed = PHYS_MAXSPEED(self) * maxspd_mod;
1180 if (time >= self.teleport_time)
1181 PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
1184 void PM_swim(float maxspd_mod)
1187 UNSET_ONGROUND(self);
1189 makevectors(PHYS_INPUT_ANGLES(self));
1190 //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z;
1191 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1192 + v_right * PHYS_INPUT_MOVEVALUES(self).y
1193 + '0 0 1' * PHYS_INPUT_MOVEVALUES(self).z;
1194 if (wishvel == '0 0 0')
1195 wishvel = '0 0 -60'; // drift towards bottom
1197 vector wishdir = normalize(wishvel);
1198 float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(self) * maxspd_mod);
1199 wishspeed = wishspeed * 0.7;
1202 self.velocity *= (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION);
1205 float addspeed = wishspeed - dotproduct(self.velocity, wishdir);
1208 float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed);
1209 self.velocity += accelspeed * wishdir;
1211 float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
1212 if (!(GAMEPLAYFIX_NOGRAVITYONGROUND))
1213 self.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1);
1214 if (self.velocity * self.velocity)
1215 CSQC_ClientMovement_Move();
1216 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1217 if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
1218 self.velocity_z -= g * 0.5;
1222 // water acceleration
1223 PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
1227 void PM_ladder(float maxspd_mod)
1230 // on a spawnfunc_func_ladder or swimming in spawnfunc_func_water
1231 self.flags &= ~FL_ONGROUND;
1234 g = PHYS_GRAVITY * PHYS_INPUT_TIMELENGTH;
1235 if (PHYS_ENTGRAVITY(self))
1236 g *= PHYS_ENTGRAVITY(self);
1237 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1240 self.velocity_z += g;
1243 self.velocity = self.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION);
1244 makevectors(PHYS_INPUT_ANGLES(self));
1245 //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z;
1246 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1247 + v_right * PHYS_INPUT_MOVEVALUES(self).y
1248 + '0 0 1' * PHYS_INPUT_MOVEVALUES(self).z;
1249 self.velocity_z += g;
1250 if (self.ladder_entity.classname == "func_water")
1252 float f = vlen(wishvel);
1253 if (f > self.ladder_entity.speed)
1254 wishvel *= (self.ladder_entity.speed / f);
1256 self.watertype = self.ladder_entity.skin;
1257 f = self.ladder_entity.origin_z + self.ladder_entity.maxs_z;
1258 if ((self.origin_z + self.view_ofs_z) < f)
1259 self.waterlevel = WATERLEVEL_SUBMERGED;
1260 else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f)
1261 self.waterlevel = WATERLEVEL_SWIMMING;
1262 else if ((self.origin_z + self.mins_z + 1) < f)
1263 self.waterlevel = WATERLEVEL_WETFEET;
1266 self.waterlevel = WATERLEVEL_NONE;
1267 self.watertype = CONTENT_EMPTY;
1271 vector wishdir = normalize(wishvel);
1272 float wishspeed = min(vlen(wishvel), self.stat_sv_maxspeed * maxspd_mod);
1273 if (time >= self.teleport_time)
1274 // water acceleration
1275 PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE*maxspd_mod, 1, 0, 0, 0);
1279 void PM_jetpack(float maxspd_mod)
1281 //makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
1282 makevectors(PHYS_INPUT_ANGLES(self));
1283 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1284 + v_right * PHYS_INPUT_MOVEVALUES(self).y;
1285 // add remaining speed as Z component
1286 float maxairspd = PHYS_MAXAIRSPEED * max(1, maxspd_mod);
1287 // fix speedhacks :P
1288 wishvel = normalize(wishvel) * min(1, vlen(wishvel) / maxairspd);
1289 // add the unused velocity as up component
1292 // if (self.BUTTON_JUMP)
1293 wishvel_z = sqrt(max(0, 1 - wishvel * wishvel));
1295 // it is now normalized, so...
1296 float a_side = PHYS_JETPACK_ACCEL_SIDE;
1297 float a_up = PHYS_JETPACK_ACCEL_UP;
1298 float a_add = PHYS_JETPACK_ANTIGRAVITY * PHYS_GRAVITY;
1300 wishvel_x *= a_side;
1301 wishvel_y *= a_side;
1306 //////////////////////////////////////////////////////////////////////////////////////
1307 // finding the maximum over all vectors of above form
1308 // with wishvel having an absolute value of 1
1309 //////////////////////////////////////////////////////////////////////////////////////
1310 // we're finding the maximum over
1311 // f(a_side, a_up, a_add, z) := a_side * (1 - z^2) + (a_add + a_up * z)^2;
1312 // for z in the range from -1 to 1
1313 //////////////////////////////////////////////////////////////////////////////////////
1314 // maximum is EITHER attained at the single extreme point:
1315 float a_diff = a_side * a_side - a_up * a_up;
1319 f = a_add * a_up / a_diff; // this is the zero of diff(f(a_side, a_up, a_add, z), z)
1320 if (f > -1 && f < 1) // can it be attained?
1322 best = (a_diff + a_add * a_add) * (a_diff + a_up * a_up) / a_diff;
1323 //print("middle\n");
1326 // OR attained at z = 1:
1327 f = (a_up + a_add) * (a_up + a_add);
1333 // OR attained at z = -1:
1334 f = (a_up - a_add) * (a_up - a_add);
1338 //print("bottom\n");
1341 //////////////////////////////////////////////////////////////////////////////////////
1343 //print("best possible acceleration: ", ftos(best), "\n");
1346 fxy = bound(0, 1 - (self.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / PHYS_JETPACK_MAXSPEED_SIDE, 1);
1347 if (wishvel_z - PHYS_GRAVITY > 0)
1348 fz = bound(0, 1 - self.velocity_z / PHYS_JETPACK_MAXSPEED_UP, 1);
1350 fz = bound(0, 1 + self.velocity_z / PHYS_JETPACK_MAXSPEED_UP, 1);
1353 fvel = vlen(wishvel);
1356 wishvel_z = (wishvel_z - PHYS_GRAVITY) * fz + PHYS_GRAVITY;
1358 fvel = min(1, vlen(wishvel) / best);
1359 if (PHYS_JETPACK_FUEL && !(ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO))
1360 f = min(1, PHYS_AMMO_FUEL(self) / (PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel));
1364 //print("this acceleration: ", ftos(vlen(wishvel) * f), "\n");
1366 if (f > 0 && wishvel != '0 0 0')
1368 self.velocity = self.velocity + wishvel * f * PHYS_INPUT_TIMELENGTH;
1369 UNSET_ONGROUND(self);
1372 if (!(ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO))
1373 self.ammo_fuel -= PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel * f;
1375 self.items |= IT_USING_JETPACK;
1377 // jetpack also inhibits health regeneration, but only for 1 second
1378 self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen);
1383 void PM_walk(float buttons_prev, float maxspd_mod)
1386 // we get here if we ran out of ammo
1387 if ((ITEMS(self) & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32) && self.ammo_fuel < 0.01)
1388 sprint(self, "You don't have any fuel for the ^2Jetpack\n");
1391 makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
1392 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1393 + v_right * PHYS_INPUT_MOVEVALUES(self).y;
1396 if (!(self.lastflags & FL_ONGROUND))
1398 if (autocvar_speedmeter)
1399 dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
1400 if (self.lastground < time - 0.3)
1401 self.velocity *= (1 - autocvar_sv_friction_on_land);
1402 if (self.jumppadcount > 1)
1403 dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
1404 self.jumppadcount = 0;
1408 vector v = self.velocity;
1413 f = 1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION * ((f < PHYS_STOPSPEED) ? (PHYS_STOPSPEED / f) : 1);
1417 Mathematical analysis time!
1419 Our goal is to invert this mess.
1421 For the two cases we get:
1422 v = v0 * (1 - PHYS_INPUT_TIMELENGTH * (PHYS_STOPSPEED / v0) * PHYS_FRICTION)
1423 = v0 - PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED * PHYS_FRICTION
1424 v0 = v + PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED * PHYS_FRICTION
1426 v = v0 * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
1427 v0 = v / (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
1429 These cases would be chosen ONLY if:
1431 v + PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED * PHYS_FRICTION < PHYS_STOPSPEED
1432 v < PHYS_STOPSPEED * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
1434 v0 >= PHYS_STOPSPEED
1435 v / (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION) >= PHYS_STOPSPEED
1436 v >= PHYS_STOPSPEED * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
1441 vector wishdir = normalize(wishvel);
1442 float wishspeed = vlen(wishvel);
1443 wishspeed = min(wishspeed, PHYS_MAXSPEED(self) * maxspd_mod);
1444 if (IS_DUCKED(self))
1447 if (time >= self.teleport_time)
1448 PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
1452 float addspeed = wishspeed - dotproduct(self.velocity, wishdir);
1455 float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed);
1456 self.velocity += accelspeed * wishdir;
1458 float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
1459 if (!(GAMEPLAYFIX_NOGRAVITYONGROUND))
1460 self.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1);
1461 if (self.velocity * self.velocity)
1462 CSQC_ClientMovement_Move();
1463 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1464 if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
1465 self.velocity_z -= g * 0.5;
1469 void PM_air(float buttons_prev, float maxspd_mod)
1472 // we get here if we ran out of ammo
1473 if ((ITEMS(self) & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32) && PHYS_AMMO_FUEL(self) < 0.01)
1474 sprint(self, "You don't have any fuel for the ^2Jetpack\n");
1476 float maxairspd, airaccel;
1477 maxairspd = PHYS_MAXAIRSPEED * min(maxspd_mod, 1);
1478 airaccel = PHYS_AIRACCELERATE * min(maxspd_mod, 1);
1480 makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
1481 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1482 + v_right * PHYS_INPUT_MOVEVALUES(self).y;
1484 vector wishdir = normalize(wishvel);
1485 float wishspeed = vlen(wishvel);
1486 float wishspeed0 = min(wishspeed, PHYS_MAXSPEED(self) * maxspd_mod);
1487 wishspeed = min(wishspeed, maxairspd);
1488 if (IS_DUCKED(self))
1491 if (time >= self.teleport_time)
1493 if (pmove_waterjumptime <= 0)
1496 float airaccelqw = PHYS_AIRACCEL_QW(self);
1497 float accelerating = (self.velocity * wishdir > 0);
1498 float wishspeed2 = wishspeed;
1501 if (PHYS_AIRSTOPACCELERATE)
1503 vector curdir = normalize(vec2(self.velocity));
1504 airaccel += (PHYS_AIRSTOPACCELERATE*maxspd_mod - airaccel) * max(0, -(curdir * wishdir));
1506 // note that for straight forward jumping:
1507 // step = accel * PHYS_INPUT_TIMELENGTH * wishspeed0;
1508 // accel = bound(0, wishspeed - vel_xy_current, step) * accelqw + step * (1 - accelqw);
1510 // dv/dt = accel * maxspeed (when slow)
1511 // dv/dt = accel * maxspeed * (1 - accelqw) (when fast)
1512 // log dv/dt = logaccel + logmaxspeed (when slow)
1513 // log dv/dt = logaccel + logmaxspeed + log(1 - accelqw) (when fast)
1514 float strafity = IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), -90) + IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), +90); // if one is nonzero, other is always zero
1515 if (PHYS_MAXAIRSTRAFESPEED)
1516 wishspeed = min(wishspeed, GeomLerp(PHYS_MAXAIRSPEED*maxspd_mod, strafity, PHYS_MAXAIRSTRAFESPEED*maxspd_mod));
1517 if (PHYS_AIRSTRAFEACCELERATE)
1518 airaccel = GeomLerp(airaccel, strafity, PHYS_AIRSTRAFEACCELERATE*maxspd_mod);
1519 if (PHYS_AIRSTRAFEACCEL_QW(self))
1520 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)));
1523 if (PHYS_WARSOWBUNNY_TURNACCEL && accelerating && PHYS_INPUT_MOVEVALUES(self).y == 0 && PHYS_INPUT_MOVEVALUES(self).x != 0)
1524 PM_AirAccelerate(wishdir, wishspeed);
1526 PM_Accelerate(wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, PHYS_AIRACCEL_QW_STRETCHFACTOR(self), PHYS_AIRACCEL_SIDEWAYS_FRICTION / maxairspd, PHYS_AIRSPEEDLIMIT_NONQW(self));
1528 if (PHYS_AIRCONTROL)
1529 CPM_PM_Aircontrol(wishdir, wishspeed2);
1532 float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
1533 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1534 self.velocity_z -= g * 0.5;
1536 self.velocity_z -= g;
1537 CSQC_ClientMovement_Move();
1538 if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
1539 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1540 self.velocity_z -= g * 0.5;
1544 // used for calculating airshots
1545 float PM_is_flying()
1547 if (IS_ONGROUND(self))
1549 if (self.waterlevel >= WATERLEVEL_SWIMMING)
1551 traceline(self.origin, self.origin - '0 0 48', MOVE_NORMAL, self);
1552 return trace_fraction >= 1;
1558 //Con_Printf(" %f", PHYS_INPUT_TIMELENGTH);
1559 if (!(PHYS_INPUT_BUTTONS(self) & 2)) // !jump
1560 UNSET_JUMP_HELD(self); // canjump = true
1561 pmove_waterjumptime -= PHYS_INPUT_TIMELENGTH;
1562 CSQC_ClientMovement_UpdateStatus();
1566 WarpZone_PlayerPhysics_FixVAngle();
1568 float maxspeed_mod = 1;
1569 maxspeed_mod *= PM_check_keepaway();
1570 maxspeed_mod *= PHYS_HIGHSPEED;
1572 // fix physics stats for g_movement_highspeed
1573 // TODO maybe rather use maxairspeed? needs testing
1575 self.stat_sv_airaccel_qw = AdjustAirAccelQW(autocvar_sv_airaccel_qw, maxspeed_mod);
1576 if (autocvar_sv_airstrafeaccel_qw)
1577 self.stat_sv_airstrafeaccel_qw = AdjustAirAccelQW(autocvar_sv_airstrafeaccel_qw, maxspeed_mod);
1579 self.stat_sv_airstrafeaccel_qw = 0;
1580 self.stat_sv_airspeedlimit_nonqw = autocvar_sv_airspeedlimit_nonqw * maxspeed_mod;
1581 self.stat_sv_maxspeed = autocvar_sv_maxspeed * maxspeed_mod; // also slow walking
1582 self.stat_movement_highspeed = autocvar_g_movement_highspeed; // TODO: remove this!
1584 self.stat_jetpack_antigravity = autocvar_g_jetpack_antigravity;
1585 self.stat_jetpack_accel_up = autocvar_g_jetpack_acceleration_up;
1586 self.stat_jetpack_accel_side = autocvar_g_jetpack_acceleration_side;
1587 self.stat_jetpack_maxspeed_side = autocvar_g_jetpack_maxspeed_side;
1588 self.stat_jetpack_maxspeed_up = autocvar_g_jetpack_maxspeed_up;
1589 self.stat_jetpack_fuel = autocvar_g_jetpack_fuel;
1592 if (self.PlayerPhysplug)
1593 if (self.PlayerPhysplug())
1597 PM_check_race_movetime();
1599 anticheat_physics();
1601 float buttons = PHYS_INPUT_BUTTONS(self);
1603 if (PM_check_specialcommand(buttons))
1608 if (buttons != self.buttons_old || PHYS_INPUT_MOVEVALUES(self) != self.movement_old || PHYS_INPUT_ANGLES(self) != self.v_angle_old)
1609 self.parm_idlesince = time;
1612 float buttons_prev = self.buttons_old;
1613 self.buttons_old = buttons;
1614 self.movement_old = PHYS_INPUT_MOVEVALUES(self);
1615 self.v_angle_old = PHYS_INPUT_ANGLES(self);
1617 PM_check_nickspam();
1621 if (IS_BOT_CLIENT(self))
1623 if (playerdemo_read())
1628 self.items &= ~IT_USING_JETPACK;
1630 if (IS_PLAYER(self))
1634 if (self.race_penalty)
1635 if (time > self.race_penalty)
1636 self.race_penalty = 0;
1639 float not_allowed_to_move = 0;
1641 if (self.race_penalty)
1642 not_allowed_to_move = 1;
1645 if (!autocvar_sv_ready_restart_after_countdown)
1646 if (time < game_starttime)
1647 not_allowed_to_move = 1;
1650 if (not_allowed_to_move)
1652 self.velocity = '0 0 0';
1653 self.movetype = MOVETYPE_NONE;
1655 self.disableclientprediction = 2;
1659 else if (self.disableclientprediction == 2)
1661 if (self.movetype == MOVETYPE_NONE)
1662 self.movetype = MOVETYPE_WALK;
1663 self.disableclientprediction = 0;
1669 if (self.movetype == MOVETYPE_NONE)
1674 // when we get here, disableclientprediction cannot be 2
1675 self.disableclientprediction = 0;
1676 if (time < self.ladder_time)
1677 self.disableclientprediction = 1;
1685 MUTATOR_CALLHOOK(PlayerPhysics);
1693 if (self.in_swamp) {
1694 maxspeed_mod *= self.swamp_slowdown; //cvar("g_balance_swamp_moverate");
1699 // conveyors: first fix velocity
1700 if (self.conveyor.state)
1701 self.velocity -= self.conveyor.movedir;
1705 if (!IS_PLAYER(self))
1707 maxspeed_mod *= autocvar_sv_spectator_speed_multiplier;
1708 if (!self.spectatorspeed)
1709 self.spectatorspeed = maxspeed_mod;
1710 if (self.impulse && self.impulse <= 19 || (self.impulse >= 200 && self.impulse <= 209) || (self.impulse >= 220 && self.impulse <= 229))
1712 if (self.lastclassname != "player")
1714 if (self.impulse == 10 || self.impulse == 15 || self.impulse == 18 || (self.impulse >= 200 && self.impulse <= 209))
1715 self.spectatorspeed = bound(1, self.spectatorspeed + 0.5, 5);
1716 else if (self.impulse == 11)
1717 self.spectatorspeed = maxspeed_mod;
1718 else if (self.impulse == 12 || self.impulse == 16 || self.impulse == 19 || (self.impulse >= 220 && self.impulse <= 229))
1719 self.spectatorspeed = bound(1, self.spectatorspeed - 0.5, 5);
1720 else if (self.impulse >= 1 && self.impulse <= 9)
1721 self.spectatorspeed = 1 + 0.5 * (self.impulse - 1);
1722 } // otherwise just clear
1725 maxspeed_mod *= self.spectatorspeed;
1730 // if dead, behave differently
1731 // in CSQC, physics don't handle dead player
1737 if (!self.fixangle && !g_bugrigs)
1738 self.angles = '0 1 0' * PHYS_INPUT_ANGLES(self).y;
1742 if (self.flags & FL_ONGROUND)
1743 if (IS_PLAYER(self)) // no fall sounds for observers thank you very much
1747 if (self.waterlevel < WATERLEVEL_SWIMMING)
1748 if (time >= self.ladder_time)
1751 self.nextstep = time + 0.3 + random() * 0.1;
1752 trace_dphitq3surfaceflags = 0;
1753 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
1754 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS))
1756 if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
1757 GlobalSound(globalsound_metalfall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
1759 GlobalSound(globalsound_fall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
1769 if (IS_PLAYER(self))
1774 if (self.flags & /* FL_WATERJUMP */ 2048)
1776 self.velocity_x = self.movedir_x;
1777 self.velocity_y = self.movedir_y;
1778 if (time > self.teleport_time || self.waterlevel == WATERLEVEL_NONE)
1780 self.flags &= ~/* FL_WATERJUMP */ 2048;
1781 self.teleport_time = 0;
1786 else if (g_bugrigs && IS_PLAYER(self))
1790 else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY || self.movetype == MOVETYPE_FLY_WORLDONLY)
1791 PM_fly(maxspeed_mod);
1793 else if (self.waterlevel >= WATERLEVEL_SWIMMING)
1794 PM_swim(maxspeed_mod);
1796 else if (time < self.ladder_time)
1797 PM_ladder(maxspeed_mod);
1799 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))
1800 PM_jetpack(maxspeed_mod);
1805 // jump if on ground with jump button pressed but only if it has been
1806 // released at least once since the last jump
1807 if (PHYS_INPUT_BUTTONS(self) & 2)
1809 if (IS_ONGROUND(self) && (!IS_JUMP_HELD(self) || !cvar("cl_movement_track_canjump")))
1811 self.velocity_z += PHYS_JUMPVELOCITY;
1812 UNSET_ONGROUND(self);
1813 SET_JUMP_HELD(self); // canjump = false
1817 UNSET_JUMP_HELD(self); // canjump = true
1819 if (IS_ONGROUND(self))
1820 PM_walk(buttons_prev, maxspeed_mod);
1822 PM_air(buttons_prev, maxspeed_mod);
1826 if (!IS_OBSERVER(self))
1832 if (self.flags & FL_ONGROUND)
1833 self.lastground = time;
1836 // conveyors: then break velocity again
1837 if (self.conveyor.state)
1838 self.velocity += self.conveyor.movedir;
1841 self.lastflags = self.flags;
1842 self.lastclassname = self.classname;
1845 void CSQC_ClientMovement_PlayerMove_Frame()
1847 // if a move is more than 50ms, do it as two moves (matching qwsv)
1848 //Con_Printf("%i ", self.cmd.msec);
1849 if (PHYS_INPUT_TIMELENGTH > 0.0005)
1851 if (PHYS_INPUT_TIMELENGTH > 0.05)
1853 PHYS_INPUT_TIMELENGTH /= 2;
1859 // we REALLY need this handling to happen, even if the move is not executed
1860 if (!(PHYS_INPUT_BUTTONS(self) & 2)) // !jump
1861 UNSET_JUMP_HELD(self); // canjump = true
1864 #undef PHYS_INPUT_ANGLES
1865 #undef PHYS_INPUT_BUTTONS
1867 #undef PHYS_INPUT_TIMELENGTH
1869 #undef PHYS_INPUT_MOVEVALUES
1871 #undef GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE
1872 #undef GAMEPLAYFIX_NOGRAVITYONGROUND
1873 #undef GAMEPLAYFIX_Q2AIRACCELERATE
1880 #undef SET_JUMP_HELD
1881 #undef UNSET_JUMP_HELD
1885 #undef UNSET_ONGROUND
1887 #undef PHYS_ACCELERATE
1888 #undef PHYS_AIRACCEL_QW
1889 #undef PHYS_AIRACCEL_QW_STRETCHFACTOR
1890 #undef PHYS_AIRACCEL_SIDEWAYS_FRICTION
1891 #undef PHYS_AIRACCELERATE
1892 #undef PHYS_AIRCONTROL
1893 #undef PHYS_AIRCONTROL_PENALTY
1894 #undef PHYS_AIRCONTROL_POWER
1895 #undef PHYS_AIRSPEEDLIMIT_NONQW
1896 #undef PHYS_AIRSTOPACCELERATE
1897 #undef PHYS_AIRSTRAFEACCEL_QW
1898 #undef PHYS_AIRSTRAFEACCELERATE
1899 #undef PHYS_EDGEFRICTION
1900 #undef PHYS_ENTGRAVITY
1901 #undef PHYS_FRICTION
1903 #undef PHYS_HIGHSPEED
1904 #undef PHYS_JUMPVELOCITY
1905 #undef PHYS_MAXAIRSPEED
1906 #undef PHYS_MAXAIRSTRAFESPEED
1907 #undef PHYS_MAXSPEED
1908 #undef PHYS_STEPHEIGHT
1909 #undef PHYS_STOPSPEED
1910 #undef PHYS_WARSOWBUNNY_ACCEL
1911 #undef PHYS_WARSOWBUNNY_BACKTOSIDERATIO
1912 #undef PHYS_WARSOWBUNNY_AIRFORWARDACCEL
1913 #undef PHYS_WARSOWBUNNY_TOPSPEED
1914 #undef PHYS_WARSOWBUNNY_TURNACCEL
1918 void SV_PlayerPhysics(void)