From: Mario Date: Tue, 15 Dec 2015 14:26:06 +0000 (+1000) Subject: Add special water physics for side scroller X-Git-Tag: xonotic-v0.8.2~1491 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7a783652a4da905351a9fb3a6e0f82849d101ef2;p=xonotic%2Fxonotic-data.pk3dir.git Add special water physics for side scroller --- diff --git a/qcsrc/common/physics.qc b/qcsrc/common/physics.qc index dc1dcacde..76e3ce9db 100644 --- a/qcsrc/common/physics.qc +++ b/qcsrc/common/physics.qc @@ -448,8 +448,16 @@ bool PlayerJump(entity this) if (this.waterlevel >= WATERLEVEL_SWIMMING) { - this.velocity_z = PHYS_MAXSPEED(this) * 0.7; - return true; + if(this.viewloc) + { + doublejump = true; + mjumpheight *= 0.7; + } + else + { + this.velocity_z = PHYS_MAXSPEED(this) * 0.7; + return true; + } } if (!doublejump) @@ -822,7 +830,7 @@ void PM_swim(entity this, float maxspd_mod) float jump = PHYS_INPUT_BUTTON_JUMP(this); // water jump only in certain situations // this mimics quakeworld code - if (jump && this.waterlevel == WATERLEVEL_SWIMMING && this.velocity_z >= -180) + if (jump && this.waterlevel == WATERLEVEL_SWIMMING && this.velocity_z >= -180 && !this.viewloc) { vector yawangles = '0 1 0' * this.v_angle.y; makevectors(yawangles); @@ -851,9 +859,12 @@ void PM_swim(entity this, float maxspd_mod) vector wishvel = v_forward * this.movement.x + v_right * this.movement.y + '0 0 1' * this.movement.z; - if (wishvel == '0 0 0') + 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; @@ -875,7 +886,7 @@ void PM_swim(entity this, float maxspd_mod) } // holding jump button swims upward slowly - if (jump) + if (jump && !this.viewloc) { #if 0 if (this.watertype & CONTENT_LAVA) @@ -894,9 +905,21 @@ void PM_swim(entity this, float maxspd_mod) #endif } } - // water acceleration - PM_Accelerate(this, wishdir, wishspeed, wishspeed, PHYS_ACCELERATE(this) * maxspd_mod, 1, 0, 0, 0); - PM_ClientMovement_Move(this); + if(this.viewloc) + { + const float addspeed = wishspeed - this.velocity * wishdir; + if (addspeed > 0) + { + const float accelspeed = min(PHYS_ACCELERATE(this) * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed); + this.velocity += accelspeed * wishdir; + } + } + else + { + // water acceleration + PM_Accelerate(this, wishdir, wishspeed, wishspeed, PHYS_ACCELERATE(this) * maxspd_mod, 1, 0, 0, 0); + PM_ClientMovement_Move(this); + } } void PM_ladder(entity this, float maxspd_mod)