View Single Post
06-22-09, 08:37 AM   #8
Ambrya
Premium Member
Premium Member
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 49
Okay, so when the the quest NPC is saying something, omit the "%s says:" part, but include %s when the NPC is doing an emote. So, adding in events from "The Sleeper Has Awakened" that include both quotes and emotes, we get this, no?


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.listOfText = {
    --Events from Ringo in the "A Little Help From My Friends" quest
    "Uuuuuuggggghhhhh....",
    "I'm not feeling so well...",
    "Maybe... you could carry me?",
    "The heat... I can't take it...",
    --Events from Kerlonian Evershade in the "The Sleeper Has Awakened" quest
    "This looks like the perfect place for a nap...",
    "Yaaaaawwwwwnnnn...",
    "Oh, I am so tired...",
    "Be on the alert! The Blackwood furbolgs are numerous in the area...",
    "You don't mind if I stop here for a moment, do you?",
    "It's quiet... Too quiet...",
    "Kerlonian Evershade looks very sleepy...",
    "Kerlonian Evershade suddenly falls asleep",
    "Kerlonian Evershade begins to drift off...",

}

me.EventHandler(self, event, msg)
      for i = 1, #self.ListOfText do
           if msg:find(self.listOfText[i]) then
                 PlaySound("RaidWarning")
                 RaidWarningFrame:AddMessage("Head's Up!  Your quest NPC needs help!!!")
                 return
           end
      end
end

me:SetScript("OnEvent", me.EventHandler)
Now, in the case of "The Sleeper Has Awakened" (and, I think, "A Little Help From My Friends" as well) the quote usually follows the emote, for instance:

Kerlonian Evershade looks very sleepy...
Kerlonian Evershade says: This looks like the perfect place for a nap...


Will this trigger the addon twice, then?

I found an old unplayed character of mine last night who hadn't done "The Sleeper Has Awakened" so I was able to run through that and get screenshots of the events and have added them into the addon as well. UNFORTUNATELY, I very stupidly accidentally turned the quest in instead of abandoning it, so I can't test the addon. (/headdesk)

If I am understanding the second example you posted, I would modify it to include "Ringo" or "Kerlonian Evershade" where "monster" is, like this?

Code:
local addon = CreateFrame("Frame", "EscortEventAlert")


local triggers = {
	CHAT_MSG_MONSTER_EMOTE = {
		["<Ringo emote message>"] = true --remember include %s where the monster name should be
	}
	CHAT_MSG_MONSTER_SAY = {
		["<Ringo say message>"] = true
	}
	
	CHAT_MSG_MONSTER_WHISPER = {
		["<Ringo whisper message>"] = true
	}
}

addon:RegisterEvent("CHAT_MSG_MONSTER_EMOTE")
addon:RegisterEvent("CHAT_MSG_MONSTER_SAY")
addon:RegisterEvent("CHAT_MSG_MONSTER_WHISPER")

local function OnEvent(self, event, msg, monster)
	if triggers[event][msg] then
		PlaySound("RaidWarning")
		RaidWarningFrame:AddMessage("Head's Up!  "Ringo" needs you to use the canteen!!!")
	end
end

addon:SetScript("OnEvent", OnEvent)

addon.triggers = triggers
And then I would include another section of the macro for Kerlonian Evershade, perhaps like this?

Code:
local addon = CreateFrame("Frame", "EscortEventAlert")


local triggers = {
	CHAT_MSG_MONSTER_EMOTE = {
		["<Ringo emote message>"] = true --remember include %s where the monster name should be
	}
	CHAT_MSG_MONSTER_SAY = {
		["<Ringo say message>"] = true
	}
	
	CHAT_MSG_MONSTER_WHISPER = {
		["<Ringo whisper message>"] = true
	}
	CHAT_MSG_MONSTER_EMOTE = {
		["<Kerlonian Evershade emote message>"] = true
	}
	CHAT_MSG_MONSTER_SAY = {
		["<Kerlonian Evershade say message>"] = true
	}
	
	CHAT_MSG_MONSTER_WHISPER = {
		["<Kerlonian Evershade whisper message>"] = true
	}

}

addon:RegisterEvent("CHAT_MSG_MONSTER_EMOTE")
addon:RegisterEvent("CHAT_MSG_MONSTER_SAY")
addon:RegisterEvent("CHAT_MSG_MONSTER_WHISPER")

local function OnEvent(self, event, msg, Ringo)
	if triggers[event][msg] then
		PlaySound("RaidWarning")
		RaidWarningFrame:AddMessage("Head's Up!  Ringo needs you to use the canteen!!!")
	end

local function OnEvent(self, event, msg, Kerlonian Evershade)
	if triggers[event][msg] then
		PlaySound("RaidWarning")
		RaidWarningFrame:AddMessage("Darn it!  That lazy druid has fallen asleep again, use the horn!!!")
	end
end

addon:SetScript("OnEvent", OnEvent)

addon.triggers = triggers
(I suspect I screwed up where the end commands go, and probably a lot more than that, just trying to see if I understand the idea.)

The nice thing about this second variation, of course, is that it doesn't appear to require me to research all the various quotes and emotes. Which means if you wanted to post this addon and take credit for it yourself, rather than humoring me, you could do so (and I would totally understand.)

Of course, the sleeping druid alert doesn't really work in the context of the NPC getting attacked, whether by a passing mob or during the scripted events, but that's okay.

Last edited by Ambrya : 06-22-09 at 09:00 AM.
  Reply With Quote