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