]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/rotating.qc
22f3dedea282926edb76fd55ec172d740aad02af
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / rotating.qc
1 #ifdef SVQC
2 void func_rotating_setactive(entity this, int astate)
3 {
4         if (astate == ACTIVE_TOGGLE)
5         {
6                 if(this.active == ACTIVE_ACTIVE)
7                         this.active = ACTIVE_NOT;
8                 else
9                         this.active = ACTIVE_ACTIVE;
10         }
11         else
12                 this.active = astate;
13
14         if(this.active  == ACTIVE_NOT)
15                 this.avelocity = '0 0 0';
16         else
17                 this.avelocity = this.pos1;
18 }
19
20 /*QUAKED spawnfunc_func_rotating (0 .5 .8) ? - - X_AXIS Y_AXIS
21 Brush model that spins in place on one axis (default Z).
22 speed   : speed to rotate (in degrees per second)
23 noise   : path/name of looping .wav file to play.
24 dmg     : Do this mutch dmg every .dmgtime intervall when blocked
25 dmgtime : See above.
26 */
27
28 spawnfunc(func_rotating)
29 {
30         if (this.noise != "")
31         {
32                 precache_sound(this.noise);
33                 ambientsound(this.origin, this.noise, VOL_BASE, ATTEN_IDLE);
34         }
35
36         this.active = ACTIVE_ACTIVE;
37         this.setactive = func_rotating_setactive;
38
39         if (!this.speed)
40                 this.speed = 100;
41         // FIXME: test if this turns the right way, then remove this comment (negate as needed)
42         if (this.spawnflags & 4) // X (untested)
43                 this.avelocity = '0 0 1' * this.speed;
44         // FIXME: test if this turns the right way, then remove this comment (negate as needed)
45         else if (this.spawnflags & 8) // Y (untested)
46                 this.avelocity = '1 0 0' * this.speed;
47         // FIXME: test if this turns the right way, then remove this comment (negate as needed)
48         else // Z
49                 this.avelocity = '0 1 0' * this.speed;
50
51         this.pos1 = this.avelocity;
52
53     if(this.dmg && (this.message == ""))
54         this.message = " was squished";
55     if(this.dmg && (this.message2 == ""))
56                 this.message2 = "was squished by";
57
58
59     if(this.dmg && (!this.dmgtime))
60         this.dmgtime = 0.25;
61
62     this.dmgtime2 = time;
63
64         if (!InitMovingBrushTrigger(this))
65                 return;
66         // no EF_LOWPRECISION here, as rounding angles is bad
67
68     setblocked(this, generic_plat_blocked);
69
70         // wait for targets to spawn
71         this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
72         SUB_THINK(this, SUB_NullThink); // for PushMove
73
74         // TODO make a reset function for this one
75 }
76 #endif