]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Swim down with crouch, swim up at full speed (to match +moveup)
authorMario <mario@smbclan.net>
Thu, 21 Jul 2016 20:14:47 +0000 (06:14 +1000)
committerMario <mario@smbclan.net>
Thu, 21 Jul 2016 20:14:47 +0000 (06:14 +1000)
qcsrc/common/physics/player.qc
qcsrc/server/cl_client.qc

index 36c5bdad40cbf19b18568263b76e87200f97da24..d010dfe6c7ee503c7f98b69878e4b6d43e178b47 100644 (file)
@@ -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
index e0b7e116eae253a3b6f85f3dc43e352b69774f99..a47e14e162b1d39042fe4efc0f70fa85e2a2a80f 100644 (file)
@@ -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)) {