]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
W_PlayStrengthSound(): Global function to play the strength sound for when a weapon...
authorSamual <samual@xonotic.org>
Sat, 1 Oct 2011 05:48:59 +0000 (01:48 -0400)
committerSamual <samual@xonotic.org>
Sat, 1 Oct 2011 05:48:59 +0000 (01:48 -0400)
Note, w_setupshot still calls it when it is given a sound argument.. otherwise however, it does not call it.

qcsrc/server/cl_weaponsystem.qc
qcsrc/server/w_shotgun.qc

index c843564e84aedbd18210d296e8fe5c694eb166cf..9aae26e6afb2c7aa10d4fc0449901bde797cce64 100644 (file)
@@ -127,11 +127,24 @@ vector w_shotorg;
 vector w_shotdir;
 vector w_shotend;
 
+.float prevstrengthsound;
+.float prevstrengthsoundattempt;
+void W_PlayStrengthSound(entity player) // void W_PlayStrengthSound
+{
+               if((!g_minstagib)
+                       && (player.items & IT_STRENGTH)
+                       && ((time > player.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) // prevent insane sound spam
+                       || (time > player.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold)))
+               {
+                       sound(player, CH_TRIGGER, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM);
+                       player.prevstrengthsound = time;
+               }
+               player.prevstrengthsoundattempt = time;
+}
+
 // this function calculates w_shotorg and w_shotdir based on the weapon model
 // offset, trueaim and antilag, and won't put w_shotorg inside a wall.
 // make sure you call makevectors first (FIXME?)
-.float prevstrengthsound;
-.float prevstrengthsoundattempt;
 void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector mi, vector ma, float antilag, float recoil, string snd, float chan, float maxdamage, float range)
 {
        float nudge = 1; // added to traceline target and subtracted from result
@@ -243,19 +256,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
        if (snd != "")
        {
                sound (ent, chan, snd, VOL_BASE, ATTN_NORM);
-
-               if(ent.items & IT_STRENGTH)
-               if(!g_minstagib)
-               if(
-                       (time > ent.prevstrengthsound + autocvar_sv_strengthsound_antispam_time)
-                       ||
-                       (time > ent.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold)
-               ) // prevent insane sound spam
-               {
-                       sound(ent, CH_TRIGGER, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM);
-                       ent.prevstrengthsound = time;
-               }
-               ent.prevstrengthsoundattempt = time;
+               W_PlayStrengthSound(ent);
        }
 
        // nudge w_shotend so a trace to w_shotend hits
index b7709fdc55ef6cba70c64f888a8baf35f871af3f..4b4c32638e7ad015fb3af32eb302aaedaa627f34 100644 (file)
@@ -54,7 +54,11 @@ void shotgun_meleethink (void)
        float i, f, swing, swing_factor, swing_damage, meleetime, is_player;
        vector targpos;
 
-       if(!self.cnt) { self.cnt = time; } // set start time of melee
+       if(!self.cnt) // set start time of melee
+       {
+               self.cnt = time; 
+               W_PlayStrengthSound(self.realowner);
+       }
 
        makevectors(self.realowner.v_angle); // update values for v_* vectors