]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_triggers.qc
magicear: support tuba notes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_triggers.qc
index 0ab2b423354013da80c2e56215aecd053eebfcca..5318182e8f10d58c2e7e7b63be5e09b27d99208a 100644 (file)
@@ -1908,6 +1908,7 @@ 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;
@@ -1921,6 +1922,34 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay,
        if not(domatch)
                return msgin;
 
+       if not(msgin)
+       {
+               // we are in TUBA mode!
+               if not(ear.spawnflags & 256)
+                       return msgin;
+
+               if(!W_Tuba_HasPlayed(self, self.message, !(ear.spawnflags & 256), ear.movedir_x, ear.movedir_y, ear.movedir_z))
+                       return msgin;
+
+               magicear_matched = TRUE;
+
+               if(dotrigger)
+               {
+                       oldself = activator = self;
+                       self = ear;
+                       SUB_UseTargets();
+                       self = oldself;
+               }
+
+               if(ear.netname != "")
+                       return ear.netname;
+
+               return msgin;
+       }
+
+       if(ear.spawnflags & 256) // ENOTUBA
+               return msgin;
+
        if(privatesay)
        {
                if(ear.spawnflags & 4)
@@ -2048,6 +2077,8 @@ void spawnfunc_trigger_magicear()
        //   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 ...)
        // message: either
        //   *pattern*
        // or
@@ -2062,6 +2093,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()