+#include "rotating.qh"
#ifdef SVQC
-void func_rotating_setactive(float astate)
-{
+void func_rotating_setactive(entity this, int astate)
+{
if (astate == ACTIVE_TOGGLE)
{
- if(self.active == ACTIVE_ACTIVE)
- self.active = ACTIVE_NOT;
+ if(this.active == ACTIVE_ACTIVE)
+ this.active = ACTIVE_NOT;
else
- self.active = ACTIVE_ACTIVE;
+ this.active = ACTIVE_ACTIVE;
+ }
+ else
+ this.active = astate;
+
+ if(this.active == ACTIVE_NOT)
+ {
+ this.avelocity = '0 0 0';
+ stopsound(this, CH_AMBIENT_SINGLE);
}
else
- self.active = astate;
+ {
+ this.avelocity = this.pos1;
+ if(this.noise && this.noise != "")
+ {
+ _sound(this, CH_AMBIENT_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
+ }
+ }
+}
+
+void func_rotating_reset(entity this)
+{
+ // TODO: reset angles as well?
- if(self.active == ACTIVE_NOT)
- self.avelocity = '0 0 0';
+ if(this.spawnflags & FUNC_ROTATING_STARTOFF)
+ {
+ this.setactive(this, ACTIVE_NOT);
+ }
else
- self.avelocity = self.pos1;
+ {
+ this.setactive(this, ACTIVE_ACTIVE);
+ }
+}
+
+void func_rotating_init_for_player(entity this, entity player)
+{
+ if (this.noise && this.noise != "" && this.active == ACTIVE_ACTIVE && IS_REAL_CLIENT(player))
+ {
+ msg_entity = player;
+ soundto (MSG_ONE, this, CH_AMBIENT_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
+ }
}
/*QUAKED spawnfunc_func_rotating (0 .5 .8) ? - - X_AXIS Y_AXIS
dmgtime : See above.
*/
-void spawnfunc_func_rotating()
+spawnfunc(func_rotating)
{
- if (self.noise != "")
+ if (this.noise && this.noise != "")
{
- precache_sound(self.noise);
- ambientsound(self.origin, self.noise, VOL_BASE, ATTEN_IDLE);
+ precache_sound(this.noise);
}
- self.active = ACTIVE_ACTIVE;
- self.setactive = func_rotating_setactive;
-
- if (!self.speed)
- self.speed = 100;
- // FIXME: test if this turns the right way, then remove this comment (negate as needed)
- if (self.spawnflags & 4) // X (untested)
- self.avelocity = '0 0 1' * self.speed;
- // FIXME: test if this turns the right way, then remove this comment (negate as needed)
- else if (self.spawnflags & 8) // Y (untested)
- self.avelocity = '1 0 0' * self.speed;
- // FIXME: test if this turns the right way, then remove this comment (negate as needed)
+ this.setactive = func_rotating_setactive;
+
+ if (!this.speed)
+ this.speed = 100;
+ if (this.spawnflags & FUNC_ROTATING_XAXIS)
+ this.avelocity = '0 0 1' * this.speed;
+ else if (this.spawnflags & FUNC_ROTATING_YAXIS)
+ this.avelocity = '1 0 0' * this.speed;
else // Z
- self.avelocity = '0 1 0' * self.speed;
+ this.avelocity = '0 1 0' * this.speed;
- self.pos1 = self.avelocity;
+ this.pos1 = this.avelocity;
- if(self.dmg && (self.message == ""))
- self.message = " was squished";
- if(self.dmg && (self.message2 == ""))
- self.message2 = "was squished by";
+ if(this.dmg && (this.message == ""))
+ this.message = " was squished";
+ if(this.dmg && (this.message2 == ""))
+ this.message2 = "was squished by";
- if(self.dmg && (!self.dmgtime))
- self.dmgtime = 0.25;
+ if(this.dmg && (!this.dmgtime))
+ this.dmgtime = 0.25;
- self.dmgtime2 = time;
+ this.dmgtime2 = time;
- if (!InitMovingBrushTrigger())
+ if (!InitMovingBrushTrigger(this))
return;
// no EF_LOWPRECISION here, as rounding angles is bad
- self.blocked = generic_plat_blocked;
+ setblocked(this, generic_plat_blocked);
// wait for targets to spawn
- self.SUB_NEXTTHINK = self.SUB_LTIME + 999999999;
- self.SUB_THINK = SUB_NullThink; // for PushMove
+ this.nextthink = this.ltime + 999999999;
+ setthink(this, SUB_NullThink); // for PushMove
+
+ this.reset = func_rotating_reset;
+ this.reset(this);
- // TODO make a reset function for this one
+ // maybe send sound to new players
+ IL_PUSH(g_initforplayer, this);
+ this.init_for_player = func_rotating_init_for_player;
}
#endif