]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
trigger_multi: replace magic numbers, minor cleanup
authorFreddy <schro.sb@gmail.com>
Thu, 15 Mar 2018 22:57:03 +0000 (23:57 +0100)
committerFreddy <schro.sb@gmail.com>
Thu, 15 Mar 2018 22:57:03 +0000 (23:57 +0100)
qcsrc/common/triggers/spawnflags.qh
qcsrc/common/triggers/trigger/multi.qc

index 06040f035f8ea205ce1b0cda3efdbdc9e68ba474..44d129d4e28a70fceada084e1da88281976aa023 100644 (file)
@@ -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);
index 96ab915632dac4d6b4cd9cc8e1324fab0833cce6..accfbe8ac47b057d745a4542cb214ae10a66acbd 100644 (file)
@@ -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)