View Single Post
06-22-09, 06:00 PM   #14
Ambrya
Premium Member
Premium Member
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 49
Originally Posted by Akryn View Post
Oh I see, well just change it to this:


Very cool, and exactly what was needed. Thank you so very much. I realized I initially did ask for a script that would run when certain things were said...then upon researching even just a small handful of quests I began to realize just how impossible that would turn out to be, collecting the accurate quotes and emotes (of which there might be up to a dozen or so associated with any given quest, if the list of events from "The Sleeper Has Awakened" is any indication) when there is no realistic way I have of collecting the data myself for each and every one.

So what I would end up with then, is this, right?

Code:
local me = CreateFrame("Frame")

me:RegisterEvent("CHAT_MSG_MONSTER_EMOTE")
me:RegisterEvent("CHAT_MSG_MONSTER_SAY")
me:RegisterEvent("CHAT_MSG_MONSTER_WHISPER")
--add any others...that's probably good enough

me.listOfNames = {
     "Ringo",
     "Kerlonian Evershade",
     "Shay",
     "A-Me 01"
     --etc
}

me.EventHandler(self, event, _, name)
      for i = 1, #self.listOfNames do
           if name:find(self.listOfNames[i]) then
                 PlaySound("RaidWarning")
                 RaidWarningFrame:AddMessage("Heads Up!  Your quest NPC needs help!!!")
                 return
           end
      end
end

me:SetScript("OnEvent", me.EventHandler)
That is just about perfect...it works for both escort quests that have a "catch" (like needing to dump the water on the NPC) and regular escorts where the NPC has a phrase they speak or emote they perform when being attacked by wandering mobs or when encountering scripted fights along the way.

One question...what is the "_" supposed to be in the line?

Code:
me.EventHandler(self, event, _, name)
Thank you so very much for taking the time to help me. I think because of its simplicity, this is definitely the route to go. I admit, though, I'm ambitious enough to want to someday make it a little more customizable, in the manner of the second script you posted. If for no other reason than it would be fun to include customized warning for each specific NPC (like the "lazy druid" line in my earlier attempt.) But I suspect that is, in fact, beyond me.

Another thought just occurred to me...if you had this addon and someone else walked by you escorting one of the quest NPCs and the NPC spoke/emoted, would it trigger the addon? How difficult would it be to check that you're on the escort quest, and not just a bystander?

Last edited by Ambrya : 06-22-09 at 06:08 PM.
  Reply With Quote