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 = PHYS_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 (!IS_ONGROUND(self))
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 UNSET_ONGROUND(self);
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 (IS_ONGROUND(self) || 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)
860 // now set angles_x so that the car points forward, but is tilted in velocity direction
861 UNSET_ONGROUND(self);
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 UNSET_ONGROUND(self);
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 = min(vlen(wishvel), PHYS_MAXSPEED(self) * maxspd_mod);
1178 if (time >= self.teleport_time)
1179 PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
1182 void PM_swim(float maxspd_mod)
1185 UNSET_ONGROUND(self);
1187 makevectors(PHYS_INPUT_ANGLES(self));
1188 //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z;
1189 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1190 + v_right * PHYS_INPUT_MOVEVALUES(self).y
1191 + '0 0 1' * PHYS_INPUT_MOVEVALUES(self).z;
1192 if (wishvel == '0 0 0')
1193 wishvel = '0 0 -60'; // drift towards bottom
1195 vector wishdir = normalize(wishvel);
1196 float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(self) * maxspd_mod);
1197 wishspeed = wishspeed * 0.7;
1200 self.velocity *= (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION);
1203 float addspeed = wishspeed - dotproduct(self.velocity, wishdir);
1206 float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed);
1207 self.velocity += accelspeed * wishdir;
1209 float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
1210 if (!(GAMEPLAYFIX_NOGRAVITYONGROUND))
1211 self.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1);
1212 if (self.velocity * self.velocity)
1213 CSQC_ClientMovement_Move();
1214 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1215 if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
1216 self.velocity_z -= g * 0.5;
1220 // water acceleration
1221 PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
1225 void PM_ladder(float maxspd_mod)
1228 // on a spawnfunc_func_ladder or swimming in spawnfunc_func_water
1229 UNSET_ONGROUND(self);
1232 g = PHYS_GRAVITY * PHYS_INPUT_TIMELENGTH;
1233 if (PHYS_ENTGRAVITY(self))
1234 g *= PHYS_ENTGRAVITY(self);
1235 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1238 self.velocity_z += g;
1241 self.velocity = self.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION);
1242 makevectors(PHYS_INPUT_ANGLES(self));
1243 //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z;
1244 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1245 + v_right * PHYS_INPUT_MOVEVALUES(self).y
1246 + '0 0 1' * PHYS_INPUT_MOVEVALUES(self).z;
1247 self.velocity_z += g;
1248 if (self.ladder_entity.classname == "func_water")
1250 float f = vlen(wishvel);
1251 if (f > self.ladder_entity.speed)
1252 wishvel *= (self.ladder_entity.speed / f);
1254 self.watertype = self.ladder_entity.skin;
1255 f = self.ladder_entity.origin_z + self.ladder_entity.maxs_z;
1256 if ((self.origin_z + self.view_ofs_z) < f)
1257 self.waterlevel = WATERLEVEL_SUBMERGED;
1258 else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f)
1259 self.waterlevel = WATERLEVEL_SWIMMING;
1260 else if ((self.origin_z + self.mins_z + 1) < f)
1261 self.waterlevel = WATERLEVEL_WETFEET;
1264 self.waterlevel = WATERLEVEL_NONE;
1265 self.watertype = CONTENT_EMPTY;
1269 vector wishdir = normalize(wishvel);
1270 float wishspeed = min(vlen(wishvel), self.stat_sv_maxspeed * maxspd_mod);
1271 if (time >= self.teleport_time)
1272 // water acceleration
1273 PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE*maxspd_mod, 1, 0, 0, 0);
1277 void PM_jetpack(float maxspd_mod)
1279 //makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
1280 makevectors(PHYS_INPUT_ANGLES(self));
1281 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1282 + v_right * PHYS_INPUT_MOVEVALUES(self).y;
1283 // add remaining speed as Z component
1284 float maxairspd = PHYS_MAXAIRSPEED * max(1, maxspd_mod);
1285 // fix speedhacks :P
1286 wishvel = normalize(wishvel) * min(1, vlen(wishvel) / maxairspd);
1287 // add the unused velocity as up component
1290 // if (self.BUTTON_JUMP)
1291 wishvel_z = sqrt(max(0, 1 - wishvel * wishvel));
1293 // it is now normalized, so...
1294 float a_side = PHYS_JETPACK_ACCEL_SIDE;
1295 float a_up = PHYS_JETPACK_ACCEL_UP;
1296 float a_add = PHYS_JETPACK_ANTIGRAVITY * PHYS_GRAVITY;
1298 wishvel_x *= a_side;
1299 wishvel_y *= a_side;
1304 //////////////////////////////////////////////////////////////////////////////////////
1305 // finding the maximum over all vectors of above form
1306 // with wishvel having an absolute value of 1
1307 //////////////////////////////////////////////////////////////////////////////////////
1308 // we're finding the maximum over
1309 // f(a_side, a_up, a_add, z) := a_side * (1 - z^2) + (a_add + a_up * z)^2;
1310 // for z in the range from -1 to 1
1311 //////////////////////////////////////////////////////////////////////////////////////
1312 // maximum is EITHER attained at the single extreme point:
1313 float a_diff = a_side * a_side - a_up * a_up;
1317 f = a_add * a_up / a_diff; // this is the zero of diff(f(a_side, a_up, a_add, z), z)
1318 if (f > -1 && f < 1) // can it be attained?
1320 best = (a_diff + a_add * a_add) * (a_diff + a_up * a_up) / a_diff;
1321 //print("middle\n");
1324 // OR attained at z = 1:
1325 f = (a_up + a_add) * (a_up + a_add);
1331 // OR attained at z = -1:
1332 f = (a_up - a_add) * (a_up - a_add);
1336 //print("bottom\n");
1339 //////////////////////////////////////////////////////////////////////////////////////
1341 //print("best possible acceleration: ", ftos(best), "\n");
1344 fxy = bound(0, 1 - (self.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / PHYS_JETPACK_MAXSPEED_SIDE, 1);
1345 if (wishvel_z - PHYS_GRAVITY > 0)
1346 fz = bound(0, 1 - self.velocity_z / PHYS_JETPACK_MAXSPEED_UP, 1);
1348 fz = bound(0, 1 + self.velocity_z / PHYS_JETPACK_MAXSPEED_UP, 1);
1351 fvel = vlen(wishvel);
1354 wishvel_z = (wishvel_z - PHYS_GRAVITY) * fz + PHYS_GRAVITY;
1356 fvel = min(1, vlen(wishvel) / best);
1357 if (PHYS_JETPACK_FUEL && !(ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO))
1358 f = min(1, PHYS_AMMO_FUEL(self) / (PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel));
1362 //print("this acceleration: ", ftos(vlen(wishvel) * f), "\n");
1364 if (f > 0 && wishvel != '0 0 0')
1366 self.velocity = self.velocity + wishvel * f * PHYS_INPUT_TIMELENGTH;
1367 UNSET_ONGROUND(self);
1370 if (!(ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO))
1371 self.ammo_fuel -= PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel * f;
1373 self.items |= IT_USING_JETPACK;
1375 // jetpack also inhibits health regeneration, but only for 1 second
1376 self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen);
1381 void PM_walk(float buttons_prev, float maxspd_mod)
1384 // we get here if we ran out of ammo
1385 if ((ITEMS(self) & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32) && self.ammo_fuel < 0.01)
1386 sprint(self, "You don't have any fuel for the ^2Jetpack\n");
1389 makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
1390 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1391 + v_right * PHYS_INPUT_MOVEVALUES(self).y;
1394 if (!(self.lastflags & FL_ONGROUND))
1396 if (autocvar_speedmeter)
1397 dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
1398 if (self.lastground < time - 0.3)
1399 self.velocity *= (1 - autocvar_sv_friction_on_land);
1400 if (self.jumppadcount > 1)
1401 dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
1402 self.jumppadcount = 0;
1406 vector v = self.velocity;
1411 f = 1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION * ((f < PHYS_STOPSPEED) ? (PHYS_STOPSPEED / f) : 1);
1415 Mathematical analysis time!
1417 Our goal is to invert this mess.
1419 For the two cases we get:
1420 v = v0 * (1 - PHYS_INPUT_TIMELENGTH * (PHYS_STOPSPEED / v0) * PHYS_FRICTION)
1421 = v0 - PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED * PHYS_FRICTION
1422 v0 = v + PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED * PHYS_FRICTION
1424 v = v0 * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
1425 v0 = v / (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
1427 These cases would be chosen ONLY if:
1429 v + PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED * PHYS_FRICTION < PHYS_STOPSPEED
1430 v < PHYS_STOPSPEED * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
1432 v0 >= PHYS_STOPSPEED
1433 v / (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION) >= PHYS_STOPSPEED
1434 v >= PHYS_STOPSPEED * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
1439 vector wishdir = normalize(wishvel);
1440 float wishspeed = vlen(wishvel);
1441 wishspeed = min(wishspeed, PHYS_MAXSPEED(self) * maxspd_mod);
1442 if (IS_DUCKED(self))
1445 if (time >= self.teleport_time)
1446 PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
1450 float addspeed = wishspeed - dotproduct(self.velocity, wishdir);
1453 float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed);
1454 self.velocity += accelspeed * wishdir;
1456 float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
1457 if (!(GAMEPLAYFIX_NOGRAVITYONGROUND))
1458 self.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1);
1459 if (self.velocity * self.velocity)
1460 CSQC_ClientMovement_Move();
1461 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1462 if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
1463 self.velocity_z -= g * 0.5;
1467 void PM_air(float buttons_prev, float maxspd_mod)
1470 // we get here if we ran out of ammo
1471 if ((ITEMS(self) & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32) && PHYS_AMMO_FUEL(self) < 0.01)
1472 sprint(self, "You don't have any fuel for the ^2Jetpack\n");
1474 float maxairspd, airaccel;
1475 maxairspd = PHYS_MAXAIRSPEED * min(maxspd_mod, 1);
1476 airaccel = PHYS_AIRACCELERATE * min(maxspd_mod, 1);
1478 makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
1479 vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
1480 + v_right * PHYS_INPUT_MOVEVALUES(self).y;
1482 vector wishdir = normalize(wishvel);
1483 float wishspeed = vlen(wishvel);
1484 float wishspeed0 = min(wishspeed, PHYS_MAXSPEED(self) * maxspd_mod);
1485 wishspeed = min(wishspeed, maxairspd);
1486 if (IS_DUCKED(self))
1489 if (time >= self.teleport_time)
1491 if (pmove_waterjumptime <= 0)
1494 float airaccelqw = PHYS_AIRACCEL_QW(self);
1495 float accelerating = (self.velocity * wishdir > 0);
1496 float wishspeed2 = wishspeed;
1499 if (PHYS_AIRSTOPACCELERATE)
1501 vector curdir = normalize(vec2(self.velocity));
1502 airaccel += (PHYS_AIRSTOPACCELERATE*maxspd_mod - airaccel) * max(0, -(curdir * wishdir));
1504 // note that for straight forward jumping:
1505 // step = accel * PHYS_INPUT_TIMELENGTH * wishspeed0;
1506 // accel = bound(0, wishspeed - vel_xy_current, step) * accelqw + step * (1 - accelqw);
1508 // dv/dt = accel * maxspeed (when slow)
1509 // dv/dt = accel * maxspeed * (1 - accelqw) (when fast)
1510 // log dv/dt = logaccel + logmaxspeed (when slow)
1511 // log dv/dt = logaccel + logmaxspeed + log(1 - accelqw) (when fast)
1512 float strafity = IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), -90) + IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), +90); // if one is nonzero, other is always zero
1513 if (PHYS_MAXAIRSTRAFESPEED)
1514 wishspeed = min(wishspeed, GeomLerp(PHYS_MAXAIRSPEED*maxspd_mod, strafity, PHYS_MAXAIRSTRAFESPEED*maxspd_mod));
1515 if (PHYS_AIRSTRAFEACCELERATE)
1516 airaccel = GeomLerp(airaccel, strafity, PHYS_AIRSTRAFEACCELERATE*maxspd_mod);
1517 if (PHYS_AIRSTRAFEACCEL_QW(self))
1518 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)));
1521 if (PHYS_WARSOWBUNNY_TURNACCEL && accelerating && PHYS_INPUT_MOVEVALUES(self).y == 0 && PHYS_INPUT_MOVEVALUES(self).x != 0)
1522 PM_AirAccelerate(wishdir, wishspeed);
1524 PM_Accelerate(wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, PHYS_AIRACCEL_QW_STRETCHFACTOR(self), PHYS_AIRACCEL_SIDEWAYS_FRICTION / maxairspd, PHYS_AIRSPEEDLIMIT_NONQW(self));
1526 if (PHYS_AIRCONTROL)
1527 CPM_PM_Aircontrol(wishdir, wishspeed2);
1530 float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
1531 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1532 self.velocity_z -= g * 0.5;
1534 self.velocity_z -= g;
1535 CSQC_ClientMovement_Move();
1536 if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
1537 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
1538 self.velocity_z -= g * 0.5;
1542 // used for calculating airshots
1543 float PM_is_flying()
1545 if (IS_ONGROUND(self))
1547 if (self.waterlevel >= WATERLEVEL_SWIMMING)
1549 traceline(self.origin, self.origin - '0 0 48', MOVE_NORMAL, self);
1550 return trace_fraction >= 1;
1556 //Con_Printf(" %f", PHYS_INPUT_TIMELENGTH);
1557 if (!(PHYS_INPUT_BUTTONS(self) & 2)) // !jump
1558 UNSET_JUMP_HELD(self); // canjump = true
1559 pmove_waterjumptime -= PHYS_INPUT_TIMELENGTH;
1560 CSQC_ClientMovement_UpdateStatus();
1564 WarpZone_PlayerPhysics_FixVAngle();
1566 float maxspeed_mod = 1;
1567 maxspeed_mod *= PM_check_keepaway();
1568 maxspeed_mod *= PHYS_HIGHSPEED;
1570 // fix physics stats for g_movement_highspeed
1571 // TODO maybe rather use maxairspeed? needs testing
1573 self.stat_sv_airaccel_qw = AdjustAirAccelQW(autocvar_sv_airaccel_qw, maxspeed_mod);
1574 if (autocvar_sv_airstrafeaccel_qw)
1575 self.stat_sv_airstrafeaccel_qw = AdjustAirAccelQW(autocvar_sv_airstrafeaccel_qw, maxspeed_mod);
1577 self.stat_sv_airstrafeaccel_qw = 0;
1578 self.stat_sv_airspeedlimit_nonqw = autocvar_sv_airspeedlimit_nonqw * maxspeed_mod;
1579 self.stat_sv_maxspeed = autocvar_sv_maxspeed * maxspeed_mod; // also slow walking
1580 self.stat_movement_highspeed = autocvar_g_movement_highspeed; // TODO: remove this!
1582 self.stat_jetpack_antigravity = PHYS_JETPACK_ANTIGRAVITY;
1583 self.stat_jetpack_accel_up = PHYS_JETPACK_ACCEL_UP;
1584 self.stat_jetpack_accel_side = PHYS_JETPACK_ACCEL_SIDE;
1585 self.stat_jetpack_maxspeed_side = PHYS_JETPACK_MAXSPEED_SIDE;
1586 self.stat_jetpack_maxspeed_up = PHYS_JETPACK_MAXSPEED_UP;
1587 self.stat_jetpack_fuel = PHYS_JETPACK_FUEL;
1590 if (self.PlayerPhysplug)
1591 if (self.PlayerPhysplug())
1595 PM_check_race_movetime();
1597 anticheat_physics();
1599 float buttons = PHYS_INPUT_BUTTONS(self);
1601 if (PM_check_specialcommand(buttons))
1606 if (buttons != self.buttons_old || PHYS_INPUT_MOVEVALUES(self) != self.movement_old || PHYS_INPUT_ANGLES(self) != self.v_angle_old)
1607 self.parm_idlesince = time;
1610 float buttons_prev = self.buttons_old;
1611 self.buttons_old = buttons;
1612 self.movement_old = PHYS_INPUT_MOVEVALUES(self);
1613 self.v_angle_old = PHYS_INPUT_ANGLES(self);
1615 PM_check_nickspam();
1619 if (IS_BOT_CLIENT(self))
1621 if (playerdemo_read())
1626 self.items &= ~IT_USING_JETPACK;
1628 if (IS_PLAYER(self))
1632 if (self.race_penalty)
1633 if (time > self.race_penalty)
1634 self.race_penalty = 0;
1637 float not_allowed_to_move = 0;
1639 if (self.race_penalty)
1640 not_allowed_to_move = 1;
1643 if (!autocvar_sv_ready_restart_after_countdown)
1644 if (time < game_starttime)
1645 not_allowed_to_move = 1;
1648 if (not_allowed_to_move)
1650 self.velocity = '0 0 0';
1651 self.movetype = MOVETYPE_NONE;
1653 self.disableclientprediction = 2;
1657 else if (self.disableclientprediction == 2)
1659 if (self.movetype == MOVETYPE_NONE)
1660 self.movetype = MOVETYPE_WALK;
1661 self.disableclientprediction = 0;
1667 if (self.movetype == MOVETYPE_NONE)
1672 // when we get here, disableclientprediction cannot be 2
1673 self.disableclientprediction = 0;
1674 if (time < self.ladder_time)
1675 self.disableclientprediction = 1;
1683 MUTATOR_CALLHOOK(PlayerPhysics);
1691 if (self.in_swamp) {
1692 maxspeed_mod *= self.swamp_slowdown; //cvar("g_balance_swamp_moverate");
1697 // conveyors: first fix velocity
1698 if (self.conveyor.state)
1699 self.velocity -= self.conveyor.movedir;
1703 if (!IS_PLAYER(self))
1705 maxspeed_mod *= autocvar_sv_spectator_speed_multiplier;
1706 if (!self.spectatorspeed)
1707 self.spectatorspeed = maxspeed_mod;
1708 if (self.impulse && self.impulse <= 19 || (self.impulse >= 200 && self.impulse <= 209) || (self.impulse >= 220 && self.impulse <= 229))
1710 if (self.lastclassname != "player")
1712 if (self.impulse == 10 || self.impulse == 15 || self.impulse == 18 || (self.impulse >= 200 && self.impulse <= 209))
1713 self.spectatorspeed = bound(1, self.spectatorspeed + 0.5, 5);
1714 else if (self.impulse == 11)
1715 self.spectatorspeed = maxspeed_mod;
1716 else if (self.impulse == 12 || self.impulse == 16 || self.impulse == 19 || (self.impulse >= 220 && self.impulse <= 229))
1717 self.spectatorspeed = bound(1, self.spectatorspeed - 0.5, 5);
1718 else if (self.impulse >= 1 && self.impulse <= 9)
1719 self.spectatorspeed = 1 + 0.5 * (self.impulse - 1);
1720 } // otherwise just clear
1723 maxspeed_mod *= self.spectatorspeed;
1728 // if dead, behave differently
1729 // in CSQC, physics don't handle dead player
1735 if (!self.fixangle && !g_bugrigs)
1736 self.angles = '0 1 0' * PHYS_INPUT_ANGLES(self).y;
1740 if (IS_ONGROUND(self))
1741 if (IS_PLAYER(self)) // no fall sounds for observers thank you very much
1745 if (self.waterlevel < WATERLEVEL_SWIMMING)
1746 if (time >= self.ladder_time)
1749 self.nextstep = time + 0.3 + random() * 0.1;
1750 trace_dphitq3surfaceflags = 0;
1751 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
1752 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS))
1754 if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
1755 GlobalSound(globalsound_metalfall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
1757 GlobalSound(globalsound_fall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
1767 if (IS_PLAYER(self))
1772 if (self.flags & /* FL_WATERJUMP */ 2048)
1774 self.velocity_x = self.movedir_x;
1775 self.velocity_y = self.movedir_y;
1776 if (time > self.teleport_time || self.waterlevel == WATERLEVEL_NONE)
1778 self.flags &= ~/* FL_WATERJUMP */ 2048;
1779 self.teleport_time = 0;
1784 else if (g_bugrigs && IS_PLAYER(self))
1788 else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY || self.movetype == MOVETYPE_FLY_WORLDONLY)
1789 PM_fly(maxspeed_mod);
1791 else if (self.waterlevel >= WATERLEVEL_SWIMMING)
1792 PM_swim(maxspeed_mod);
1794 else if (time < self.ladder_time)
1795 PM_ladder(maxspeed_mod);
1797 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))
1798 PM_jetpack(maxspeed_mod);
1803 // jump if on ground with jump button pressed but only if it has been
1804 // released at least once since the last jump
1805 if (PHYS_INPUT_BUTTONS(self) & 2)
1807 if (IS_ONGROUND(self) && (!IS_JUMP_HELD(self) || !cvar("cl_movement_track_canjump")))
1809 self.velocity_z += PHYS_JUMPVELOCITY;
1810 UNSET_ONGROUND(self);
1811 SET_JUMP_HELD(self); // canjump = false
1815 UNSET_JUMP_HELD(self); // canjump = true
1817 if (IS_ONGROUND(self))
1818 PM_walk(buttons_prev, maxspeed_mod);
1820 PM_air(buttons_prev, maxspeed_mod);
1824 if (!IS_OBSERVER(self))
1830 if (IS_ONGROUND(self))
1831 self.lastground = time;
1834 // conveyors: then break velocity again
1835 if (self.conveyor.state)
1836 self.velocity += self.conveyor.movedir;
1839 self.lastflags = self.flags;
1840 self.lastclassname = self.classname;
1843 void CSQC_ClientMovement_PlayerMove_Frame()
1845 // if a move is more than 50ms, do it as two moves (matching qwsv)
1846 //Con_Printf("%i ", self.cmd.msec);
1847 if (PHYS_INPUT_TIMELENGTH > 0.0005)
1849 if (PHYS_INPUT_TIMELENGTH > 0.05)
1851 PHYS_INPUT_TIMELENGTH /= 2;
1857 // we REALLY need this handling to happen, even if the move is not executed
1858 if (!(PHYS_INPUT_BUTTONS(self) & 2)) // !jump
1859 UNSET_JUMP_HELD(self); // canjump = true
1862 #undef PHYS_INPUT_ANGLES
1863 #undef PHYS_INPUT_BUTTONS
1865 #undef PHYS_INPUT_TIMELENGTH
1867 #undef PHYS_INPUT_MOVEVALUES
1869 #undef GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE
1870 #undef GAMEPLAYFIX_NOGRAVITYONGROUND
1871 #undef GAMEPLAYFIX_Q2AIRACCELERATE
1878 #undef SET_JUMP_HELD
1879 #undef UNSET_JUMP_HELD
1883 #undef UNSET_ONGROUND
1885 #undef PHYS_ACCELERATE
1886 #undef PHYS_AIRACCEL_QW
1887 #undef PHYS_AIRACCEL_QW_STRETCHFACTOR
1888 #undef PHYS_AIRACCEL_SIDEWAYS_FRICTION
1889 #undef PHYS_AIRACCELERATE
1890 #undef PHYS_AIRCONTROL
1891 #undef PHYS_AIRCONTROL_PENALTY
1892 #undef PHYS_AIRCONTROL_POWER
1893 #undef PHYS_AIRSPEEDLIMIT_NONQW
1894 #undef PHYS_AIRSTOPACCELERATE
1895 #undef PHYS_AIRSTRAFEACCEL_QW
1896 #undef PHYS_AIRSTRAFEACCELERATE
1897 #undef PHYS_EDGEFRICTION
1898 #undef PHYS_ENTGRAVITY
1899 #undef PHYS_FRICTION
1901 #undef PHYS_HIGHSPEED
1902 #undef PHYS_JUMPVELOCITY
1903 #undef PHYS_MAXAIRSPEED
1904 #undef PHYS_MAXAIRSTRAFESPEED
1905 #undef PHYS_MAXSPEED
1906 #undef PHYS_STEPHEIGHT
1907 #undef PHYS_STOPSPEED
1908 #undef PHYS_WARSOWBUNNY_ACCEL
1909 #undef PHYS_WARSOWBUNNY_BACKTOSIDERATIO
1910 #undef PHYS_WARSOWBUNNY_AIRFORWARDACCEL
1911 #undef PHYS_WARSOWBUNNY_TOPSPEED
1912 #undef PHYS_WARSOWBUNNY_TURNACCEL
1916 void SV_PlayerPhysics(void)