From: Mario Date: Mon, 28 Aug 2017 00:13:47 +0000 (+1000) Subject: Add a spawnflag to start func_rotating off, and add a basic reset function to func_ro... X-Git-Tag: xonotic-v0.8.5~2493 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=0ea2cba0b38927637a03233f36bcb00cc337268a;p=xonotic%2Fxonotic-data.pk3dir.git Add a spawnflag to start func_rotating off, and add a basic reset function to func_rotating --- diff --git a/qcsrc/common/triggers/func/rotating.qc b/qcsrc/common/triggers/func/rotating.qc index 9715c2545..6268dcfeb 100644 --- a/qcsrc/common/triggers/func/rotating.qc +++ b/qcsrc/common/triggers/func/rotating.qc @@ -1,5 +1,7 @@ #include "rotating.qh" #ifdef SVQC +const int FUNC_ROTATING_STARTOFF = BIT(4); + void func_rotating_setactive(entity this, int astate) { if (astate == ACTIVE_TOGGLE) @@ -18,6 +20,22 @@ void func_rotating_setactive(entity this, int astate) this.avelocity = this.pos1; } +void func_rotating_reset(entity this) +{ + // TODO: reset angles as well? + + if(this.spawnflags & FUNC_ROTATING_STARTOFF) + { + this.avelocity = '0 0 0'; + this.active = ACTIVE_NOT; + } + else + { + this.avelocity = this.pos1; + this.active = ACTIVE_ACTIVE; + } +} + /*QUAKED spawnfunc_func_rotating (0 .5 .8) ? - - X_AXIS Y_AXIS Brush model that spins in place on one axis (default Z). speed : speed to rotate (in degrees per second) @@ -34,16 +52,15 @@ spawnfunc(func_rotating) ambientsound(this.origin, this.noise, VOL_BASE, ATTEN_IDLE); } - this.active = ACTIVE_ACTIVE; this.setactive = func_rotating_setactive; if (!this.speed) this.speed = 100; // FIXME: test if this turns the right way, then remove this comment (negate as needed) - if (this.spawnflags & 4) // X (untested) + if (this.spawnflags & BIT(2)) // X (untested) this.avelocity = '0 0 1' * this.speed; // FIXME: test if this turns the right way, then remove this comment (negate as needed) - else if (this.spawnflags & 8) // Y (untested) + else if (this.spawnflags & BIT(3)) // Y (untested) this.avelocity = '1 0 0' * this.speed; // FIXME: test if this turns the right way, then remove this comment (negate as needed) else // Z @@ -51,6 +68,15 @@ spawnfunc(func_rotating) this.pos1 = this.avelocity; + // do this after setting pos1, so we can safely reactivate the func_rotating + if(this.spawnflags & FUNC_ROTATING_STARTOFF) + { + this.avelocity = '0 0 0'; + this.active = ACTIVE_NOT; + } + else + this.active = ACTIVE_ACTIVE; + if(this.dmg && (this.message == "")) this.message = " was squished"; if(this.dmg && (this.message2 == "")) @@ -72,6 +98,6 @@ spawnfunc(func_rotating) this.nextthink = this.ltime + 999999999; setthink(this, SUB_NullThink); // for PushMove - // TODO make a reset function for this one + this.reset = func_rotating_reset; } #endif