3 const int FUNC_ROTATING_STARTOFF = BIT(4);
5 void func_rotating_setactive(entity this, int astate)
7 if (astate == ACTIVE_TOGGLE)
9 if(this.active == ACTIVE_ACTIVE)
10 this.active = ACTIVE_NOT;
12 this.active = ACTIVE_ACTIVE;
17 if(this.active == ACTIVE_NOT)
18 this.avelocity = '0 0 0';
20 this.avelocity = this.pos1;
23 void func_rotating_reset(entity this)
25 // TODO: reset angles as well?
27 if(this.spawnflags & FUNC_ROTATING_STARTOFF)
29 this.avelocity = '0 0 0';
30 this.active = ACTIVE_NOT;
34 this.avelocity = this.pos1;
35 this.active = ACTIVE_ACTIVE;
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
47 spawnfunc(func_rotating)
51 precache_sound(this.noise);
52 ambientsound(this.origin, this.noise, VOL_BASE, ATTEN_IDLE);
55 this.setactive = func_rotating_setactive;
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)
67 this.avelocity = '0 1 0' * this.speed;
69 this.pos1 = this.avelocity;
71 // do this after setting pos1, so we can safely reactivate the func_rotating
72 if(this.spawnflags & FUNC_ROTATING_STARTOFF)
74 this.avelocity = '0 0 0';
75 this.active = ACTIVE_NOT;
78 this.active = ACTIVE_ACTIVE;
80 if(this.dmg && (this.message == ""))
81 this.message = " was squished";
82 if(this.dmg && (this.message2 == ""))
83 this.message2 = "was squished by";
86 if(this.dmg && (!this.dmgtime))
91 if (!InitMovingBrushTrigger(this))
93 // no EF_LOWPRECISION here, as rounding angles is bad
95 setblocked(this, generic_plat_blocked);
97 // wait for targets to spawn
98 this.nextthink = this.ltime + 999999999;
99 setthink(this, SUB_NullThink); // for PushMove
101 this.reset = func_rotating_reset;