Merge branch 'DefaultUser/func_button_dont_accumulate_dmg' into 'master'
authorMario <zacjardine@y7mail.com>
Sat, 25 Nov 2017 01:22:01 +0000 (01:22 +0000)
committerMario <zacjardine@y7mail.com>
Sat, 25 Nov 2017 01:22:01 +0000 (01:22 +0000)
Add spawnflag that enables buttons to not accumulate damage

See merge request xonotic/xonotic-data.pk3dir!481

qcsrc/common/triggers/func/button.qc
qcsrc/common/triggers/func/button.qh

index 8ded50d..ddd62ae 100644 (file)
@@ -94,11 +94,22 @@ void button_damage(entity this, entity inflictor, entity attacker, float damage,
        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)
        {
-               this.enemy = attacker;
-               button_fire(this);
+               if (this.health <= damage)
+               {
+                       this.enemy = attacker;
+                       button_fire(this);
+               }
+       }
+       else
+       {
+               this.health = this.health - damage;
+               if (this.health <= 0)
+               {
+                       this.enemy = attacker;
+                       button_fire(this);
+               }
        }
 }
 
index 6f70f09..75a6006 100644 (file)
@@ -1 +1,3 @@
 #pragma once
+
+const int BUTTON_DONTACCUMULATEDMG = 128;