From 01470a138909d853d92a85a4bc27ce2afbdd4fd9 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 22 Jul 2016 06:14:47 +1000 Subject: [PATCH] Swim down with crouch, swim up at full speed (to match +moveup) --- qcsrc/common/physics/player.qc | 14 +++++++++----- qcsrc/server/cl_client.qc | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 36c5bdad4..d010dfe6c 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -131,6 +131,8 @@ void PM_ClientMovement_UpdateStatus(entity this, bool ground) bool do_crouch = PHYS_INPUT_BUTTON_CROUCH(this); if(this.hook && !wasfreed(this.hook)) do_crouch = false; + if(this.waterlevel >= WATERLEVEL_SWIMMING) + do_crouch = false; if(hud != HUD_NORMAL) do_crouch = false; if(STAT(FROZEN, this)) @@ -871,22 +873,21 @@ void PM_swim(entity this, float maxspd_mod) } } makevectors(this.v_angle); + float wishdown = this.movement.z; + if(PHYS_INPUT_BUTTON_CROUCH(this)) + wishdown = -PHYS_MAXSPEED(this); //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; + + '0 0 1' * wishdown; if(this.viewloc) wishvel.z = -160; // drift anyway else if (wishvel == '0 0 0') wishvel = '0 0 -60'; // drift towards bottom - vector wishdir = normalize(wishvel); float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(this) * maxspd_mod) * 0.7; - if (IS_DUCKED(this)) - wishspeed *= 0.5; - // if (pmove_waterjumptime <= 0) // TODO: use { // water friction @@ -913,6 +914,9 @@ void PM_swim(entity this, float maxspd_mod) { if (IS_NEXUIZ_DERIVED(gamemode)) #endif + if(this.waterlevel >= WATERLEVEL_SUBMERGED) + this.velocity_z = PHYS_MAXSPEED(this); + else this.velocity_z = 200; #if 0 else diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index e0b7e116e..a47e14e16 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2281,6 +2281,8 @@ void PlayerPreThink (entity this) .entity weaponentity = weaponentities[0]; // TODO: unhardcode if (this.hook.state) { do_crouch = false; + } else if (this.waterlevel >= WATERLEVEL_SWIMMING) { + do_crouch = false; } else if (this.vehicle) { do_crouch = false; } else if (STAT(FROZEN, this)) { -- 2.39.2