]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Player_Footsteps: move to physics
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 3 Dec 2015 08:22:39 +0000 (19:22 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 3 Dec 2015 08:22:39 +0000 (19:22 +1100)
qcsrc/common/physics.qc
qcsrc/server/cl_client.qc

index 2fd3dbaa7a08e14b0dfa4e601648226929049213..ad795a2b60eced763ef9b15dffed04628fa7ece5 100644 (file)
@@ -742,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;
@@ -752,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;
-    GlobalSound(this, 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
 }
 
@@ -1398,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;
index 9ba9cb1b2bf0b3cd82524a7b20be50fbf44c154d..e63a9afbc7d9d8a0652b4f440918fb87fe1ee84c 100644 (file)
@@ -2520,34 +2520,6 @@ void PlayerPreThink ()
                self.clip_load = self.clip_size = 0;
 }
 
-void Player_Footsteps(entity this)
-{
-       // play stupid sounds
-       if (g_footsteps && !gameover && (this.flags & FL_ONGROUND))
-       if (!this.crouch && (vlen(this.velocity) > autocvar_sv_maxspeed * 0.6) && this.deadflag == DEAD_NO && time < this.lastground + 0.2)
-       {
-               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_fraction == 1)
-                               dprint("nohit\n");
-                       else
-                               dprint(ftos(trace_dphitq3surfaceflags), "\n");
-                       */
-                       if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS))
-                       {
-                               if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
-                                       GlobalSound(this, GS_STEP_METAL, CH_PLAYER, VOICETYPE_PLAYERSOUND);
-                               else
-                                       GlobalSound(this, GS_STEP, CH_PLAYER, VOICETYPE_PLAYERSOUND);
-                       }
-               }
-       }
-}
-
 void DrownPlayer(entity this)
 {
        if(this.deadflag != DEAD_NO)
@@ -2622,7 +2594,6 @@ void PlayerPostThink ()
 
        if(IS_PLAYER(self)) {
                DrownPlayer(self);
-               Player_Footsteps(self);
                CheckRules_Player();
                UpdateChatBubble();
                if (self.impulse)