Thread Tools Display Modes
06-22-09, 09:37 PM   #21
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Also, apparently they changed RaidWarningFrame...this works for me.

Code:
local me = CreateFrame("Frame", "stupidframe")

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", "Yo! The goblin has fainted, throw some water on him, quick!!"},
     {"Kerlonian Evershade", "Darn it!  That lazy druid has fallen asleep again, time to use the horn!!!"},
     {"Shay", "That dippy night elf girl is chasing butterflies again, better ring the bell and call her back."},
     {"A-Me 01", "The suicidal ape robot is charging off into the fray again, go defend her!"},
     --etc
}

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

me:SetScript("OnEvent", me.EventHandler)
  Reply With Quote
06-22-09, 09:57 PM   #22
Ambrya
Premium Member
Premium Member
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 49
Woot! Thank you very much.

Okay, I tested it on my friend's toon again, and it did indeed work. There are a few issues with it triggering at times when it shouldn't--like when the quest NPC says something at the start of the quest right after you've accepted it, or when he says/emotes something after you've responded to the event.

For instance, in "The Druid Has Awakened" after you blow the horn, you get an emote that says "Kerlonian Evershade wakes up" and that will trigger the alert again. Also, the alert gets double-triggered when there is both an emote and a quote, which is always (as far as I can tell) the case with at least this one particular quest.

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


Results in two dings (I think...) and two copies of the alert text on the screen.

I imagine, however, that fixing these issues will be delving into more complex coding than we really want to deal with, however. I'm not so worried about the double-trigger effect, because hey, worst that will happen is the player is made REALLY aware that they're about to lose their escort NPC, but the alert being triggered by quotes/emotes at the start of the quest and when the "special event requiring attention" has already been dealt with could be confusing to some people. But like I said, if it requires too complicated a fix, we might just want to disclaim it in the "known issues" bit.

Last edited by Ambrya : 06-22-09 at 11:57 PM.
  Reply With Quote
06-23-09, 05:12 AM   #23
Recluse
A Cliff Giant
 
Recluse's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 70
Well, to prevent double triggers and the triggering at the beginning of the escort, you'd have to do a match or pattern match on the actual emotes/messages. This would require knowing which emotes/messages should trigger the warning, and to code for those specifically.

It wouldn't be too much harder than what you have done already, aside from the data collection to know which emotes/messages to trigger the addon for. You're certainly on the right path, though.
__________________
We'd be together, but only diamonds last forever...
  Reply With Quote
06-23-09, 05:24 AM   #24
Coren
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 6
Originally Posted by Ambrya View Post
(...)
Results in two dings (I think...) and two copies of the alert text on the screen.
You could store the current time of your warning and suppress following ones in a time frame:
Code:
...
if name:find(self.listOfNames[i][1]) then
    -- only one warning per 10 seconds
    if ((me.Time == nil) or (time() - me.Time > 10)) then
        me.Time = time();
        PlaySound("RaidWarning")
        ...
    end
...
Originally Posted by Ambrya View Post
(...), but the alert being triggered by quotes/emotes at the start of the quest and when the "special event requiring attention" has already been dealt with could be confusing to some people. (...).
You could register "QUEST_LOG_UPDATE" and set me.Time to time() + 20 at that event. Then the first 20s after the quest start nothing would be output.
  Reply With Quote
06-23-09, 08:47 AM   #25
Ambrya
Premium Member
Premium Member
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 49
Originally Posted by Coren View Post
You could store the current time of your warning and suppress following ones in a time frame:

Okay, I tend to start making code look messy when I try to patchwork stuff in, but I've added this in, hopefully without screwing up the indentations to keep everything tidy, etc too much and will take it for a test run later.

You could register "QUEST_LOG_UPDATE" and set me.Time to time() + 20 at that event. Then the first 20s after the quest start nothing would be output.
I added the registration for the "QUEST_LOG_UPDATE event, but I'm not sure how to do the rest, or at least not sure at which point in the script to do it. I'll probably drop that down to 10 seconds as well, since it seems like with the quest I'm using as a test case on my friend's toon, the first event requiring an action occurs fairly soon after the quest begins sometimes.

Here's what I have...did I butcher it too badly?

Code:
local me = CreateFrame("Frame", "stupidframe")

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

me.listOfNames = {
     {"Ringo", "Yo! The goblin has fainted, throw some water on him, quick!!"},
     {"Kerlonian Evershade", "Darn it!  That lazy druid has fallen asleep again, time to use the horn!!!"},
     {"Shay", "That dippy night elf girl is chasing butterflies again, better ring the bell and call her back."},
     {"A-Me 01", "The suicidal ape robot is charging off into the fray again, go defend her!"},
     --etc
}

function me.EventHandler(self, event, _, name)
      for i = 1, #self.listOfNames do
           if name:find(self.listOfNames[i][1]) then
               -- only one warning per 10 seconds
               if ((me.Time == nil) or (time() - me.Time > 10)) then
                    me.Time = time();
                    PlaySound("RaidWarning")
                    local msg = self.listOfNames[i][2] or "Heads Up!  Your quest NPC needs help!!!"
                    RaidNotice_AddMessage(RaidWarningFrame, msg, ChatTypeInfo["RAID_WARNING"])
                    return
               end
           end
      end
end

