From fca0b262506051bfd8d28547a7e9b54e43d9b18d Mon Sep 17 00:00:00 2001 From: Freddy Date: Wed, 30 Aug 2017 23:28:20 +0200 Subject: [PATCH] Add spawnflag that enables buttons to not accumulate damage --- qcsrc/common/triggers/func/button.qc | 19 +++++++++++++++---- qcsrc/common/triggers/func/button.qh | 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/qcsrc/common/triggers/func/button.qc b/qcsrc/common/triggers/func/button.qc index 8ded50d16..ddd62ae4e 100644 --- a/qcsrc/common/triggers/func/button.qc +++ b/qcsrc/common/triggers/func/button.qc @@ -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); + } } } diff --git a/qcsrc/common/triggers/func/button.qh b/qcsrc/common/triggers/func/button.qh index 6f70f09be..a7e0e8a26 100644 --- a/qcsrc/common/triggers/func/button.qh +++ b/qcsrc/common/triggers/func/button.qh @@ -1 +1,3 @@ #pragma once + +#define BUTTON_DONTACCUMULATEDMG 128 -- 2.39.2