]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/func/button.qc
Move entity spawnflags to a common file
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / button.qc
index c450aaa1f2a7b5f429033b51fb05763c1c1ed733..8e5e3530e3512759e9423ddac0975cbdc0ccdd7a 100644 (file)
@@ -1,4 +1,5 @@
 #include "button.qh"
+#include "../spawnflags.qh"
 #ifdef SVQC
 // button and multiple button
 
@@ -8,8 +9,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 +60,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 +90,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);
+               }
        }
 }
 
@@ -106,11 +124,7 @@ When a button is touched, it moves some distance in the direction of it's angle,
 "wait"         override the default 1 second wait (-1 = never return)
 "lip"          override the default 4 pixel lip remaining at end of move
 "health"       if set, the button must be killed instead of touched. If set to -1, the button will fire on ANY attack, even damageless ones like the InstaGib laser
-"sounds"
-0) steam metal
-1) wooden clunk
-2) metallic click
-3) in-out
+"noise"                sound that is played when the button is activated
 */
 spawnfunc(func_button)
 {
@@ -150,6 +164,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