]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Don't activate status effects if their end time is <= current time, e.g. spawnshield...
authorterencehill <piuntn@gmail.com>
Tue, 8 Aug 2023 17:27:21 +0000 (19:27 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 8 Aug 2023 17:27:21 +0000 (19:27 +0200)
qcsrc/common/mutators/mutator/status_effects/status_effects.qc
qcsrc/common/mutators/mutator/status_effects/status_effects.qh
qcsrc/server/items/items.qc

index eb1ced075d17c3643e5b260044c05d21f7191c33..2079182ac3e9c3935ed9ddcb08e43e646cb7275b 100644 (file)
@@ -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);
 }
 
index f7795094cdb805648c6815fd9e4a353df5528e78..9aa50d97f777c557f1508c87dc91cb382d51ac14 100644 (file)
@@ -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
index ed8ba9a52e7dbe79a801f088dec2a5a3cc2c845b..434e5a8f04abfd578686b4798773d234d58e984e 100644 (file)
@@ -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);
        }