]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/trigger/counter.qc
Fix (de)activation of func_button
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / counter.qc
1 #include "counter.qh"
2 #ifdef SVQC
3 void counter_use(entity this, entity actor, entity trigger)
4 {
5         this.count -= 1;
6         if (this.count < 0)
7                 return;
8
9         if (this.count == 0)
10         {
11                 if(IS_PLAYER(actor) && (this.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
12                         Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COMPLETED);
13
14                 this.enemy = actor;
15                 multi_trigger(this);
16         }
17         else
18         {
19                 if(IS_PLAYER(actor) && (this.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
20                 if(this.count >= 4)
21                         Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COUNTER);
22                 else
23                         Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COUNTER_FEWMORE, this.count);
24         }
25 }
26
27 void counter_reset(entity this)
28 {
29         this.count = this.cnt;
30         multi_reset(this);
31 }
32
33 /*QUAKED spawnfunc_trigger_counter (.5 .5 .5) ? nomessage
34 Acts as an intermediary for an action that takes multiple inputs.
35
36 If nomessage is not set, t will print "1 more.. " etc when triggered and "sequence complete" when finished.
37
38 After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself.
39 */
40 spawnfunc(trigger_counter)
41 {
42         this.wait = -1;
43         if (!this.count)
44                 this.count = 2;
45         this.cnt = this.count;
46
47         this.use = counter_use;
48         this.reset = counter_reset;
49 }
50 #endif