3 void sys_phys_fix(entity this, float dt)
5 WarpZone_PlayerPhysics_FixVAngle(this);
6 Physics_UpdateStats(this, PHYS_HIGHSPEED(this));
9 bool sys_phys_override(entity this)
11 int buttons = PHYS_INPUT_BUTTON_MASK(this);
12 if (PM_check_specialcommand(this, buttons)) { return true; }
13 if (this.PlayerPhysplug && this.PlayerPhysplug(this)) { return true; }
17 void sys_phys_monitor(entity this)
19 int buttons = PHYS_INPUT_BUTTON_MASK(this);
20 anticheat_physics(this);
22 if (buttons != this.buttons_old
23 || this.movement != this.movement_old
24 || this.v_angle != this.v_angle_old) { this.parm_idlesince = time; }
26 PM_check_nickspam(this);
30 void sys_phys_ai(entity this)
32 if (!IS_BOT_CLIENT(this)) { return; }
33 if (playerdemo_read(this)) { return; }
37 void sys_phys_pregame_hold(entity this)
39 if (!IS_PLAYER(this)) { return; }
40 const bool allowed_to_move = (time >= game_starttime);
41 if (!allowed_to_move) {
42 this.velocity = '0 0 0';
43 this.movetype = MOVETYPE_NONE;
44 this.disableclientprediction = 2;
45 } else if (this.disableclientprediction == 2) {
46 if (this.movetype == MOVETYPE_NONE) { this.movetype = MOVETYPE_WALK; }
47 this.disableclientprediction = 0;
51 void sys_phys_spectator_control(entity this)
53 float maxspeed_mod = autocvar_sv_spectator_speed_multiplier;
54 if (!this.spectatorspeed) { this.spectatorspeed = maxspeed_mod; }
55 if ((this.impulse >= 1 && this.impulse <= 19)
56 || (this.impulse >= 200 && this.impulse <= 209)
57 || (this.impulse >= 220 && this.impulse <= 229)
59 if (this.lastclassname != STR_PLAYER) {
60 if (this.impulse == 10
63 || (this.impulse >= 200 && this.impulse <= 209)
64 ) { this.spectatorspeed = bound(1, this.spectatorspeed + 0.5, 5); } else if (this.impulse == 11) {
65 this.spectatorspeed = maxspeed_mod;
66 } else if (this.impulse == 12
69 || (this.impulse >= 220 && this.impulse <= 229)
71 this.spectatorspeed = bound(1, this.spectatorspeed - 0.5, 5);
72 } else if (this.impulse >= 1 && this.impulse <= 9) {
73 this.spectatorspeed = 1 + 0.5 * (this.impulse - 1);
75 } // otherwise just clear
80 void sys_phys_fixspeed(entity this, float maxspeed_mod)
82 float spd = max(PHYS_MAXSPEED(this), PHYS_MAXAIRSPEED(this)) * maxspeed_mod;
83 if (this.speed != spd) {
85 string temps = ftos(spd);
86 stuffcmd(this, strcat("cl_forwardspeed ", temps, "\n"));
87 stuffcmd(this, strcat("cl_backspeed ", temps, "\n"));
88 stuffcmd(this, strcat("cl_sidespeed ", temps, "\n"));
89 stuffcmd(this, strcat("cl_upspeed ", temps, "\n"));
92 if (this.jumpspeedcap_min != autocvar_sv_jumpspeedcap_min) {
93 this.jumpspeedcap_min = autocvar_sv_jumpspeedcap_min;
94 stuffcmd(this, sprintf("\ncl_jumpspeedcap_min \"%s\"\n", autocvar_sv_jumpspeedcap_min));
96 if (this.jumpspeedcap_max != autocvar_sv_jumpspeedcap_max) {
97 this.jumpspeedcap_max = autocvar_sv_jumpspeedcap_max;
98 stuffcmd(this, sprintf("\ncl_jumpspeedcap_max \"%s\"\n", autocvar_sv_jumpspeedcap_max));
102 void sys_phys_land(entity this)
104 if (autocvar_speedmeter) {
105 LOG_TRACEF("landing velocity: %v (abs: %f)", this.velocity, vlen(this.velocity));
107 if (this.jumppadcount > 1) {
108 LOG_TRACEF("%dx jumppad combo", this.jumppadcount);
110 this.jumppadcount = 0;
113 STATIC_INIT(sys_phys)
115 entity listener = new_pure(sys_phys);
116 subscribe(listener, phys_land, sys_phys_land);