3 local TourGuide
= TourGuide
7 TourGuide
.TrackEvents
= {"CHAT_MSG_LOOT", "CHAT_MSG_SYSTEM", "QUEST_COMPLETE", "QUEST_WATCH_UPDATE", "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)
56 function TourGuide
:QUEST_COMPLETE(event
)
57 local quest
= GetTitleText()
58 self
:Debug(10, "QUEST_COMPLETE", quest
)
59 if self
:GetQuestLogIndexByName(quest
) then
60 self
:DebugF(1, "Player has quest %q, turning in?", quest
)
66 function TourGuide
:QUEST_WATCH_UPDATE(event
)
67 if self
:GetCurrentObjectiveInfo() == "COMPLETE" then self
:UpdateStatusFrame() end
71 function TourGuide
:QUEST_LOG_UPDATE(event
)
72 self
:Debug(10, "QUEST_LOG_UPDATE")
73 local action
, quest
, note
, logi
, complete
, hasitem
, turnedin
, fullquestname
= self
:GetCurrentObjectiveInfo()
74 local questturnedin
= turninquest
and not self
:GetQuestLogIndexByName(turninquest
)
75 if turninquest
then self
:DebugF(1, "Turnin quest %q (%s)", turninquest
, tostring(not self
:GetQuestLogIndexByName(turninquest
))) end
78 self
:Debug(1, "Detected early chain quest turnin, searching for quest...")
79 --~ self:CompleteQuest(turninquest)
80 elseif action
== "ACCEPT" then self
:UpdateStatusFrame()
81 --~ elseif action == "TURNIN" and turninquest == quest and not logi then self:SetTurnedIn()
82 elseif action
== "COMPLETE" and complete
then self
:UpdateStatusFrame() end
87 function TourGuide
:CHAT_MSG_LOOT(event
, msg
)
88 local action
, quest
, _
, _
, _
, _
, _
, _
, _
, _
, lootitem
, lootqty
= self
:GetCurrentObjectiveInfo()
89 local _
, _
, itemid
, name
= msg
:find("^You receive .*Hitem:(%d+).*(%[.+%])")
90 self
:Debug(10, event
, msg
:gsub("|","||"), action
, quest
, lootitem
, lootqty
, itemid
, name
)
92 if action
== "BUY" and name
and name
== quest
93 or action
== "NOTE" and lootitem
and itemid
== lootitem
and (GetItemCount(lootitem
) + 1) >= lootqty
then
94 return self
:SetTurnedIn()
99 function TourGuide
:UI_INFO_MESSAGE(event
, msg
)
100 local action
, quest
= self
:GetCurrentObjectiveInfo()
102 if msg
== ERR_NEWTAXIPATH
and action
== "GETFLIGHTPOINT" then
103 self
:Debug(1, "Discovered flight point")
109 local orig
= GetQuestReward
110 GetQuestReward
= function(...)
111 local quest
= GetTitleText()
112 TourGuide
:Debug(10, "GetQuestReward", quest
)
113 TourGuide
:CompleteQuest(quest
)