Merge branch 'master' into Mario/vaporizer_damage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / counter.qc
1 #ifdef SVQC
2 void counter_use()
3 {
4         self.count -= 1;
5         if (self.count < 0)
6                 return;
7
8         if (self.count == 0)
9         {
10                 if(IS_PLAYER(activator) && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
11                         Send_Notification(NOTIF_ONE, activator, MSG_CENTER, CENTER_SEQUENCE_COMPLETED);
12
13                 self.enemy = activator;
14                 multi_trigger ();
15         }
16         else
17         {
18                 if(IS_PLAYER(activator) && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
19                 if(self.count >= 4)
20                         Send_Notification(NOTIF_ONE, activator, MSG_CENTER, CENTER_SEQUENCE_COUNTER);
21                 else
22                         Send_Notification(NOTIF_ONE, activator, MSG_CENTER, CENTER_SEQUENCE_COUNTER_FEWMORE, self.count);
23         }
24 }
25
26 void counter_reset()
27 {
28         self.count = self.cnt;
29         multi_reset();
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 void spawnfunc_trigger_counter()
40 {
41         self.wait = -1;
42         if (!self.count)
43                 self.count = 2;
44         self.cnt = self.count;
45
46         self.use = counter_use;
47         self.reset = counter_reset;
48 }
49 #endif