From 81323b9fcb2819407b31451453e3651b9675f520 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 31 May 2021 09:59:44 +1000 Subject: [PATCH] Apply strength sound and buff shield stats to the entity directly rather than player state (they can affect non-player entities) --- qcsrc/common/mutators/mutator/buffs/sv_buffs.qc | 7 +++---- qcsrc/common/mutators/mutator/powerups/sv_powerups.qc | 9 ++++----- qcsrc/server/client.qh | 3 --- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 7bc6cd7128..c2eb01618d 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -208,7 +208,7 @@ void buff_Touch(entity this, entity toucher) || (STAT(FROZEN, toucher)) || (toucher.vehicle) || (!this.buffdef) // TODO: error out or maybe reset type if this occurs? - || (time < PS(toucher).buff_shield) + || (time < toucher.buff_shield) ) { // can't touch this @@ -527,8 +527,7 @@ METHOD(Buff, m_remove, void(StatusEffects this, entity actor, int removal_type)) } else if(removal_type == STATUSEFFECT_REMOVE_NORMAL && !IS_INDEPENDENT_PLAYER(actor)) Send_Notification(NOTIF_ALL_EXCEPT, actor, MSG_INFO, INFO_ITEM_BUFF_LOST, actor.netname, buffid); - entity store = IS_PLAYER(actor) ? PS(actor) : actor; - store.buff_shield = time + max(0, autocvar_g_buffs_pickup_delay); // always put in a delay, even if small + actor.buff_shield = time + max(0, autocvar_g_buffs_pickup_delay); // always put in a delay, even if small } if(IS_PLAYER(actor)) actor.effects &= ~EF_NOSHADOW; @@ -804,7 +803,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerUseKey, CBC_ORDER_FIRST) Send_Notification(NOTIF_ALL_EXCEPT, player, MSG_INFO, INFO_ITEM_BUFF_LOST, player.netname, buffid); buff_RemoveAll(player, STATUSEFFECT_REMOVE_NORMAL); - PS(player).buff_shield = time + max(0, autocvar_g_buffs_pickup_delay); + player.buff_shield = time + max(0, autocvar_g_buffs_pickup_delay); sound(player, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM); return true; } diff --git a/qcsrc/common/mutators/mutator/powerups/sv_powerups.qc b/qcsrc/common/mutators/mutator/powerups/sv_powerups.qc index e727d493f8..c4b79eb9c2 100644 --- a/qcsrc/common/mutators/mutator/powerups/sv_powerups.qc +++ b/qcsrc/common/mutators/mutator/powerups/sv_powerups.qc @@ -3,16 +3,15 @@ MUTATOR_HOOKFUNCTION(powerups, W_PlayStrengthSound) { entity player = M_ARGV(0, entity); - entity store = IS_PLAYER(player) ? PS(player) : player; // because non-player entities can fire weapons if(StatusEffects_active(STATUSEFFECT_Strength, player) - && ((time > store.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) // prevent insane sound spam - || (time > store.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold))) + && ((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, SND_STRENGTH_FIRE, VOL_BASE, ATTEN_NORM); - store.prevstrengthsound = time; + player.prevstrengthsound = time; } - store.prevstrengthsoundattempt = time; + player.prevstrengthsoundattempt = time; } MUTATOR_HOOKFUNCTION(powerups, LogDeath_AppendItemCodes) diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 31d65f9486..3199d155a9 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -275,9 +275,6 @@ 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); - ATTRIB(Player, buff_shield, float, this.buff_shield); INIT(Player) { this.classname = STR_PLAYER; -- 2.39.2