From 7f5fab6098796ae9549c212d928331f44418c8ea Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 2 Feb 2018 03:31:34 +1000 Subject: [PATCH] Fix trigger_delay not saving the activator and trigger, add a spawnflag to trigger_counter to make it activate at every step, not just when the sequence is completed, add a delay field to trigger_heal to control how quickly the player is healed --- qcsrc/common/triggers/trigger/counter.qc | 7 +++++- qcsrc/common/triggers/trigger/delay.qc | 13 ++++++++-- qcsrc/common/triggers/trigger/heal.qc | 31 ++++++++++++------------ qcsrc/common/triggers/triggers.qc | 5 ---- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/qcsrc/common/triggers/trigger/counter.qc b/qcsrc/common/triggers/trigger/counter.qc index 16490fae5..87c046b0d 100644 --- a/qcsrc/common/triggers/trigger/counter.qc +++ b/qcsrc/common/triggers/trigger/counter.qc @@ -8,12 +8,14 @@ void counter_use(entity this, entity actor, entity trigger) if (this.count < 0) return; + bool doactivate = (this.spawnflags & 4); + if (this.count == 0) { if(IS_PLAYER(actor) && !(this.spawnflags & SPAWNFLAG_NOMESSAGE)) Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COMPLETED); - SUB_UseTargets(this, actor, trigger); + doactivate = true; if(this.respawntime) { @@ -31,6 +33,9 @@ void counter_use(entity this, entity actor, entity trigger) Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COUNTER_FEWMORE, this.count); } } + + if(doactivate) + SUB_UseTargets(this, actor, trigger); } void counter_reset(entity this) diff --git a/qcsrc/common/triggers/trigger/delay.qc b/qcsrc/common/triggers/trigger/delay.qc index dc1a781f8..2cd4cfd13 100644 --- a/qcsrc/common/triggers/trigger/delay.qc +++ b/qcsrc/common/triggers/trigger/delay.qc @@ -1,13 +1,22 @@ #include "delay.qh" #ifdef SVQC +void delay_delayeduse(entity this) +{ + SUB_UseTargets(this, this.enemy, this.goalentity); + this.enemy = this.goalentity = NULL; +} + void delay_use(entity this, entity actor, entity trigger) { - setthink(this, SUB_UseTargets_self); - this.nextthink = time + this.wait; + this.enemy = actor; + this.goalentity = trigger; + setthink(this, delay_delayeduse); + this.nextthink = time + this.wait; } void delay_reset(entity this) { + this.enemy = this.goalentity = NULL; setthink(this, func_null); this.nextthink = 0; } diff --git a/qcsrc/common/triggers/trigger/heal.qc b/qcsrc/common/triggers/trigger/heal.qc index 1f63a5a53..61a65d8b5 100644 --- a/qcsrc/common/triggers/trigger/heal.qc +++ b/qcsrc/common/triggers/trigger/heal.qc @@ -16,7 +16,7 @@ void trigger_heal_touch(entity this, entity toucher) bool is_trigger = !boolean(!this.nottargeted && this.targetname != ""); if(is_trigger) EXACTTRIGGER_TOUCH(this, toucher); - toucher.triggerhealtime = time + 1; + toucher.triggerhealtime = time + this.delay; bool playthesound = (this.spawnflags & 4); if (toucher.health < this.max_health) @@ -37,31 +37,30 @@ void trigger_heal_use(entity this, entity actor, entity trigger) trigger_heal_touch(this, actor); } -spawnfunc(trigger_heal) +void trigger_heal_init(entity this) { this.active = ACTIVE_ACTIVE; - - EXACTTRIGGER_INIT; - settouch(this, trigger_heal_touch); - if (!this.health) + if(!this.delay) + this.delay = 1; + if(!this.health) this.health = 10; - if (!this.max_health) - this.max_health = 200; //Max health topoff for field + if(!this.max_health) + this.max_health = 200; // max health topoff for field if(this.noise == "") this.noise = "misc/mediumhealth.wav"; precache_sound(this.noise); } +spawnfunc(trigger_heal) +{ + EXACTTRIGGER_INIT; + settouch(this, trigger_heal_touch); + trigger_heal_init(this); +} + spawnfunc(target_heal) { - this.active = ACTIVE_ACTIVE; this.use = trigger_heal_use; - if (!this.health) - this.health = 10; - if (!this.max_health) - this.max_health = 200; //Max health topoff for field - if(this.noise == "") - this.noise = "misc/mediumhealth.wav"; - precache_sound(this.noise); + trigger_heal_init(this); } #endif diff --git a/qcsrc/common/triggers/triggers.qc b/qcsrc/common/triggers/triggers.qc index 2a76d80c4..f6cb013d9 100644 --- a/qcsrc/common/triggers/triggers.qc +++ b/qcsrc/common/triggers/triggers.qc @@ -293,8 +293,3 @@ void SUB_UseTargets_Ex(entity this, entity actor, entity trigger, bool preventRe void SUB_UseTargets(entity this, entity actor, entity trigger) { SUB_UseTargets_Ex(this, actor, trigger, false); } void SUB_UseTargets_PreventReuse(entity this, entity actor, entity trigger) { SUB_UseTargets_Ex(this, actor, trigger, true); } - -void SUB_UseTargets_self(entity this) -{ - SUB_UseTargets(this, NULL, NULL); -} -- 2.39.2