From c6fc61901baa4252cf1115acdcfba4197e3fc495 Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 8 Aug 2023 19:27:21 +0200 Subject: [PATCH] Don't activate status effects if their end time is <= current time, e.g. spawnshield if g_spawnshieldtime is 0 --- .../common/mutators/mutator/status_effects/status_effects.qc | 5 ++++- .../common/mutators/mutator/status_effects/status_effects.qh | 4 +++- qcsrc/server/items/items.qc | 3 +-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/qcsrc/common/mutators/mutator/status_effects/status_effects.qc b/qcsrc/common/mutators/mutator/status_effects/status_effects.qc index eb1ced075..2079182ac 100644 --- a/qcsrc/common/mutators/mutator/status_effects/status_effects.qc +++ b/qcsrc/common/mutators/mutator/status_effects/status_effects.qc @@ -25,8 +25,11 @@ float StatusEffects_gettime(StatusEffects this, entity actor) } #endif #ifdef SVQC -void StatusEffects_apply(StatusEffects this, entity actor, float eff_time, int eff_flags) +void StatusEffects_apply_timecheck(StatusEffects this, entity actor, float eff_time, int eff_flags, bool timecheck) { + if (!actor || (timecheck && eff_time <= time)) + return; + this.m_apply(this, actor, eff_time, eff_flags); } diff --git a/qcsrc/common/mutators/mutator/status_effects/status_effects.qh b/qcsrc/common/mutators/mutator/status_effects/status_effects.qh index f7795094c..9aa50d97f 100644 --- a/qcsrc/common/mutators/mutator/status_effects/status_effects.qh +++ b/qcsrc/common/mutators/mutator/status_effects/status_effects.qh @@ -190,7 +190,9 @@ float StatusEffects_gettime(StatusEffects this, entity actor); #endif #ifdef SVQC // call when applying the effect to an entity -void StatusEffects_apply(StatusEffects this, entity actor, float eff_time, int eff_flags); +void StatusEffects_apply_timecheck(StatusEffects this, entity actor, float eff_time, int eff_flags, bool timecheck); +#define StatusEffects_apply(this, actor, eff_time, eff_flags) StatusEffects_apply_timecheck(this, actor, eff_time, eff_flags, true) +#define StatusEffects_apply_notimecheck(this, actor, eff_time, eff_flags) StatusEffects_apply_timecheck(this, actor, eff_time, eff_flags, false) // copies all the status effect fields to the specified storage entity // does not perform an update diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index ed8ba9a52..434e5a8f0 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -1742,7 +1742,7 @@ float GiveItems(entity e, float beginarg, float endarg) if(!StatusEffects_active(STATUSEFFECT_Superweapons, e)) { if(!g_weaponarena && (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS)) - StatusEffects_apply(STATUSEFFECT_Superweapons, e, autocvar_g_balance_superweapons_time, 0); + StatusEffects_apply_notimecheck(STATUSEFFECT_Superweapons, e, autocvar_g_balance_superweapons_time, 0); } if(e.statuseffects) @@ -1754,7 +1754,6 @@ float GiveItems(entity e, float beginarg, float endarg) else e.statuseffects.statuseffect_time[it.m_id] += time; }); - StatusEffects_update(e); } -- 2.39.2