3 local TourGuide
= TourGuide
7 TourGuide
.TrackEvents
= {"CHAT_MSG_LOOT", "CHAT_MSG_SYSTEM", "QUEST_WATCH_UPDATE", "QUEST_LOG_UPDATE", "ZONE_CHANGED", "ZONE_CHANGED_INDOORS", "MINIMAP_ZONE_CHANGED", "ZONE_CHANGED_NEW_AREA", "PLAYER_LEVEL_UP"}
10 function TourGuide
:PLAYER_LEVEL_UP(event
, newlevel
)
11 local level
= self
:GetObjectiveTag("LV")
12 self
:Debug(1, "PLAYER_LEVEL_UP", newlevel
, level
)
13 if level
and newlevel
>= level
then self
:SetTurnedIn() end
17 function TourGuide
:ZONE_CHANGED()
18 local action
, quest
= self
:GetObjectiveInfo()
19 if (action
== "RUN" or action
== "FLY" or action
== "HEARTH" or action
== "BOAT") and (GetSubZoneText() == quest
or GetZoneText() == quest
) then
20 self
:DebugF(1, "Detected zone change %q - %q", action
, quest
)
24 TourGuide
.ZONE_CHANGED_INDOORS
= TourGuide
.ZONE_CHANGED
25 TourGuide
.MINIMAP_ZONE_CHANGED
= TourGuide
.ZONE_CHANGED
26 TourGuide
.ZONE_CHANGED_NEW_AREA
= TourGuide
.ZONE_CHANGED
29 function TourGuide
:CHAT_MSG_SYSTEM(event
, msg
)
30 local action
, quest
= self
:GetObjectiveInfo()
32 if action
== "SETHEARTH" then
33 local _
, _
, loc
= msg
:find("(.*) is now your home.")
34 if loc
and loc
== quest
then
35 self
:DebugF(1, "Detected setting hearth to %q", loc
)
36 return self
:SetTurnedIn()
40 if action
== "ACCEPT" then
41 local _
, _
, text
= msg
:find("Quest accepted: (.*)")
42 if text
and quest
:gsub("%s%(Part %d+%)", "") == text
then
43 self
:DebugF(1, "Detected quest accept %q", quest
)
44 return self
:UpdateStatusFrame()
50 function TourGuide
:QUEST_WATCH_UPDATE(event
)
51 if self
:GetObjectiveInfo() == "COMPLETE" then self
:UpdateStatusFrame() end
55 function TourGuide
:QUEST_LOG_UPDATE(event
)
56 self
:Debug(10, "QUEST_LOG_UPDATE")
57 local action
, _
, logi
, complete
= self
:GetObjectiveInfo(), self
:GetObjectiveStatus()
59 if (self
.updatedelay
and not logi
) or action
== "ACCEPT" or action
== "COMPLETE" and complete
then self
:UpdateStatusFrame() end
63 function TourGuide
:CHAT_MSG_LOOT(event
, msg
)
64 local action
, quest
= self
:GetObjectiveInfo()
65 local lootitem
, lootqty
= self
:GetObjectiveTag("L")
66 local _
, _
, itemid
, name
= msg
:find("^You .*Hitem:(%d+).*(%[.+%])")
67 self
:Debug(10, event
, msg
:gsub("|","||"), action
, quest
, lootitem
, lootqty
, itemid
, name
)
69 if action
== "BUY" and name
and name
== quest
70 or (action
== "BUY" or action
== "NOTE") and lootitem
and itemid
== lootitem
and (GetItemCount(lootitem
) + 1) >= lootqty
then
71 return self
:SetTurnedIn()
76 function TourGuide
:UI_INFO_MESSAGE(event
, msg
)
77 if msg
== ERR_NEWTAXIPATH
and self
:GetObjectiveInfo() == "GETFLIGHTPOINT" then
78 self
:Debug(1, "Discovered flight point")
84 local orig
= GetQuestReward
85 GetQuestReward
= function(...)
86 local quest
= GetTitleText()
87 TourGuide
:Debug(10, "GetQuestReward", quest
)
88 TourGuide
:CompleteQuest(quest
, true)