]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/frozen_resurfacing' into 'master'
authorMario <mario.mario@y7mail.com>
Sun, 24 May 2020 11:41:02 +0000 (11:41 +0000)
committerMario <mario.mario@y7mail.com>
Sun, 24 May 2020 11:41:02 +0000 (11:41 +0000)
Frozen resurfacing

See merge request xonotic/xonotic-data.pk3dir!817

qcsrc/common/physics/player.qc
qcsrc/ecs/systems/physics.qc

index 13fcc670f3225e87d1d941faaa906db6041b5145..91073a88e48bd79e0b949120b38857e1243d8e9b 100644 (file)
@@ -617,13 +617,6 @@ void PM_check_frozen(entity this)
        }
        else
                PHYS_CS(this).movement = '0 0 0';
-
-       if(this.waterlevel >= WATERLEVEL_SWIMMING)
-       {
-               this.velocity = this.velocity * 0.5;
-               if(this.waterlevel >= WATERLEVEL_SUBMERGED)
-                       this.velocity.z = 160;
-       }
 }
 
 void PM_check_hitground(entity this)
index 1155c09f274c3e122b0f118fba293adcefc33fff..75657c90f268c6f9248377114df942c96fbf1674 100644 (file)
@@ -217,14 +217,24 @@ void sys_phys_simulate(entity this, float dt)
        vector wishvel = forward * PHYS_CS(this).movement.x
            + right * PHYS_CS(this).movement.y
            + '0 0 1' * PHYS_CS(this).movement.z * (this.com_phys_vel_2d ? 0 : 1);
-       if (this.com_phys_water && !PHYS_FROZEN(this)) {
-               if (PHYS_INPUT_BUTTON_CROUCH(this)) {
-                       wishvel.z = -PHYS_MAXSPEED(this);
+       if (this.com_phys_water) {
+               if (PHYS_FROZEN(this))
+               {
+                       if(this.waterlevel >= WATERLEVEL_SUBMERGED && this.velocity.z >= -70) // don't change the speed too abruptally
+                               wishvel = '0 0 160'; // resurface
+                       else if(this.waterlevel >= WATERLEVEL_SWIMMING && this.velocity.z > 0)
+                               wishvel = eZ * 1.3 * min(this.velocity.z, 160); // resurface a bit more above the surface
                }
-               if (this.viewloc) {
-                       wishvel.z = -160;    // drift anyway
-               } else if (wishvel == '0 0 0') {
-                       wishvel = '0 0 -60'; // drift towards bottom
+               else
+               {
+                       if (PHYS_INPUT_BUTTON_CROUCH(this)) {
+                               wishvel.z = -PHYS_MAXSPEED(this);
+                       }
+                       if (this.viewloc) {
+                               wishvel.z = -160;    // drift anyway
+                       } else if (wishvel == '0 0 0') {
+                               wishvel = '0 0 -60'; // drift towards bottom
+                       }
                }
        }
        if (this.com_phys_ladder) {