]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
func_breakable: replace spawnflag magic numbers
authorFreddy <schro.sb@gmail.com>
Tue, 6 Mar 2018 18:57:21 +0000 (19:57 +0100)
committerFreddy <schro.sb@gmail.com>
Tue, 6 Mar 2018 18:57:21 +0000 (19:57 +0100)
qcsrc/common/triggers/func/breakable.qc
qcsrc/common/triggers/func/breakable.qh
qcsrc/common/triggers/func/button.qc
qcsrc/common/triggers/func/door.qc
qcsrc/common/triggers/spawnflags.qh
qcsrc/common/triggers/trigger/multi.qc

index ec71bc3fc3b044e10888e56a1e8a6d0d4c872c32..cd0b94377fd00db830796b092b4b5ac62d2dbe14 100644 (file)
 //   target = targets to trigger when broken
 //   health = amount of damage it can take
 //   spawnflags:
-//     1 = start disabled (needs to be triggered to activate)
-//     2 = indicate damage
-//     4 = don't take direct damage (needs to be triggered to 'explode', then triggered again to restore)
+//     BREAKABLE_START_DISABLED: needs to be triggered to activate
+//     BREAKABLE_INDICATE_DAMAGE: indicate damage
+//     BREAKABLE_NODAMAGE: don't take direct damage (needs to be triggered to 'explode', then triggered again to restore)
+//     NOSPLASH: don't take splash damage
 // notes:
 //   for mdl_dead to work, origin must be set (using a common/origin brush).
 //   Otherwise mdl_dead will be displayed at the map origin, and nobody would
@@ -81,7 +82,7 @@ void LaunchDebris (entity this, string debrisname, vector force)
 void func_breakable_colormod(entity this)
 {
        float h;
-       if (!(this.spawnflags & 2))
+       if (!(this.spawnflags & BREAKABLE_INDICATE_DAMAGE))
                return;
        h = this.health / this.max_health;
        if(h < 0.25)
@@ -136,7 +137,7 @@ void func_breakable_behave_destroyed(entity this)
        this.bot_attack = false;
        this.event_damage = func_null;
        this.state = 1;
-       if(this.spawnflags & 4)
+       if(this.spawnflags & BREAKABLE_NODAMAGE)
                this.use = func_null;
        func_breakable_colormod(this);
        if (this.noise1)
@@ -158,7 +159,7 @@ void func_breakable_behave_restore(entity this)
                WaypointSprite_UpdateMaxHealth(this.sprite, this.max_health);
                WaypointSprite_UpdateHealth(this.sprite, this.health);
        }
-       if(!(this.spawnflags & 4))
+       if(!(this.spawnflags & BREAKABLE_NODAMAGE))
        {
                this.takedamage = DAMAGE_AIM;
                if(!this.bot_attack)
@@ -166,7 +167,7 @@ void func_breakable_behave_restore(entity this)
                this.bot_attack = true;
                this.event_damage = func_breakable_damage;
        }
-       if(this.spawnflags & 4)
+       if(this.spawnflags & BREAKABLE_NODAMAGE)
                this.use = func_breakable_destroy; // don't need to set it usually, as .use isn't reset
        this.state = 0;
        //this.nextthink = 0; // cancel auto respawn
@@ -250,7 +251,7 @@ void func_breakable_damage(entity this, entity inflictor, entity attacker, float
 {
        if(this.state == 1)
                return;
-       if(this.spawnflags & DOOR_NOSPLASH)
+       if(this.spawnflags & NOSPLASH)
                if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
                        return;
        if(this.team)
@@ -290,7 +291,7 @@ void func_breakable_reset(entity this)
 {
        this.team = this.team_saved;
        func_breakable_look_restore(this);
-       if(this.spawnflags & 1)
+       if(this.spawnflags & BREAKABLE_START_DISABLED)
                func_breakable_behave_destroyed(this);
        else
                func_breakable_behave_restore(this);
@@ -330,12 +331,12 @@ spawnfunc(func_breakable)
        this.mdl = this.model;
        SetBrushEntityModel(this);
 
-       if(this.spawnflags & 4)
+       if(this.spawnflags & BREAKABLE_NODAMAGE)
                this.use = func_breakable_destroy;
        else
                this.use = func_breakable_restore;
 
-       if(this.spawnflags & 4)
+       if(this.spawnflags & BREAKABLE_NODAMAGE)
        {
                this.takedamage = DAMAGE_NO;
                this.event_damage = func_null;
index 761a2c7a98f350fe53629bc13f74e3874eb19673..c53793aa9449a522d1c196871dc608d3a3a46d40 100644 (file)
@@ -1,4 +1,5 @@
 #pragma once
+#include "../spawnflags.qh"
 
 #ifdef SVQC
 spawnfunc(func_breakable);
index 8e5e3530e3512759e9423ddac0975cbdc0ccdd7a..fd113205f0e49627d57306ea92f6457a1a96d592 100644 (file)
@@ -92,7 +92,7 @@ void button_touch(entity this, entity toucher)
 
 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(this.spawnflags & NOSPLASH)
                if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
                        return;
        if (this.spawnflags & BUTTON_DONTACCUMULATEDMG)
index 5b4fae04303818c4300d7c083aca2bd02985a047..d31c5a464b416f56ea268b87238963f67ea4ea14 100644 (file)
@@ -264,7 +264,7 @@ void door_use(entity this, entity actor, entity trigger)
 
 void door_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
 {
-       if(this.spawnflags & DOOR_NOSPLASH)
+       if(this.spawnflags & NOSPLASH)
                if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
                        return;
        this.health = this.health - damage;
index 051a24309d57c69f50367512ab3bd44a1cbcc629..8712e71107ee3b83307c6b5dd2166dc1c9d97899 100644 (file)
@@ -1,9 +1,17 @@
 #pragma once
 
+// generic usage
+const int NOSPLASH = BIT(8); // generic anti-splashdamage spawnflag
+
 // bobbing
 const int BOBBING_XAXIS = BIT(0);
 const int BOBBING_YAXIS = BIT(1);
 
+// breakable
+const int BREAKABLE_START_DISABLED = BIT(0);
+const int BREAKABLE_INDICATE_DAMAGE = BIT(1);
+const int BREAKABLE_NODAMAGE = BIT(2);
+
 // button
 const int BUTTON_DONTACCUMULATEDMG = BIT(7);
 
@@ -14,8 +22,6 @@ const int SPAWNFLAGS_GOLD_KEY = BIT(3); // Quake 1 compat, can only be used with
 const int SPAWNFLAGS_SILVER_KEY = BIT(4); // Quake 1 compat, can only be used with func_door!
 const int DOOR_TOGGLE = BIT(5);
 
-const int DOOR_NOSPLASH = BIT(8); // generic anti-splashdamage spawnflag
-
 const int DOOR_NONSOLID = BIT(10);
 const int DOOR_CRUSH = BIT(11); // can't use PLAT_CRUSH cause that is the same as DOOR_DONT_LINK
 
index 24b7d5f2acc11419f32f0340462675f9d7fa2a05..96ab915632dac4d6b4cd9cc8e1324fab0833cce6 100644 (file)
@@ -101,7 +101,7 @@ void multi_eventdamage(entity this, entity inflictor, entity attacker, float dam
 {
        if(!this.takedamage)
                return;
-       if(this.spawnflags & DOOR_NOSPLASH)
+       if(this.spawnflags & NOSPLASH)
                if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
                        return;
        if(this.team)