]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move footsteps to the mutator system
authorMario <mario.mario@y7mail.com>
Thu, 6 Jun 2013 07:48:06 +0000 (17:48 +1000)
committerMario <mario.mario@y7mail.com>
Thu, 6 Jun 2013 07:48:06 +0000 (17:48 +1000)
qcsrc/server/cl_physics.qc
qcsrc/server/defs.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator_footsteps.qc [new file with mode: 0644]
qcsrc/server/mutators/mutator_jump_grunt.qc
qcsrc/server/mutators/mutators.qh
qcsrc/server/progs.src
qcsrc/server/sv_main.qc

index 3263d627f41ddd7123690887250f2f694ffe2bd3..3dd91dfb4b4e9239942e718213e4b1de4125e9be 100644 (file)
@@ -849,29 +849,6 @@ void SV_PlayerPhysics()
                self.angles_z = 0;
        }
 
-       if(self.flags & FL_ONGROUND)
-       if(IS_PLAYER(self)) // no fall sounds for observers thank you very much
-       if(self.wasFlying)
-       {
-               self.wasFlying = 0;
-
-               if(self.waterlevel < WATERLEVEL_SWIMMING)
-               if(time >= self.ladder_time)
-               if not(self.hook)
-               {
-                       self.nextstep = time + 0.3 + random() * 0.1;
-                       trace_dphitq3surfaceflags = 0;
-                       tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
-                       if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
-                       {
-                               if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
-                                       GlobalSound(globalsound_metalfall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
-                               else
-                                       GlobalSound(globalsound_fall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
-                       }
-               }
-       }
-
        if(IsFlying(self))
                self.wasFlying = 1;
 
index 74d4345b824529469b3855d185a249e14221ccd4..47e4ebe832ee2e41fb4eeb53199bcbb46e314059 100644 (file)
@@ -16,7 +16,7 @@ noref float require_spawnfunc_prefix; // if this float exists, only functions wi
 
 // Globals
 
-float g_cloaked, g_footsteps, g_grappling_hook, g_minstagib;
+float g_cloaked, g_grappling_hook, g_minstagib;
 float g_warmup_limit;
 float g_warmup_allguns;
 float g_warmup_allow_timeout;
@@ -226,9 +226,6 @@ float alreadychangedlevel;
 .float in_swamp;              // bool
 .entity swampslug;            // Uses this to release from swamp ("untouch" fix)
 
-// footstep interval
-.float nextstep;
-
 float blockSpectators; //if set, new or existing spectators or observers will be removed unless they become a player within g_maxplayers_spectator_blocktime seconds
 .float spectatortime; //point in time since the client is spectating or observing
 void checkSpectatorBlock();
index 46d0beeee6069cee890fd2768e9d085e520e2556..1b0fed0675349671bf0d867a52586dd34ccf5ff0 100644 (file)
@@ -925,6 +925,7 @@ void readlevelcvars(void)
        CHECK_MUTATOR_ADD("g_norecoil", mutator_norecoil, 1);
        CHECK_MUTATOR_ADD("g_multijump", mutator_multijump, 1);
        CHECK_MUTATOR_ADD("g_jump_grunt", mutator_jump_grunt, 1);
+       CHECK_MUTATOR_ADD("g_footsteps", mutator_footsteps, 1);
        CHECK_MUTATOR_ADD("g_sandbox", sandbox, 1);
        
        #undef CHECK_MUTATOR_ADD
@@ -955,7 +956,6 @@ void readlevelcvars(void)
        g_cloaked = cvar("g_cloaked");
     if(g_cts)
         g_cloaked = 1; // always enable cloak in CTS
-       g_footsteps = cvar("g_footsteps");
        g_grappling_hook = cvar("g_grappling_hook");
        g_jetpack = cvar("g_jetpack");
        sv_maxidle = cvar("sv_maxidle");
@@ -1336,12 +1336,6 @@ void precache()
             precache_playermodel(s);
     }
 
-    if (g_footsteps)
-    {
-        PrecacheGlobalSound((globalsound_step = "misc/footstep0 6"));
-        PrecacheGlobalSound((globalsound_metalstep = "misc/metalfootstep0 6"));
-    }
-
     // gore and miscellaneous sounds
     //precache_sound ("misc/h2ohit.wav");
     precache_model ("models/hook.md3");
diff --git a/qcsrc/server/mutators/mutator_footsteps.qc b/qcsrc/server/mutators/mutator_footsteps.qc
new file mode 100644 (file)
index 0000000..1538c3f
--- /dev/null
@@ -0,0 +1,87 @@
+// footstep interval
+.float nextstep;
+
+MUTATOR_HOOKFUNCTION(footsteps_PlayerPhysics)
+{
+       if(self.flags & FL_ONGROUND)
+       if(IS_PLAYER(self)) // no fall sounds for observers thank you very much
+       if(self.wasFlying)
+       {
+               self.wasFlying = 0;
+
+               if(self.waterlevel < WATERLEVEL_SWIMMING)
+               if(time >= self.ladder_time)
+               if not(self.hook)
+               {
+                       self.nextstep = time + 0.3 + random() * 0.1;
+                       trace_dphitq3surfaceflags = 0;
+                       tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
+                       if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
+                       {
+                               if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
+                                       GlobalSound(globalsound_metalfall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+                               else
+                                       GlobalSound(globalsound_fall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+                       }
+               }
+       }
+       
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(footsteps_StartFrame)
+{
+       entity oldself = self;
+       
+       if(gameover)
+               return FALSE;
+       
+       for(self = world; (self = findfloat(self, damagedbycontents, TRUE)); )
+       {
+               float velocity_len = vlen(self.velocity);
+               // play stupid sounds
+               if (self.flags & FL_ONGROUND)
+               if (velocity_len > autocvar_sv_maxspeed * 0.6)
+               if (!self.deadflag)
+               if (time < self.lastground + 0.2)
+               {
+                       if((time > self.nextstep) || (time < (self.nextstep - 10.0)))
+                       {
+                               self.nextstep = time + 0.3 + random() * 0.1;
+                               trace_dphitq3surfaceflags = 0;
+                               tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
+                               if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
+                               {
+                                       if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
+                                               GlobalSound(globalsound_metalstep, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+                                       else
+                                               GlobalSound(globalsound_step, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+                               }
+                       }
+               }
+       }
+       self = oldself;
+       
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(footsteps_BuildMutatorsString)
+{
+       ret_string = strcat(ret_string, ":Footsteps");
+       return FALSE;
+}
+
+MUTATOR_DEFINITION(mutator_footsteps)
+{
+       MUTATOR_HOOK(PlayerPhysics, footsteps_PlayerPhysics, CBC_ORDER_ANY);
+       MUTATOR_HOOK(SV_StartFrame, footsteps_StartFrame, CBC_ORDER_ANY);
+       MUTATOR_HOOK(BuildMutatorsString, footsteps_BuildMutatorsString, CBC_ORDER_ANY);
+       
+       MUTATOR_ONADD
+       {
+               PrecacheGlobalSound((globalsound_step = "misc/footstep0 6"));
+        PrecacheGlobalSound((globalsound_metalstep = "misc/metalfootstep0 6"));
+       }
+
+       return FALSE;
+}
index b99d1c8444e786315da7677cfae874924197563c..e5cc74fc556c43e873019f90b0d7fc395947ddf3 100644 (file)
@@ -15,7 +15,7 @@ MUTATOR_HOOKFUNCTION(grunt_BuildMutatorsString)
 MUTATOR_DEFINITION(mutator_jump_grunt)
 {
        MUTATOR_HOOK(PlayerJump, grunt_PlayerJump, CBC_ORDER_ANY);
-       MUTATOR_HOOK(BuildMutatorsString, norecoil_BuildMutatorsString, CBC_ORDER_ANY);
+       MUTATOR_HOOK(BuildMutatorsString, grunt_BuildMutatorsString, CBC_ORDER_ANY);
 
        return FALSE;
 }
index 243cfd71c61e67d46d477c915ba32f4afac3fea8..edfd81d31df045dbf215a900baf8bdec8109dbb1 100644 (file)
@@ -28,5 +28,6 @@ MUTATOR_DECLARATION(mutator_random_gravity);
 MUTATOR_DECLARATION(mutator_norecoil);
 MUTATOR_DECLARATION(mutator_multijump);
 MUTATOR_DECLARATION(mutator_jump_grunt);
+MUTATOR_DECLARATION(mutator_footsteps);
 
 MUTATOR_DECLARATION(sandbox);
index 684ed03c9fda119233100d8822d10aebd445fdae..3f97fd36f30b6aa0e966168e3864ebbed8cbd831 100644 (file)
@@ -255,6 +255,7 @@ mutators/mutator_random_gravity.qc
 mutators/mutator_norecoil.qc
 mutators/mutator_multijump.qc
 mutators/mutator_jump_grunt.qc
+mutators/mutator_footsteps.qc
 
 ../warpzonelib/anglestransform.qc
 ../warpzonelib/mathlib.qc
index 538dcc62c624b173caa59b1ff53686a39dd50109..e22cba6bbf773ac645c04ac2e793f994d9e081af 100644 (file)
@@ -106,34 +106,6 @@ void CreatureFrame (void)
 
                        if(autocvar_g_maxspeed > 0 && velocity_len > autocvar_g_maxspeed)
                                Damage (self, world, world, 100000, DEATH_SHOOTING_STAR, self.origin, '0 0 0');
-                       // play stupid sounds
-                       if (g_footsteps)
-                       if (!gameover)
-                       if (self.flags & FL_ONGROUND)
-                       if (velocity_len > autocvar_sv_maxspeed * 0.6)
-                       if (!self.deadflag)
-                       if (time < self.lastground + 0.2)
-                       {
-                               if((time > self.nextstep) || (time < (self.nextstep - 10.0)))
-                               {
-                                       self.nextstep = time + 0.3 + random() * 0.1;
-                                       trace_dphitq3surfaceflags = 0;
-                                       tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
-                                       /*
-                                       if(trace_fraction == 1)
-                                               dprint("nohit\n");
-                                       else
-                                               dprint(ftos(trace_dphitq3surfaceflags), "\n");
-                                       */
-                                       if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
-                                       {
-                                               if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
-                                                       GlobalSound(globalsound_metalstep, CH_PLAYER, VOICETYPE_PLAYERSOUND);
-                                               else
-                                                       GlobalSound(globalsound_step, CH_PLAYER, VOICETYPE_PLAYERSOUND);
-                                       }
-                               }
-                       }
                }
                
         self.oldvelocity = self.velocity;