3 local TourGuide
= TourGuide
7 TourGuide
.TrackEvents
= {"CHAT_MSG_LOOT", "CHAT_MSG_SYSTEM", "QUEST_COMPLETE", "UNIT_QUEST_LOG_UPDATE", "QUEST_WATCH_UPDATE", "QUEST_FINISHED", "QUEST_LOG_UPDATE",
8 "ZONE_CHANGED", "ZONE_CHANGED_INDOORS", "MINIMAP_ZONE_CHANGED", "ZONE_CHANGED_NEW_AREA"}
11 function TourGuide
:ZONE_CHANGED(...)
12 local action
, quest
, note
, logi
, complete
, hasitem
, turnedin
, fullquestname
= self
:GetCurrentObjectiveInfo()
13 if (action
== "RUN" or action
== "FLY" or action
== "HEARTH" or action
== "BOAT") and (GetSubZoneText() == quest
or GetZoneText() == quest
) then
14 self
:DebugF(1, "Detected zone change %q - %q", action
, quest
)
18 TourGuide
.ZONE_CHANGED_INDOORS
= TourGuide
.ZONE_CHANGED
19 TourGuide
.MINIMAP_ZONE_CHANGED
= TourGuide
.ZONE_CHANGED
20 TourGuide
.ZONE_CHANGED_NEW_AREA
= TourGuide
.ZONE_CHANGED
23 function TourGuide
:CHAT_MSG_SYSTEM(event
, msg
)
24 local action
, quest
, note
, logi
, complete
, hasitem
, turnedin
, fullquestname
= self
:GetCurrentObjectiveInfo()
26 if action
== "SETHEARTH" then
27 local _
, _
, loc
= msg
:find("(.*) is now your home.")
28 if loc
and loc
== quest
then
29 self
:DebugF(1, "Detected setting hearth to %q", loc
)
30 return self
:SetTurnedIn()
34 if action
== "ACCEPT" then
35 local _
, _
, text
= msg
:find("Quest accepted: (.*)")
36 if text
and quest
:gsub("%s%(Part %d+%)", "") == text
then
37 self
:DebugF(1, "Detected quest accept %q", quest
)
38 return self
:UpdateStatusFrame()
42 local _
, _
, text
= msg
:find("(.*) completed.")
43 if not text
then return end
45 if quest
:gsub("%s%(Part %d+%)", "") == text
then
46 self
:DebugF(1, "Detected quest turnin %q", quest
)
47 return self
:SetTurnedIn()
50 self
:Debug(1, "Detected early turnin, searching for quest...")
51 self
:CompleteQuest(text
)
55 function TourGuide
:QUEST_COMPLETE(event
)
56 self
:DebugF(1, "Quest Complete %q", GetTitleText())
57 --~ hadquest = GetTitleText()
58 --~ local action, quest, note, logi, complete, hasitem, turnedin = self:GetCurrentObjectiveInfo()
59 --~ if (action == "TURNIN" or action == "ITEM") and logi then hadquest = quest
60 --~ else hadquest = nil end
64 function TourGuide
:UNIT_QUEST_LOG_UPDATE(event
, unit
)
65 if unit
~= "player" or not hadquest
then return end
66 self
:Debug(1, "Unit quest log update")
68 local action
, quest
, note
, logi
, complete
, hasitem
, turnedin
= self
:GetCurrentObjectiveInfo()
69 if hadquest
== quest
and not logi
then
70 self
:DebugF(1, "Chain turnin detected, %q - %q", action
, quest
)
71 self
:UpdateStatusFrame()
77 function TourGuide
:QUEST_WATCH_UPDATE(event
)
78 if self
:GetCurrentObjectiveInfo() == "COMPLETE" then self
:UpdateStatusFrame() end
83 function TourGuide
:QUEST_FINISHED()
84 local quest
= GetTitleText()
85 self
:DebugF(1, "Quest Finished %q", quest
)
86 if self
:GetQuestLogIndexByName(quest
) then
87 self
:DebugF(1, "Player has quest %q, turning in?", quest
)
90 --~ local action, quest, note, logi, complete, hasitem, turnedin = self:GetCurrentObjectiveInfo()
91 --~ if action == "TURNIN" and logi then turninquest = quest
92 --~ else turninquest = nil end
96 function TourGuide
:QUEST_LOG_UPDATE(event
)
97 self
:Debug(1, "Quest log update")
98 local action
, quest
, note
, logi
, complete
, hasitem
, turnedin
, fullquestname
= self
:GetCurrentObjectiveInfo()
99 local questturnedin
= turninquest
and not self
:GetQuestLogIndexByName(turninquest
)
100 if turninquest
then self
:DebugF(1, "Turned in quest %q", turninquest
) end
102 if questturnedin
then
103 self
:Debug(1, "Detected early chain quest turnin, searching for quest...")
104 self
:CompleteQuest(turninquest
)
105 elseif action
== "ACCEPT" then self
:UpdateStatusFrame()
106 elseif action
== "TURNIN" and turninquest
== quest
and not logi
then self
:SetTurnedIn()
107 elseif action
== "COMPLETE" and complete
then self
:UpdateStatusFrame() end
112 function TourGuide
:CHAT_MSG_LOOT(event
, msg
)
113 local action
, quest
= self
:GetCurrentObjectiveInfo()
115 if action
== "BUY" then
116 local _
, _
, name
= msg
:find("^You receive item: .*(%[.+%])")
117 if name
and name
== quest
then return self
:SetTurnedIn() end
122 function TourGuide
:UI_INFO_MESSAGE(event
, msg
)
123 local action
, quest
= self
:GetCurrentObjectiveInfo()
125 if msg
== ERR_NEWTAXIPATH
and action
== "GETFLIGHTPOINT" then
126 self
:Debug(1, "Discovered flight point")