]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/rotating.qc
be2c7ed9c3d3828c972cfb592d764223f69c9d87
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / rotating.qc
1 #ifdef SVQC
2 void func_rotating_setactive(float astate)
3 {SELFPARAM();
4
5         if (astate == ACTIVE_TOGGLE)
6         {
7                 if(self.active == ACTIVE_ACTIVE)
8                         self.active = ACTIVE_NOT;
9                 else
10                         self.active = ACTIVE_ACTIVE;
11         }
12         else
13                 self.active = astate;
14
15         if(self.active  == ACTIVE_NOT)
16                 self.avelocity = '0 0 0';
17         else
18                 self.avelocity = self.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 (self.noise != "")
32         {
33                 precache_sound(self.noise);
34                 ambientsound(self.origin, self.noise, VOL_BASE, ATTEN_IDLE);
35         }
36
37         self.active = ACTIVE_ACTIVE;
38         self.setactive = func_rotating_setactive;
39
40         if (!self.speed)
41                 self.speed = 100;
42         // FIXME: test if this turns the right way, then remove this comment (negate as needed)
43         if (self.spawnflags & 4) // X (untested)
44                 self.avelocity = '0 0 1' * self.speed;
45         // FIXME: test if this turns the right way, then remove this comment (negate as needed)
46         else if (self.spawnflags & 8) // Y (untested)
47                 self.avelocity = '1 0 0' * self.speed;
48         // FIXME: test if this turns the right way, then remove this comment (negate as needed)
49         else // Z
50                 self.avelocity = '0 1 0' * self.speed;
51
52         self.pos1 = self.avelocity;
53
54     if(self.dmg && (self.message == ""))
55         self.message = " was squished";
56     if(self.dmg && (self.message2 == ""))
57                 self.message2 = "was squished by";
58
59
60     if(self.dmg && (!self.dmgtime))
61         self.dmgtime = 0.25;
62
63     self.dmgtime2 = time;
64
65         if (!InitMovingBrushTrigger())
66                 return;
67         // no EF_LOWPRECISION here, as rounding angles is bad
68
69     self.blocked = generic_plat_blocked;
70
71         // wait for targets to spawn
72         self.SUB_NEXTTHINK = self.SUB_LTIME + 999999999;
73         self.SUB_THINK = SUB_NullThink; // for PushMove
74
75         // TODO make a reset function for this one
76 }
77 #endif