1 QuestHelper_File
["main.lua"] = "Development Version"
3 QuestHelper
= CreateFrame("Frame", "QuestHelper", nil)
5 -- Just to make sure it's always 'seen' (there's nothing that can be seen, but still...), and therefore always updating.
6 QuestHelper
:SetFrameStrata("TOOLTIP")
8 QuestHelper_SaveVersion
= 10
9 QuestHelper_CharVersion
= 1
10 QuestHelper_Locale
= GetLocale() -- This variable is used only for the collected data, and has nothing to do with displayed text.
11 QuestHelper_Quests
= {}
12 QuestHelper_Objectives
= {}
17 QuestHelper_DefaultPref
=
22 filter_blocked
=false, -- Hides blocked objectives, such as quest turn-ins for incomplete quests
23 filter_watched
=false, -- Limits to Watched objectives
25 track_minimized
=false,
42 locale
= GetLocale(), -- This variable is used for display purposes, and has nothing to do with the collected data.
43 perf_scale
= 1, -- How much background processing can the current machine handle? Higher means more load, lower means better performance.
47 QuestHelper_FlightInstructors
= {}
48 QuestHelper_FlightLinks
= {}
49 QuestHelper_FlightRoutes
= {}
50 QuestHelper_KnownFlightRoutes
= {}
51 QuestHelper_SeenRealms
= {}
53 QuestHelper
.tooltip
= CreateFrame("GameTooltip", "QuestHelperTooltip", nil, "GameTooltipTemplate")
54 QuestHelper
.objective_objects
= {}
55 QuestHelper
.user_objectives
= {}
56 QuestHelper
.quest_objects
= {}
57 QuestHelper
.player_level
= 1
58 QuestHelper
.locale
= QuestHelper_Locale
60 QuestHelper
.faction
= (UnitFactionGroup("player") == "Alliance" and 1) or
61 (UnitFactionGroup("player") == "Horde" and 2)
63 assert(QuestHelper
.faction
)
65 QuestHelper
.font
= {serif
=GameFontNormal
:GetFont(), sans
=ChatFontNormal
:GetFont(), fancy
=QuestTitleFont
:GetFont()}
67 function QuestHelper
:GetFontPath(list_string
, font
)
69 for name
in string.gmatch(list_string
, "[^;]+") do
70 if font
:SetFont(name
, 10) then
72 elseif font
:SetFont("Interface\\AddOns\\QuestHelper\\Fonts\\"..name
, 10) then
73 return "Interface\\AddOns\\QuestHelper\\Fonts\\"..name
79 function QuestHelper
:SetLocaleFonts()
84 local font
= self
:CreateText(self
)
86 if QuestHelper_Locale
~= QuestHelper_Pref
.locale
then
87 -- Only use alternate fonts if using a language the client wasn't intended for.
88 local replacements
= QuestHelper_SubstituteFonts
[QuestHelper_Pref
.locale
]
90 self
.font
.sans
= self
:GetFontPath(replacements
.sans
, font
)
91 self
.font
.serif
= self
:GetFontPath(replacements
.serif
, font
)
92 self
.font
.fancy
= self
:GetFontPath(replacements
.fancy
, font
)
96 self
.font
.sans
= self
.font
.sans
or self
:GetFontPath(QuestHelper_Pref
.locale
.."_sans.ttf", font
)
97 self
.font
.serif
= self
.font
.serif
or self
:GetFontPath(QuestHelper_Pref
.locale
.."_serif.ttf", font
) or self
.font
.sans
98 self
.font
.fancy
= self
.font
.fancy
or self
:GetFontPath(QuestHelper_Pref
.locale
.."_fancy.ttf", font
) or self
.font
.serif
100 self
:ReleaseText(font
)
102 self
.font
.sans
= self
.font
.sans
or ChatFontNormal
:GetFont()
103 self
.font
.serif
= self
.font
.serif
or GameFontNormal
:GetFont()
104 self
.font
.fancy
= self
.font
.fancy
or QuestTitleFont
:GetFont()
106 -- Need to change the font of the chat frame, for any messages that QuestHelper displays.
107 -- This should do nothing if not using an alternate font.
108 DEFAULT_CHAT_FRAME
:SetFont(self
.font
.sans
, select(2, DEFAULT_CHAT_FRAME
:GetFont()))
111 QuestHelper
.route
= {}
112 QuestHelper
.to_add
= {}
113 QuestHelper
.to_remove
= {}
114 QuestHelper
.quest_log
= {}
115 QuestHelper
.pos
= {nil, {}, 0, 0, 1, "You are here.", 0}
116 QuestHelper
.sharing
= false -- Will be set to true when sharing with at least one user.
118 function QuestHelper
.tooltip
:GetPrevLines() -- Just a helper to make life easier.
119 local last
= self
:NumLines()
120 local name
= self
:GetName()
121 return _G
[name
.."TextLeft"..last
], _G
[name
.."TextRight"..last
]
124 function QuestHelper
:SetTargetLocation(i
, x
, y
, toffset
)
125 -- Informs QuestHelper that you're going to be at some location in toffset seconds.
126 local c
, z
= unpack(QuestHelper_ZoneLookup
[i
])
128 self
.target
= self
:CreateTable()
129 self
.target
[2] = self
:CreateTable()
131 self
.target_time
= time()+(toffset
or 0)
133 x
, y
= self
.Astrolabe
:TranslateWorldMapPosition(c
, z
, x
, y
, c
, 0)
134 self
.target
[1] = self
.zone_nodes
[i
]
135 self
.target
[3] = x
* self
.continent_scales_x
[c
]
136 self
.target
[4] = y
* self
.continent_scales_y
[c
]
138 self
:SetTargetLocationRecalculate()
141 function QuestHelper
:SetTargetLocationRecalculate()
143 for i
, n
in ipairs(self
.target
[1]) do
144 local a
, b
= n
.x
-self
.target
[3], n
.y
-self
.target
[4]
145 self
.target
[2][i
] = math
.sqrt(a
*a
+b
*b
)
150 function QuestHelper
:UnsetTargetLocation()
151 -- Unsets the target set above.
153 self
:ReleaseTable(self
.target
[2])
154 self
:ReleaseTable(self
.target
)
156 self
.target_time
= nil
160 local interruptcount
= 0 -- counts how many "played gained control" messages we recieve, used for flight paths
161 local init_cartographer_later
= false
163 function QuestHelper
:Initialize()
164 local file_problem
= false
165 local expected_version
= GetAddOnMetadata("QuestHelper", "Version")
167 local expected_files
=
169 ["upgrade.lua"] = true,
171 ["recycle.lua"] = true,
172 ["objective.lua"] = true,
173 ["quest.lua"] = true,
174 ["questlog.lua"] = true,
175 ["utility.lua"] = true,
176 ["dodads.lua"] = true,
177 ["graph.lua"] = true,
178 ["teleport.lua"] = true,
179 ["pathfinding.lua"] = true,
180 ["routing.lua"] = true,
181 ["custom.lua"] = true,
183 ["hidden.lua"] = true,
186 ["mapbutton.lua"] = true,
188 ["pattern.lua"] = true,
189 ["flightpath.lua"] = true,
190 ["tracker.lua"] = true,
191 ["objtips.lua"] = true,
192 ["cartographer.lua"] = true,
193 ["tomtom.lua"] = true,
194 ["textviewer.lua"] = true,
195 ["error.lua"] = true,
196 ["timeslice.lua"] = true,
198 ["static.lua"] = true,
199 ["static_deDE.lua"] = true,
200 ["static_enUS.lua"] = true,
201 ["static_esES.lua"] = true,
202 ["static_esMX.lua"] = true,
203 ["static_frFR.lua"] = true,
204 ["static_koKR.lua"] = true,
205 ["static_ruRU.lua"] = true,
206 ["static_zhCN.lua"] = true,
207 ["static_zhTW.lua"] = true,
209 ["collect.lua"] = true,
210 ["collect_achievement.lua"] = true,
211 ["collect_lzw.lua"] = true,
212 ["collect_traveled.lua"] = true,
213 ["collect_zone.lua"] = true,
214 ["collect_location.lua"] = true,
215 ["collect_merger.lua"] = true,
216 ["collect_monster.lua"] = true,
217 ["collect_item.lua"] = true,
218 ["collect_object.lua"] = true,
219 ["collect_loot.lua"] = true,
220 ["collect_patterns.lua"] = true,
221 ["collect_flight.lua"] = true,
224 for file
, version
in pairs(QuestHelper_File
) do
225 if not expected_files
[file
] then
226 DEFAULT_CHAT_FRAME
:AddMessage("Unexpected QuestHelper file: "..file
)
228 elseif version
~= expected_version
then
229 DEFAULT_CHAT_FRAME
:AddMessage("Wrong version of QuestHelper file: "..file
.." (found '"..version
.."', should be '"..expected_version
.."')")
230 if version
~= "Development Version" and expected_version
~= "Development Version" then
231 -- Developers are allowed to mix dev versions with release versions
237 for file
in pairs(expected_files
) do
238 if not QuestHelper_File
[file
] then
239 DEFAULT_CHAT_FRAME
:AddMessage("Missing QuestHelper file: "..file
)
244 -- Don't need this table anymore.
245 QuestHelper_File
= nil
247 if QuestHelper_StaticData
and not QuestHelper_StaticData
[GetLocale()] then
249 DEFAULT_CHAT_FRAME
:AddMessage("Static data does not seem to exist")
253 message(QHText("PLEASE_RESTART"))
254 QuestHelper_ErrorCatcher_ExplicitError("not-installed-properly")
255 QuestHelper
= nil -- Just in case anybody else is checking for us, we're not home
259 if not GetCategoryList
then
260 message(QHText("PRIVATE_SERVER"))
261 QuestHelper_ErrorCatcher_ExplicitError("error id cakbep ten T")
266 if not DongleStub
then
267 message(QHText("NOT_UNZIPPED_CORRECTLY"))
268 QuestHelper_ErrorCatcher_ExplicitError("not-unzipped-properly")
269 QuestHelper
= nil -- Just in case anybody else is checking for us, we're not home
273 QuestHelper_ErrorCatcher_CompletelyStarted()
275 if not QuestHelper_StaticData
then
276 -- If there is no static data for some mysterious reason, create an empty table so that
277 -- other parts of the code can carry on as usual, using locally collected data if it exists.
278 QuestHelper_StaticData
= {}
281 QHFormatSetLocale(QuestHelper_Pref
.locale
or GetLocale())
283 if not QuestHelper_UID
then
284 QuestHelper_UID
= self
:CreateUID()
286 QuestHelper_SaveDate
= time()
288 self
.Astrolabe
= DongleStub("Astrolabe-0.4-QuestHelper")
289 QuestHelper_BuildZoneLookup()
291 if QuestHelper_Locale
~= GetLocale() then
292 self
:TextOut(QHText("LOCALE_ERROR"))
296 if not self
:ZoneSanity() then
297 self
:TextOut(QHText("ZONE_LAYOUT_ERROR"))
298 message("QuestHelper: "..QHText("ZONE_LAYOUT_ERROR"))
302 QuestHelper_UpgradeDatabase(_G
)
303 QuestHelper_UpgradeComplete()
305 if QuestHelper_SaveVersion
~= 10 then
306 self
:TextOut(QHText("DOWNGRADE_ERROR"))
310 if QuestHelper_IsPolluted(_G
) then
311 self
:TextOut(QHFormat("NAG_POLLUTED"))
312 self
:Purge(nil, true, true)
315 local signature
= expected_version
.. " on " .. GetBuildInfo()
316 QuestHelper_Quests
[signature
] = QuestHelper_Quests
[signature
] or {}
317 QuestHelper_Objectives
[signature
] = QuestHelper_Objectives
[signature
] or {}
318 QuestHelper_FlightInstructors
[signature
] = QuestHelper_FlightInstructors
[signature
] or {}
319 QuestHelper_FlightRoutes
[signature
] = QuestHelper_FlightRoutes
[signature
] or {}
321 QuestHelper_Quests_Local
= QuestHelper_Quests
[signature
]
322 QuestHelper_Objectives_Local
= QuestHelper_Objectives
[signature
]
323 QuestHelper_FlightInstructors_Local
= QuestHelper_FlightInstructors
[signature
]
324 QuestHelper_FlightRoutes_Local
= QuestHelper_FlightRoutes
[signature
]
326 QuestHelper_SeenRealms
[GetRealmName()] = true -- some attempt at tracking private servers
330 self
.player_level
= UnitLevel("player")
332 self
:UnregisterEvent("VARIABLES_LOADED")
333 self
:RegisterEvent("PLAYER_TARGET_CHANGED")
334 self
:RegisterEvent("LOOT_OPENED")
335 self
:RegisterEvent("QUEST_COMPLETE")
336 self
:RegisterEvent("QUEST_LOG_UPDATE")
337 self
:RegisterEvent("QUEST_PROGRESS")
338 self
:RegisterEvent("MERCHANT_SHOW")
339 self
:RegisterEvent("QUEST_DETAIL")
340 self
:RegisterEvent("TAXIMAP_OPENED")
341 self
:RegisterEvent("PLAYER_CONTROL_GAINED")
342 self
:RegisterEvent("PLAYER_LEVEL_UP")
343 self
:RegisterEvent("PARTY_MEMBERS_CHANGED")
344 self
:RegisterEvent("CHAT_MSG_ADDON")
345 self
:RegisterEvent("CHAT_MSG_SYSTEM")
346 self
:RegisterEvent("BAG_UPDATE")
347 self
:RegisterEvent("GOSSIP_SHOW")
348 self
:RegisterEvent("PLAYER_ENTERING_WORLD")
350 for key
, def
in pairs(QuestHelper_DefaultPref
) do
351 if QuestHelper_Pref
[key
] == nil then
352 QuestHelper_Pref
[key
] = def
356 self
:SetLocaleFonts()
358 if QuestHelper_Pref
.share
and not QuestHelper_Pref
.solo
then
362 if QuestHelper_Pref
.hide
then
363 self
.map_overlay
:Hide()
366 self
:HandlePartyChange()
370 for locale
in pairs(QuestHelper_StaticData
) do
371 if locale
~= self
.locale
then
372 -- Will delete references to locales you don't use.
373 QuestHelper_StaticData
[locale
] = nil
374 _G
["QuestHelper_StaticData_" .. locale
] = nil
378 local static
= QuestHelper_StaticData
[self
.locale
]
381 if static
.flight_instructors
then for faction
in pairs(static
.flight_instructors
) do
382 if faction
~= self
.faction
then
383 -- Will delete references to flight instructors that don't belong to your faction.
384 static
.flight_instructors
[faction
] = nil
388 if static
.quest
then for faction
in pairs(static
.quest
) do
389 if faction
~= self
.faction
then
390 -- Will delete references to quests that don't belong to your faction.
391 static
.quest
[faction
] = nil
398 -- Adding QuestHelper_CharVersion, so I know if I've already converted this characters saved data.
399 if not QuestHelper_CharVersion
then
400 -- Changing per-character flight routes, now only storing the flight points they have,
401 -- will attempt to guess the routes from this.
404 for i
, l
in pairs(QuestHelper_KnownFlightRoutes
) do
405 for key
in pairs(l
) do
410 QuestHelper_KnownFlightRoutes
= routes
412 -- Deleting the player's home again.
413 -- But using the new CharVersion variable I'm adding is cleaner that what I was doing, so I'll go with it.
414 QuestHelper_Home
= nil
415 QuestHelper_CharVersion
= 1
418 if not QuestHelper_Home
then
419 -- Not going to bother complaining about the player's home not being set, uncomment this when the home is used in routing.
420 -- self:TextOut(QHText("HOME_NOT_KNOWN"))
423 self
.minimap_dodad
= self
:CreateMipmapDodad()
425 if QuestHelper_Pref
.map_button
then
426 QuestHelper
:InitMapButton()
429 if QuestHelper_Pref
.cart_wp
then
430 init_cartographer_later
= true
433 if QuestHelper_Pref
.tomtom_wp
then
437 self
.tracker
:SetScale(QuestHelper_Pref
.track_scale
)
439 if QuestHelper_Pref
.track
and not QuestHelper_Pref
.hide
then
443 local version
= GetAddOnMetadata("QuestHelper", "Version") or "Unknown"
444 if QuestHelper_Version
~= version
then
445 QuestHelper_Version
= version
449 self
:SetScript("OnUpdate", self
.OnUpdate
)
451 -- Seems to do its own garbage collection pass before fully loading, so I'll just rely on that
452 --collectgarbage("collect") -- Free everything we aren't using.
454 if self
.debug_objectives
then
455 for name
, data
in pairs(self
.debug_objectives
) do
456 self
:LoadDebugObjective(name
, data
)
460 self
.Routing
:Initialize() -- Set up the routing task
462 --[[ -- This is just an example of how the WoW profiler biases its profiles heavily.
468 for x = 0, 130000000, 1 do
474 for x = 0, 12000000, 1 do
481 for x = 0, 1200000, 1 do
489 local ta = debugprofilestop()
491 local tb = debugprofilestop()
493 local tc = debugprofilestop()
495 QuestHelper:TextOut(string.format("%d %d %d", ta, tb - ta, tc - tb))
496 QuestHelper:TextOut(string.format("%d %d", GetFunctionCPUUsage(A), GetFunctionCPUUsage(B)))
498 --/script SetCVar("scriptProfile", value)]]
502 local please_donate_enabled
= true
504 function QuestHelper
:OnEvent(event
)
505 if event
== "VARIABLES_LOADED" then
506 local tstart
= GetTime()
508 QH_Timeslice_Increment(GetTime() - tstart
, "init")
511 local tstart
= GetTime()
513 if event
== "GOSSIP_SHOW" then
514 local name
, id
= UnitName("npc"), self
:GetUnitID("npc")
516 self
:GetObjective("monster", name
).o
.id
= id
517 --self:TextOut("NPC: "..name.." = "..id)
521 if event
== "PLAYER_TARGET_CHANGED" then
522 local name
, id
= UnitName("target"), self
:GetUnitID("target")
524 self
:GetObjective("monster", name
).o
.id
= id
525 --self:TextOut("Target: "..name.." = "..id)
528 if UnitExists("target") and UnitIsVisible("target") and UnitCreatureType("target") ~= "Critter" and not UnitIsPlayer("target") and not UnitPlayerControlled("target") then
529 local index
, x
, y
= self
:UnitPosition("target")
531 if index
then -- Might not have a position if inside an instance.
534 -- Modify the weight based on how far they are from us.
535 -- We don't know the exact location (using our own location), so the farther, the less sure we are that it's correct.
536 if CheckInteractDistance("target", 3) then w
= 1
537 elseif CheckInteractDistance("target", 2) then w
= 0.89
538 elseif CheckInteractDistance("target", 1) or CheckInteractDistance("target", 4) then w
= 0.33 end
540 local monster_objective
= self
:GetObjective("monster", UnitName("target"))
541 self
:AppendObjectivePosition(monster_objective
, index
, x
, y
, w
)
543 monster_objective
.o
.faction
= (UnitFactionGroup("target") == "Alliance" and 1) or
544 (UnitFactionGroup("target") == "Horde" and 2) or nil
546 local level
= UnitLevel("target")
547 if level
and level
>= 1 then
548 local w
= monster_objective
.o
.levelw
or 0
549 monster_objective
.o
.level
= ((monster_objective
.o
.level
or 0)*w
+level
)/(w
+1)
550 monster_objective
.o
.levelw
= w
+1
556 if event
== "LOOT_OPENED" then
557 local target
= UnitName("target")
558 if target
and UnitIsDead("target") and UnitCreatureType("target") ~= "Critter" and not UnitIsPlayer("target") and not UnitPlayerControlled("target") then
559 local index
, x
, y
= self
:UnitPosition("target")
561 local monster_objective
= self
:GetObjective("monster", target
)
562 monster_objective
.o
.looted
= (monster_objective
.o
.looted
or 0) + 1
564 if index
then -- Might not have a position if inside an instance.
565 self
:AppendObjectivePosition(monster_objective
, index
, x
, y
)
568 for i
= 1, GetNumLootItems() do
569 local icon
, name
, number, rarity
= GetLootSlotInfo(i
)
571 if number and number >= 1 then
572 self
:AppendItemObjectiveDrop(self
:GetObjective("item", name
), name
, target
, number)
574 local total
= (name
:match(COPPER_AMOUNT
:gsub("%%d", "%(%%d+%)")) or 0) +
575 (name
:match(SILVER_AMOUNT
:gsub("%%d", "%(%%d+%)")) or 0) * 100 +
576 (name
:match(GOLD_AMOUNT
:gsub("%%d", "%(%%d+%)")) or 0) * 10000
579 self
:AppendObjectiveDrop(self
:GetObjective("item", "money"), target
, total
)
585 local container
= nil
587 -- Go through the players inventory and look for a locked item, we're probably looting it.
588 for bag
= 0,NUM_BAG_SLOTS
do
589 for slot
= 1,GetContainerNumSlots(bag
) do
590 local link
= GetContainerItemLink(bag
, slot
)
591 if link
and select(3, GetContainerItemInfo(bag
, slot
)) then
592 if container
== nil then
593 -- Found a locked item and haven't previously assigned to container, assign its name, or false if we fail to parse it.
594 container
= select(3, string.find(link
, "|h%[(.+)%]|h|r")) or false
596 -- Already tried to assign to a container. If there are multiple locked items, we give up.
604 local container_objective
= self
:GetObjective("item", container
)
605 container_objective
.o
.opened
= (container_objective
.o
.opened
or 0) + 1
607 for i
= 1, GetNumLootItems() do
608 local icon
, name
, number, rarity
= GetLootSlotInfo(i
)
609 if name
and number >= 1 then
610 self
:AppendItemObjectiveContainer(self
:GetObjective("item", name
), container
, number)
614 -- No idea where the items came from.
615 local index
, x
, y
= self
:PlayerPosition()
618 for i
= 1, GetNumLootItems() do
619 local icon
, name
, number, rarity
= GetLootSlotInfo(i
)
620 if name
and number >= 1 then
621 self
:AppendItemObjectivePosition(self
:GetObjective("item", name
), name
, index
, x
, y
)
629 if event
== "CHAT_MSG_SYSTEM" then
630 local home_name
= self
:convertPattern(ERR_DEATHBIND_SUCCESS_S
)(arg1
)
633 self
:TextOut(QHText("HOME_CHANGED"))
634 self
:TextOut(QHText("WILL_RESET_PATH"))
636 local home
= QuestHelper_Home
639 QuestHelper_Home
= home
642 home
[1], home
[2], home
[3], home
[4] = self
.i
, self
.x
, self
.y
, home_name
643 self
.defered_graph_reset
= true
648 if event
== "CHAT_MSG_ADDON" then
649 if arg1
== "QHpr" and (arg3
== "PARTY" or arg3
== "WHISPER") and arg4
~= UnitName("player") then
650 self
:HandleRemoteData(arg2
, arg4
)
654 if event
== "PARTY_MEMBERS_CHANGED" then
655 self
:HandlePartyChange()
658 if event
== "QUEST_LOG_UPDATE" or
659 event
== "PLAYER_LEVEL_UP" or
660 event
== "PARTY_MEMBERS_CHANGED" then
661 self
.defered_quest_scan
= true
664 if event
== "QUEST_DETAIL" then
665 if not self
.quest_giver
then self
.quest_giver
= {} end
666 local npc
= UnitName("npc")
668 -- Some NPCs aren't actually creatures, and so their positions might not be marked by PLAYER_TARGET_CHANGED.
669 local index
, x
, y
= self
:UnitPosition("npc")
671 if index
then -- Might not have a position if inside an instance.
672 local npc_objective
= self
:GetObjective("monster", npc
)
673 self
:AppendObjectivePosition(npc_objective
, index
, x
, y
)
674 self
.quest_giver
[GetTitleText()] = npc
679 if event
== "QUEST_COMPLETE" or event
== "QUEST_PROGRESS" then
680 local quest
= GetTitleText()
682 local level
, hash
= self
:GetQuestLevel(quest
)
683 if not level
or level
< 1 then
684 --self:TextOut("Don't know quest level for ".. quest.."!")
687 local q
= self
:GetQuest(quest
, level
, hash
)
693 local unit
= UnitName("npc")
698 -- Some NPCs aren't actually creatures, and so their positions might not be marked by PLAYER_TARGET_CHANGED.
699 local index
, x
, y
= self
:UnitPosition("npc")
700 if index
then -- Might not have a position if inside an instance.
701 local npc_objective
= self
:GetObjective("monster", unit
)
702 self
:AppendObjectivePosition(npc_objective
, index
, x
, y
)
704 elseif not q
.o
.finish
then
705 local index
, x
, y
= self
:PlayerPosition()
706 if index
then -- Might not have a position if inside an instance.
707 self
:AppendObjectivePosition(q
, index
, x
, y
)
713 if event
== "MERCHANT_SHOW" then
714 local npc_name
= UnitName("npc")
716 local npc_objective
= self
:GetObjective("monster", npc_name
)
719 local item_name
= GetMerchantItemInfo(index
)
722 local item_objective
= self
:GetObjective("item", item_name
)
723 if not item_objective
.o
.vendor
then
724 item_objective
.o
.vendor
= {npc_name
}
727 for i
, vendor
in ipairs(item_objective
.o
.vendor
) do
728 if npc_name
== vendor
then
734 table.insert(item_objective
.o
.vendor
, npc_name
)
744 if event
== "TAXIMAP_OPENED" then
748 if event
== "PLAYER_CONTROL_GAINED" then
749 interruptcount
= interruptcount
+ 1
752 if event
== "BAG_UPDATE" then
753 for slot
= 1,GetContainerNumSlots(arg1
) do
754 local link
= GetContainerItemLink(arg1
, slot
)
756 local id
, name
= select(3, string.find(link
, "|Hitem:(%d+):.-|h%[(.-)%]|h"))
758 self
:GetObjective("item", name
).o
.id
= tonumber(id
)
764 if event
== "PLAYER_ENTERING_WORLD" and please_donate_enabled
then
765 startup_time
= GetTime()
766 _
, month
, day
, year
= CalendarGetDate();
767 if year
> 2008 or year
== 2008 and month
> 11 or year
== 2008 and month
== 11 and day
> 24 or year
== 2008 and month
== 11 and day
< 21 then -- don't feel right about pestering people during thanksgiving
769 please_donate_enabled
= false
773 QH_Timeslice_Increment(GetTime() - tstart
, "event")
776 local map_shown_decay
= 0
777 local delayed_action
= 100
778 --local update_count = 0
781 function QuestHelper
:OnUpdate()
782 local tstart
= GetTime()
784 if please_donate_enabled
and startup_time
and startup_time
+ 1 < GetTime() then
785 QuestHelper
:TextOut(QHText("PLEASE_DONATE"))
787 please_donate_enabled
= false
790 if init_cartographer_later
and Cartographer_Waypoints
then -- there has to be a better way to do this
791 init_cartographer_later
= false
792 if QuestHelper_Pref
.cart_wp
then
793 self
:EnableCartographer()
797 if not ontaxi
and UnitOnTaxi("player") then
800 elseif ontaxi
and not UnitOnTaxi("player") then
801 self
:flightEnded(interruptcount
> 1)
803 ontaxi
= UnitOnTaxi("player")
805 -- For now I'm ripping out the update_count code
806 --update_count = update_count - 1
807 --if update_count <= 0 then
809 -- Reset the update count for next time around; this will make sure the body executes every time
810 -- when perf_scale >= 1, and down to 1 in 10 iterations when perf_scale < 1, or when hidden.
811 --update_count = update_count + (QuestHelper_Pref.hide and 10 or 1/QuestHelper_Pref.perf_scale)
813 --if update_count < 0 then
814 -- Make sure the count doesn't go perpetually negative; don't know what will happen if it underflows.
818 if self
.Astrolabe
.WorldMapVisible
then
819 -- We won't trust that the zone returned by Astrolabe is correct until map_shown_decay is 0.
821 elseif map_shown_decay
> 0 then
822 map_shown_decay
= map_shown_decay
- 1
824 --SetMapToCurrentZone() -- not sure why this existed
827 delayed_action
= delayed_action
- 1
828 if delayed_action
<= 0 then
830 self
:HandlePartyChange()
833 local nc
, nz
, nx
, ny
= self
.Astrolabe
:GetCurrentPlayerPosition()
836 if nc
and nc
~= -1 then -- We just want the raw data here, before we've done anything clever.
837 tc
, tx
, ty
= self
.Astrolabe
:GetAbsoluteContinentPosition(nc
, nz
, nx
, ny
)
838 QuestHelper
: Assert(tc
and tx
and ty
) -- is it true? nobody knows! :D
841 if nc
and nc
== self
.c
and map_shown_decay
> 0 and self
.z
> 0 and self
.z
~= nz
then
842 -- There's a chance Astrolable will return the wrong zone if you're messing with the world map, if you can
843 -- be seen in that zone but aren't in it.
844 local nnx
, nny
= self
.Astrolabe
:TranslateWorldMapPosition(nc
, nz
, nx
, ny
, nc
, self
.z
)
845 if nnx
> 0 and nny
> 0 and nnx
< 1 and nny
< 1 then
846 nz
, nx
, ny
= self
.z
, nnx
, nny
850 if nc
and nc
> 0 and nz
== 0 and nc
== self
.c
and self
.z
> 0 then
851 nx
, ny
= self
.Astrolabe
:TranslateWorldMapPosition(nc
, nz
, nx
, ny
, nc
, self
.z
)
852 if nx
and ny
--[[and nx > -0.1 and ny > -0.1 and nx < 1.1 and ny < 1.1]] then -- removing the conditional because I think I can use the data even when it's a little wonky
855 nc
, nz
, nx
, ny
= nil, nil, nil, nil
859 if nc
and nz
> 0 then
860 self
.c
, self
.z
, self
.x
, self
.y
= nc
, nz
, nx
, ny
861 self
.i
= QuestHelper_IndexLookup
[nc
][nz
]
864 self
.collect_c
, self
.collect_x
, self
.collect_y
, self
.collect_rc
, self
.collect_rz
= tc
, tx
, ty
, nc
, nz
866 if self
.defered_quest_scan
and not self
.graph_in_limbo
then
867 self
.defered_quest_scan
= false
871 QH_Timeslice_Toggle("routing", not not self
.c
)
873 local level
= UnitLevel("player")
874 if level
>= 58 and self
.player_level
< 58 then
875 self
.defered_graph_reset
= true
877 self
.player_level
= level
879 self
:PumpCommMessages()
882 QH_Collector_OnUpdate()
884 QH_Timeslice_Increment(GetTime() - tstart
, "onupdate")
889 -- Some or all of these may be nil. c,x,y should be enough for a location - c is the pure continent (currently either 0 or 3 for Azeroth or Outland) and x,y are the coordinates within that continent.
890 -- rc and rz are the continent and zone that Questhelper thinks it's within. For various reasons, this isn't perfect. TODO: Base it off the map zone name identifiers instead of the map itself?
891 function QuestHelper
:RetrieveRawLocation()
892 return self
.collect_c
, self
.collect_x
, self
.collect_y
, self
.collect_rc
, self
.collect_rz
895 QuestHelper
:RegisterEvent("VARIABLES_LOADED")
896 QuestHelper
:SetScript("OnEvent", QuestHelper
.OnEvent
)