3 void sys_phys_fix(entity this, float dt)
5 WarpZone_PlayerPhysics_FixVAngle(this);
6 Physics_UpdateStats(this, PHYS_HIGHSPEED(this));
7 this.oldmovement = this.movement;
10 bool sys_phys_override(entity this, float dt)
12 int buttons = PHYS_INPUT_BUTTON_MASK(this);
13 if (PM_check_specialcommand(this, buttons)) { return true; }
14 if (this.PlayerPhysplug && this.PlayerPhysplug(this, dt)) { return true; }
18 void sys_phys_monitor(entity this, float dt)
20 int buttons = PHYS_INPUT_BUTTON_MASK(this);
21 anticheat_physics(this);
23 if (buttons != this.buttons_old
24 || this.movement != this.movement_old
25 || this.v_angle != this.v_angle_old) { this.parm_idlesince = time; }
27 PM_check_nickspam(this);
28 PM_check_punch(this, dt);
31 void sys_phys_ai(entity this)
33 if (!IS_BOT_CLIENT(this)) { return; }
34 if (playerdemo_read(this)) { return; }
38 void sys_phys_pregame_hold(entity this)
40 if (!IS_PLAYER(this)) { return; }
41 const bool allowed_to_move = (time >= game_starttime);
42 if (!allowed_to_move) {
43 this.velocity = '0 0 0';
44 set_movetype(this, MOVETYPE_NONE);
45 this.disableclientprediction = 2;
46 } else if (this.disableclientprediction == 2) {
47 if (this.move_movetype == MOVETYPE_NONE) { set_movetype(this, MOVETYPE_WALK); }
48 this.disableclientprediction = 0;
52 void sys_phys_spectator_control(entity this)
54 float maxspeed_mod = autocvar_sv_spectator_speed_multiplier;
55 if (!this.spectatorspeed) { this.spectatorspeed = maxspeed_mod; }
56 if ((this.impulse >= 1 && this.impulse <= 19)
57 || (this.impulse >= 200 && this.impulse <= 209)
58 || (this.impulse >= 220 && this.impulse <= 229)
60 if (this.lastclassname != STR_PLAYER) {
61 if (this.impulse == 10
64 || (this.impulse >= 200 && this.impulse <= 209)
65 ) { this.spectatorspeed = bound(1, this.spectatorspeed + 0.5, 5); } else if (this.impulse == 11) {
66 this.spectatorspeed = maxspeed_mod;
67 } else if (this.impulse == 12
70 || (this.impulse >= 220 && this.impulse <= 229)
72 this.spectatorspeed = bound(1, this.spectatorspeed - 0.5, 5);
73 } else if (this.impulse >= 1 && this.impulse <= 9) {
74 this.spectatorspeed = 1 + 0.5 * (this.impulse - 1);
76 } // otherwise just clear
81 void sys_phys_fixspeed(entity this, float maxspeed_mod)
83 float spd = max(PHYS_MAXSPEED(this), PHYS_MAXAIRSPEED(this)) * maxspeed_mod;
84 if (this.speed != spd) {
86 string temps = ftos(spd);
87 stuffcmd(this, strcat("cl_forwardspeed ", temps, "\n"));
88 stuffcmd(this, strcat("cl_backspeed ", temps, "\n"));
89 stuffcmd(this, strcat("cl_sidespeed ", temps, "\n"));
90 stuffcmd(this, strcat("cl_upspeed ", temps, "\n"));
93 if (this.jumpspeedcap_min != autocvar_sv_jumpspeedcap_min) {
94 this.jumpspeedcap_min = autocvar_sv_jumpspeedcap_min;
95 stuffcmd(this, sprintf("\ncl_jumpspeedcap_min \"%s\"\n", autocvar_sv_jumpspeedcap_min));
97 if (this.jumpspeedcap_max != autocvar_sv_jumpspeedcap_max) {
98 this.jumpspeedcap_max = autocvar_sv_jumpspeedcap_max;
99 stuffcmd(this, sprintf("\ncl_jumpspeedcap_max \"%s\"\n", autocvar_sv_jumpspeedcap_max));
103 void sys_phys_land(entity this)
105 if (autocvar_speedmeter) {
106 LOG_TRACEF("landing velocity: %v (abs: %f)", this.velocity, vlen(this.velocity));
108 if (this.jumppadcount > 1) {
109 LOG_TRACEF("%dx jumppad combo", this.jumppadcount);
111 this.jumppadcount = 0;
114 STATIC_INIT(sys_phys)
116 entity listener = new_pure(sys_phys);
117 subscribe(listener, phys_land, sys_phys_land);