From d611f37d63254ae205c5e125e90f93e86de3e524 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 18 May 2020 19:38:41 +1000 Subject: [PATCH] Allow deactivating trigger_relay_if, trigger_relay_teamcheck and trigger_disablerelay, also fix trigger_disablerelay functionality --- qcsrc/common/mapobjects/trigger/disablerelay.qc | 13 +++++++++---- qcsrc/common/mapobjects/trigger/relay_if.qc | 5 +++++ qcsrc/common/mapobjects/trigger/relay_teamcheck.qc | 5 +++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/qcsrc/common/mapobjects/trigger/disablerelay.qc b/qcsrc/common/mapobjects/trigger/disablerelay.qc index eee61c993..dde1a77c7 100644 --- a/qcsrc/common/mapobjects/trigger/disablerelay.qc +++ b/qcsrc/common/mapobjects/trigger/disablerelay.qc @@ -2,18 +2,21 @@ #ifdef SVQC void trigger_disablerelay_use(entity this, entity actor, entity trigger) { + if(this.active != ACTIVE_ACTIVE) + return; + int a = 0, b = 0; for(entity e = NULL; (e = find(e, targetname, this.target)); ) { - if(e.use == SUB_UseTargets) + if(e.active == ACTIVE_ACTIVE) { - e.use = SUB_DontUseTargets; + e.active = ACTIVE_NOT; ++a; } - else if(e.use == SUB_DontUseTargets) + else if(e.active == ACTIVE_NOT) { - e.use = SUB_UseTargets; + e.active = ACTIVE_ACTIVE; ++b; } } @@ -24,6 +27,8 @@ void trigger_disablerelay_use(entity this, entity actor, entity trigger) spawnfunc(trigger_disablerelay) { + this.reset = spawnfunc_trigger_disablerelay; // this spawnfunc resets fully + this.active = ACTIVE_ACTIVE; this.use = trigger_disablerelay_use; } #endif diff --git a/qcsrc/common/mapobjects/trigger/relay_if.qc b/qcsrc/common/mapobjects/trigger/relay_if.qc index 9adcd666e..7586bd338 100644 --- a/qcsrc/common/mapobjects/trigger/relay_if.qc +++ b/qcsrc/common/mapobjects/trigger/relay_if.qc @@ -2,6 +2,9 @@ #ifdef SVQC void trigger_relay_if_use(entity this, entity actor, entity trigger) { + if(this.active != ACTIVE_ACTIVE) + return; + int n = this.count; // TODO make this generic AND faster than nextent()ing through all, if somehow possible @@ -15,6 +18,8 @@ void trigger_relay_if_use(entity this, entity actor, entity trigger) spawnfunc(trigger_relay_if) { + this.reset = spawnfunc_trigger_relay_if; // this spawnfunc resets fully + this.active = ACTIVE_ACTIVE; this.use = trigger_relay_if_use; } #endif diff --git a/qcsrc/common/mapobjects/trigger/relay_teamcheck.qc b/qcsrc/common/mapobjects/trigger/relay_teamcheck.qc index bf03b1542..5291f5290 100644 --- a/qcsrc/common/mapobjects/trigger/relay_teamcheck.qc +++ b/qcsrc/common/mapobjects/trigger/relay_teamcheck.qc @@ -2,6 +2,9 @@ #ifdef SVQC void trigger_relay_teamcheck_use(entity this, entity actor, entity trigger) { + if(this.active != ACTIVE_ACTIVE) + return; + if(actor.team) { if(this.spawnflags & RELAYTEAMCHECK_INVERT) @@ -24,11 +27,13 @@ void trigger_relay_teamcheck_use(entity this, entity actor, entity trigger) void trigger_relay_teamcheck_reset(entity this) { + this.active = ACTIVE_ACTIVE; this.team = this.team_saved; } spawnfunc(trigger_relay_teamcheck) { + this.active = ACTIVE_ACTIVE; this.team_saved = this.team; IL_PUSH(g_saved_team, this); this.use = trigger_relay_teamcheck_use; -- 2.39.2