From fd6ed106134f8d9ec0bd1c15ee687b49418e5de1 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 19 Jul 2017 00:09:26 +1000 Subject: [PATCH] Port prevstrengthsound and prevstrengthsoundattempt to PlayerState --- qcsrc/server/client.qh | 2 ++ qcsrc/server/weapons/common.qc | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 3218b4449..01b6ad9fd 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -154,6 +154,8 @@ CLASS(Player, Client) ATTRIB(Player, dual_weapons, vector, this.dual_weapons); // TODO: actually WepSet! ATTRIB(Player, itemkeys, int, this.itemkeys); ATTRIB(Player, ballistics_density, float, this.ballistics_density); + ATTRIB(Player, prevstrengthsound, float, this.prevstrengthsound); + ATTRIB(Player, prevstrengthsoundattempt, float, this.prevstrengthsoundattempt); INIT(Player) { this.classname = STR_PLAYER; diff --git a/qcsrc/server/weapons/common.qc b/qcsrc/server/weapons/common.qc index 6d1637550..bcec9df17 100644 --- a/qcsrc/server/weapons/common.qc +++ b/qcsrc/server/weapons/common.qc @@ -20,16 +20,18 @@ void W_GiveWeapon(entity e, int wep) } } -void W_PlayStrengthSound(entity player) // void W_PlayStrengthSound +void W_PlayStrengthSound(entity player) { + entity store = IS_PLAYER(player) ? PS(player) : player; // because non-player entities can fire, but can they have items? TODO + if((player.items & ITEM_Strength.m_itemid) - && ((time > player.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) // prevent insane sound spam - || (time > player.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold))) + && ((time > store.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) // prevent insane sound spam + || (time > store.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold))) { sound(player, CH_TRIGGER, SND_STRENGTH_FIRE, VOL_BASE, ATTEN_NORM); - player.prevstrengthsound = time; + store.prevstrengthsound = time; } - player.prevstrengthsoundattempt = time; + store.prevstrengthsoundattempt = time; } float W_CheckProjectileDamage(entity inflictor, entity projowner, int deathtype, float exception) -- 2.39.2