From 2a8308e236e5471e8924d45a8797b693035785aa Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Tue, 19 Oct 2010 07:34:34 +0200 Subject: [PATCH] a simpler strength sound limiter --- defaultXonotic.cfg | 4 ++++ qcsrc/server/cl_weaponsystem.qc | 14 ++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 050a2915d..2a0a24b19 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -1968,3 +1968,7 @@ r_shadow_glossexact 1 // use fake light if map has no lightmaps r_fakelight 1 + +// strength sound settings +set sv_strengthsound_antispam_time 0.1 "minimum distance of strength sounds" +set sv_strengthsound_antispam_refire_threshold 0.04 "apply minimum distance only if refire of the gun is smaller than this" diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index 5131201b4..9e1eedae0 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -131,6 +131,7 @@ vector w_shotend; // 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 maxdamage, float range) { float nudge = 1; // added to traceline target and subtracted from result @@ -246,13 +247,18 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m sound (ent, CHAN_WEAPON, snd, VOL_BASE, ATTN_NORM); } - if (ent.items & IT_STRENGTH) - if (!g_minstagib) - if(ent.weapon != WEP_HLAC && ent.weapon != WEP_TUBA && ent.weapon != WEP_ELECTRO && ent.weapon != WEP_LASER || ((ent.weapon == WEP_ELECTRO && cvar("g_balance_electro_lightning") || ent.weapon == WEP_LASER || ent.weapon == WEP_TUBA || ent.weapon == WEP_HLAC) && ent.prevstrengthsound + cvar("sv_hitsound_antispam_time") * 2 < time)) // prevent insane sound spam + if(ent.items & IT_STRENGTH) + if(!g_minstagib) + if( + (time > ent.prevstrengthsound + cvar("sv_strengthsound_antispam_time")) + || + (time > ent.prevstrengthsoundattempt + cvar("sv_strengthsound_antispam_refire_threshold")) + ) // prevent insane sound spam { - sound (ent, CHAN_AUTO, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM); + sound(ent, CHAN_AUTO, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM); ent.prevstrengthsound = time; } + ent.prevstrengthsoundattempt = time; // nudge w_shotend so a trace to w_shotend hits w_shotend = w_shotend + normalize(w_shotend - w_shotorg) * nudge; -- 2.39.2