]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_triggers.qc
Merge remote-tracking branch 'origin/master' into terencehill/menu_focus_stuff
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_triggers.qc
index 0ab2b423354013da80c2e56215aecd053eebfcca..12c75ae9e57199fb5499b0a910c5ecda94d3ed42 100644 (file)
@@ -66,7 +66,7 @@ void SUB_UseTargets()
                if(clienttype(activator) == CLIENTTYPE_REAL)
                {
                        centerprint (activator, self.message);
-                       if (!self.noise)
+                       if (self.noise == "")
                                play2(activator, "misc/talk.wav");
                }
        }
@@ -192,7 +192,7 @@ void multi_trigger()
        else
        {       // we can't just remove (self) here, because this is a touch function
                // called wheil C code is looping through area links...
-               self.touch = SUB_Null;
+               self.touch = func_null;
        }
 }
 
@@ -254,7 +254,8 @@ void multi_reset()
                self.takedamage = DAMAGE_YES;
                self.solid = SOLID_BBOX;
        }
-       self.think = SUB_Null;
+       self.think = func_null;
+       self.nextthink = 0;
        self.team = self.team_saved;
 }
 
@@ -359,7 +360,8 @@ void delay_use()
 
 void delay_reset()
 {
-       self.think = SUB_Null;
+       self.think = func_null;
+       self.nextthink = 0;
 }
 
 void spawnfunc_trigger_delay()
@@ -466,20 +468,12 @@ void trigger_hurt_touch()
                        Damage (other, self, own, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
                }
        }
-       else
+       else if(other.damagedbytriggers)
        {
-               if (!other.owner)
+               if(other.takedamage)
                {
-                       if (other.items & IT_KEY1 || other.items & IT_KEY2)     // reset flag
-                       {
-                               EXACTTRIGGER_TOUCH;
-                               other.pain_finished = min(other.pain_finished, time + 2);
-                       }
-                       else if (other.classname == "rune")                     // reset runes
-                       {
-                               EXACTTRIGGER_TOUCH;
-                               other.nextthink = min(other.nextthink, time + 1);
-                       }
+                       EXACTTRIGGER_TOUCH;
+                       Damage(other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
                }
        }
 
@@ -503,9 +497,9 @@ void spawnfunc_trigger_hurt()
        self.enemy = world; // I hate you all
        if (!self.dmg)
                self.dmg = 1000;
-       if (!self.message)
+       if (self.message == "")
                self.message = "was in the wrong place";
-       if (!self.message2)
+       if (self.message2 == "")
                self.message2 = "was thrown into a world of hurt by";
        // self.message = "someone like %s always gets wrongplaced";
 
@@ -545,6 +539,7 @@ void trigger_heal_touch()
        if (other.iscreature)
        {
                if (other.takedamage)
+               if (!other.deadflag)
                if (other.triggerhealtime < time)
                {
                        EXACTTRIGGER_TOUCH;
@@ -1333,9 +1328,9 @@ void spawnfunc_misc_laser()
        if(self.colormod == '0 0 0')
                if(!self.alpha)
                        self.colormod = '1 0 0';
-       if(!self.message)
+       if(self.message == "")
                self.message = "saw the light";
-       if (!self.message2)
+       if (self.message2 == "")
                self.message2 = "was pushed into a laser by";
        if(!self.scale)
                self.scale = 1;
@@ -1390,6 +1385,8 @@ void trigger_impulse_touch1()
         return;
     }
 
+    str = min(self.radius, vlen(self.origin - other.origin));
+
     if(self.falloff == 1)
         str = (str / self.radius) * self.strength;
     else if(self.falloff == 2)
@@ -1908,19 +1905,54 @@ void spawnfunc_trigger_disablerelay()
 }
 
 float magicear_matched;
+float W_Tuba_HasPlayed(entity pl, string melody, float instrument, float ignorepitch, float mintempo, float maxtempo);
 string trigger_magicear_processmessage(entity ear, entity source, float teamsay, entity privatesay, string msgin)
 {
        float domatch, dotrigger, matchstart, l;
        string s, msg;
        entity oldself;
+       string savemessage;
 
        magicear_matched = FALSE;
 
-       dotrigger = ((self.classname == "player") && (self.deadflag == DEAD_NO) && ((ear.radius == 0) || (vlen(source.origin - ear.origin) <= ear.radius)));
+       dotrigger = ((source.classname == "player") && (source.deadflag == DEAD_NO) && ((ear.radius == 0) || (vlen(source.origin - ear.origin) <= ear.radius)));
        domatch = ((ear.spawnflags & 32) || dotrigger);
+
        if not(domatch)
                return msgin;
 
+       if not(msgin)
+       {
+               // we are in TUBA mode!
+               if not(ear.spawnflags & 256)
+                       return msgin;
+
+               if(!W_Tuba_HasPlayed(source, ear.message, ear.movedir_x, !(ear.spawnflags & 512), ear.movedir_y, ear.movedir_z))
+                       return msgin;
+
+               magicear_matched = TRUE;
+
+               if(dotrigger)
+               {
+                       oldself = self;
+                       activator = source;
+                       self = ear;
+                       savemessage = self.message;
+                       self.message = string_null;
+                       SUB_UseTargets();
+                       self.message = savemessage;
+                       self = oldself;
+               }
+
+               if(ear.netname != "")
+                       return ear.netname;
+
+               return msgin;
+       }
+
+       if(ear.spawnflags & 256) // ENOTUBA
+               return msgin;
+
        if(privatesay)
        {
                if(ear.spawnflags & 4)
@@ -1942,7 +1974,7 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay,
        matchstart = -1;
        l = strlen(ear.message);
 
-       if(self.spawnflags & 128)
+       if(ear.spawnflags & 128)
                msg = msgin;
        else
                msg = strdecolorize(msgin);
@@ -1993,9 +2025,13 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay,
 
        if(dotrigger)
        {
-               oldself = activator = self;
+               oldself = self;
+               activator = source;
                self = ear;
+               savemessage = self.message;
+               self.message = string_null;
                SUB_UseTargets();
+               self.message = savemessage;
                self = oldself;
        }
 
@@ -2041,13 +2077,16 @@ void spawnfunc_trigger_magicear()
 
        // actually handled in "say" processing
        // spawnflags:
-       //   1 = ignore say
-       //   2 = ignore teamsay
-       //   4 = ignore tell
-       //   8 = ignore tell to unknown player
+       //    1 = ignore say
+       //    2 = ignore teamsay
+       //    4 = ignore tell
+       //    8 = ignore tell to unknown player
        //   16 = let netname replace the whole message (otherwise, netname is a word replacement if set)
        //   32 = perform the replacement even if outside the radius or dead
        //   64 = continue replacing/triggering even if this one matched
+       //  128 = don't decolorize message before matching
+       //  256 = message is a tuba note sequence (pitch.duration pitch.duration ...)
+       //  512 = tuba notes must be exact right pitch, no transposing
        // message: either
        //   *pattern*
        // or
@@ -2062,6 +2101,10 @@ void spawnfunc_trigger_magicear()
        //   "hearing distance"
        // target:
        //   what to trigger
+       // movedir:
+       //   for spawnflags 256, defines 'instrument+1 mintempo maxtempo' (zero component doesn't matter)
+
+       self.movedir_x -= 1; // map to tuba instrument numbers
 }
 
 void relay_activators_use()