]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up trigger_counter's code so it doesn't abuse trigger_multiple's functions...
authorMario <mario@smbclan.net>
Wed, 31 Jan 2018 11:56:03 +0000 (21:56 +1000)
committerMario <mario@smbclan.net>
Wed, 31 Jan 2018 11:56:03 +0000 (21:56 +1000)
qcsrc/common/triggers/trigger/counter.qc

index 8246aed7c329a67c8eaa10cf3f4822186ba62cfc..16490fae52a481d65f2edf30a1612317807c5d13 100644 (file)
@@ -1,5 +1,7 @@
 #include "counter.qh"
 #ifdef SVQC
+void counter_reset(entity this);
+
 void counter_use(entity this, entity actor, entity trigger)
 {
        this.count -= 1;
@@ -8,38 +10,47 @@ void counter_use(entity this, entity actor, entity trigger)
 
        if (this.count == 0)
        {
-               if(IS_PLAYER(actor) && (this.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
+               if(IS_PLAYER(actor) && !(this.spawnflags & SPAWNFLAG_NOMESSAGE))
                        Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COMPLETED);
 
-               this.enemy = actor;
-               multi_trigger(this);
+               SUB_UseTargets(this, actor, trigger);
+
+               if(this.respawntime)
+               {
+                       setthink(this, counter_reset);
+                       this.nextthink = time + this.respawntime;
+               }
        }
        else
        {
-               if(IS_PLAYER(actor) && (this.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
-               if(this.count >= 4)
-                       Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COUNTER);
-               else
-                       Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COUNTER_FEWMORE, this.count);
+               if(IS_PLAYER(actor) && !(this.spawnflags & SPAWNFLAG_NOMESSAGE))
+               {
+                       if(this.count >= 4)
+                               Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COUNTER);
+                       else
+                               Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COUNTER_FEWMORE, this.count);
+               }
        }
 }
 
 void counter_reset(entity this)
 {
+       setthink(this, func_null);
+       this.nextthink = 0;
        this.count = this.cnt;
-       multi_reset(this);
 }
 
 /*QUAKED spawnfunc_trigger_counter (.5 .5 .5) ? nomessage
 Acts as an intermediary for an action that takes multiple inputs.
 
-If nomessage is not set, t will print "1 more.. " etc when triggered and "sequence complete" when finished.
+If nomessage is not set, it will print "1 more.. " etc when triggered and "sequence complete" when finished.
+
+If respawntime is set, it will re-enable itself after the time once the sequence has been completed
 
 After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself.
 */
 spawnfunc(trigger_counter)
 {
-       this.wait = -1;
        if (!this.count)
                this.count = 2;
        this.cnt = this.count;