From: Freddy Date: Thu, 15 Mar 2018 22:57:03 +0000 (+0100) Subject: trigger_multi: replace magic numbers, minor cleanup X-Git-Tag: xonotic-v0.8.5~2176^2~9 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=53a55d6c8f5dd9d6383f9bf996c5ce26e8b51759;p=xonotic%2Fxonotic-data.pk3dir.git trigger_multi: replace magic numbers, minor cleanup --- diff --git a/qcsrc/common/triggers/spawnflags.qh b/qcsrc/common/triggers/spawnflags.qh index 06040f035..44d129d4e 100644 --- a/qcsrc/common/triggers/spawnflags.qh +++ b/qcsrc/common/triggers/spawnflags.qh @@ -2,9 +2,11 @@ // generic usage const int START_ENABLED = BIT(0); +const int ALL_ENTITIES = BIT(1); const int ON_MAPLOAD = BIT(1); const int INVERT_TEAMS = BIT(2); const int NOSPLASH = BIT(8); // generic anti-splashdamage spawnflag +const int ONLY_PLAYERS = BIT(14); // triggers const int SPAWNFLAG_NOMESSAGE = BIT(0); diff --git a/qcsrc/common/triggers/trigger/multi.qc b/qcsrc/common/triggers/trigger/multi.qc index 96ab91563..accfbe8ac 100644 --- a/qcsrc/common/triggers/trigger/multi.qc +++ b/qcsrc/common/triggers/trigger/multi.qc @@ -24,10 +24,12 @@ void multi_trigger(entity this) return; // allready been triggered } - if(this.spawnflags & 16384) - if(!IS_PLAYER(this.enemy)) + if(this.spawnflags & ONLY_PLAYERS && !IS_PLAYER(this.enemy)) + { return; // only players + } + // TODO: restructure this so that trigger_secret is more independent if (this.classname == "trigger_secret") { if (!IS_PLAYER(this.enemy)) @@ -37,9 +39,11 @@ void multi_trigger(entity this) } if (this.noise) + { _sound (this.enemy, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM); + } -// don't trigger again until reset + // don't trigger again until reset this.takedamage = DAMAGE_NO; SUB_UseTargets(this, this.enemy, this.goalentity); @@ -69,15 +73,20 @@ void multi_use(entity this, entity actor, entity trigger) void multi_touch(entity this, entity toucher) { - if(!(this.spawnflags & 2)) - if(!toucher.iscreature) - return; + if(!(this.spawnflags & ALL_ENTITIES) && !toucher.iscreature) + { + return; + } if(this.team) - if(((this.spawnflags & 4) == 0) == (this.team != toucher.team)) + { + if(((this.spawnflags & INVERT_TEAMS) == 0) == (this.team != toucher.team)) + { return; + } + } -// if the trigger has an angles field, check player's facing direction + // if the trigger has an angles field, check player's facing direction if (this.movedir != '0 0 0') { makevectors (toucher.angles); @@ -87,8 +96,12 @@ void multi_touch(entity this, entity toucher) // if the trigger has pressed keys, check that the player is pressing those keys if(this.pressedkeys && IS_PLAYER(toucher)) // only for players - if(!(CS(toucher).pressedkeys & this.pressedkeys)) - return; + { + if(!(CS(toucher).pressedkeys & this.pressedkeys)) + { + return; + } + } EXACTTRIGGER_TOUCH(this, toucher); @@ -105,7 +118,7 @@ void multi_eventdamage(entity this, entity inflictor, entity attacker, float dam if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH)) return; if(this.team) - if(((this.spawnflags & 4) == 0) == (this.team != attacker.team)) + if(((this.spawnflags & INVERT_TEAMS) == 0) == (this.team != attacker.team)) return; this.health = this.health - damage; if (this.health <= 0)