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