4 .int disableclientprediction;
6 void sys_phys_update(entity this, float dt)
8 sys_in_update(this, dt);
10 sys_phys_fix(this, dt);
11 if (sys_phys_override(this)) return;
12 sys_phys_monitor(this);
14 int buttons_prev = this.buttons_old;
15 this.buttons_old = PHYS_INPUT_BUTTON_MASK(this);
16 this.movement_old = this.movement;
17 this.v_angle_old = this.v_angle;
21 sys_phys_pregame_hold(this);
24 if (PHYS_MOVETYPE(this) == MOVETYPE_NONE) return;
26 // when we get here, disableclientprediction cannot be 2
27 this.disableclientprediction = 0;
30 viewloc_PlayerPhysics(this);
32 PM_check_frozen(this);
34 PM_check_blocked(this);
36 float maxspeed_mod = (!this.in_swamp) ? 1 : this.swamp_slowdown; // cvar("g_balance_swamp_moverate");
38 // conveyors: first fix velocity
39 if (this.conveyor.state) this.velocity -= this.conveyor.movedir;
41 MUTATOR_CALLHOOK(PlayerPhysics, this);
43 if (!IS_PLAYER(this)) {
44 sys_phys_spectator_control(this);
45 maxspeed_mod = this.spectatorspeed;
47 sys_phys_fixspeed(this, maxspeed_mod);
51 vector midpoint = ((this.absmin + this.absmax) * 0.5);
52 if (pointcontents(midpoint) == CONTENT_WATER) {
53 this.velocity = this.velocity * 0.5;
56 // if(pointcontents(midpoint + '0 0 2') == CONTENT_WATER)
57 // { this.velocity_z = 70; }
62 if (IS_SVQC && !PHYS_FIXANGLE(this)) this.angles = '0 1 0' * this.v_angle.y;
64 if (IS_PLAYER(this)) {
65 if (IS_ONGROUND(this)) {
66 PM_check_hitground(this);
68 } else if (IsFlying(this)) {
69 this.wasFlying = true;
71 CheckPlayerJump(this);
74 if (this.flags & FL_WATERJUMP) {
75 this.velocity_x = this.movedir.x;
76 this.velocity_y = this.movedir.y;
77 if (time > PHYS_TELEPORT_TIME(this)
78 || this.waterlevel == WATERLEVEL_NONE
79 || PHYS_WATERJUMP_TIME(this) <= 0
81 this.flags &= ~FL_WATERJUMP;
82 PHYS_TELEPORT_TIME(this) = 0;
83 PHYS_WATERJUMP_TIME(this) = 0;
85 } else if (MUTATOR_CALLHOOK(PM_Physics, this, maxspeed_mod)) {
87 } else if (PHYS_MOVETYPE(this) == MOVETYPE_NOCLIP
88 || PHYS_MOVETYPE(this) == MOVETYPE_FLY
89 || PHYS_MOVETYPE(this) == MOVETYPE_FLY_WORLDONLY
90 || MUTATOR_CALLHOOK(IsFlying, this)) {
91 PM_fly(this, maxspeed_mod);
92 } else if (this.waterlevel >= WATERLEVEL_SWIMMING) {
93 PM_swim(this, maxspeed_mod);
94 } else if (time < this.ladder_time) {
95 PM_ladder(this, maxspeed_mod);
96 } else if (ITEMS_STAT(this) & IT_USING_JETPACK) {
97 PM_jetpack(this, maxspeed_mod);
98 } else if (IS_ONGROUND(this)) {
99 PM_walk(this, maxspeed_mod);
101 PM_air(this, buttons_prev, maxspeed_mod);
105 if (IS_ONGROUND(this)) this.lastground = time;
107 // conveyors: then break velocity again
108 if (this.conveyor.state) this.velocity += this.conveyor.movedir;
110 this.lastflags = this.flags;
112 this.lastclassname = this.classname;