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") and (GetSubZoneText() == quest
or GetZoneText() == quest
) then self
:SetTurnedIn() end
15 TourGuide
.ZONE_CHANGED_INDOORS
= TourGuide
.ZONE_CHANGED
16 TourGuide
.MINIMAP_ZONE_CHANGED
= TourGuide
.ZONE_CHANGED
17 TourGuide
.ZONE_CHANGED_NEW_AREA
= TourGuide
.ZONE_CHANGED
20 function TourGuide
:CHAT_MSG_SYSTEM(event
, msg
)
21 local action
, quest
, note
, logi
, complete
, hasitem
, turnedin
, fullquestname
= self
:GetCurrentObjectiveInfo()
23 if action
== "SETHEARTH" then
24 local _
, _
, loc
= msg
:find("(.*) is now your home.")
25 if loc
and loc
== quest
then return self
:SetTurnedIn() end
28 if action
== "ACCEPT" then
29 local _
, _
, text
= msg
:find("Quest accepted: (.*)")
30 if text
and quest
== text
then return self
:UpdateStatusFrame() end
33 local _
, _
, text
= msg
:find("(.*) completed.")
34 if not text
then return end
36 if quest
== text
then return self
:SetTurnedIn() end
40 action
, quest
, note
, logi
, complete
, hasitem
, turnedin
, fullquestname
= self
:GetObjectiveInfo(i
)
41 if action
== "ACCEPT" and not turnedin
and text
== quest
then
42 self
.turnedin
[fullquestname
] = true
43 return self
:UpdateStatusFrame()
50 function TourGuide
:QUEST_COMPLETE(event
)
51 local action
, quest
, note
, logi
, complete
, hasitem
, turnedin
= self
:GetCurrentObjectiveInfo()
52 if (action
== "TURNIN" or action
== "ITEM") and logi
then hadquest
= quest
53 else hadquest
= nil end
57 function TourGuide
:UNIT_QUEST_LOG_UPDATE(event
, unit
)
58 if unit
~= "player" then return end
60 local action
, quest
, note
, logi
, complete
, hasitem
, turnedin
= self
:GetCurrentObjectiveInfo()
61 if hadquest
== quest
and not logi
and action
== "ITEM" then self
:SetTurnedIn()
62 elseif hadquest
== quest
and not logi
then self
:UpdateStatusFrame() end
67 function TourGuide
:QUEST_WATCH_UPDATE(event
)
68 local action
, quest
, note
, logi
, complete
, hasitem
, turnedin
= self
:GetCurrentObjectiveInfo()
69 if action
== "COMPLETE" then self
:UpdateStatusFrame() end
74 function TourGuide
:QUEST_FINISHED()
75 local action
, quest
, note
, logi
, complete
, hasitem
, turnedin
= self
:GetCurrentObjectiveInfo()
76 if action
== "TURNIN" and logi
then turninquest
= quest
77 else turninquest
= nil end
81 function TourGuide
:QUEST_LOG_UPDATE(event
)
82 local action
, quest
, note
, logi
, complete
, hasitem
, turnedin
, fullquestname
= self
:GetCurrentObjectiveInfo()
84 if action
== "ACCEPT" then return self
:UpdateStatusFrame()
85 elseif action
== "TURNIN" and turninquest
== quest
and not logi
then return self
:SetTurnedIn()
86 elseif action
== "COMPLETE" and complete
then return self
:UpdateStatusFrame() end
90 function TourGuide
:CHAT_MSG_LOOT(event
, msg
)
91 local action
, quest
= self
:GetCurrentObjectiveInfo()
93 if action
== "BUY" then
94 local _
, _
, name
= msg
:find("^You receive item: .*(%[.+%])")
95 if name
and name
== quest
then return self
:SetTurnedIn() end