X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ffunc%2Fbutton.qc;h=5584f9ffa167bbb476fbd16ce6804e08ba3c836f;hp=0ed374a331255d1da8b94c0f857550095890400a;hb=42a9e3d7ece2c716e5cd6899e90841acb7fb891b;hpb=6be3fc1c5d51414554bb8f8f05dee5a0d12f7688 diff --git a/qcsrc/common/triggers/func/button.qc b/qcsrc/common/triggers/func/button.qc index 0ed374a33..5584f9ffa 100644 --- a/qcsrc/common/triggers/func/button.qc +++ b/qcsrc/common/triggers/func/button.qc @@ -1,25 +1,24 @@ #ifdef SVQC // button and multiple button -void() button_wait; -void() button_return; +void button_wait(entity this); +void button_return(entity this); -void button_wait() +void button_wait(entity this) { self.state = STATE_TOP; self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait; - self.SUB_THINK = button_return; - activator = self.enemy; - SUB_UseTargets(); + SUB_THINK(self, button_return); + SUB_UseTargets(self, self.enemy, NULL); self.frame = 1; // use alternate textures } -void button_done() +void button_done(entity this) { self.state = STATE_BOTTOM; } -void button_return() +void button_return(entity this) { self.state = STATE_DOWN; SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, button_done); @@ -36,7 +35,7 @@ void button_blocked() void button_fire() -{ +{SELFPARAM(); self.health = self.max_health; self.takedamage = DAMAGE_NO; // will be reset upon return @@ -44,32 +43,32 @@ void button_fire() return; if (self.noise != "") - sound (self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM); + _sound (self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM); self.state = STATE_UP; SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, button_wait); } -void button_reset() +void button_reset(entity this) { - self.health = self.max_health; - setorigin(self, self.pos1); - self.frame = 0; // use normal textures - self.state = STATE_BOTTOM; - if (self.health) - self.takedamage = DAMAGE_YES; // can be shot again + this.health = this.max_health; + setorigin(this, this.pos1); + this.frame = 0; // use normal textures + this.state = STATE_BOTTOM; + if (this.health) + this.takedamage = DAMAGE_YES; // can be shot again } -void button_use() +void button_use(entity this, entity actor, entity trigger) { - if(self.active != ACTIVE_ACTIVE) + if(this.active != ACTIVE_ACTIVE) return; - self.enemy = activator; - button_fire (); + this.enemy = actor; + WITHSELF(this, button_fire()); } -void button_touch() +void button_touch(entity this) { if (!other) return; @@ -83,16 +82,16 @@ void button_touch() button_fire (); } -void button_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) +void button_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) { - if(self.spawnflags & DOOR_NOSPLASH) + if(this.spawnflags & DOOR_NOSPLASH) if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH)) return; - self.health = self.health - damage; - if (self.health <= 0) + this.health = this.health - damage; + if (this.health <= 0) { - self.enemy = damage_attacker; - button_fire (); + this.enemy = damage_attacker; + WITHSELF(this, button_fire()); } } @@ -112,44 +111,44 @@ When a button is touched, it moves some distance in the direction of it's angle, 2) metallic click 3) in-out */ -void spawnfunc_func_button() +spawnfunc(func_button) { - SetMovedir (); + SetMovedir(this); - if (!InitMovingBrushTrigger()) + if (!InitMovingBrushTrigger(this)) return; - self.effects |= EF_LOWPRECISION; + this.effects |= EF_LOWPRECISION; - self.blocked = button_blocked; - self.use = button_use; + this.blocked = button_blocked; + this.use = button_use; -// if (self.health == 0) // all buttons are now shootable -// self.health = 10; - if (self.health) +// if (this.health == 0) // all buttons are now shootable +// this.health = 10; + if (this.health) { - self.max_health = self.health; - self.event_damage = button_damage; - self.takedamage = DAMAGE_YES; + this.max_health = this.health; + this.event_damage = button_damage; + this.takedamage = DAMAGE_YES; } else - self.touch = button_touch; + settouch(this, button_touch); - if (!self.speed) - self.speed = 40; - if (!self.wait) - self.wait = 1; - if (!self.lip) - self.lip = 4; + if (!this.speed) + this.speed = 40; + if (!this.wait) + this.wait = 1; + if (!this.lip) + this.lip = 4; - if(self.noise != "") - precache_sound(self.noise); + if(this.noise != "") + precache_sound(this.noise); - self.active = ACTIVE_ACTIVE; + this.active = ACTIVE_ACTIVE; - self.pos1 = self.origin; - self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip); - self.flags |= FL_NOTARGET; + this.pos1 = this.origin; + this.pos2 = this.pos1 + this.movedir*(fabs(this.movedir*this.size) - this.lip); + this.flags |= FL_NOTARGET; - button_reset(); + button_reset(this); } #endif