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