1 QuestHelper_File
["main.lua"] = "Development Version"
2 QuestHelper_Loadtime
["main.lua"] = GetTime()
4 QuestHelper
= CreateFrame("Frame", "QuestHelper", nil)
6 -- Just to make sure it's always 'seen' (there's nothing that can be seen, but still...), and therefore always updating.
7 QuestHelper
:SetFrameStrata("TOOLTIP")
9 QuestHelper_SaveVersion
= 10
10 QuestHelper_CharVersion
= 1
11 QuestHelper_Locale
= GetLocale() -- This variable is used only for the collected data, and has nothing to do with displayed text.
12 QuestHelper_Quests
= {}
13 QuestHelper_Objectives
= {}
18 QuestHelper_DefaultPref
=
23 filter_blocked
=false, -- Hides blocked objectives, such as quest turn-ins for incomplete quests
24 filter_watched
=false, -- Limits to Watched objectives
26 track_minimized
=false,
43 locale
= GetLocale(), -- This variable is used for display purposes, and has nothing to do with the collected data.
44 perf_scale
= 1, -- How much background processing can the current machine handle? Higher means more load, lower means better performance.
45 perfload_scale
= 1, -- Performance scale to use on startup
49 -- We do it here also in case things decide they care about preferences before the init function is called. Shouldn't happen, but maybe does.
50 setmetatable(QuestHelper_Pref
, {__index
=QuestHelper_DefaultPref
})
52 QuestHelper_FlightInstructors
= {}
53 QuestHelper_FlightLinks
= {}
54 QuestHelper_FlightRoutes
= {}
55 QuestHelper_KnownFlightRoutes
= {}
56 QuestHelper_SeenRealms
= {}
58 QuestHelper
.tooltip
= CreateFrame("GameTooltip", "QuestHelperTooltip", nil, "GameTooltipTemplate")
59 QuestHelper
.objective_objects
= {}
60 QuestHelper
.user_objectives
= {}
61 QuestHelper
.quest_objects
= {}
62 QuestHelper
.player_level
= 1
63 QuestHelper
.locale
= QuestHelper_Locale
65 QuestHelper
.faction
= (UnitFactionGroup("player") == "Alliance" and 1) or
66 (UnitFactionGroup("player") == "Horde" and 2)
68 assert(QuestHelper
.faction
)
70 QuestHelper
.font
= {serif
=GameFontNormal
:GetFont(), sans
=ChatFontNormal
:GetFont(), fancy
=QuestTitleFont
:GetFont()}
72 function QuestHelper
:GetFontPath(list_string
, font
)
74 for name
in string.gmatch(list_string
, "[^;]+") do
75 if font
:SetFont(name
, 10) then
77 elseif font
:SetFont("Interface\\AddOns\\QuestHelper\\Fonts\\"..name
, 10) then
78 return "Interface\\AddOns\\QuestHelper\\Fonts\\"..name
84 function QuestHelper
:SetLocaleFonts()
89 local font
= self
:CreateText(self
)
91 if QuestHelper_Locale
~= QuestHelper_Pref
.locale
then
92 -- Only use alternate fonts if using a language the client wasn't intended for.
93 local replacements
= QuestHelper_SubstituteFonts
[QuestHelper_Pref
.locale
]
95 self
.font
.sans
= self
:GetFontPath(replacements
.sans
, font
)
96 self
.font
.serif
= self
:GetFontPath(replacements
.serif
, font
)
97 self
.font
.fancy
= self
:GetFontPath(replacements
.fancy
, font
)
101 self
.font
.sans
= self
.font
.sans
or self
:GetFontPath(QuestHelper_Pref
.locale
.."_sans.ttf", font
)
102 self
.font
.serif
= self
.font
.serif
or self
:GetFontPath(QuestHelper_Pref
.locale
.."_serif.ttf", font
) or self
.font
.sans
103 self
.font
.fancy
= self
.font
.fancy
or self
:GetFontPath(QuestHelper_Pref
.locale
.."_fancy.ttf", font
) or self
.font
.serif
105 self
:ReleaseText(font
)
107 self
.font
.sans
= self
.font
.sans
or ChatFontNormal
:GetFont()
108 self
.font
.serif
= self
.font
.serif
or GameFontNormal
:GetFont()
109 self
.font
.fancy
= self
.font
.fancy
or QuestTitleFont
:GetFont()
111 -- Need to change the font of the chat frame, for any messages that QuestHelper displays.
112 -- This should do nothing if not using an alternate font.
113 DEFAULT_CHAT_FRAME
:SetFont(self
.font
.sans
, select(2, DEFAULT_CHAT_FRAME
:GetFont()))
116 QuestHelper
.route
= {}
117 QuestHelper
.to_add
= {}
118 QuestHelper
.to_remove
= {}
119 QuestHelper
.quest_log
= {}
120 QuestHelper
.pos
= {nil, {}, 0, 0, 1, "You are here.", 0}
121 QuestHelper
.sharing
= false -- Will be set to true when sharing with at least one user.
123 function QuestHelper
.tooltip
:GetPrevLines() -- Just a helper to make life easier.
124 local last
= self
:NumLines()
125 local name
= self
:GetName()
126 return _G
[name
.."TextLeft"..last
], _G
[name
.."TextRight"..last
]
129 function QuestHelper
:SetTargetLocation(i
, x
, y
, toffset
)
130 -- Informs QuestHelper that you're going to be at some location in toffset seconds.
131 local c
, z
= unpack(QuestHelper_ZoneLookup
[i
])
133 self
.target
= self
:CreateTable()
134 self
.target
[2] = self
:CreateTable()
136 self
.target_time
= time()+(toffset
or 0)
138 x
, y
= self
.Astrolabe
:TranslateWorldMapPosition(c
, z
, x
, y
, c
, 0)
139 self
.target
[1] = self
.zone_nodes
[i
]
140 self
.target
[3] = x
* self
.continent_scales_x
[c
]
141 self
.target
[4] = y
* self
.continent_scales_y
[c
]
143 self
:SetTargetLocationRecalculate()
146 function QuestHelper
:SetTargetLocationRecalculate()
148 for i
, n
in ipairs(self
.target
[1]) do
149 local a
, b
= n
.x
-self
.target
[3], n
.y
-self
.target
[4]
150 self
.target
[2][i
] = math
.sqrt(a
*a
+b
*b
)
155 function QuestHelper
:UnsetTargetLocation()
156 -- Unsets the target set above.
158 self
:ReleaseTable(self
.target
[2])
159 self
:ReleaseTable(self
.target
)
161 self
.target_time
= nil
165 local interruptcount
= 0 -- counts how many "played gained control" messages we recieve, used for flight paths
166 local init_cartographer_later
= false
168 function QuestHelper
:Initialize()
169 QuestHelper_Loadtime
["init_start"] = GetTime()
171 -- Use DefaultPref as fallback for unset preference keys.
172 setmetatable(QuestHelper_Pref
, {__index
=QuestHelper_DefaultPref
})
174 local file_problem
= false
175 local expected_version
= GetAddOnMetadata("QuestHelper", "Version")
177 local expected_files
=
179 ["bst_pre.lua"] = true,
180 ["bst_post.lua"] = true,
181 ["bst_astrolabe.lua"] = true,
182 ["bst_ctl.lua"] = true,
183 ["bst_libaboutpanel.lua"] = true,
185 ["upgrade.lua"] = true,
187 ["recycle.lua"] = true,
188 ["objective.lua"] = true,
189 ["quest.lua"] = true,
190 ["questlog.lua"] = true,
191 ["utility.lua"] = true,
192 ["dodads.lua"] = true,
193 ["graph.lua"] = true,
194 ["teleport.lua"] = true,
195 ["pathfinding.lua"] = true,
196 ["routing.lua"] = true,
197 ["custom.lua"] = true,
199 ["hidden.lua"] = true,
202 ["mapbutton.lua"] = true,
204 ["pattern.lua"] = true,
205 ["flightpath.lua"] = true,
206 ["tracker.lua"] = true,
207 ["objtips.lua"] = true,
208 ["cartographer.lua"] = true,
209 ["tomtom.lua"] = true,
210 ["textviewer.lua"] = true,
211 ["error.lua"] = true,
212 ["timeslice.lua"] = true,
215 ["static.lua"] = true,
216 ["static_deDE.lua"] = true,
217 ["static_enUS.lua"] = true,
218 ["static_esES.lua"] = true,
219 ["static_esMX.lua"] = true,
220 ["static_frFR.lua"] = true,
221 ["static_koKR.lua"] = true,
222 ["static_ruRU.lua"] = true,
223 ["static_zhCN.lua"] = true,
224 ["static_zhTW.lua"] = true,
226 ["collect.lua"] = true,
227 ["collect_achievement.lua"] = true,
228 ["collect_lzw.lua"] = true,
229 ["collect_traveled.lua"] = true,
230 ["collect_zone.lua"] = true,
231 ["collect_location.lua"] = true,
232 ["collect_merger.lua"] = true,
233 ["collect_monster.lua"] = true,
234 ["collect_item.lua"] = true,
235 ["collect_object.lua"] = true,
236 ["collect_loot.lua"] = true,
237 ["collect_patterns.lua"] = true,
238 ["collect_flight.lua"] = true,
239 ["collect_util.lua"] = true,
240 ["collect_quest.lua"] = true,
241 ["collect_equip.lua"] = true,
242 ["collect_notifier.lua"] = true,
243 ["collect_bitstream.lua"] = true,
244 ["collect_spec.lua"] = true,
245 ["collect_upgrade.lua"] = true,
246 ["collect_merchant.lua"] = true,
249 local uninstallederr
= ""
251 for file
, version
in pairs(QuestHelper_File
) do
252 if not expected_files
[file
] then
253 local errmsg
= "Unexpected QuestHelper file: "..file
254 DEFAULT_CHAT_FRAME
:AddMessage(errmsg
)
255 uninstallederr
= uninstallederr
.. " " .. errmsg
.. "\n"
257 elseif version
~= expected_version
then
258 local errmsg
= "Wrong version of QuestHelper file: "..file
.." (found '"..version
.."', should be '"..expected_version
.."')"
259 DEFAULT_CHAT_FRAME
:AddMessage(errmsg
)
260 uninstallederr
= uninstallederr
.. " " .. errmsg
.. "\n"
261 if version
~= "Development Version" and expected_version
~= "Development Version" then
262 -- Developers are allowed to mix dev versions with release versions
268 for file
in pairs(expected_files
) do
269 if not QuestHelper_File
[file
] then
270 local errmsg
= "Missing QuestHelper file: "..file
271 DEFAULT_CHAT_FRAME
:AddMessage(errmsg
)
272 uninstallederr
= uninstallederr
.. " " .. errmsg
.. "\n"
277 -- Don't need this table anymore.
278 QuestHelper_File
= nil
280 if QuestHelper_StaticData
and not QuestHelper_StaticData
[GetLocale()] then
281 local errmsg
= "Static data does not seem to exist"
282 DEFAULT_CHAT_FRAME
:AddMessage(errmsg
)
284 -- TODO: Are you sure this should be an error? Shouldn't we let people we don't have data for collect their own?
285 uninstallederr
= uninstallederr
.. " " .. errmsg
.. "\n"
290 message(QHText("PLEASE_RESTART"))
291 QuestHelper_ErrorCatcher_ExplicitError("not-installed-properly" .. "\n" .. uninstallederr
)
292 QuestHelper
= nil -- Just in case anybody else is checking for us, we're not home
296 if not GetCategoryList
then
297 message(QHText("PRIVATE_SERVER"))
298 QuestHelper_ErrorCatcher_ExplicitError("error id cakbep ten T")
303 if not DongleStub
then
304 message(QHText("NOT_UNZIPPED_CORRECTLY"))
305 QuestHelper_ErrorCatcher_ExplicitError("not-unzipped-properly")
306 QuestHelper
= nil -- Just in case anybody else is checking for us, we're not home
310 QuestHelper_ErrorCatcher_CompletelyStarted()
312 if not QuestHelper_StaticData
then
313 -- If there is no static data for some mysterious reason, create an empty table so that
314 -- other parts of the code can carry on as usual, using locally collected data if it exists.
315 QuestHelper_StaticData
= {}
318 QHFormatSetLocale(QuestHelper_Pref
.locale
or GetLocale())
320 if not QuestHelper_UID
then
321 QuestHelper_UID
= self
:CreateUID()
323 QuestHelper_SaveDate
= time()
325 self
.Astrolabe
= DongleStub("Astrolabe-0.4-QuestHelper")
326 QuestHelper_BuildZoneLookup()
328 if QuestHelper_Locale
~= GetLocale() then
329 self
:TextOut(QHText("LOCALE_ERROR"))
333 if not self
:ZoneSanity() then
334 self
:TextOut(QHText("ZONE_LAYOUT_ERROR"))
335 message("QuestHelper: "..QHText("ZONE_LAYOUT_ERROR"))
339 QuestHelper_UpgradeDatabase(_G
)
340 QuestHelper_UpgradeComplete()
342 if QuestHelper_SaveVersion
~= 10 then
343 self
:TextOut(QHText("DOWNGRADE_ERROR"))
347 if QuestHelper_IsPolluted(_G
) then
348 self
:TextOut(QHFormat("NAG_POLLUTED"))
349 self
:Purge(nil, true, true)
352 local signature
= expected_version
.. " on " .. GetBuildInfo()
353 QuestHelper_Quests
[signature
] = QuestHelper_Quests
[signature
] or {}
354 QuestHelper_Objectives
[signature
] = QuestHelper_Objectives
[signature
] or {}
355 QuestHelper_FlightInstructors
[signature
] = QuestHelper_FlightInstructors
[signature
] or {}
356 QuestHelper_FlightRoutes
[signature
] = QuestHelper_FlightRoutes
[signature
] or {}
358 QuestHelper_Quests_Local
= QuestHelper_Quests
[signature
]
359 QuestHelper_Objectives_Local
= QuestHelper_Objectives
[signature
]
360 QuestHelper_FlightInstructors_Local
= QuestHelper_FlightInstructors
[signature
]
361 QuestHelper_FlightRoutes_Local
= QuestHelper_FlightRoutes
[signature
]
363 QuestHelper_SeenRealms
[GetRealmName()] = true -- some attempt at tracking private servers
367 self
.player_level
= UnitLevel("player")
369 self
:UnregisterEvent("VARIABLES_LOADED")
370 self
:RegisterEvent("PLAYER_TARGET_CHANGED")
371 self
:RegisterEvent("LOOT_OPENED")
372 self
:RegisterEvent("QUEST_COMPLETE")
373 self
:RegisterEvent("QUEST_LOG_UPDATE")
374 self
:RegisterEvent("QUEST_PROGRESS")
375 self
:RegisterEvent("MERCHANT_SHOW")
376 self
:RegisterEvent("QUEST_DETAIL")
377 self
:RegisterEvent("TAXIMAP_OPENED")
378 self
:RegisterEvent("PLAYER_CONTROL_GAINED")
379 self
:RegisterEvent("PLAYER_LEVEL_UP")
380 self
:RegisterEvent("PARTY_MEMBERS_CHANGED")
381 self
:RegisterEvent("CHAT_MSG_ADDON")
382 self
:RegisterEvent("CHAT_MSG_SYSTEM")
383 self
:RegisterEvent("BAG_UPDATE")
384 self
:RegisterEvent("GOSSIP_SHOW")
385 self
:RegisterEvent("CHAT_MSG_CHANNEL_NOTICE")
387 self
:SetLocaleFonts()
389 if QuestHelper_Pref
.share
and not QuestHelper_Pref
.solo
then
393 if QuestHelper_Pref
.hide
then
394 self
.map_overlay
:Hide()
397 self
:HandlePartyChange()
401 for locale
in pairs(QuestHelper_StaticData
) do
402 if locale
~= self
.locale
then
403 -- Will delete references to locales you don't use.
404 QuestHelper_StaticData
[locale
] = nil
405 _G
["QuestHelper_StaticData_" .. locale
] = nil
409 local static
= QuestHelper_StaticData
[self
.locale
]
412 if static
.flight_instructors
then for faction
in pairs(static
.flight_instructors
) do
413 if faction
~= self
.faction
then
414 -- Will delete references to flight instructors that don't belong to your faction.
415 static
.flight_instructors
[faction
] = nil
419 if static
.quest
then for faction
in pairs(static
.quest
) do
420 if faction
~= self
.faction
then
421 -- Will delete references to quests that don't belong to your faction.
422 static
.quest
[faction
] = nil
427 -- Adding QuestHelper_CharVersion, so I know if I've already converted this characters saved data.
428 if not QuestHelper_CharVersion
then
429 -- Changing per-character flight routes, now only storing the flight points they have,
430 -- will attempt to guess the routes from this.
433 for i
, l
in pairs(QuestHelper_KnownFlightRoutes
) do
434 for key
in pairs(l
) do
439 QuestHelper_KnownFlightRoutes
= routes
441 -- Deleting the player's home again.
442 -- But using the new CharVersion variable I'm adding is cleaner that what I was doing, so I'll go with it.
443 QuestHelper_Home
= nil
444 QuestHelper_CharVersion
= 1
447 if not QuestHelper_Home
then
448 -- Not going to bother complaining about the player's home not being set, uncomment this when the home is used in routing.
449 -- self:TextOut(QHText("HOME_NOT_KNOWN"))
452 self
.minimap_dodad
= self
:CreateMipmapDodad()
454 if QuestHelper_Pref
.map_button
then
455 QuestHelper
:InitMapButton()
458 if QuestHelper_Pref
.cart_wp
then
459 init_cartographer_later
= true
462 if QuestHelper_Pref
.tomtom_wp
then
466 self
.tracker
:SetScale(QuestHelper_Pref
.track_scale
)
468 if QuestHelper_Pref
.track
and not QuestHelper_Pref
.hide
then
472 local version
= GetAddOnMetadata("QuestHelper", "Version") or "Unknown"
474 local major
, minor
= (QuestHelper_Version
or ""):match("^(%d+)%.(%d+)")
475 major
, minor
= tonumber(major
), tonumber(minor
)
477 -- For versions before 0.82, we're changing the default level offset to 3.
478 if major
== 0 and minor
and minor
< 82 and QuestHelper_Pref
.level
== 2 then
479 QuestHelper_Pref
.level
= nil
482 -- For versions before 0.84...
483 if major
== 0 and minor
and minor
< 84 then
484 -- remove all keys that match their default setting.
485 for key
, val
in pairs(QuestHelper_DefaultPref
) do
486 if QuestHelper_Pref
[key
] == val
then
487 QuestHelper_Pref
[key
] = nil
492 self
:SetScript("OnUpdate", self
.OnUpdate
)
494 -- Seems to do its own garbage collection pass before fully loading, so I'll just rely on that
495 --collectgarbage("collect") -- Free everything we aren't using.
497 if self
.debug_objectives
then
498 for name
, data
in pairs(self
.debug_objectives
) do
499 self
:LoadDebugObjective(name
, data
)
503 QH_Timeslice_Add(function ()
505 self
.Routing
:Initialize() -- Set up the routing task
508 --[[ -- This is just an example of how the WoW profiler biases its profiles heavily.
514 for x = 0, 130000000, 1 do
520 for x = 0, 12000000, 1 do
527 for x = 0, 1200000, 1 do
535 local ta = debugprofilestop()
537 local tb = debugprofilestop()
539 local tc = debugprofilestop()
541 QuestHelper:TextOut(string.format("%d %d %d", ta, tb - ta, tc - tb))
542 QuestHelper:TextOut(string.format("%d %d", GetFunctionCPUUsage(A), GetFunctionCPUUsage(B)))
544 --/script SetCVar("scriptProfile", value)]]
546 LibStub("LibAboutPanelQH").new(nil, "QuestHelper")
548 QuestHelper_Loadtime
["init_end"] = GetTime()
552 local please_donate_enabled
= false
553 local please_donate_initted
= false
555 function QuestHelper
:OnEvent(event
)
556 if event
== "VARIABLES_LOADED" then
557 local tstart
= GetTime()
559 QH_Timeslice_Increment(GetTime() - tstart
, "init")
562 local tstart
= GetTime()
564 if event
== "GOSSIP_SHOW" then
565 local name
, id
= UnitName("npc"), self
:GetUnitID("npc")
567 self
:GetObjective("monster", name
).o
.id
= id
568 --self:TextOut("NPC: "..name.." = "..id)
572 if event
== "PLAYER_TARGET_CHANGED" then
573 local name
, id
= UnitName("target"), self
:GetUnitID("target")
575 self
:GetObjective("monster", name
).o
.id
= id
576 --self:TextOut("Target: "..name.." = "..id)
579 if UnitExists("target") and UnitIsVisible("target") and UnitCreatureType("target") ~= "Critter" and not UnitIsPlayer("target") and not UnitPlayerControlled("target") then
580 local index
, x
, y
= self
:UnitPosition("target")
582 if index
then -- Might not have a position if inside an instance.
585 -- Modify the weight based on how far they are from us.
586 -- We don't know the exact location (using our own location), so the farther, the less sure we are that it's correct.
587 if CheckInteractDistance("target", 3) then w
= 1
588 elseif CheckInteractDistance("target", 2) then w
= 0.89
589 elseif CheckInteractDistance("target", 1) or CheckInteractDistance("target", 4) then w
= 0.33 end
591 local monster_objective
= self
:GetObjective("monster", UnitName("target"))
592 self
:AppendObjectivePosition(monster_objective
, index
, x
, y
, w
)
594 monster_objective
.o
.faction
= (UnitFactionGroup("target") == "Alliance" and 1) or
595 (UnitFactionGroup("target") == "Horde" and 2) or nil
597 local level
= UnitLevel("target")
598 if level
and level
>= 1 then
599 local w
= monster_objective
.o
.levelw
or 0
600 monster_objective
.o
.level
= ((monster_objective
.o
.level
or 0)*w
+level
)/(w
+1)
601 monster_objective
.o
.levelw
= w
+1
607 if event
== "LOOT_OPENED" then
608 local target
= UnitName("target")
609 if target
and UnitIsDead("target") and UnitCreatureType("target") ~= "Critter" and not UnitIsPlayer("target") and not UnitPlayerControlled("target") then
610 local index
, x
, y
= self
:UnitPosition("target")
612 local monster_objective
= self
:GetObjective("monster", target
)
613 monster_objective
.o
.looted
= (monster_objective
.o
.looted
or 0) + 1
615 if index
then -- Might not have a position if inside an instance.
616 self
:AppendObjectivePosition(monster_objective
, index
, x
, y
)
619 for i
= 1, GetNumLootItems() do
620 local icon
, name
, number, rarity
= GetLootSlotInfo(i
)
622 if number and number >= 1 then
623 self
:AppendItemObjectiveDrop(self
:GetObjective("item", name
), name
, target
, number)
625 local total
= (name
:match(COPPER_AMOUNT
:gsub("%%d", "%(%%d+%)")) or 0) +
626 (name
:match(SILVER_AMOUNT
:gsub("%%d", "%(%%d+%)")) or 0) * 100 +
627 (name
:match(GOLD_AMOUNT
:gsub("%%d", "%(%%d+%)")) or 0) * 10000
630 self
:AppendObjectiveDrop(self
:GetObjective("item", "money"), target
, total
)
636 local container
= nil
638 -- Go through the players inventory and look for a locked item, we're probably looting it.
639 for bag
= 0,NUM_BAG_SLOTS
do
640 for slot
= 1,GetContainerNumSlots(bag
) do
641 local link
= GetContainerItemLink(bag
, slot
)
642 if link
and select(3, GetContainerItemInfo(bag
, slot
)) then
643 if container
== nil then
644 -- Found a locked item and haven't previously assigned to container, assign its name, or false if we fail to parse it.
645 container
= select(3, string.find(link
, "|h%[(.+)%]|h|r")) or false
647 -- Already tried to assign to a container. If there are multiple locked items, we give up.
655 local container_objective
= self
:GetObjective("item", container
)
656 container_objective
.o
.opened
= (container_objective
.o
.opened
or 0) + 1
658 for i
= 1, GetNumLootItems() do
659 local icon
, name
, number, rarity
= GetLootSlotInfo(i
)
660 if name
and number >= 1 then
661 self
:AppendItemObjectiveContainer(self
:GetObjective("item", name
), container
, number)
665 -- No idea where the items came from.
666 local index
, x
, y
= self
:PlayerPosition()
669 for i
= 1, GetNumLootItems() do
670 local icon
, name
, number, rarity
= GetLootSlotInfo(i
)
671 if name
and number >= 1 then
672 self
:AppendItemObjectivePosition(self
:GetObjective("item", name
), name
, index
, x
, y
)
680 if event
== "CHAT_MSG_SYSTEM" then
681 local home_name
= self
:convertPattern(ERR_DEATHBIND_SUCCESS_S
)(arg1
)
684 self
:TextOut(QHText("HOME_CHANGED"))
685 self
:TextOut(QHText("WILL_RESET_PATH"))
687 local home
= QuestHelper_Home
690 QuestHelper_Home
= home
693 home
[1], home
[2], home
[3], home
[4] = self
.i
, self
.x
, self
.y
, home_name
694 self
.defered_graph_reset
= true
699 if event
== "CHAT_MSG_ADDON" then
700 if arg1
== "QHpr" and (arg3
== "PARTY" or arg3
== "WHISPER") and arg4
~= UnitName("player") then
701 self
:HandleRemoteData(arg2
, arg4
)
705 if event
== "PARTY_MEMBERS_CHANGED" then
706 self
:HandlePartyChange()
709 if event
== "QUEST_LOG_UPDATE" or
710 event
== "PLAYER_LEVEL_UP" or
711 event
== "PARTY_MEMBERS_CHANGED" then
712 self
.defered_quest_scan
= true
715 if event
== "QUEST_DETAIL" then
716 if not self
.quest_giver
then self
.quest_giver
= {} end
717 local npc
= UnitName("npc")
719 -- Some NPCs aren't actually creatures, and so their positions might not be marked by PLAYER_TARGET_CHANGED.
720 local index
, x
, y
= self
:UnitPosition("npc")
722 if index
then -- Might not have a position if inside an instance.
723 local npc_objective
= self
:GetObjective("monster", npc
)
724 self
:AppendObjectivePosition(npc_objective
, index
, x
, y
)
725 self
.quest_giver
[GetTitleText()] = npc
730 if event
== "QUEST_COMPLETE" or event
== "QUEST_PROGRESS" then
731 local quest
= GetTitleText()
733 local level
, hash
= self
:GetQuestLevel(quest
)
734 if not level
or level
< 1 then
735 --self:TextOut("Don't know quest level for ".. quest.."!")
738 local q
= self
:GetQuest(quest
, level
, hash
)
744 local unit
= UnitName("npc")
749 -- Some NPCs aren't actually creatures, and so their positions might not be marked by PLAYER_TARGET_CHANGED.
750 local index
, x
, y
= self
:UnitPosition("npc")
751 if index
then -- Might not have a position if inside an instance.
752 local npc_objective
= self
:GetObjective("monster", unit
)
753 self
:AppendObjectivePosition(npc_objective
, index
, x
, y
)
755 elseif not q
.o
.finish
then
756 local index
, x
, y
= self
:PlayerPosition()
757 if index
then -- Might not have a position if inside an instance.
758 self
:AppendObjectivePosition(q
, index
, x
, y
)
764 if event
== "MERCHANT_SHOW" then
765 local npc_name
= UnitName("npc")
767 local npc_objective
= self
:GetObjective("monster", npc_name
)
770 local item_name
= GetMerchantItemInfo(index
)
773 local item_objective
= self
:GetObjective("item", item_name
)
774 if not item_objective
.o
.vendor
then
775 item_objective
.o
.vendor
= {npc_name
}
778 for i
, vendor
in ipairs(item_objective
.o
.vendor
) do
779 if npc_name
== vendor
then
785 table.insert(item_objective
.o
.vendor
, npc_name
)
795 if event
== "TAXIMAP_OPENED" then
799 if event
== "PLAYER_CONTROL_GAINED" then
800 interruptcount
= interruptcount
+ 1
803 if event
== "BAG_UPDATE" then
804 for slot
= 1,GetContainerNumSlots(arg1
) do
805 local link
= GetContainerItemLink(arg1
, slot
)
807 local id
, name
= select(3, string.find(link
, "|Hitem:(%d+):.-|h%[(.-)%]|h"))
809 self
:GetObjective("item", name
).o
.id
= tonumber(id
)
815 if event
== "CHAT_MSG_CHANNEL_NOTICE" and please_donate_enabled
and not please_donate_initted
then
816 please_donate_enabled
= QHNagInit()
817 startup_time
= GetTime()
818 please_donate_initted
= true
823 QH_Timeslice_Increment(GetTime() - tstart
, "event")
826 local map_shown_decay
= 0
827 local delayed_action
= 100
828 --local update_count = 0
832 function QuestHelper
:OnUpdate()
833 local tstart
= GetTime()
836 if not QuestHelper_Loadtime
["onupdate"] then QuestHelper_Loadtime
["onupdate"] = GetTime() end
838 if frams
== 250 then please_donate_enabled
= false end -- TOOK TOO LONG >:(
839 if please_donate_enabled
and startup_time
and startup_time
+ 1 < GetTime() then
840 QuestHelper
:TextOut(QHText("PLEASE_DONATE"))
842 please_donate_enabled
= false
844 QHUpdateNagTick() -- These probably shouldn't be in OnUpdate. Eventually I'll move them somewhere cleaner.
846 if init_cartographer_later
and Cartographer_Waypoints
then -- there has to be a better way to do this
847 init_cartographer_later
= false
848 if QuestHelper_Pref
.cart_wp
then
849 self
:EnableCartographer()
853 if not ontaxi
and UnitOnTaxi("player") then
856 elseif ontaxi
and not UnitOnTaxi("player") then
857 self
:flightEnded(interruptcount
> 1)
859 ontaxi
= UnitOnTaxi("player")
861 -- For now I'm ripping out the update_count code
862 --update_count = update_count - 1
863 --if update_count <= 0 then
865 -- Reset the update count for next time around; this will make sure the body executes every time
866 -- when perf_scale >= 1, and down to 1 in 10 iterations when perf_scale < 1, or when hidden.
867 --update_count = update_count + (QuestHelper_Pref.hide and 10 or 1/QuestHelper_Pref.perf_scale)
869 --if update_count < 0 then
870 -- Make sure the count doesn't go perpetually negative; don't know what will happen if it underflows.
874 if self
.Astrolabe
.WorldMapVisible
then
875 -- We won't trust that the zone returned by Astrolabe is correct until map_shown_decay is 0.
877 elseif map_shown_decay
> 0 then
878 map_shown_decay
= map_shown_decay
- 1
880 --SetMapToCurrentZone() -- not sure why this existed
883 delayed_action
= delayed_action
- 1
884 if delayed_action
<= 0 then
886 self
:HandlePartyChange()
889 local nc
, nz
, nx
, ny
= self
.Astrolabe
:GetCurrentPlayerPosition()
892 if nc
and nc
~= -1 then -- We just want the raw data here, before we've done anything clever.
893 tc
, tx
, ty
= self
.Astrolabe
:GetAbsoluteContinentPosition(nc
, nz
, nx
, ny
)
894 QuestHelper
: Assert(tc
and tx
and ty
) -- is it true? nobody knows! :D
897 if nc
and nc
== self
.c
and map_shown_decay
> 0 and self
.z
> 0 and self
.z
~= nz
then
898 -- There's a chance Astrolable will return the wrong zone if you're messing with the world map, if you can
899 -- be seen in that zone but aren't in it.
900 local nnx
, nny
= self
.Astrolabe
:TranslateWorldMapPosition(nc
, nz
, nx
, ny
, nc
, self
.z
)
901 if nnx
> 0 and nny
> 0 and nnx
< 1 and nny
< 1 then
902 nz
, nx
, ny
= self
.z
, nnx
, nny
906 if nc
and nc
> 0 and nz
== 0 and nc
== self
.c
and self
.z
> 0 then
907 nx
, ny
= self
.Astrolabe
:TranslateWorldMapPosition(nc
, nz
, nx
, ny
, nc
, self
.z
)
908 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
911 nc
, nz
, nx
, ny
= nil, nil, nil, nil
915 if nc
and nz
> 0 then
916 self
.c
, self
.z
, self
.x
, self
.y
= nc
, nz
, nx
, ny
917 self
.i
= QuestHelper_IndexLookup
[nc
][nz
]
920 self
.collect_c
, self
.collect_x
, self
.collect_y
, self
.collect_rc
, self
.collect_rz
= tc
, tx
, ty
, nc
, nz
922 local level
= UnitLevel("player")
923 if level
>= 58 and self
.player_level
< 58 then
924 self
.defered_graph_reset
= true
926 if level
~= self
.player_level
then
927 self
.defered_quest_scan
= true
929 self
.player_level
= level
931 if self
.defered_quest_scan
and not self
.graph_in_limbo
then
932 self
.defered_quest_scan
= false
936 QH_Timeslice_Toggle("routing", not not self
.c
)
938 self
:PumpCommMessages()
941 QH_Collector_OnUpdate()
943 QH_Timeslice_Increment(GetTime() - tstart
, "onupdate")
948 -- 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.
949 -- 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?
950 function QuestHelper
:RetrieveRawLocation()
951 return self
.collect_c
, self
.collect_x
, self
.collect_y
, self
.collect_rc
, self
.collect_rz
954 QuestHelper
:RegisterEvent("VARIABLES_LOADED")
955 QuestHelper
:SetScript("OnEvent", QuestHelper
.OnEvent
)