From: Freddy Date: Tue, 6 Mar 2018 18:57:21 +0000 (+0100) Subject: func_breakable: replace spawnflag magic numbers X-Git-Tag: xonotic-v0.8.5~2176^2~41 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1d65ea6a7233ef415ac452ecdccdc65a0635a589;p=xonotic%2Fxonotic-data.pk3dir.git func_breakable: replace spawnflag magic numbers --- diff --git a/qcsrc/common/triggers/func/breakable.qc b/qcsrc/common/triggers/func/breakable.qc index ec71bc3fc..cd0b94377 100644 --- a/qcsrc/common/triggers/func/breakable.qc +++ b/qcsrc/common/triggers/func/breakable.qc @@ -34,9 +34,10 @@ // 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; diff --git a/qcsrc/common/triggers/func/breakable.qh b/qcsrc/common/triggers/func/breakable.qh index 761a2c7a9..c53793aa9 100644 --- a/qcsrc/common/triggers/func/breakable.qh +++ b/qcsrc/common/triggers/func/breakable.qh @@ -1,4 +1,5 @@ #pragma once +#include "../spawnflags.qh" #ifdef SVQC spawnfunc(func_breakable); diff --git a/qcsrc/common/triggers/func/button.qc b/qcsrc/common/triggers/func/button.qc index 8e5e3530e..fd113205f 100644 --- a/qcsrc/common/triggers/func/button.qc +++ b/qcsrc/common/triggers/func/button.qc @@ -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) diff --git a/qcsrc/common/triggers/func/door.qc b/qcsrc/common/triggers/func/door.qc index 5b4fae043..d31c5a464 100644 --- a/qcsrc/common/triggers/func/door.qc +++ b/qcsrc/common/triggers/func/door.qc @@ -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; diff --git a/qcsrc/common/triggers/spawnflags.qh b/qcsrc/common/triggers/spawnflags.qh index 051a24309..8712e7110 100644 --- a/qcsrc/common/triggers/spawnflags.qh +++ b/qcsrc/common/triggers/spawnflags.qh @@ -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 diff --git a/qcsrc/common/triggers/trigger/multi.qc b/qcsrc/common/triggers/trigger/multi.qc index 24b7d5f2a..96ab91563 100644 --- a/qcsrc/common/triggers/trigger/multi.qc +++ b/qcsrc/common/triggers/trigger/multi.qc @@ -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)