]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/func/button.qc
Merge branch 'master' into terencehill/min_spec_time
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / button.qc
index c450aaa1f2a7b5f429033b51fb05763c1c1ed733..c51c034f1681caef48773e01172325e19b7848e9 100644 (file)
@@ -8,8 +8,11 @@ void button_return(entity this);
 void button_wait(entity this)
 {
        this.state = STATE_TOP;
-       this.nextthink = this.ltime + this.wait;
-       setthink(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
 }
@@ -56,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
 }
@@ -83,16 +89,27 @@ void button_touch(entity this, entity toucher)
        button_fire (this);
 }
 
-void button_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+void button_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
 {
        if(this.spawnflags & DOOR_NOSPLASH)
                if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
                        return;
-       this.health = this.health - damage;
-       if (this.health <= 0)
+       if (this.spawnflags & BUTTON_DONTACCUMULATEDMG)
+       {
+               if (this.health <= damage)
+               {
+                       this.enemy = attacker;
+                       button_fire(this);
+               }
+       }
+       else
        {
-               this.enemy = damage_attacker;
-               button_fire(this);
+               this.health = this.health - damage;
+               if (this.health <= 0)
+               {
+                       this.enemy = attacker;
+                       button_fire(this);
+               }
        }
 }
 
@@ -150,6 +167,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