X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftrigger%2Fmultivibrator.qc;h=932fda13ca94a5984f9e4d286848430147575158;hb=7ea9095eda4f4d279e9703c9c5c770e905baa543;hp=a50f62b7abd699f207746792a1693f7a07dd9c26;hpb=2a38620bbb43f7b62bbd93e8c22b6abbe627ca86;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/trigger/multivibrator.qc b/qcsrc/common/triggers/trigger/multivibrator.qc index a50f62b7a..932fda13c 100644 --- a/qcsrc/common/triggers/trigger/multivibrator.qc +++ b/qcsrc/common/triggers/trigger/multivibrator.qc @@ -1,28 +1,34 @@ +#include "multivibrator.qh" #ifdef SVQC -void multivibrator_send() -{SELFPARAM(); +void multivibrator_send(entity this) +{ float newstate; float cyclestart; - cyclestart = floor((time + self.phase) / (self.wait + self.respawntime)) * (self.wait + self.respawntime) - self.phase; + cyclestart = floor((time + this.phase) / (this.wait + this.respawntime)) * (this.wait + this.respawntime) - this.phase; - newstate = (time < cyclestart + self.wait); + newstate = (time < cyclestart + this.wait); - if(self.state != newstate) - SUB_UseTargets(self, self, NULL); - self.state = newstate; + if(this.state != newstate) + SUB_UseTargets(this, this, NULL); + this.state = newstate; - if(self.state) - self.nextthink = cyclestart + self.wait + 0.01; + if(this.state) + this.nextthink = cyclestart + this.wait + 0.01; else - self.nextthink = cyclestart + self.wait + self.respawntime + 0.01; + this.nextthink = cyclestart + this.wait + this.respawntime + 0.01; +} + +void multivibrator_send_think(entity this) +{ + multivibrator_send(this); } void multivibrator_toggle(entity this, entity actor, entity trigger) { if(this.nextthink == 0) { - WITHSELF(this, multivibrator_send()); + multivibrator_send(this); } else { @@ -35,15 +41,15 @@ void multivibrator_toggle(entity this, entity actor, entity trigger) } } -void multivibrator_reset() -{SELFPARAM(); - if(!(self.spawnflags & 1)) - self.nextthink = 0; // wait for a trigger event +void multivibrator_reset(entity this) +{ + if(!(this.spawnflags & START_ENABLED)) + this.nextthink = 0; // wait for a trigger event else - self.nextthink = max(1, time); + this.nextthink = max(1, time); } -/*QUAKED trigger_multivibrator (.5 .5 .5) (-8 -8 -8) (8 8 8) START_ON +/*QUAKED trigger_multivibrator (.5 .5 .5) (-8 -8 -8) (8 8 8) START_ENABLED "Multivibrator" trigger gate... repeatedly sends trigger events. When triggered, turns on or off. -------- KEYS -------- target: trigger all entities with this targetname when it goes off @@ -52,21 +58,21 @@ phase: offset of the timing wait: "on" cycle time (default: 1) respawntime: "off" cycle time (default: same as wait) -------- SPAWNFLAGS -------- -START_ON: assume it is already turned on (when targeted) +START_ENABLED: assume it is already turned on (when targeted) */ spawnfunc(trigger_multivibrator) { - if(!self.wait) - self.wait = 1; - if(!self.respawntime) - self.respawntime = self.wait; + if(!this.wait) + this.wait = 1; + if(!this.respawntime) + this.respawntime = this.wait; - self.state = 0; - self.use = multivibrator_toggle; - self.think = multivibrator_send; - self.nextthink = max(1, time); + this.state = 0; + this.use = multivibrator_toggle; + setthink(this, multivibrator_send_think); + this.nextthink = max(1, time); IFTARGETED - multivibrator_reset(); + multivibrator_reset(this); } #endif