]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/trigger/monoflop.qc
take3: format 903 files
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / monoflop.qc
1 #include "monoflop.qh"
2 #ifdef SVQC
3 /*QUAKED spawnfunc_trigger_monoflop (.5 .5 .5) (-8 -8 -8) (8 8 8)
4 "Mono-flop" trigger gate... turns one trigger event into one "on" and one "off" event, separated by a delay of "wait"
5 */
6 void monoflop_use(entity this, entity actor, entity trigger)
7 {
8         this.nextthink = time + this.wait;
9         this.enemy = actor;
10         if (this.state) {
11                 return;
12         }
13         this.state = 1;
14         SUB_UseTargets(this, actor, trigger);
15 }
16 void monoflop_fixed_use(entity this, entity actor, entity trigger)
17 {
18         if (this.state) {
19                 return;
20         }
21         this.nextthink = time + this.wait;
22         this.state = 1;
23         this.enemy = actor;
24         SUB_UseTargets(this, actor, trigger);
25 }
26
27 void monoflop_think(entity this)
28 {
29         this.state = 0;
30         SUB_UseTargets(this, this.enemy, NULL);
31 }
32
33 void monoflop_reset(entity this)
34 {
35         this.state = 0;
36         this.nextthink = 0;
37 }
38
39 spawnfunc(trigger_monoflop)
40 {
41         if (!this.wait) {
42                 this.wait = 1;
43         }
44         if (this.spawnflags & 1) {
45                 this.use = monoflop_fixed_use;
46         } else {
47                 this.use = monoflop_use;
48         }
49         setthink(this, monoflop_think);
50         this.state = 0;
51         this.reset = monoflop_reset;
52 }
53 #endif