]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
a simpler strength sound limiter
authorRudolf Polzer <divverent@alientrap.org>
Tue, 19 Oct 2010 05:34:34 +0000 (07:34 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Tue, 19 Oct 2010 05:34:34 +0000 (07:34 +0200)
defaultXonotic.cfg
qcsrc/server/cl_weaponsystem.qc

index 050a2915df005d8183456c873e5d9adfb720ccc2..2a0a24b19202b74ac1a0fbde01820dffcb45084e 100644 (file)
@@ -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"
index 5131201b4fa8adf5166fbe792eb6c25d5e15e625..9e1eedae0339cac49b07111f5f2a04beee7ee49c 100644 (file)
@@ -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;