]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/physics.qc
Make water transition slightly less broken
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics.qc
index d21579fa653f422d90d239e94a2325e6ea33a127..be93c620edfc0655efe0e1c138c1c05453ef2be6 100644 (file)
@@ -122,7 +122,8 @@ void PM_ClientMovement_UpdateStatus(entity this, bool ground)
 {
 #ifdef CSQC
        // make sure player is not stuck
-       PM_ClientMovement_Unstick(this);
+       if(autocvar_cl_movement != 3)
+               PM_ClientMovement_Unstick(this);
 
        // set crouched
        if (PHYS_INPUT_BUTTON_CROUCH(this))
@@ -158,27 +159,30 @@ void PM_ClientMovement_UpdateStatus(entity this, bool ground)
                        UNSET_ONGROUND(this);
        }
 
-       // set watertype/waterlevel
-       origin1 = this.origin;
-       origin1.z += this.mins_z + 1;
-       this.waterlevel = WATERLEVEL_NONE;
+       if(autocvar_cl_movement != 3)
+       {
+               // set watertype/waterlevel
+               origin1 = this.origin;
+               origin1.z += this.mins_z + 1;
+               this.waterlevel = WATERLEVEL_NONE;
 
-       int thepoint = pointcontents(origin1);
+               int thepoint = pointcontents(origin1);
 
-       this.watertype = (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME);
+               this.watertype = (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME);
 
-       if (this.watertype)
-       {
-               this.waterlevel = WATERLEVEL_WETFEET;
-               origin1.z = this.origin.z + (this.mins.z + this.maxs.z) * 0.5;
-               thepoint = pointcontents(origin1);
-               if (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
+               if (this.watertype)
                {
-                       this.waterlevel = WATERLEVEL_SWIMMING;
-                       origin1.z = this.origin.z + 22;
+                       this.waterlevel = WATERLEVEL_WETFEET;
+                       origin1.z = this.origin.z + (this.mins.z + this.maxs.z) * 0.5;
                        thepoint = pointcontents(origin1);
                        if (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
-                               this.waterlevel = WATERLEVEL_SUBMERGED;
+                       {
+                               this.waterlevel = WATERLEVEL_SWIMMING;
+                               origin1.z = this.origin.z + 22;
+                               thepoint = pointcontents(origin1);
+                               if (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
+                                       this.waterlevel = WATERLEVEL_SUBMERGED;
+                       }
                }
        }
 
@@ -516,7 +520,7 @@ bool PlayerJump(entity this)
        animdecide_setaction(this, ANIMACTION_JUMP, true);
 
        if (autocvar_g_jump_grunt)
-               WITH(entity, this, this, PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND));
+               PlayerSound(this, playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
 #endif
        return true;
 }
@@ -738,8 +742,6 @@ void PM_check_frozen(entity this)
 void PM_check_hitground(entity this)
 {
 #ifdef SVQC
-       if (!IS_PLAYER(this)) return; // no fall sounds for observers thank you very much
-       if (!IS_ONGROUND(this)) return;
        if (!this.wasFlying) return;
     this.wasFlying = false;
     if (this.waterlevel >= WATERLEVEL_SWIMMING) return;
@@ -748,9 +750,32 @@ void PM_check_hitground(entity this)
     this.nextstep = time + 0.3 + random() * 0.1;
     trace_dphitq3surfaceflags = 0;
     tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this);
-    if ((trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)) return;
-    entity fall = (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS) ? GS_FALL_METAL : GS_FALL;
-    WITH(entity, self, this, GlobalSound(fall, CH_PLAYER, VOICETYPE_PLAYERSOUND));
+    if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS) return;
+    entity gs = (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
+       ? GS_FALL_METAL
+       : GS_FALL;
+    GlobalSound(this, gs, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+#endif
+}
+
+void PM_Footsteps(entity this)
+{
+#ifdef SVQC
+       if (!g_footsteps) return;
+       if (IS_DUCKED(this)) return;
+       if (time >= this.lastground + 0.2) return;
+       if (vdist(this.velocity, <=, autocvar_sv_maxspeed * 0.6)) return;
+       if ((time > this.nextstep) || (time < (this.nextstep - 10.0)))
+       {
+               this.nextstep = time + 0.3 + random() * 0.1;
+               trace_dphitq3surfaceflags = 0;
+               tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this);
+               if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS) return;
+               entity gs = (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
+                       ? GS_STEP_METAL
+                       : GS_STEP;
+               GlobalSound(this, gs, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+       }
 #endif
 }
 
@@ -1362,15 +1387,15 @@ void PM_Main(entity this)
                stuffcmd(this, strcat("cl_upspeed ", temps, "\n"));
        }
 
-       if(this.stat_jumpspeedcap_min != PHYS_JUMPSPEEDCAP_MIN)
+       if(this.jumpspeedcap_min != autocvar_sv_jumpspeedcap_min)
        {
-               this.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MIN;
-               stuffcmd(this, strcat("cl_jumpspeedcap_min ", PHYS_JUMPSPEEDCAP_MIN, "\n"));
+               this.jumpspeedcap_min = autocvar_sv_jumpspeedcap_min;
+               stuffcmd(this, sprintf("\ncl_jumpspeedcap_min \"%s\"\n", autocvar_sv_jumpspeedcap_min));
        }
-       if(this.stat_jumpspeedcap_max != PHYS_JUMPSPEEDCAP_MAX)
+       if(this.jumpspeedcap_max != autocvar_sv_jumpspeedcap_max)
        {
-               this.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MAX;
-               stuffcmd(this, strcat("cl_jumpspeedcap_max ", PHYS_JUMPSPEEDCAP_MAX, "\n"));
+               this.jumpspeedcap_max = autocvar_sv_jumpspeedcap_max;
+               stuffcmd(this, sprintf("\ncl_jumpspeedcap_max \"%s\"\n", autocvar_sv_jumpspeedcap_max));
        }
 #endif
 
@@ -1394,7 +1419,11 @@ void PM_Main(entity this)
                this.angles = '0 1 0' * this.v_angle.y;
 #endif
 
-       PM_check_hitground(this);
+       if (IS_PLAYER(this) && IS_ONGROUND(this))
+       {
+               PM_check_hitground(this);
+               PM_Footsteps(this);
+       }
 
        if(IsFlying(this))
                this.wasFlying = 1;