1 QuestHelper_File
["manager_achievement.lua"] = "Development Version"
2 QuestHelper_Loadtime
["manager_achievement.lua"] = GetTime()
6 --X 0 is a monster kill, asset is the monster ID
7 --X 1 is winning PvP objectives in a thorough manner (holding all bases, controlling all flags)
8 --X 7 is weapon skill, asset is probably a skill ID of some sort
9 --X 8 is another achievement, asset is achievement ID
10 --X 9 is completing quests globally
11 --X 10 is completing a daily quest every day
12 --X 11 is completing quests in specific areas
13 --X 14 is completing daily quests
14 --X 27 is a quest, asset is quest ID
15 --X 28 is getting a spell cast on you, asset is a spell ID
16 --X 29 is casting a spell (often crafting), asset is a spell ID
17 --X 30 is PvP objectives (flags, assaulting, defending)
18 --X 31 is PvP kills in battleground PvP locations
19 --X 32 is winning ranked arena matches in specific locations (asset is probably a location ID)
20 --X 34 is the Squashling (owning a specific pet?), asset is the spell ID
21 --X 35 is PvP kills while under the influence of something
22 --X 36 is acquiring items (soulbound), asset is an item ID
23 --X 37 is winning arenas
24 --X 41 is eating or drinking a specific item, asset is item ID
25 --X 42 is fishing things up, asset is item ID
26 --X 43 is exploration, asset is a location ID?
27 --X 45 is purchasing 7 bank slots
28 --X 46 is exalted rep, asset is presumably some kind of faction ID
29 --X 47 is 5 reputations to exalted
30 --X 49 is equipping items, asset is a slot ID (quality is presumably encoded into flags)
31 --X 52 is killing specific classes of player
32 --X 53 is kill-a-given-race, asset is race ID?
33 -- 54 is using emotes on targets, asset ID is likely the emote ID
34 --X 56 is being a wrecking ball in Alterac Valley
35 --X 62 is getting gold from quest rewards
36 --X 67 is looting gold
37 -- 68 is reading books
38 -- 70 is killing players in world PvP locations
39 -- 72 is fishing things from schools or wreckage
40 --X 73 is killing Mal'Ganis on Heroic. Why? Who can say.
41 --X 75 is obtaining mounts
42 -- 109 is fishing, either in general or in specific locations
43 -- 110 is casting spells on specific targets, asset ID is the spell ID
44 --X 112 is learning cooking recipes
45 --X 113 is honorable kills
46 local achievement_type_blacklist
= {}
47 for _
, v
in pairs({0, 1, 7, 8, 9, 10, 11, 14, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 41, 42, 46, 47, 49, 52, 53, 56, 62, 67, 73, 75, 112, 113}) do
48 achievement_type_blacklist
[v
] = true
51 local achievement_list
= {}
53 --local crittypes = {}
54 --QuestHelper_ZorbaForgotToRemoveThis = {}
57 local qhdinfodump
= {}
58 local function qhadumpy()
59 for k
, v
in pairs(qhdinfodump
) do
62 for tk
, tv
in pairs(v
) do
66 QuestHelper
:TextOut(string.format("%d: %d, %s", k
, ct
, some
))
70 local function registerAchievement(id
)
71 --if db.achievements[id] then return end
73 local _
, title
, _
, complete
= GetAchievementInfo(id
)
74 --QuestHelper:TextOut(string.format("Registering %d (%s)", id, title))
75 local prev
= GetPreviousAchievement(id
)
79 db.achievements[id] = {
85 local dbi = db.achievements[id]
89 registerAchievement(prev
)
92 local critcount
= GetAchievementNumCriteria(id
)
93 if critcount
== 0 then record
= true end
95 for i
= 1, critcount
do
96 local crit_name
, crit_type
, crit_complete
, crit_quantity
, crit_reqquantity
, _
, _
, crit_asset
, _
, crit_id
= GetAchievementCriteriaInfo(id
, i
)
98 if qhdinfo
and not achievement_type_blacklist
[crit_type
] then
99 if not qhdinfodump
[crit_type
] then qhdinfodump
[crit_type
] = {} end
100 qhdinfodump
[crit_type
][title
.. " --- " .. crit_name
] = true
104 table.insert(dbi.criterialist, crit_id)
105 ass ert (not db.criteria[crit_id])
106 crittypes[crit_type] = (crittypes[crit_type] or 0) + 1]]
108 if not achievement_type_blacklist
[crit_type
] then record
= true end
111 db.criteria[crit_id] = {
114 complete = crit_complete,
115 progress = crit_quantity,
116 progress_total = crit_reqquantity,
121 if record
then achievement_list
[id
] = true end
124 local function createAchievementList()
125 for _
, catid
in pairs(GetCategoryList()) do
126 for d
= 1, GetCategoryNumAchievements(catid
) do
127 registerAchievement(GetAchievementInfo(catid
, d
), db
)
132 local achievement_stop_time
= 0
134 local GetAchievementInfo
= GetAchievementInfo
135 local GetAchievementNumCriteria
= GetAchievementNumCriteria
136 local GetAchievementCriteriaInfo
= GetAchievementCriteriaInfo
138 local function retrieveAchievement(id
, db
)
141 local _
, _
, _
, complete
= GetAchievementInfo(id
)
142 --QuestHelper:TextOut(string.format("Registering %d (%s)", id, title))
144 db
.achievements
[id
] = QuestHelper
:CreateTable("collect_achievement achievement")
145 db
.achievements
[id
].complete
= complete
147 local dbi
= db
.achievements
[id
]
149 local critcount
= GetAchievementNumCriteria(id
)
151 --QuestHelper:TextOut(string.format("%d criteria", crit))
152 for i
= 1, critcount
do
153 QuestHelper
: Assert(not db
.criteria
[crit_id
])
154 local _
, _
, crit_complete
, crit_quantity
, crit_reqquantity
, _
, _
, _
, _
, crit_id
= GetAchievementCriteriaInfo(id
, i
)
156 db
.criteria
[crit_id
] = QuestHelper
:CreateTable("collect_achievement criteria")
157 db
.criteria
[crit_id
].complete
= crit_complete
158 db
.criteria
[crit_id
].progress
= crit_quantity
159 db
.criteria
[crit_id
].parent
= id
163 local function getAchievementDB()
169 for k
in pairs(achievement_list
) do
170 retrieveAchievement(k
, db
)
173 --QuestHelper: TextOut(tostring(ct))
179 local registered
= {}
182 function QH_AchievementManagerRegister(funky
) -- I am imagining "funky" being said in the same tone of voice that "spicy" is in Puzzle Pirates
183 table.insert(registered
, funky
)
185 function QH_AchievementManagerRegister_Prescan(funky
)
186 table.insert(prescan
, funky
)
189 local updating
= false
190 local updating_continue
= false
192 local function ScanAchievements()
193 while updating_continue
do
194 updating_continue
= false
196 for _
, v
in ipairs(prescan
) do
200 local old
= AchievementDB
201 local new
= getAchievementDB()
203 for _
, v
in ipairs(registered
) do
213 local function OnEvent()
214 --print("oe", updating, AchievementDB)
215 if not updating
and AchievementDB
then
217 QH_Timeslice_Add(ScanAchievements
, "criteria")
220 updating_continue
= true
224 QH_Event("CRITERIA_UPDATE", OnEvent
)
225 QH_Event("ACHIEVEMENT_EARNED", OnEvent
)
227 function QH_AchievementManagerRegister_Poke()
231 createAchievementList()
233 local function prod_achievement()
236 function QH_AchievementManager_Init()
237 AchievementDB
= getAchievementDB() -- 'coz we're lazy
241 if QuestHelper_File
["manager_achievement.lua"] == "Development Version" then
243 -- runnin' around like a headless chicken
244 -- collidin' with walls
245 -- fallin' over backwards, waving arms wildly
246 -- little bit of drool
247 -- you know how it goes
251 local function eatAchievement(id
)
252 local _
, title
, _
, complete
= GetAchievementInfo(id
)
253 --QuestHelper:TextOut(string.format("Registering %d (%s)", id, title))
254 local prev
= GetPreviousAchievement(id
)
259 registerAchievement(prev
)
262 local critcount
= GetAchievementNumCriteria(id
)
264 the_data
[id
] = {name
= title
}
266 for i
= 1, critcount
do
267 local _
, crit_type
, _
, _
, _
, _
, _
, crit_asset
, _
, crit_id
= GetAchievementCriteriaInfo(id
, i
)
269 the_data
[id
]["crit_" .. crit_type
] = (the_data
["crit_" .. crit_type
] or 0) + 1
271 if crit_type
== 0 then
272 the_data
[id
]["monster_" .. crit_asset
] = true
277 function dump_the_data_zorba_needs()
279 QuestHelper_Errors
.achievement_cruft
= the_data
281 for _
, catid
in pairs(GetCategoryList()) do
282 for d
= 1, GetCategoryNumAchievements(catid
) do
283 eatAchievement(GetAchievementInfo(catid
, d
))