]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix trigger_delay not saving the activator and trigger, add a spawnflag to trigger_co...
authorMario <mario@smbclan.net>
Thu, 1 Feb 2018 17:31:34 +0000 (03:31 +1000)
committerMario <mario@smbclan.net>
Thu, 1 Feb 2018 17:31:34 +0000 (03:31 +1000)
qcsrc/common/triggers/trigger/counter.qc
qcsrc/common/triggers/trigger/delay.qc
qcsrc/common/triggers/trigger/heal.qc
qcsrc/common/triggers/triggers.qc

index 16490fae52a481d65f2edf30a1612317807c5d13..87c046b0dba724fc877ad318b9b95e1be69fb8e1 100644 (file)
@@ -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)
index dc1a781f81a0c81933fae9d47f63baf53506555a..2cd4cfd1338ac0809f3f9ff451a65ee3f5a59f8d 100644 (file)
@@ -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;
 }
index 1f63a5a5388fe8a4d38035bcb076d0ed156d3a7f..61a65d8b596ca3f12e735978659d5b8cc08c40c2 100644 (file)
@@ -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
index 2a76d80c41a7a7f41675d9a06826b2e236683d28..f6cb013d9e2df3d4ad8b4170ac8299148576a6c4 100644 (file)
@@ -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);
-}