]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/ecs/systems/physics.qc
Move resurfacing (when frozen) code to sys_phys_simulate
[xonotic/xonotic-data.pk3dir.git] / qcsrc / ecs / systems / physics.qc
index 1155c09f274c3e122b0f118fba293adcefc33fff..fb0781e49e527391914ce6bc924e29eab822b2e4 100644 (file)
@@ -217,14 +217,22 @@ 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)
+                               wishvel = '0 0 160'; // resurface
                }
-               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) {