.int disableclientprediction;
+void sys_phys_simulate(entity this, float dt);
+
void sys_phys_update(entity this, float dt)
{
sys_in_update(this, dt);
sys_phys_fix(this, dt);
- if (sys_phys_override(this)) return;
- sys_phys_monitor(this);
+ if (sys_phys_override(this)) { return; } sys_phys_monitor(this);
int buttons_prev = this.buttons_old;
this.buttons_old = PHYS_INPUT_BUTTON_MASK(this);
sys_phys_pregame_hold(this);
if (IS_SVQC) {
- if (PHYS_MOVETYPE(this) == MOVETYPE_NONE) return;
-
+ if (PHYS_MOVETYPE(this) == MOVETYPE_NONE) { return; }
// when we get here, disableclientprediction cannot be 2
this.disableclientprediction = 0;
}
PM_check_blocked(this);
- float maxspeed_mod = (!this.in_swamp) ? 1 : this.swamp_slowdown; // cvar("g_balance_swamp_moverate");
+ float maxspeed_mod = (!this.in_swamp) ? 1 : this.swamp_slowdown; // cvar("g_balance_swamp_moverate");
// conveyors: first fix velocity
- if (this.conveyor.state) this.velocity -= this.conveyor.movedir;
-
+ if (this.conveyor.state) { this.velocity -= this.conveyor.movedir; }
MUTATOR_CALLHOOK(PlayerPhysics, this);
if (!IS_PLAYER(this)) {
goto end;
}
- if (IS_SVQC && !PHYS_FIXANGLE(this)) this.angles = '0 1 0' * this.v_angle.y;
-
+ if (IS_SVQC && !PHYS_FIXANGLE(this)) { this.angles = '0 1 0' * this.v_angle.y; }
if (IS_PLAYER(this)) {
if (IS_ONGROUND(this)) {
PM_check_hitground(this);
|| PHYS_MOVETYPE(this) == MOVETYPE_FLY
|| PHYS_MOVETYPE(this) == MOVETYPE_FLY_WORLDONLY
|| MUTATOR_CALLHOOK(IsFlying, this)) {
- PM_fly(this, maxspeed_mod);
+ this.com_phys_friction = PHYS_FRICTION(this);
+ this.com_phys_vel_max = PHYS_MAXSPEED(this) * maxspeed_mod;
+ this.com_phys_acc_rate = PHYS_ACCELERATE(this) * maxspeed_mod;
+ sys_phys_simulate(this, dt);
} else if (this.waterlevel >= WATERLEVEL_SWIMMING) {
PM_swim(this, maxspeed_mod);
} else if (time < this.ladder_time) {
}
LABEL(end)
- if (IS_ONGROUND(this)) this.lastground = time;
-
+ if (IS_ONGROUND(this)) { this.lastground = time; }
// conveyors: then break velocity again
- if (this.conveyor.state) this.velocity += this.conveyor.movedir;
-
+ if (this.conveyor.state) { this.velocity += this.conveyor.movedir; }
this.lastflags = this.flags;
this.lastclassname = this.classname;
}
+
+void sys_phys_simulate(entity this, float dt)
+{
+ // noclipping or flying
+ UNSET_ONGROUND(this);
+
+ this.velocity = this.velocity * (1 - dt * this.com_phys_friction);
+ makevectors(this.v_angle);
+ // wishvel = v_forward * this.movement.x + v_right * this.movement.y + v_up * this.movement.z;
+ vector wishvel = v_forward * this.movement.x
+ + v_right * this.movement.y
+ + '0 0 1' * this.movement.z;
+ // acceleration
+ vector wishdir = normalize(wishvel);
+ float wishspeed = min(vlen(wishvel), this.com_phys_vel_max);
+ if (IS_CSQC || time >= PHYS_TELEPORT_TIME(this)) {
+ PM_Accelerate(this, wishdir, wishspeed, wishspeed, this.com_phys_acc_rate, 1, 0, 0, 0);
+ }
+ PM_ClientMovement_Move(this);
+}