]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/physics.qc
Use a temporary hack to hide the jump sound issue
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics.qc
index 7a22ae1e53bb73521c690fc05a8c80f08f6aaed2..f7551e253a5341be8df131b048529c4a3f011f05 100644 (file)
@@ -186,8 +186,8 @@ void PM_ClientMovement_UpdateStatus(entity this, bool ground)
                }
        }
 
-       if (IS_ONGROUND(this) || this.velocity.z <= 0 || PHYS_TELEPORT_TIME(this) <= 0)
-               PHYS_TELEPORT_TIME(this) = 0;
+       if (IS_ONGROUND(this) || this.velocity.z <= 0 || pmove_waterjumptime <= 0)
+               pmove_waterjumptime = 0;
 #endif
 }
 
@@ -520,7 +520,7 @@ bool PlayerJump(entity this)
        animdecide_setaction(this, ANIMACTION_JUMP, true);
 
        if (autocvar_g_jump_grunt)
-               WITH(entity, self, this, PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND));
+               PlayerSound(this, playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
 #endif
        return true;
 }
@@ -546,7 +546,11 @@ void CheckWaterJump(entity this)
                        this.velocity_z = 225;
                        this.flags |= FL_WATERJUMP;
                        SET_JUMP_HELD(this);
+               #ifdef SVQC
                        PHYS_TELEPORT_TIME(this) = time + 2;    // safety net
+               #elif defined(CSQC)
+                       pmove_waterjumptime = time + 2;
+               #endif
                }
        }
 }
@@ -742,8 +746,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;
@@ -752,9 +754,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
 }
 
@@ -782,7 +807,9 @@ void PM_fly(entity this, float maxspd_mod)
        // acceleration
        vector wishdir = normalize(wishvel);
        float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(this) * maxspd_mod);
+#ifdef SVQC
        if(time >= PHYS_TELEPORT_TIME(this))
+#endif
                PM_Accelerate(this, wishdir, wishspeed, wishspeed, PHYS_ACCELERATE(this) * maxspd_mod, 1, 0, 0, 0);
        PM_ClientMovement_Move(this);
 }
@@ -811,7 +838,9 @@ void PM_swim(entity this, float maxspd_mod)
                        {
                                this.velocity = forward * 50;
                                this.velocity_z = 310;
-                               PHYS_TELEPORT_TIME(this) = 2;
+                       #ifdef CSQC
+                               pmove_waterjumptime = 2;
+                       #endif
                                UNSET_ONGROUND(this);
                                SET_JUMP_HELD(this);
                        }
@@ -1142,7 +1171,11 @@ void PM_air(entity this, float buttons_prev, float maxspd_mod)
        vector wishdir = normalize(wishvel);
        float wishspeed = vlen(wishvel);
 
-       if(PHYS_TELEPORT_TIME(this) < time)
+#ifdef SVQC
+       if(time >= PHYS_TELEPORT_TIME(this))
+#elif defined(CSQC)
+       if(pmove_waterjumptime <= 0)
+#endif
        {
                float maxairspd = PHYS_MAXAIRSPEED(this) * min(maxspd_mod, 1);
 
@@ -1237,7 +1270,7 @@ void PM_Main(entity this)
        this.team = myteam + 1; // is this correct?
        if (!(PHYS_INPUT_BUTTON_JUMP(this))) // !jump
                UNSET_JUMP_HELD(this); // canjump = true
-       PHYS_TELEPORT_TIME(this) -= PHYS_INPUT_TIMELENGTH;
+       pmove_waterjumptime -= PHYS_INPUT_TIMELENGTH;
 
        PM_ClientMovement_UpdateStatus(this, true);
 #endif
@@ -1366,15 +1399,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
 
@@ -1398,7 +1431,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;