will this help? maybe
[QuestHelper.git] / manager_completed.lua
blob12f2e596e467c66abd0a755188e85141496c1fb8
1 QuestHelper_File["manager_completed.lua"] = "Development Version"
2 QuestHelper_Loadtime["manager_completed.lua"] = GetTime()
4 local completed_active = false
5 local rescan
7 function QH_Incomplete()
8 if QueryQuestsCompleted then
9 completed_active = not completed_active
10 if completed_active then
11 QuestHelper:TextOut("Activating incomplete quest list. Please check your map.")
12 else
13 QuestHelper:TextOut("Deactivating incomplete quest list.")
14 end
15 rescan()
16 else
17 QuestHelper:TextOut("This feature isn't available until the WoW 3.3 patch. Sorry!")
18 end
19 end
21 if not QueryQuestsCompleted then return end
24 local quests = {}
26 local temp_notifications = {}
28 function QH_GetCompletedTable()
29 return quests
30 end
32 local notifications = {}
34 function QH_AddCompletionNotifier(func)
35 table.insert(notifications, func)
36 end
38 local function notify()
39 for _, v in ipairs(notifications) do
40 v(quests)
41 end
42 end
44 local poll_again = true
45 local poll_timeout = GetTime() + 30
46 local poll_first = true
48 QH_Event("QUEST_QUERY_COMPLETE", function ()
49 quests = GetQuestsCompleted() -- entertainingly, we actually want exactly the output of this. How convenient! Blizzard does things right <3 forever
51 notify()
52 end)
54 local GetQuestReward_Orig = GetQuestReward
55 GetQuestReward = function (...)
56 poll_again = true
57 GetQuestReward_Orig(...)
58 end
60 QH_OnUpdate(function()
61 if poll_again and poll_timeout < GetTime() then
62 QueryQuestsCompleted()
63 --print("QQC")
64 poll_again = false
65 poll_first = false
66 end
67 end, "quest_completed")
71 -- now over here we're rigging up something to scatter waypoints all over the goddamn map
72 -- we're just tossing them out like sprinkles
73 -- neon lozenges, scattered upon the ground
74 -- colors across the leaves, sucrose stars hangin' out across the foliage
75 -- here comes a squirrel
76 -- oh look it is eating the candy! how adorable
77 -- we should take it home and keep it as a pet
78 -- now you understand waypoints.
79 -- Aloha.
80 local waypoint_zone
82 function rescan()
83 if not waypoint_zone then return end
84 if not QuestHelper.Astrolabe.WorldMapVisible then return end
86 QH_POI_Reset()
88 if not completed_active then return end
90 local questlist = DB_GetItem("questlist", waypoint_zone, true)
91 if not questlist then return end
93 local donequests = QH_GetCompletedTable()
95 for _, v in ipairs(questlist) do
96 if donequests[v] then
97 --print("Done:", v)
98 else
99 --print("Not done:", v)
100 local ql = DB_GetItem("quest", v)
101 --print(ql.start)
102 --print(ql.start.loc)
103 --print(ql.start.loc[1])
104 QH_POI_Add(waypoint_zone, ql.start.loc[1].x, ql.start.loc[1].y, string.format("%s (quest #%d)", ql.name, v))
108 QH_AddCompletionNotifier(rescan)
110 QH_Event("WORLD_MAP_UPDATE", function ()
111 local c, z = QuestHelper.Astrolabe:GetCurrentVirtualMapCZ()
112 --print(c, z)
113 if not QuestHelper_IndexLookup[c] or not QuestHelper_IndexLookup[c][z] then return end
114 QuestHelper: Assert(QuestHelper_IndexLookup[c])
115 QuestHelper: Assert(QuestHelper_IndexLookup[c][z])
116 waypoint_zone = QuestHelper_IndexLookup[c][z]
118 rescan()
119 end)