me:SetScript("OnEvent", me.EventHandler)
  Reply With Quote
06-23-09, 01:02 PM   #26
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
I removed a debugging thing and comment that I forgot to delete before, and added the "start of quest timer" stuff to what you posted.

Code:
local me = CreateFrame("Frame")

me:RegisterEvent("CHAT_MSG_MONSTER_EMOTE")
me:RegisterEvent("CHAT_MSG_MONSTER_SAY")
me:RegisterEvent("CHAT_MSG_MONSTER_WHISPER")
me:RegisterEvent("QUEST_LOG_UPDATE")

me.listOfNames = {
     {"Ringo", "Yo! The goblin has fainted, throw some water on him, quick!!"},
     {"Kerlonian Evershade", "Darn it!  That lazy druid has fallen asleep again, time to use the horn!!!"},
     {"Shay", "That dippy night elf girl is chasing butterflies again, better ring the bell and call her back."},
     {"A-Me 01", "The suicidal ape robot is charging off into the fray again, go defend her!"},
     --etc
}

function me.EventHandler(self, event, _, name)
      if event == "QUEST_LOG_UPDATE" then
           me.Time = time()
           return
      end
      for i = 1, #self.listOfNames do
           if name:find(self.listOfNames[i][1]) then
               -- only one warning per 10 seconds
               if (not me.Time) or (time() - me.Time > 10) then
                    me.Time = time()
                    PlaySound("RaidWarning")
                    local msg = self.listOfNames[i][2] or "Heads Up!  Your quest NPC needs help!!!"
                    RaidNotice_AddMessage(RaidWarningFrame, msg, ChatTypeInfo["RAID_WARNING"])
                    return
               end
           end
      end
end

me:SetScript("OnEvent", me.EventHandler)

Last edited by Akryn : 06-23-09 at 01:08 PM.
  Reply With Quote
06-23-09, 02:25 PM   #27
Ambrya
Premium Member
Premium Member
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 49
Marvelous, thank you so much! Gonna update the file and test it. Do I need to establish the 10/20/whatever second value somewhere in the line 18 (me.Time = time())?

Last edited by Ambrya : 06-23-09 at 02:27 PM.
  Reply With Quote
06-23-09, 05:14 PM   #28
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by Ambrya View Post
Do I need to establish the 10/20/whatever second value somewhere in the line 18 (me.Time = time())?
Nope that's
Code:
 if (not me.Time) or (time() - me.Time > 10) then
  Reply With Quote
06-23-09, 05:22 PM   #29
Ambrya
Premium Member
Premium Member
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 49
Originally Posted by Akryn View Post
Nope that's
Code:
 if (not me.Time) or (time() - me.Time > 10) then
Hmmm, okay I will try it again. It still dinged at the beginning of the quest last time I tried it, which is why I assumed it needed something more added, but I will double check.

It might be a matter of playing with the amount of time allowed. I'm going to have to change the 10 seconds anyway, it appears. Last test-drive I did, it took more than 10 seconds to get within range of the NPC and blow the horn to wake him up, which means I still got the ding when he emoted after the event was over.
  Reply With Quote
06-23-09, 05:35 PM   #30
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
It's possible that the emote event fires before the quest log event. Hopefully that's not the case
  Reply With Quote
06-23-09, 10:49 PM   #31
Ambrya
Premium Member
Premium Member
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 49
Well, I changed the time to 20 seconds and the next time I tested it, I didn't get the ding immediately as I accepted the quest. So either changing it to 20 seconds fixed the problem, OR it is as you said, sometimes the quote event registers before the quest log update event. In any case, I listed it as a "known issue" and have posted the first beta of the mod here:

Escort Event Alert

Thanks again for all the help and input!
  Reply With Quote
07-26-09, 06:45 PM   #32
Ambrya
Premium Member
Premium Member
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 49
Akryn, question for you...

I was updating the file to add a whole bunch of NPC names and came across Stinky's Escape. The NPC's name is "Stinky" Ignatz, complete with quotes. Keeping in mind what you posted earlier in this thread, adding that to the list of names I would write it like this, correct?

Code:
me.listOfNames = {
     {"/Stinky/ Ignatz"},
     --etc
}
Correct?

Also, I was wondering if there is a way to put in an alert if the NPC enters combat mode, in case it's a quest where the NPC doesn't speak or emote when attacked.

Thanks!
  Reply With Quote
07-26-09, 06:56 PM   #33
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
It would be:

{"\"Stinky\" Ignatz"},

the character \ is an escape character, i.e. basically it means that whatever comes immediately after it is either a special command ( \n means newline) or should be interpreted literally as opposed to part of the code (e.g. \" means an actual quote as opposed to an instruction to end the string)

I don't think that you can check the combat status of entities outside of your target/focus/party/party's targets/etc.
  Reply With Quote
07-26-09, 07:30 PM   #34
Ambrya
Premium Member
Premium Member
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 49
Thank you!
  Reply With Quote
07-26-09, 08:26 PM   #35
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
While escaping the quotes is one way to do it, Lua recognizes both " and ' for quotes. Thus...

Code:
print("'Stinky' Ignatz")
gives you 'Stinky' Ignatz

and

Code:
print('"Stinky" Ignatz')
gives you "Stinky" Ignatz
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Perhaps a strange request...


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off