]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/func/button.qc
Merge branch 'master' into Lyberta/RandomItems
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / button.qc
index 8424776ff0645a1c39ccfda635d81d05ba24d9c0..8ded50d16b2da0d88a35c68eb333006786a15636 100644 (file)
@@ -1,3 +1,4 @@
+#include "button.qh"
 #ifdef SVQC
 // button and multiple button
 
@@ -7,8 +8,11 @@ void button_return(entity this);
 void button_wait(entity this)
 {
        this.state = STATE_TOP;
-       this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
-       SUB_THINK(this, button_return);
+       if(this.wait >= 0)
+       {
+               this.nextthink = this.ltime + this.wait;
+               setthink(this, button_return);
+       }
        SUB_UseTargets(this, this.enemy, NULL);
        this.frame = 1;                 // use alternate textures
 }
@@ -28,7 +32,7 @@ void button_return(entity this)
 }
 
 
-void button_blocked()
+void button_blocked(entity this, entity blocker)
 {
        // do nothing, just don't come all the way back out
 }
@@ -55,6 +59,9 @@ void button_reset(entity this)
        setorigin(this, this.pos1);
        this.frame = 0;                 // use normal textures
        this.state = STATE_BOTTOM;
+       this.velocity = '0 0 0';
+       setthink(this, func_null);
+       this.nextthink = 0;
        if (this.health)
                this.takedamage = DAMAGE_YES;   // can be shot again
 }
@@ -65,20 +72,20 @@ void button_use(entity this, entity actor, entity trigger)
                return;
 
        this.enemy = actor;
-       WITHSELF(this, button_fire(this));
+       button_fire(this);
 }
 
-void button_touch(entity this)
+void button_touch(entity this, entity toucher)
 {
-       if (!other)
+       if (!toucher)
                return;
-       if (!other.iscreature)
+       if (!toucher.iscreature)
                return;
-       if(other.velocity * this.movedir < 0)
+       if(toucher.velocity * this.movedir < 0)
                return;
-       this.enemy = other;
-       if (other.owner)
-               this.enemy = other.owner;
+       this.enemy = toucher;
+       if (toucher.owner)
+               this.enemy = toucher.owner;
        button_fire (this);
 }
 
@@ -90,8 +97,8 @@ void button_damage(entity this, entity inflictor, entity attacker, float damage,
        this.health = this.health - damage;
        if (this.health <= 0)
        {
-               this.enemy = damage_attacker;
-               WITHSELF(this, button_fire(this));
+               this.enemy = attacker;
+               button_fire(this);
        }
 }
 
@@ -119,7 +126,7 @@ spawnfunc(func_button)
                return;
        this.effects |= EF_LOWPRECISION;
 
-       this.blocked = button_blocked;
+       setblocked(this, button_blocked);
        this.use = button_use;
 
 //     if (this.health == 0) // all buttons are now shootable
@@ -149,6 +156,8 @@ spawnfunc(func_button)
        this.pos2 = this.pos1 + this.movedir*(fabs(this.movedir*this.size) - this.lip);
     this.flags |= FL_NOTARGET;
 
+    this.reset = button_reset;
+
        button_reset(this);
 }
 #endif