From 0e8f5d03035b36902a64bb1d7f974cdec17cc9f7 Mon Sep 17 00:00:00 2001 From: Samual Date: Sat, 1 Oct 2011 01:48:59 -0400 Subject: [PATCH] W_PlayStrengthSound(): Global function to play the strength sound for when a weapon is fired -- this allows for weapons (like shotgun) to call this statement on their own instead of necessarily when W_SetupShot needs to. 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 | 31 ++++++++++++++++--------------- qcsrc/server/w_shotgun.qc | 6 +++++- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index c843564e8..9aae26e6a 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -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 diff --git a/qcsrc/server/w_shotgun.qc b/qcsrc/server/w_shotgun.qc index b7709fdc5..4b4c32638 100644 --- a/qcsrc/server/w_shotgun.qc +++ b/qcsrc/server/w_shotgun.qc @@ -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 -- 2.39.2