]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/trigger/multi.qc
Merge branch 'master' into terencehill/translate_colors_2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / multi.qc
index b85258702771c69d620f18dfa9025f9a4865970f..3f0a4b27fef60d5058fba15f2298da394ae14950 100644 (file)
@@ -3,7 +3,7 @@
 #ifdef SVQC
 // the wait time has passed, so set back up for another activation
 void multi_wait()
-{
+{SELFPARAM();
        if (self.max_health)
        {
                self.health = self.max_health;
@@ -17,12 +17,16 @@ void multi_wait()
 // self.enemy should be set to the activator so it can be held through a delay
 // so wait for the delay time before firing
 void multi_trigger()
-{
+{SELFPARAM();
        if (self.nextthink > time)
        {
                return;         // allready been triggered
        }
 
+       if(self.spawnflags & 16384)
+       if(!IS_PLAYER(self.enemy))
+               return; // only players
+
        if (self.classname == "trigger_secret")
        {
                if (!IS_PLAYER(self.enemy))
@@ -32,7 +36,7 @@ void multi_trigger()
        }
 
        if (self.noise)
-               sound (self.enemy, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
+               _sound (self.enemy, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
 
 // don't trigger again until reset
        self.takedamage = DAMAGE_NO;
@@ -58,14 +62,14 @@ void multi_trigger()
 }
 
 void multi_use()
-{
+{SELFPARAM();
        self.goalentity = other;
        self.enemy = activator;
        multi_trigger();
 }
 
 void multi_touch()
-{
+{SELFPARAM();
        if(!(self.spawnflags & 2))
        if(!other.iscreature)
                        return;
@@ -82,6 +86,12 @@ void multi_touch()
                        return;         // not facing the right way
        }
 
+       // if the trigger has pressed keys, check that the player is pressing those keys
+       if(self.pressedkeys)
+       if(IS_PLAYER(other)) // only for players
+       if(!(other.pressedkeys & self.pressedkeys))
+               return;
+
        EXACTTRIGGER_TOUCH;
 
        self.enemy = other;
@@ -89,35 +99,35 @@ void multi_touch()
        multi_trigger ();
 }
 
-void multi_eventdamage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+void multi_eventdamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
 {
-       if (!self.takedamage)
+       if(!this.takedamage)
                return;
-       if(self.spawnflags & DOOR_NOSPLASH)
+       if(this.spawnflags & DOOR_NOSPLASH)
                if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
                        return;
-       self.health = self.health - damage;
-       if (self.health <= 0)
+       this.health = this.health - damage;
+       if (this.health <= 0)
        {
-               self.enemy = attacker;
-               self.goalentity = inflictor;
-               multi_trigger();
+               this.enemy = attacker;
+               this.goalentity = inflictor;
+               WITHSELF(this, multi_trigger());
        }
 }
 
-void multi_reset()
+void multi_reset(entity this)
 {
-       if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) )
-               self.touch = multi_touch;
-       if (self.max_health)
+       if ( !(this.spawnflags & SPAWNFLAG_NOTOUCH) )
+               this.touch = multi_touch;
+       if (this.max_health)
        {
-               self.health = self.max_health;
-               self.takedamage = DAMAGE_YES;
-               self.solid = SOLID_BBOX;
+               this.health = this.max_health;
+               this.takedamage = DAMAGE_YES;
+               this.solid = SOLID_BBOX;
        }
-       self.think = func_null;
-       self.nextthink = 0;
-       self.team = self.team_saved;
+       this.think = func_null;
+       this.nextthink = 0;
+       this.team = this.team_saved;
 }
 
 /*QUAKED spawnfunc_trigger_multiple (.5 .5 .5) ? notouch
@@ -133,24 +143,18 @@ sounds
 4)
 set "message" to text string
 */
-void spawnfunc_trigger_multiple()
+spawnfunc(trigger_multiple)
 {
        self.reset = multi_reset;
        if (self.sounds == 1)
-       {
-               precache_sound ("misc/secret.wav");
                self.noise = "misc/secret.wav";
-       }
        else if (self.sounds == 2)
-       {
-               precache_sound ("misc/talk.wav");
-               self.noise = "misc/talk.wav";
-       }
+               self.noise = strzone(SND(TALK));
        else if (self.sounds == 3)
-       {
-               precache_sound ("misc/trigger1.wav");
                self.noise = "misc/trigger1.wav";
-       }
+
+       if(self.noise)
+               precache_sound(self.noise);
 
        if (!self.wait)
                self.wait = 0.2;
@@ -196,9 +200,9 @@ sounds
 4)
 set "message" to text string
 */
-void spawnfunc_trigger_once()
+spawnfunc(trigger_once)
 {
-       self.wait = -1;
-       spawnfunc_trigger_multiple();
+       this.wait = -1;
+       spawnfunc_trigger_multiple(this);
 }
 #endif