Merge branch 'master' into Mario/vaporizer_damage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / monoflop.qc
1 #ifdef SVQC
2 /*QUAKED spawnfunc_trigger_monoflop (.5 .5 .5) (-8 -8 -8) (8 8 8)
3 "Mono-flop" trigger gate... turns one trigger event into one "on" and one "off" event, separated by a delay of "wait"
4 */
5 void monoflop_use()
6 {
7         self.nextthink = time + self.wait;
8         self.enemy = activator;
9         if(self.state)
10                 return;
11         self.state = 1;
12         SUB_UseTargets();
13 }
14 void monoflop_fixed_use()
15 {
16         if(self.state)
17                 return;
18         self.nextthink = time + self.wait;
19         self.state = 1;
20         self.enemy = activator;
21         SUB_UseTargets();
22 }
23
24 void monoflop_think()
25 {
26         self.state = 0;
27         activator = self.enemy;
28         SUB_UseTargets();
29 }
30
31 void monoflop_reset()
32 {
33         self.state = 0;
34         self.nextthink = 0;
35 }
36
37 void spawnfunc_trigger_monoflop()
38 {
39         if(!self.wait)
40                 self.wait = 1;
41         if(self.spawnflags & 1)
42                 self.use = monoflop_fixed_use;
43         else
44                 self.use = monoflop_use;
45         self.think = monoflop_think;
46         self.state = 0;
47         self.reset = monoflop_reset;
48 }
49 #endif