jcallahan@246
|
1 -- LUA API ------------------------------------------------------------
|
jcallahan@246
|
2
|
jcallahan@0
|
3 local _G = getfenv(0)
|
jcallahan@0
|
4
|
jcallahan@0
|
5 local pairs = _G.pairs
|
jcallahan@1
|
6 local tonumber = _G.tonumber
|
jcallahan@1
|
7
|
jcallahan@1
|
8 local bit = _G.bit
|
jcallahan@1
|
9 local math = _G.math
|
jcallahan@1
|
10 local table = _G.table
|
jcallahan@1
|
11
|
jcallahan@78
|
12 local select = _G.select
|
jcallahan@78
|
13
|
jcallahan@0
|
14
|
jcallahan@246
|
15 -- ADDON NAMESPACE ----------------------------------------------------
|
jcallahan@246
|
16
|
jcallahan@0
|
17 local ADDON_NAME, private = ...
|
jcallahan@0
|
18
|
jcallahan@0
|
19 local LibStub = _G.LibStub
|
jcallahan@249
|
20 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0")
|
jcallahan@0
|
21
|
jcallahan@48
|
22 local deformat = LibStub("LibDeformat-3.0")
|
jcallahan@115
|
23 local LPJ = LibStub("LibPetJournal-2.0")
|
jcallahan@141
|
24 local MapData = LibStub("LibMapData-1.0")
|
jcallahan@48
|
25
|
jcallahan@4
|
26 local DatamineTT = _G.CreateFrame("GameTooltip", "WDPDatamineTT", _G.UIParent, "GameTooltipTemplate")
|
jcallahan@5
|
27 DatamineTT:SetOwner(_G.WorldFrame, "ANCHOR_NONE")
|
jcallahan@5
|
28
|
jcallahan@0
|
29
|
jcallahan@246
|
30 -- CONSTANTS ----------------------------------------------------------
|
jcallahan@246
|
31
|
jcallahan@246
|
32 local AF = private.ACTION_TYPE_FLAGS
|
jcallahan@246
|
33 local CLIENT_LOCALE = _G.GetLocale()
|
jcallahan@239
|
34 local DB_VERSION = 16
|
jcallahan@246
|
35 local DEBUGGING = false
|
jcallahan@156
|
36 local EVENT_DEBUG = false
|
jcallahan@246
|
37 local OBJECT_ID_ANVIL = 192628
|
jcallahan@246
|
38 local OBJECT_ID_FORGE = 1685
|
jcallahan@246
|
39 local PLAYER_CLASS = _G.select(2, _G.UnitClass("player"))
|
jcallahan@246
|
40 local PLAYER_FACTION = _G.UnitFactionGroup("player")
|
jcallahan@246
|
41 local PLAYER_GUID = _G.UnitGUID("player")
|
jcallahan@246
|
42 local PLAYER_NAME = _G.UnitName("player")
|
jcallahan@246
|
43 local PLAYER_RACE = _G.select(2, _G.UnitRace("player"))
|
jcallahan@246
|
44
|
jcallahan@246
|
45 local ALLOWED_LOCALES = {
|
jcallahan@246
|
46 enUS = true,
|
jcallahan@246
|
47 enGB = true,
|
jcallahan@246
|
48 }
|
jcallahan@157
|
49
|
jcallahan@0
|
50 local DATABASE_DEFAULTS = {
|
jcallahan@128
|
51 char = {},
|
jcallahan@0
|
52 global = {
|
jcallahan@0
|
53 items = {},
|
jcallahan@0
|
54 npcs = {},
|
jcallahan@0
|
55 objects = {},
|
jcallahan@0
|
56 quests = {},
|
jcallahan@167
|
57 spells = {},
|
jcallahan@17
|
58 zones = {},
|
jcallahan@0
|
59 }
|
jcallahan@0
|
60 }
|
jcallahan@0
|
61
|
jcallahan@1
|
62 local EVENT_MAPPING = {
|
jcallahan@90
|
63 AUCTION_HOUSE_SHOW = true,
|
jcallahan@90
|
64 BANKFRAME_OPENED = true,
|
jcallahan@90
|
65 BATTLEFIELDS_SHOW = true,
|
jcallahan@56
|
66 BLACK_MARKET_ITEM_UPDATE = true,
|
jcallahan@48
|
67 CHAT_MSG_LOOT = true,
|
jcallahan@95
|
68 CHAT_MSG_MONSTER_SAY = "RecordQuote",
|
jcallahan@95
|
69 CHAT_MSG_MONSTER_WHISPER = "RecordQuote",
|
jcallahan@95
|
70 CHAT_MSG_MONSTER_YELL = "RecordQuote",
|
jcallahan@40
|
71 CHAT_MSG_SYSTEM = true,
|
jcallahan@23
|
72 COMBAT_LOG_EVENT_UNFILTERED = true,
|
jcallahan@18
|
73 COMBAT_TEXT_UPDATE = true,
|
jcallahan@140
|
74 CURSOR_UPDATE = true,
|
jcallahan@90
|
75 FORGE_MASTER_OPENED = true,
|
jcallahan@90
|
76 GOSSIP_SHOW = true,
|
jcallahan@246
|
77 GROUP_ROSTER_CHANGE = true,
|
jcallahan@93
|
78 GUILDBANKFRAME_OPENED = true,
|
jcallahan@42
|
79 ITEM_TEXT_BEGIN = true,
|
jcallahan@189
|
80 ITEM_UPGRADE_MASTER_OPENED = true,
|
jcallahan@124
|
81 LOOT_CLOSED = true,
|
jcallahan@1
|
82 LOOT_OPENED = true,
|
jcallahan@89
|
83 MAIL_SHOW = true,
|
jcallahan@133
|
84 MERCHANT_CLOSED = true,
|
jcallahan@7
|
85 MERCHANT_SHOW = "UpdateMerchantItems",
|
jcallahan@61
|
86 MERCHANT_UPDATE = "UpdateMerchantItems",
|
jcallahan@25
|
87 PET_BAR_UPDATE = true,
|
jcallahan@115
|
88 PET_JOURNAL_LIST_UPDATE = true,
|
jcallahan@156
|
89 PLAYER_REGEN_DISABLED = true,
|
jcallahan@156
|
90 PLAYER_REGEN_ENABLED = true,
|
jcallahan@2
|
91 PLAYER_TARGET_CHANGED = true,
|
jcallahan@9
|
92 QUEST_COMPLETE = true,
|
jcallahan@9
|
93 QUEST_DETAIL = true,
|
jcallahan@9
|
94 QUEST_LOG_UPDATE = true,
|
jcallahan@97
|
95 QUEST_PROGRESS = true,
|
jcallahan@178
|
96 SHOW_LOOT_TOAST = true,
|
jcallahan@88
|
97 TAXIMAP_OPENED = true,
|
jcallahan@92
|
98 TRADE_SKILL_SHOW = true,
|
jcallahan@167
|
99 TRAINER_CLOSED = true,
|
jcallahan@27
|
100 TRAINER_SHOW = true,
|
jcallahan@90
|
101 TRANSMOGRIFY_OPEN = true,
|
jcallahan@246
|
102 UNIT_PET = true,
|
jcallahan@4
|
103 UNIT_QUEST_LOG_CHANGED = true,
|
jcallahan@1
|
104 UNIT_SPELLCAST_FAILED = "HandleSpellFailure",
|
jcallahan@1
|
105 UNIT_SPELLCAST_FAILED_QUIET = "HandleSpellFailure",
|
jcallahan@1
|
106 UNIT_SPELLCAST_INTERRUPTED = "HandleSpellFailure",
|
jcallahan@1
|
107 UNIT_SPELLCAST_SENT = true,
|
jcallahan@1
|
108 UNIT_SPELLCAST_SUCCEEDED = true,
|
jcallahan@90
|
109 VOID_STORAGE_OPEN = true,
|
jcallahan@129
|
110 ZONE_CHANGED = "SetCurrentAreaID",
|
jcallahan@129
|
111 ZONE_CHANGED_INDOORS = "SetCurrentAreaID",
|
jcallahan@129
|
112 ZONE_CHANGED_NEW_AREA = "SetCurrentAreaID",
|
jcallahan@0
|
113 }
|
jcallahan@0
|
114
|
jcallahan@4
|
115
|
jcallahan@246
|
116 -- VARIABLES ----------------------------------------------------------
|
jcallahan@246
|
117
|
jcallahan@92
|
118 local anvil_spell_ids = {}
|
jcallahan@92
|
119 local currently_drunk
|
jcallahan@128
|
120 local char_db
|
jcallahan@128
|
121 local global_db
|
jcallahan@246
|
122 local group_member_uids = {}
|
jcallahan@246
|
123 local group_owner_guids_to_pet_guids = {}
|
jcallahan@246
|
124 local group_pet_guids = {}
|
jcallahan@187
|
125 local item_process_timer_handle
|
jcallahan@92
|
126 local faction_standings = {}
|
jcallahan@92
|
127 local forge_spell_ids = {}
|
jcallahan@95
|
128 local languages_known = {}
|
jcallahan@95
|
129 local name_to_id_map = {}
|
jcallahan@177
|
130 local killed_npc_id
|
jcallahan@2
|
131 local target_location_timer_handle
|
jcallahan@86
|
132 local current_target_id
|
jcallahan@126
|
133 local current_area_id
|
jcallahan@131
|
134 local current_loot
|
jcallahan@1
|
135
|
jcallahan@121
|
136 -- Data for our current action. Including possible values as a reference.
|
jcallahan@122
|
137 local current_action = {
|
jcallahan@121
|
138 identifier = nil,
|
jcallahan@121
|
139 loot_label = nil,
|
jcallahan@121
|
140 loot_list = nil,
|
jcallahan@121
|
141 loot_sources = nil,
|
jcallahan@121
|
142 map_level = nil,
|
jcallahan@121
|
143 spell_label = nil,
|
jcallahan@123
|
144 target_type = nil,
|
jcallahan@121
|
145 x = nil,
|
jcallahan@121
|
146 y = nil,
|
jcallahan@121
|
147 zone_data = nil,
|
jcallahan@121
|
148 }
|
jcallahan@92
|
149
|
jcallahan@246
|
150
|
jcallahan@246
|
151 -- HELPERS ------------------------------------------------------------
|
jcallahan@246
|
152
|
jcallahan@245
|
153 local function Debug(message, ...)
|
jcallahan@151
|
154 if not DEBUGGING then
|
jcallahan@151
|
155 return
|
jcallahan@151
|
156 end
|
jcallahan@245
|
157 _G.print(message:format(...))
|
jcallahan@151
|
158 end
|
jcallahan@151
|
159
|
jcallahan@151
|
160
|
jcallahan@169
|
161 local TradeSkillExecutePer
|
jcallahan@169
|
162 do
|
jcallahan@169
|
163 local header_list = {}
|
jcallahan@169
|
164
|
jcallahan@169
|
165 -- iter_func returns true to indicate that the loop should be broken
|
jcallahan@169
|
166 function TradeSkillExecutePer(iter_func)
|
jcallahan@169
|
167 if not _G.TradeSkillFrame or not _G.TradeSkillFrame:IsVisible() then
|
jcallahan@169
|
168 return
|
jcallahan@169
|
169 end
|
jcallahan@167
|
170 -- Clear the search box focus so the scan will have correct results.
|
jcallahan@167
|
171 local search_box = _G.TradeSkillFrameSearchBox
|
jcallahan@167
|
172 search_box:SetText("")
|
jcallahan@169
|
173
|
jcallahan@167
|
174 _G.TradeSkillSearch_OnTextChanged(search_box)
|
jcallahan@167
|
175 search_box:ClearFocus()
|
jcallahan@167
|
176 search_box:GetScript("OnEditFocusLost")(search_box)
|
jcallahan@169
|
177
|
jcallahan@169
|
178 table.wipe(header_list)
|
jcallahan@169
|
179
|
jcallahan@169
|
180 -- Save the current state of the TradeSkillFrame so it can be restored after we muck with it.
|
jcallahan@169
|
181 local have_materials = _G.TradeSkillFrame.filterTbl.hasMaterials
|
jcallahan@169
|
182 local have_skillup = _G.TradeSkillFrame.filterTbl.hasSkillUp
|
jcallahan@169
|
183
|
jcallahan@169
|
184 if have_materials then
|
jcallahan@169
|
185 _G.TradeSkillFrame.filterTbl.hasMaterials = false
|
jcallahan@169
|
186 _G.TradeSkillOnlyShowMakeable(false)
|
jcallahan@169
|
187 end
|
jcallahan@169
|
188
|
jcallahan@169
|
189 if have_skillup then
|
jcallahan@169
|
190 _G.TradeSkillFrame.filterTbl.hasSkillUp = false
|
jcallahan@169
|
191 _G.TradeSkillOnlyShowSkillUps(false)
|
jcallahan@169
|
192 end
|
jcallahan@169
|
193 _G.SetTradeSkillInvSlotFilter(0, 1, 1)
|
jcallahan@169
|
194 _G.TradeSkillUpdateFilterBar()
|
jcallahan@169
|
195 _G.TradeSkillFrame_Update()
|
jcallahan@169
|
196
|
jcallahan@169
|
197 -- Expand all headers so we can see all the recipes there are
|
jcallahan@169
|
198 for tradeskill_index = 1, _G.GetNumTradeSkills() do
|
jcallahan@169
|
199 local name, tradeskill_type, _, is_expanded = _G.GetTradeSkillInfo(tradeskill_index)
|
jcallahan@169
|
200
|
jcallahan@169
|
201 if tradeskill_type == "header" or tradeskill_type == "subheader" then
|
jcallahan@169
|
202 if not is_expanded then
|
jcallahan@169
|
203 header_list[name] = true
|
jcallahan@169
|
204 _G.ExpandTradeSkillSubClass(tradeskill_index)
|
jcallahan@169
|
205 end
|
jcallahan@169
|
206 elseif iter_func(name, tradeskill_index) then
|
jcallahan@169
|
207 break
|
jcallahan@169
|
208 end
|
jcallahan@169
|
209 end
|
jcallahan@169
|
210
|
jcallahan@169
|
211 -- Restore the state of the things we changed.
|
jcallahan@169
|
212 for tradeskill_index = 1, _G.GetNumTradeSkills() do
|
jcallahan@169
|
213 local name, tradeskill_type, _, is_expanded = _G.GetTradeSkillInfo(tradeskill_index)
|
jcallahan@169
|
214
|
jcallahan@169
|
215 if header_list[name] then
|
jcallahan@169
|
216 _G.CollapseTradeSkillSubClass(tradeskill_index)
|
jcallahan@169
|
217 end
|
jcallahan@169
|
218 end
|
jcallahan@169
|
219 _G.TradeSkillFrame.filterTbl.hasMaterials = have_materials
|
jcallahan@169
|
220 _G.TradeSkillOnlyShowMakeable(have_materials)
|
jcallahan@169
|
221 _G.TradeSkillFrame.filterTbl.hasSkillUp = have_skillup
|
jcallahan@169
|
222 _G.TradeSkillOnlyShowSkillUps(have_skillup)
|
jcallahan@169
|
223
|
jcallahan@169
|
224 _G.TradeSkillUpdateFilterBar()
|
jcallahan@169
|
225 _G.TradeSkillFrame_Update()
|
jcallahan@167
|
226 end
|
jcallahan@169
|
227 end -- do-block
|
jcallahan@167
|
228
|
jcallahan@167
|
229
|
jcallahan@39
|
230 local ActualCopperCost
|
jcallahan@39
|
231 do
|
jcallahan@39
|
232 local BARTERING_SPELL_ID = 83964
|
jcallahan@39
|
233
|
jcallahan@39
|
234 local STANDING_DISCOUNTS = {
|
jcallahan@39
|
235 HATED = 0,
|
jcallahan@39
|
236 HOSTILE = 0,
|
jcallahan@39
|
237 UNFRIENDLY = 0,
|
jcallahan@39
|
238 NEUTRAL = 0,
|
jcallahan@39
|
239 FRIENDLY = 0.05,
|
jcallahan@39
|
240 HONORED = 0.1,
|
jcallahan@39
|
241 REVERED = 0.15,
|
jcallahan@39
|
242 EXALTED = 0.2,
|
jcallahan@39
|
243 }
|
jcallahan@39
|
244
|
jcallahan@39
|
245
|
jcallahan@39
|
246 function ActualCopperCost(copper_cost, rep_standing)
|
jcallahan@39
|
247 if not copper_cost or copper_cost == 0 then
|
jcallahan@39
|
248 return 0
|
jcallahan@39
|
249 end
|
jcallahan@39
|
250 local modifier = 1
|
jcallahan@39
|
251
|
jcallahan@39
|
252 if _G.IsSpellKnown(BARTERING_SPELL_ID) then
|
jcallahan@39
|
253 modifier = modifier - 0.1
|
jcallahan@39
|
254 end
|
jcallahan@39
|
255
|
jcallahan@39
|
256 if rep_standing then
|
jcallahan@39
|
257 if PLAYER_RACE == "Goblin" then
|
jcallahan@39
|
258 modifier = modifier - STANDING_DISCOUNTS["EXALTED"]
|
jcallahan@39
|
259 elseif STANDING_DISCOUNTS[rep_standing] then
|
jcallahan@39
|
260 modifier = modifier - STANDING_DISCOUNTS[rep_standing]
|
jcallahan@39
|
261 end
|
jcallahan@39
|
262 end
|
jcallahan@39
|
263 return math.floor(copper_cost / modifier)
|
jcallahan@39
|
264 end
|
jcallahan@39
|
265 end -- do-block
|
jcallahan@39
|
266
|
jcallahan@39
|
267
|
jcallahan@153
|
268 -- Called on a timer
|
jcallahan@177
|
269 local function ClearKilledNPC()
|
jcallahan@177
|
270 killed_npc_id = nil
|
jcallahan@177
|
271 end
|
jcallahan@177
|
272
|
jcallahan@177
|
273
|
jcallahan@203
|
274 local function ClearKilledBossID()
|
jcallahan@203
|
275 private.raid_finder_boss_id = nil
|
jcallahan@203
|
276 private.world_boss_id = nil
|
jcallahan@203
|
277 end
|
jcallahan@203
|
278
|
jcallahan@203
|
279
|
jcallahan@29
|
280 local function InstanceDifficultyToken()
|
jcallahan@233
|
281 local _, instance_type, instance_difficulty, _, _, _, is_dynamic = _G.GetInstanceInfo()
|
jcallahan@59
|
282
|
jcallahan@59
|
283 if not instance_type or instance_type == "" then
|
jcallahan@59
|
284 instance_type = "NONE"
|
jcallahan@59
|
285 end
|
jcallahan@233
|
286 return ("%s:%d:%s"):format(instance_type:upper(), instance_difficulty, _G.tostring(is_dynamic))
|
jcallahan@29
|
287 end
|
jcallahan@29
|
288
|
jcallahan@29
|
289
|
jcallahan@19
|
290 local function DBEntry(data_type, unit_id)
|
jcallahan@19
|
291 if not data_type or not unit_id then
|
jcallahan@6
|
292 return
|
jcallahan@6
|
293 end
|
jcallahan@128
|
294 local unit = global_db[data_type][unit_id]
|
jcallahan@6
|
295
|
jcallahan@10
|
296 if not unit then
|
jcallahan@187
|
297 unit = {}
|
jcallahan@187
|
298 global_db[data_type][unit_id] = unit
|
jcallahan@6
|
299 end
|
jcallahan@10
|
300 return unit
|
jcallahan@6
|
301 end
|
jcallahan@263
|
302 private.DBEntry = DBEntry
|
jcallahan@6
|
303
|
jcallahan@214
|
304 local NPCEntry
|
jcallahan@214
|
305 do
|
jcallahan@214
|
306 local npc_prototype = {}
|
jcallahan@214
|
307 local npc_meta = {
|
jcallahan@214
|
308 __index = npc_prototype
|
jcallahan@214
|
309 }
|
jcallahan@6
|
310
|
jcallahan@214
|
311 function NPCEntry(identifier)
|
jcallahan@227
|
312 local npc = DBEntry("npcs", identifier)
|
jcallahan@29
|
313
|
jcallahan@214
|
314 if not npc then
|
jcallahan@214
|
315 return
|
jcallahan@214
|
316 end
|
jcallahan@227
|
317 return _G.setmetatable(npc, npc_meta)
|
jcallahan@22
|
318 end
|
jcallahan@214
|
319
|
jcallahan@248
|
320 function npc_prototype:EncounterData(difficulty_token)
|
jcallahan@214
|
321 self.encounter_data = self.encounter_data or {}
|
jcallahan@248
|
322 self.encounter_data[difficulty_token] = self.encounter_data[difficulty_token] or {}
|
jcallahan@248
|
323 self.encounter_data[difficulty_token].stats = self.encounter_data[difficulty_token].stats or {}
|
jcallahan@248
|
324
|
jcallahan@248
|
325 return self.encounter_data[difficulty_token]
|
jcallahan@214
|
326 end
|
jcallahan@22
|
327 end
|
jcallahan@22
|
328
|
jcallahan@22
|
329
|
jcallahan@1
|
330 local function CurrentLocationData()
|
jcallahan@161
|
331 if _G.GetCurrentMapAreaID() ~= current_area_id then
|
jcallahan@145
|
332 return _G.GetRealZoneText(), current_area_id, 0, 0, 0, InstanceDifficultyToken()
|
jcallahan@145
|
333 end
|
jcallahan@1
|
334 local map_level = _G.GetCurrentMapDungeonLevel() or 0
|
jcallahan@1
|
335 local x, y = _G.GetPlayerMapPosition("player")
|
jcallahan@1
|
336
|
jcallahan@1
|
337 x = x or 0
|
jcallahan@1
|
338 y = y or 0
|
jcallahan@1
|
339
|
jcallahan@1
|
340 if x == 0 and y == 0 then
|
jcallahan@1
|
341 for level_index = 1, _G.GetNumDungeonMapLevels() do
|
jcallahan@1
|
342 _G.SetDungeonMapLevel(level_index)
|
jcallahan@1
|
343 x, y = _G.GetPlayerMapPosition("player")
|
jcallahan@1
|
344
|
jcallahan@1
|
345 if x and y and (x > 0 or y > 0) then
|
jcallahan@1
|
346 _G.SetDungeonMapLevel(map_level)
|
jcallahan@1
|
347 map_level = level_index
|
jcallahan@1
|
348 break
|
jcallahan@1
|
349 end
|
jcallahan@1
|
350 end
|
jcallahan@1
|
351 end
|
jcallahan@1
|
352
|
jcallahan@1
|
353 if _G.DungeonUsesTerrainMap() then
|
jcallahan@1
|
354 map_level = map_level - 1
|
jcallahan@1
|
355 end
|
jcallahan@31
|
356 local x = _G.floor(x * 1000)
|
jcallahan@31
|
357 local y = _G.floor(y * 1000)
|
jcallahan@28
|
358
|
jcallahan@31
|
359 if x % 2 ~= 0 then
|
jcallahan@31
|
360 x = x + 1
|
jcallahan@28
|
361 end
|
jcallahan@28
|
362
|
jcallahan@31
|
363 if y % 2 ~= 0 then
|
jcallahan@31
|
364 y = y + 1
|
jcallahan@28
|
365 end
|
jcallahan@126
|
366 return _G.GetRealZoneText(), current_area_id, x, y, map_level, InstanceDifficultyToken()
|
jcallahan@1
|
367 end
|
jcallahan@1
|
368
|
jcallahan@1
|
369
|
jcallahan@1
|
370 local function ItemLinkToID(item_link)
|
jcallahan@1
|
371 if not item_link then
|
jcallahan@1
|
372 return
|
jcallahan@1
|
373 end
|
jcallahan@7
|
374 return tonumber(item_link:match("item:(%d+)"))
|
jcallahan@1
|
375 end
|
jcallahan@260
|
376 private.ItemLinkToID = ItemLinkToID
|
jcallahan@4
|
377
|
jcallahan@171
|
378 local function UnitTypeIsNPC(unit_type)
|
jcallahan@171
|
379 return unit_type == private.UNIT_TYPES.NPC or unit_type == private.UNIT_TYPES.VEHICLE
|
jcallahan@171
|
380 end
|
jcallahan@171
|
381
|
jcallahan@171
|
382
|
jcallahan@34
|
383 local ParseGUID
|
jcallahan@4
|
384 do
|
jcallahan@229
|
385 local UNIT_TYPES = private.UNIT_TYPES
|
jcallahan@4
|
386 local UNIT_TYPE_BITMASK = 0x007
|
jcallahan@4
|
387
|
jcallahan@34
|
388 function ParseGUID(guid)
|
jcallahan@5
|
389 if not guid then
|
jcallahan@5
|
390 return
|
jcallahan@5
|
391 end
|
jcallahan@229
|
392 local bitfield = tonumber(guid:sub(1, 5))
|
jcallahan@4
|
393
|
jcallahan@229
|
394 if not bitfield then
|
jcallahan@229
|
395 return UNIT_TYPES.UNKNOWN
|
jcallahan@229
|
396 end
|
jcallahan@229
|
397 local unit_type = _G.bit.band(bitfield, UNIT_TYPE_BITMASK)
|
jcallahan@229
|
398
|
jcallahan@229
|
399 if unit_type ~= UNIT_TYPES.PLAYER and unit_type ~= UNIT_TYPES.PET then
|
jcallahan@66
|
400 return unit_type, tonumber(guid:sub(6, 10), 16)
|
jcallahan@4
|
401 end
|
jcallahan@4
|
402 return unit_type
|
jcallahan@4
|
403 end
|
jcallahan@249
|
404
|
jcallahan@249
|
405 private.ParseGUID = ParseGUID
|
jcallahan@4
|
406 end -- do-block
|
jcallahan@4
|
407
|
jcallahan@4
|
408
|
jcallahan@141
|
409 local UpdateDBEntryLocation
|
jcallahan@141
|
410 do
|
jcallahan@141
|
411 -- Fishing node coordinate code based on code in GatherMate2 with permission from Kagaro.
|
jcallahan@141
|
412 local function FishingCoordinates(x, y, yard_width, yard_height)
|
jcallahan@141
|
413 local facing = _G.GetPlayerFacing()
|
jcallahan@141
|
414
|
jcallahan@141
|
415 if not facing then
|
jcallahan@141
|
416 return x, y
|
jcallahan@141
|
417 end
|
jcallahan@246
|
418 local rad = facing + math.pi
|
jcallahan@141
|
419 return x + math.sin(rad) * 15 / yard_width, y + math.cos(rad) * 15 / yard_height
|
jcallahan@10
|
420 end
|
jcallahan@10
|
421
|
jcallahan@24
|
422
|
jcallahan@141
|
423 function UpdateDBEntryLocation(entry_type, identifier)
|
jcallahan@141
|
424 if not identifier then
|
jcallahan@141
|
425 return
|
jcallahan@141
|
426 end
|
jcallahan@141
|
427 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData()
|
jcallahan@141
|
428 local entry = DBEntry(entry_type, identifier)
|
jcallahan@141
|
429 entry[difficulty_token] = entry[difficulty_token] or {}
|
jcallahan@141
|
430 entry[difficulty_token].locations = entry[difficulty_token].locations or {}
|
jcallahan@141
|
431
|
jcallahan@141
|
432 local zone_token = ("%s:%d"):format(zone_name, area_id)
|
jcallahan@141
|
433 local zone_data = entry[difficulty_token].locations[zone_token]
|
jcallahan@141
|
434
|
jcallahan@141
|
435 if not zone_data then
|
jcallahan@141
|
436 zone_data = {}
|
jcallahan@141
|
437 entry[difficulty_token].locations[zone_token] = zone_data
|
jcallahan@141
|
438 end
|
jcallahan@141
|
439
|
jcallahan@141
|
440 -- Special case for Fishing.
|
jcallahan@141
|
441 if current_action.spell_label == "FISHING" then
|
jcallahan@141
|
442 local yard_width, yard_height = MapData:MapArea(area_id, map_level)
|
jcallahan@141
|
443
|
jcallahan@141
|
444 if yard_width > 0 and yard_height > 0 then
|
jcallahan@141
|
445 x, y = FishingCoordinates(x, y, yard_width, yard_height)
|
jcallahan@141
|
446 current_action.x = x
|
jcallahan@141
|
447 current_action.y = y
|
jcallahan@141
|
448 end
|
jcallahan@141
|
449 end
|
jcallahan@141
|
450 local location_token = ("%d:%d:%d"):format(map_level, x, y)
|
jcallahan@141
|
451
|
jcallahan@141
|
452 zone_data[location_token] = zone_data[location_token] or true
|
jcallahan@141
|
453 return zone_data
|
jcallahan@10
|
454 end
|
jcallahan@141
|
455 end -- do-block
|
jcallahan@10
|
456
|
jcallahan@10
|
457
|
jcallahan@19
|
458 local function HandleItemUse(item_link, bag_index, slot_index)
|
jcallahan@19
|
459 if not item_link then
|
jcallahan@19
|
460 return
|
jcallahan@19
|
461 end
|
jcallahan@19
|
462 local item_id = ItemLinkToID(item_link)
|
jcallahan@19
|
463
|
jcallahan@19
|
464 if not bag_index or not slot_index then
|
jcallahan@19
|
465 for new_bag_index = 0, _G.NUM_BAG_FRAMES do
|
jcallahan@19
|
466 for new_slot_index = 1, _G.GetContainerNumSlots(new_bag_index) do
|
jcallahan@19
|
467 if item_id == ItemLinkToID(_G.GetContainerItemLink(new_bag_index, new_slot_index)) then
|
jcallahan@19
|
468 bag_index = new_bag_index
|
jcallahan@19
|
469 slot_index = new_slot_index
|
jcallahan@19
|
470 break
|
jcallahan@19
|
471 end
|
jcallahan@19
|
472 end
|
jcallahan@19
|
473 end
|
jcallahan@19
|
474 end
|
jcallahan@19
|
475
|
jcallahan@19
|
476 if not bag_index or not slot_index then
|
jcallahan@19
|
477 return
|
jcallahan@19
|
478 end
|
jcallahan@19
|
479 local _, _, _, _, _, is_lootable = _G.GetContainerItemInfo(bag_index, slot_index)
|
jcallahan@19
|
480
|
jcallahan@19
|
481 if not is_lootable then
|
jcallahan@19
|
482 return
|
jcallahan@19
|
483 end
|
jcallahan@19
|
484 DatamineTT:ClearLines()
|
jcallahan@19
|
485 DatamineTT:SetBagItem(bag_index, slot_index)
|
jcallahan@19
|
486
|
jcallahan@19
|
487 for line_index = 1, DatamineTT:NumLines() do
|
jcallahan@19
|
488 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
|
jcallahan@19
|
489
|
jcallahan@19
|
490 if not current_line then
|
jcallahan@19
|
491 break
|
jcallahan@19
|
492 end
|
jcallahan@230
|
493 local is_ptr = select(4, _G.GetBuildInfo()) ~= 50100
|
jcallahan@19
|
494
|
jcallahan@230
|
495 if is_ptr or current_line:GetText() == _G.ITEM_OPENABLE then
|
jcallahan@122
|
496 table.wipe(current_action)
|
jcallahan@123
|
497 current_action.target_type = AF.ITEM
|
jcallahan@122
|
498 current_action.identifier = item_id
|
jcallahan@122
|
499 current_action.loot_label = "contains"
|
jcallahan@19
|
500 break
|
jcallahan@19
|
501 end
|
jcallahan@19
|
502 end
|
jcallahan@19
|
503 end
|
jcallahan@19
|
504
|
jcallahan@19
|
505
|
jcallahan@39
|
506 local UnitFactionStanding
|
jcallahan@32
|
507 local UpdateFactionData
|
jcallahan@32
|
508 do
|
jcallahan@32
|
509 local MAX_FACTION_INDEX = 1000
|
jcallahan@20
|
510
|
jcallahan@32
|
511 local STANDING_NAMES = {
|
jcallahan@32
|
512 "HATED",
|
jcallahan@32
|
513 "HOSTILE",
|
jcallahan@32
|
514 "UNFRIENDLY",
|
jcallahan@32
|
515 "NEUTRAL",
|
jcallahan@32
|
516 "FRIENDLY",
|
jcallahan@32
|
517 "HONORED",
|
jcallahan@32
|
518 "REVERED",
|
jcallahan@32
|
519 "EXALTED",
|
jcallahan@32
|
520 }
|
jcallahan@32
|
521
|
jcallahan@39
|
522
|
jcallahan@39
|
523 function UnitFactionStanding(unit)
|
jcallahan@135
|
524 local unit_name = _G.UnitName(unit)
|
jcallahan@39
|
525 UpdateFactionData()
|
jcallahan@39
|
526 DatamineTT:ClearLines()
|
jcallahan@39
|
527 DatamineTT:SetUnit(unit)
|
jcallahan@39
|
528
|
jcallahan@39
|
529 for line_index = 1, DatamineTT:NumLines() do
|
jcallahan@64
|
530 local faction_name = _G["WDPDatamineTTTextLeft" .. line_index]:GetText():trim()
|
jcallahan@39
|
531
|
jcallahan@135
|
532 if faction_name and faction_name ~= unit_name and faction_standings[faction_name] then
|
jcallahan@39
|
533 return faction_name, faction_standings[faction_name]
|
jcallahan@39
|
534 end
|
jcallahan@39
|
535 end
|
jcallahan@39
|
536 end
|
jcallahan@39
|
537
|
jcallahan@39
|
538
|
jcallahan@32
|
539 function UpdateFactionData()
|
jcallahan@32
|
540 for faction_index = 1, MAX_FACTION_INDEX do
|
jcallahan@32
|
541 local faction_name, _, current_standing, _, _, _, _, _, is_header = _G.GetFactionInfo(faction_index)
|
jcallahan@32
|
542
|
jcallahan@86
|
543 if faction_name then
|
jcallahan@32
|
544 faction_standings[faction_name] = STANDING_NAMES[current_standing]
|
jcallahan@32
|
545 elseif not faction_name then
|
jcallahan@32
|
546 break
|
jcallahan@32
|
547 end
|
jcallahan@20
|
548 end
|
jcallahan@20
|
549 end
|
jcallahan@32
|
550 end -- do-block
|
jcallahan@20
|
551
|
jcallahan@48
|
552
|
jcallahan@75
|
553 local GenericLootUpdate
|
jcallahan@75
|
554 do
|
jcallahan@77
|
555 local function LootTable(entry, loot_type, top_field)
|
jcallahan@75
|
556 if top_field then
|
jcallahan@75
|
557 entry[top_field] = entry[top_field] or {}
|
jcallahan@75
|
558 entry[top_field][loot_type] = entry[top_field][loot_type] or {}
|
jcallahan@75
|
559 return entry[top_field][loot_type]
|
jcallahan@75
|
560 end
|
jcallahan@48
|
561 entry[loot_type] = entry[loot_type] or {}
|
jcallahan@75
|
562 return entry[loot_type]
|
jcallahan@48
|
563 end
|
jcallahan@48
|
564
|
jcallahan@75
|
565 function GenericLootUpdate(data_type, top_field)
|
jcallahan@132
|
566 local loot_type = current_loot.label
|
jcallahan@75
|
567 local loot_count = ("%s_count"):format(loot_type)
|
jcallahan@77
|
568 local source_list = {}
|
jcallahan@75
|
569
|
jcallahan@131
|
570 if current_loot.sources then
|
jcallahan@131
|
571 for source_guid, loot_data in pairs(current_loot.sources) do
|
jcallahan@119
|
572 local entry, source_id
|
jcallahan@78
|
573
|
jcallahan@131
|
574 if current_loot.target_type == AF.ITEM then
|
jcallahan@119
|
575 -- Items return the player as the source, so we need to use the item's ID (disenchant, milling, etc)
|
jcallahan@131
|
576 source_id = current_loot.identifier
|
jcallahan@119
|
577 entry = DBEntry(data_type, source_id)
|
jcallahan@131
|
578 elseif current_loot.target_type == AF.OBJECT then
|
jcallahan@131
|
579 source_id = ("%s:%s"):format(current_loot.spell_label, select(2, ParseGUID(source_guid)))
|
jcallahan@119
|
580 entry = DBEntry(data_type, source_id)
|
jcallahan@119
|
581 else
|
jcallahan@119
|
582 source_id = select(2, ParseGUID(source_guid))
|
jcallahan@119
|
583 entry = DBEntry(data_type, source_id)
|
jcallahan@119
|
584 end
|
jcallahan@75
|
585
|
jcallahan@119
|
586 if entry then
|
jcallahan@119
|
587 local loot_table = LootTable(entry, loot_type, top_field)
|
jcallahan@77
|
588
|
jcallahan@119
|
589 if not source_list[source_guid] then
|
jcallahan@119
|
590 if top_field then
|
jcallahan@119
|
591 entry[top_field][loot_count] = (entry[top_field][loot_count] or 0) + 1
|
jcallahan@119
|
592 else
|
jcallahan@119
|
593 entry[loot_count] = (entry[loot_count] or 0) + 1
|
jcallahan@119
|
594 end
|
jcallahan@119
|
595 source_list[source_guid] = true
|
jcallahan@77
|
596 end
|
jcallahan@119
|
597 UpdateDBEntryLocation(data_type, source_id)
|
jcallahan@75
|
598
|
jcallahan@119
|
599 for item_id, quantity in pairs(loot_data) do
|
jcallahan@119
|
600 table.insert(loot_table, ("%d:%d"):format(item_id, quantity))
|
jcallahan@119
|
601 end
|
jcallahan@75
|
602 end
|
jcallahan@75
|
603 end
|
jcallahan@75
|
604 end
|
jcallahan@121
|
605
|
jcallahan@121
|
606 -- This is used for Gas Extractions.
|
jcallahan@131
|
607 if #current_loot.list <= 0 then
|
jcallahan@78
|
608 return
|
jcallahan@78
|
609 end
|
jcallahan@82
|
610 local entry
|
jcallahan@82
|
611
|
jcallahan@82
|
612 -- At this point we only have a name if it's an object.
|
jcallahan@131
|
613 if current_loot.target_type == AF.OBJECT then
|
jcallahan@131
|
614 entry = DBEntry(data_type, ("%s:%s"):format(current_loot.spell_label, current_loot.object_name))
|
jcallahan@82
|
615 else
|
jcallahan@131
|
616 entry = DBEntry(data_type, current_loot.identifier)
|
jcallahan@82
|
617 end
|
jcallahan@75
|
618
|
jcallahan@75
|
619 if not entry then
|
jcallahan@75
|
620 return
|
jcallahan@75
|
621 end
|
jcallahan@77
|
622 local loot_table = LootTable(entry, loot_type, top_field)
|
jcallahan@77
|
623
|
jcallahan@131
|
624 if not source_list[current_loot.identifier] then
|
jcallahan@77
|
625 if top_field then
|
jcallahan@77
|
626 entry[top_field][loot_count] = (entry[top_field][loot_count] or 0) + 1
|
jcallahan@77
|
627 else
|
jcallahan@77
|
628 entry[loot_count] = (entry[loot_count] or 0) + 1
|
jcallahan@77
|
629 end
|
jcallahan@77
|
630 end
|
jcallahan@75
|
631
|
jcallahan@131
|
632 for index = 1, #current_loot.list do
|
jcallahan@131
|
633 table.insert(loot_table, current_loot.list[index])
|
jcallahan@75
|
634 end
|
jcallahan@48
|
635 end
|
jcallahan@75
|
636 end -- do-block
|
jcallahan@48
|
637
|
jcallahan@97
|
638
|
jcallahan@97
|
639 local ReplaceKeywords
|
jcallahan@97
|
640 do
|
jcallahan@97
|
641 local KEYWORD_SUBSTITUTIONS = {
|
jcallahan@97
|
642 class = PLAYER_CLASS,
|
jcallahan@97
|
643 name = PLAYER_NAME,
|
jcallahan@97
|
644 race = PLAYER_RACE,
|
jcallahan@97
|
645 }
|
jcallahan@97
|
646
|
jcallahan@97
|
647
|
jcallahan@97
|
648 function ReplaceKeywords(text)
|
jcallahan@97
|
649 if not text or text == "" then
|
jcallahan@97
|
650 return ""
|
jcallahan@97
|
651 end
|
jcallahan@97
|
652
|
jcallahan@97
|
653 for category, lookup in pairs(KEYWORD_SUBSTITUTIONS) do
|
jcallahan@97
|
654 local category_format = ("<%s>"):format(category)
|
jcallahan@97
|
655 text = text:gsub(lookup, category_format):gsub(lookup:lower(), category_format)
|
jcallahan@97
|
656 end
|
jcallahan@97
|
657 return text
|
jcallahan@97
|
658 end
|
jcallahan@97
|
659 end -- do-block
|
jcallahan@97
|
660
|
jcallahan@97
|
661
|
jcallahan@154
|
662 -- Contains a dirty hack due to Blizzard's strange handling of Micro Dungeons; GetMapInfo() will not return correct information
|
jcallahan@154
|
663 -- unless the WorldMapFrame is shown.
|
jcallahan@143
|
664 do
|
jcallahan@143
|
665 -- MapFileName = MapAreaID
|
jcallahan@143
|
666 local MICRO_DUNGEON_IDS = {
|
jcallahan@143
|
667 ShrineofTwoMoons = 903,
|
jcallahan@143
|
668 ShrineofSevenStars = 905,
|
jcallahan@143
|
669 }
|
jcallahan@126
|
670
|
jcallahan@143
|
671 function WDP:SetCurrentAreaID(event_name)
|
jcallahan@156
|
672 if private.in_combat then
|
jcallahan@156
|
673 private.set_area_id = true
|
jcallahan@156
|
674 return
|
jcallahan@156
|
675 end
|
jcallahan@155
|
676 local map_area_id = _G.GetCurrentMapAreaID()
|
jcallahan@155
|
677
|
jcallahan@155
|
678 if map_area_id == current_area_id then
|
jcallahan@155
|
679 return
|
jcallahan@155
|
680 end
|
jcallahan@143
|
681 local world_map = _G.WorldMapFrame
|
jcallahan@143
|
682 local map_visible = world_map:IsVisible()
|
jcallahan@143
|
683 local sfx_value = _G.tonumber(_G.GetCVar("Sound_EnableSFX"))
|
jcallahan@143
|
684
|
jcallahan@143
|
685 if not map_visible then
|
jcallahan@143
|
686 _G.SetCVar("Sound_EnableSFX", 0)
|
jcallahan@143
|
687 world_map:Show()
|
jcallahan@143
|
688 end
|
jcallahan@143
|
689 local micro_dungeon_id = MICRO_DUNGEON_IDS[select(5, _G.GetMapInfo())]
|
jcallahan@143
|
690
|
jcallahan@154
|
691 _G.SetMapToCurrentZone()
|
jcallahan@154
|
692
|
jcallahan@143
|
693 if micro_dungeon_id then
|
jcallahan@143
|
694 current_area_id = micro_dungeon_id
|
jcallahan@143
|
695 else
|
jcallahan@143
|
696 current_area_id = _G.GetCurrentMapAreaID()
|
jcallahan@143
|
697 end
|
jcallahan@143
|
698
|
jcallahan@154
|
699 if map_visible then
|
jcallahan@154
|
700 _G.SetMapByID(map_area_id)
|
jcallahan@154
|
701 else
|
jcallahan@143
|
702 world_map:Hide()
|
jcallahan@143
|
703 _G.SetCVar("Sound_EnableSFX", sfx_value)
|
jcallahan@143
|
704 end
|
jcallahan@143
|
705 end
|
jcallahan@154
|
706 end
|
jcallahan@126
|
707
|
jcallahan@246
|
708
|
jcallahan@246
|
709 -- METHODS ------------------------------------------------------------
|
jcallahan@246
|
710
|
jcallahan@0
|
711 function WDP:OnInitialize()
|
jcallahan@128
|
712 local db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default")
|
jcallahan@128
|
713 global_db = db.global
|
jcallahan@128
|
714 char_db = db.char
|
jcallahan@14
|
715
|
jcallahan@14
|
716 local raw_db = _G["WoWDBProfilerData"]
|
jcallahan@18
|
717 local build_num = tonumber(private.build_num)
|
jcallahan@14
|
718
|
jcallahan@136
|
719 if (raw_db.version and raw_db.version < DB_VERSION) or (raw_db.build_num and raw_db.build_num < build_num) then
|
jcallahan@74
|
720 for entry in pairs(DATABASE_DEFAULTS.global) do
|
jcallahan@128
|
721 global_db[entry] = {}
|
jcallahan@74
|
722 end
|
jcallahan@74
|
723 end
|
jcallahan@35
|
724 raw_db.build_num = build_num
|
jcallahan@63
|
725 raw_db.version = DB_VERSION
|
jcallahan@249
|
726
|
jcallahan@251
|
727 if DEBUGGING then -- TODO: Remove this when comment subsystem is finished.
|
jcallahan@251
|
728 self:RegisterChatCommand("comment", private.ProcessCommentCommand)
|
jcallahan@251
|
729 end
|
jcallahan@0
|
730 end
|
jcallahan@0
|
731
|
jcallahan@0
|
732
|
jcallahan@153
|
733 function WDP:EventDispatcher(...)
|
jcallahan@153
|
734 local event_name = ...
|
jcallahan@153
|
735
|
jcallahan@153
|
736 if DEBUGGING then
|
jcallahan@154
|
737 if event_name == "COMBAT_LOG_EVENT_UNFILTERED" then
|
jcallahan@154
|
738 Debug(event_name)
|
jcallahan@154
|
739 else
|
jcallahan@154
|
740 Debug(...)
|
jcallahan@153
|
741 end
|
jcallahan@153
|
742 end
|
jcallahan@153
|
743 local func = EVENT_MAPPING[event_name]
|
jcallahan@153
|
744
|
jcallahan@153
|
745 if _G.type(func) == "boolean" then
|
jcallahan@153
|
746 self[event_name](self, ...)
|
jcallahan@153
|
747 elseif _G.type(func) == "function" then
|
jcallahan@159
|
748 self[func](self, ...)
|
jcallahan@153
|
749 end
|
jcallahan@153
|
750 end
|
jcallahan@153
|
751
|
jcallahan@153
|
752
|
jcallahan@0
|
753 function WDP:OnEnable()
|
jcallahan@0
|
754 for event_name, mapping in pairs(EVENT_MAPPING) do
|
jcallahan@156
|
755 if EVENT_DEBUG then
|
jcallahan@153
|
756 self:RegisterEvent(event_name, "EventDispatcher")
|
jcallahan@153
|
757 else
|
jcallahan@153
|
758 self:RegisterEvent(event_name, (_G.type(mapping) ~= "boolean") and mapping or nil)
|
jcallahan@153
|
759 end
|
jcallahan@0
|
760 end
|
jcallahan@95
|
761
|
jcallahan@95
|
762 for index = 1, _G.GetNumLanguages() do
|
jcallahan@95
|
763 languages_known[_G.GetLanguageByIndex(index)] = true
|
jcallahan@95
|
764 end
|
jcallahan@187
|
765 item_process_timer_handle = self:ScheduleRepeatingTimer("ProcessItems", 30)
|
jcallahan@31
|
766 target_location_timer_handle = self:ScheduleRepeatingTimer("UpdateTargetLocation", 0.5)
|
jcallahan@19
|
767
|
jcallahan@19
|
768 _G.hooksecurefunc("UseContainerItem", function(bag_index, slot_index, target_unit)
|
jcallahan@19
|
769 if target_unit then
|
jcallahan@19
|
770 return
|
jcallahan@19
|
771 end
|
jcallahan@19
|
772 HandleItemUse(_G.GetContainerItemLink(bag_index, slot_index), bag_index, slot_index)
|
jcallahan@19
|
773 end)
|
jcallahan@19
|
774
|
jcallahan@19
|
775 _G.hooksecurefunc("UseItemByName", function(identifier, target_unit)
|
jcallahan@19
|
776 if target_unit then
|
jcallahan@19
|
777 return
|
jcallahan@19
|
778 end
|
jcallahan@19
|
779 local _, item_link = _G.GetItemInfo(identifier)
|
jcallahan@19
|
780 HandleItemUse(item_link)
|
jcallahan@19
|
781 end)
|
jcallahan@263
|
782
|
jcallahan@129
|
783 self:SetCurrentAreaID("OnEnable")
|
jcallahan@246
|
784 self:GROUP_ROSTER_CHANGE()
|
jcallahan@0
|
785 end
|
jcallahan@0
|
786
|
jcallahan@0
|
787
|
jcallahan@219
|
788 local ScrapeItemUpgradeStats
|
jcallahan@219
|
789 do
|
jcallahan@219
|
790 local intermediary = {}
|
jcallahan@219
|
791
|
jcallahan@220
|
792 function ScrapeItemUpgradeStats(item_id, upgrade_id, reforge_id)
|
jcallahan@220
|
793 if not ALLOWED_LOCALES[CLIENT_LOCALE] then
|
jcallahan@220
|
794 return
|
jcallahan@220
|
795 end
|
jcallahan@219
|
796 local create_entry
|
jcallahan@219
|
797
|
jcallahan@219
|
798 table.wipe(intermediary)
|
jcallahan@219
|
799
|
jcallahan@219
|
800 for line_index = 1, DatamineTT:NumLines() do
|
jcallahan@219
|
801 local left_text = _G["WDPDatamineTTTextLeft" .. line_index]:GetText()
|
jcallahan@219
|
802
|
jcallahan@219
|
803 if not left_text then
|
jcallahan@219
|
804 return
|
jcallahan@219
|
805 end
|
jcallahan@219
|
806 local amount, stat = left_text:match("+(.-) (.*)")
|
jcallahan@219
|
807
|
jcallahan@219
|
808 if amount and stat then
|
jcallahan@220
|
809 if reforge_id and reforge_id ~= 0 then
|
jcallahan@220
|
810 local reforge_string = stat:find("Reforged")
|
jcallahan@220
|
811
|
jcallahan@220
|
812 if reforge_string then
|
jcallahan@220
|
813 stat = stat:sub(0, reforge_string - 3)
|
jcallahan@220
|
814 intermediary.reforge_id = reforge_id
|
jcallahan@220
|
815 end
|
jcallahan@219
|
816 end
|
jcallahan@219
|
817 create_entry = true
|
jcallahan@219
|
818 intermediary[stat:lower():gsub(" ", "_"):gsub("|r", "")] = tonumber(amount)
|
jcallahan@219
|
819 end
|
jcallahan@219
|
820 end
|
jcallahan@219
|
821
|
jcallahan@219
|
822 if not create_entry then
|
jcallahan@219
|
823 return
|
jcallahan@219
|
824 end
|
jcallahan@219
|
825 local item = DBEntry("items", item_id)
|
jcallahan@225
|
826 item.upgrade_id = upgrade_id
|
jcallahan@219
|
827 item.upgrades = item.upgrades or {}
|
jcallahan@219
|
828 item.upgrades[upgrade_id] = item.upgrades[upgrade_id] or {}
|
jcallahan@219
|
829
|
jcallahan@219
|
830 for stat, amount in pairs(intermediary) do
|
jcallahan@219
|
831 item.upgrades[upgrade_id][stat] = amount
|
jcallahan@219
|
832 end
|
jcallahan@219
|
833 end
|
jcallahan@220
|
834 end
|
jcallahan@220
|
835
|
jcallahan@220
|
836 -- do-block
|
jcallahan@219
|
837
|
jcallahan@219
|
838
|
jcallahan@187
|
839 local function RecordItemData(item_id, item_link, durability)
|
jcallahan@191
|
840 local item_string = select(3, item_link:find("^|%x+|H(.+)|h%[.+%]"))
|
jcallahan@219
|
841 local item
|
jcallahan@0
|
842
|
jcallahan@191
|
843 if item_string then
|
jcallahan@220
|
844 local _, _, _, _, _, _, _, suffix_id, unique_id, _, reforge_id, upgrade_id = (":"):split(item_string)
|
jcallahan@201
|
845 suffix_id = tonumber(suffix_id)
|
jcallahan@219
|
846 upgrade_id = tonumber(upgrade_id)
|
jcallahan@199
|
847
|
jcallahan@201
|
848 if suffix_id and suffix_id ~= 0 then
|
jcallahan@219
|
849 item = DBEntry("items", item_id)
|
jcallahan@201
|
850 item.suffix_id = suffix_id
|
jcallahan@201
|
851 item.unique_id = bit.band(unique_id, 0xFFFF)
|
jcallahan@201
|
852 end
|
jcallahan@191
|
853
|
jcallahan@219
|
854 if upgrade_id and upgrade_id ~= 0 then
|
jcallahan@220
|
855 DatamineTT:SetHyperlink(item_link)
|
jcallahan@220
|
856 ScrapeItemUpgradeStats(item_id, upgrade_id, reforge_id)
|
jcallahan@191
|
857 end
|
jcallahan@0
|
858 end
|
jcallahan@212
|
859
|
jcallahan@212
|
860 if durability and durability > 0 then
|
jcallahan@219
|
861 item = item or DBEntry("items", item_id)
|
jcallahan@212
|
862 item.durability = durability
|
jcallahan@212
|
863 end
|
jcallahan@0
|
864 end
|
jcallahan@0
|
865
|
jcallahan@0
|
866
|
jcallahan@187
|
867 function WDP:ProcessItems()
|
jcallahan@187
|
868 for slot_index = _G.INVSLOT_FIRST_EQUIPPED, _G.INVSLOT_LAST_EQUIPPED do
|
jcallahan@1
|
869 local item_id = _G.GetInventoryItemID("player", slot_index)
|
jcallahan@0
|
870
|
jcallahan@0
|
871 if item_id and item_id > 0 then
|
jcallahan@1
|
872 local _, max_durability = _G.GetInventoryItemDurability(slot_index)
|
jcallahan@187
|
873 RecordItemData(item_id, _G.GetInventoryItemLink("player", slot_index), max_durability)
|
jcallahan@0
|
874 end
|
jcallahan@0
|
875 end
|
jcallahan@0
|
876
|
jcallahan@0
|
877 for bag_index = 0, _G.NUM_BAG_SLOTS do
|
jcallahan@0
|
878 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do
|
jcallahan@1
|
879 local item_id = _G.GetContainerItemID(bag_index, slot_index)
|
jcallahan@0
|
880
|
jcallahan@0
|
881 if item_id and item_id > 0 then
|
jcallahan@1
|
882 local _, max_durability = _G.GetContainerItemDurability(bag_index, slot_index)
|
jcallahan@187
|
883 RecordItemData(item_id, _G.GetContainerItemLink(bag_index, slot_index), max_durability)
|
jcallahan@0
|
884 end
|
jcallahan@0
|
885 end
|
jcallahan@0
|
886 end
|
jcallahan@0
|
887 end
|
jcallahan@0
|
888
|
jcallahan@118
|
889
|
jcallahan@215
|
890 local TargetedNPC
|
jcallahan@118
|
891 do
|
jcallahan@118
|
892 local GENDER_NAMES = {
|
jcallahan@118
|
893 "UNKNOWN",
|
jcallahan@118
|
894 "MALE",
|
jcallahan@118
|
895 "FEMALE",
|
jcallahan@118
|
896 }
|
jcallahan@118
|
897
|
jcallahan@118
|
898
|
jcallahan@118
|
899 local REACTION_NAMES = {
|
jcallahan@118
|
900 "HATED",
|
jcallahan@118
|
901 "HOSTILE",
|
jcallahan@118
|
902 "UNFRIENDLY",
|
jcallahan@118
|
903 "NEUTRAL",
|
jcallahan@118
|
904 "FRIENDLY",
|
jcallahan@118
|
905 "HONORED",
|
jcallahan@118
|
906 "REVERED",
|
jcallahan@118
|
907 "EXALTED",
|
jcallahan@118
|
908 }
|
jcallahan@118
|
909
|
jcallahan@118
|
910
|
jcallahan@118
|
911 local POWER_TYPE_NAMES = {
|
jcallahan@118
|
912 ["0"] = "MANA",
|
jcallahan@118
|
913 ["1"] = "RAGE",
|
jcallahan@118
|
914 ["2"] = "FOCUS",
|
jcallahan@118
|
915 ["3"] = "ENERGY",
|
jcallahan@118
|
916 ["6"] = "RUNIC_POWER",
|
jcallahan@118
|
917 }
|
jcallahan@118
|
918
|
jcallahan@118
|
919
|
jcallahan@215
|
920 function TargetedNPC()
|
jcallahan@118
|
921 if not _G.UnitExists("target") or _G.UnitPlayerControlled("target") or currently_drunk then
|
jcallahan@118
|
922 current_target_id = nil
|
jcallahan@118
|
923 return
|
jcallahan@118
|
924 end
|
jcallahan@118
|
925 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target"))
|
jcallahan@118
|
926
|
jcallahan@171
|
927 if not unit_idnum or not UnitTypeIsNPC(unit_type) then
|
jcallahan@118
|
928 return
|
jcallahan@118
|
929 end
|
jcallahan@118
|
930 current_target_id = unit_idnum
|
jcallahan@118
|
931
|
jcallahan@118
|
932 local npc = NPCEntry(unit_idnum)
|
jcallahan@118
|
933 local _, class_token = _G.UnitClass("target")
|
jcallahan@118
|
934 npc.class = class_token
|
jcallahan@118
|
935 npc.faction = UnitFactionStanding("target")
|
jcallahan@118
|
936 npc.genders = npc.genders or {}
|
jcallahan@118
|
937 npc.genders[GENDER_NAMES[_G.UnitSex("target")] or "UNDEFINED"] = true
|
jcallahan@118
|
938 npc.is_pvp = _G.UnitIsPVP("target") and true or nil
|
jcallahan@118
|
939 npc.reaction = ("%s:%s:%s"):format(_G.UnitLevel("player"), _G.UnitFactionGroup("player"), REACTION_NAMES[_G.UnitReaction("player", "target")])
|
jcallahan@118
|
940
|
jcallahan@248
|
941 local encounter_data = npc:EncounterData(InstanceDifficultyToken()).stats
|
jcallahan@118
|
942 local npc_level = ("level_%d"):format(_G.UnitLevel("target"))
|
jcallahan@250
|
943 local level_data = encounter_data[npc_level]
|
jcallahan@250
|
944
|
jcallahan@250
|
945 if not level_data then
|
jcallahan@250
|
946 level_data = {}
|
jcallahan@250
|
947 encounter_data[npc_level] = level_data
|
jcallahan@250
|
948 end
|
jcallahan@257
|
949 level_data.max_health = level_data.max_health or _G.UnitHealthMax("target")
|
jcallahan@257
|
950
|
jcallahan@257
|
951 if not level_data.power then
|
jcallahan@257
|
952 local max_power = _G.UnitManaMax("target")
|
jcallahan@257
|
953
|
jcallahan@257
|
954 if max_power > 0 then
|
jcallahan@257
|
955 local power_type = _G.UnitPowerType("target")
|
jcallahan@257
|
956 level_data.power = ("%s:%d"):format(POWER_TYPE_NAMES[_G.tostring(power_type)] or power_type, max_power)
|
jcallahan@257
|
957 end
|
jcallahan@118
|
958 end
|
jcallahan@118
|
959 name_to_id_map[_G.UnitName("target")] = unit_idnum
|
jcallahan@118
|
960 return npc, unit_idnum
|
jcallahan@118
|
961 end
|
jcallahan@118
|
962 end -- do-block
|
jcallahan@118
|
963
|
jcallahan@118
|
964
|
jcallahan@113
|
965 do
|
jcallahan@113
|
966 local COORD_MAX = 5
|
jcallahan@0
|
967
|
jcallahan@113
|
968 function WDP:UpdateTargetLocation()
|
jcallahan@113
|
969 if currently_drunk or not _G.UnitExists("target") or _G.UnitPlayerControlled("target") or (_G.UnitIsTapped("target") and not _G.UnitIsDead("target")) then
|
jcallahan@2
|
970 return
|
jcallahan@2
|
971 end
|
jcallahan@113
|
972
|
jcallahan@113
|
973 for index = 1, 4 do
|
jcallahan@113
|
974 if not _G.CheckInteractDistance("target", index) then
|
jcallahan@113
|
975 return
|
jcallahan@113
|
976 end
|
jcallahan@113
|
977 end
|
jcallahan@215
|
978 local npc = TargetedNPC()
|
jcallahan@113
|
979
|
jcallahan@113
|
980 if not npc then
|
jcallahan@113
|
981 return
|
jcallahan@113
|
982 end
|
jcallahan@113
|
983 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData()
|
jcallahan@248
|
984 local npc_data = npc:EncounterData(difficulty_token).stats[("level_%d"):format(_G.UnitLevel("target"))]
|
jcallahan@113
|
985 local zone_token = ("%s:%d"):format(zone_name, area_id)
|
jcallahan@118
|
986 npc_data.locations = npc_data.locations or {} -- TODO: Fix this. It is broken. Possibly something to do with the timed updates.
|
jcallahan@113
|
987
|
jcallahan@113
|
988 local zone_data = npc_data.locations[zone_token]
|
jcallahan@113
|
989
|
jcallahan@113
|
990 if not zone_data then
|
jcallahan@113
|
991 zone_data = {}
|
jcallahan@113
|
992 npc_data.locations[zone_token] = zone_data
|
jcallahan@113
|
993 end
|
jcallahan@113
|
994
|
jcallahan@113
|
995 for location_token in pairs(zone_data) do
|
jcallahan@113
|
996 local loc_level, loc_x, loc_y = (":"):split(location_token)
|
jcallahan@113
|
997 loc_level = tonumber(loc_level)
|
jcallahan@113
|
998
|
jcallahan@113
|
999 if map_level == loc_level and math.abs(x - loc_x) <= COORD_MAX and math.abs(y - loc_y) <= COORD_MAX then
|
jcallahan@113
|
1000 return
|
jcallahan@113
|
1001 end
|
jcallahan@113
|
1002 end
|
jcallahan@141
|
1003 zone_data[("%d:%d:%d"):format(map_level, x, y)] = true
|
jcallahan@2
|
1004 end
|
jcallahan@113
|
1005 end -- do-block
|
jcallahan@2
|
1006
|
jcallahan@118
|
1007
|
jcallahan@246
|
1008 -- EVENT HANDLERS -----------------------------------------------------
|
jcallahan@246
|
1009
|
jcallahan@90
|
1010 function WDP:BLACK_MARKET_ITEM_UPDATE(event_name)
|
jcallahan@243
|
1011 if not ALLOWED_LOCALES[CLIENT_LOCALE] then
|
jcallahan@243
|
1012 return
|
jcallahan@243
|
1013 end
|
jcallahan@56
|
1014 local num_items = _G.C_BlackMarket.GetNumItems()
|
jcallahan@56
|
1015
|
jcallahan@56
|
1016 for index = 1, num_items do
|
jcallahan@56
|
1017 local name, texture, quantity, item_type, is_usable, level, level_type, seller_name, min_bid, min_increment, current_bid, has_high_bid, num_bids, time_left, item_link, market_id = _G.C_BlackMarket.GetItemInfoByIndex(index);
|
jcallahan@56
|
1018
|
jcallahan@56
|
1019 if item_link then
|
jcallahan@56
|
1020 DBEntry("items", ItemLinkToID(item_link)).black_market = seller_name or "UNKNOWN"
|
jcallahan@56
|
1021 end
|
jcallahan@56
|
1022 end
|
jcallahan@56
|
1023 end
|
jcallahan@56
|
1024
|
jcallahan@56
|
1025
|
jcallahan@246
|
1026 function WDP:GROUP_ROSTER_CHANGE()
|
jcallahan@246
|
1027 local is_raid = _G.IsInRaid()
|
jcallahan@246
|
1028 local unit_type = is_raid and "raid" or "party"
|
jcallahan@246
|
1029 local group_size = is_raid and _G.GetNumGroupMembers() or _G.GetNumSubgroupMembers()
|
jcallahan@246
|
1030
|
jcallahan@246
|
1031 table.wipe(group_member_uids)
|
jcallahan@246
|
1032
|
jcallahan@246
|
1033 for index = 1, group_size do
|
jcallahan@246
|
1034 group_member_uids[_G.UnitGUID(unit_type .. index)] = true
|
jcallahan@246
|
1035 end
|
jcallahan@246
|
1036 group_member_uids[_G.UnitGUID("player")] = true
|
jcallahan@246
|
1037 end
|
jcallahan@246
|
1038
|
jcallahan@246
|
1039
|
jcallahan@246
|
1040 function WDP:UNIT_PET(event_name, unit_id)
|
jcallahan@246
|
1041 local unit_guid = _G.UnitGUID(unit_id)
|
jcallahan@246
|
1042 local current_pet_guid = group_owner_guids_to_pet_guids[unit_guid]
|
jcallahan@246
|
1043
|
jcallahan@246
|
1044 if current_pet_guid then
|
jcallahan@246
|
1045 Debug("Removing existing pet GUID for %s", _G.UnitName(unit_id))
|
jcallahan@246
|
1046 group_owner_guids_to_pet_guids[unit_guid] = nil
|
jcallahan@246
|
1047 group_pet_guids[current_pet_guid] = nil
|
jcallahan@246
|
1048 end
|
jcallahan@246
|
1049 local pet_guid = _G.UnitGUID(unit_id .. "pet")
|
jcallahan@246
|
1050
|
jcallahan@246
|
1051 if pet_guid then
|
jcallahan@246
|
1052 Debug("Adding new pet GUID for %s.", _G.UnitName(unit_id))
|
jcallahan@246
|
1053 group_owner_guids_to_pet_guids[unit_id] = pet_guid
|
jcallahan@246
|
1054 group_pet_guids[pet_guid] = true
|
jcallahan@246
|
1055 end
|
jcallahan@246
|
1056 end
|
jcallahan@246
|
1057
|
jcallahan@246
|
1058
|
jcallahan@178
|
1059 function WDP:SHOW_LOOT_TOAST(event_name, loot_type, item_link, quantity)
|
jcallahan@178
|
1060 if loot_type ~= "item" then
|
jcallahan@178
|
1061 return
|
jcallahan@178
|
1062 end
|
jcallahan@203
|
1063 local npc = NPCEntry(private.raid_finder_boss_id or private.world_boss_id)
|
jcallahan@216
|
1064 ClearKilledBossID()
|
jcallahan@178
|
1065
|
jcallahan@178
|
1066 if not npc then
|
jcallahan@245
|
1067 Debug("%s: NPC is nil.", event_name)
|
jcallahan@178
|
1068 return
|
jcallahan@178
|
1069 end
|
jcallahan@178
|
1070 local item_id = ItemLinkToID(item_link)
|
jcallahan@178
|
1071
|
jcallahan@178
|
1072 if not item_id then
|
jcallahan@245
|
1073 Debug("%s: ItemID is nil, from item link %s", event_name, item_link)
|
jcallahan@178
|
1074 return
|
jcallahan@178
|
1075 end
|
jcallahan@179
|
1076 local loot_type = "drops"
|
jcallahan@248
|
1077 local encounter_data = npc:EncounterData(InstanceDifficultyToken())
|
jcallahan@178
|
1078 encounter_data[loot_type] = encounter_data[loot_type] or {}
|
jcallahan@178
|
1079 encounter_data.loot_counts = encounter_data.loot_counts or {}
|
jcallahan@178
|
1080 encounter_data.loot_counts[loot_type] = (encounter_data.loot_counts[loot_type] or 0) + 1
|
jcallahan@178
|
1081
|
jcallahan@178
|
1082 table.insert(encounter_data[loot_type], ("%d:%d"):format(item_id, quantity))
|
jcallahan@245
|
1083 Debug("%s: %sX%d (%d)", event_name, item_link, quantity, item_id)
|
jcallahan@178
|
1084 end
|
jcallahan@178
|
1085
|
jcallahan@178
|
1086
|
jcallahan@179
|
1087 do
|
jcallahan@179
|
1088 local CHAT_MSG_LOOT_UPDATE_FUNCS = {
|
jcallahan@179
|
1089 [AF.NPC] = function(item_id, quantity)
|
jcallahan@245
|
1090 Debug("CHAT_MSG_LOOT: %d (%d)", item_id, quantity)
|
jcallahan@179
|
1091 end,
|
jcallahan@179
|
1092 [AF.ZONE] = function(item_id, quantity)
|
jcallahan@179
|
1093 current_loot = {
|
jcallahan@179
|
1094 list = {
|
jcallahan@179
|
1095 ("%d:%d"):format(item_id, quantity)
|
jcallahan@179
|
1096 },
|
jcallahan@179
|
1097 identifier = current_action.identifier,
|
jcallahan@179
|
1098 label = current_action.loot_label or "drops",
|
jcallahan@179
|
1099 map_level = current_action.map_level,
|
jcallahan@179
|
1100 object_name = current_action.object_name,
|
jcallahan@179
|
1101 spell_label = current_action.spell_label,
|
jcallahan@179
|
1102 target_type = current_action.target_type,
|
jcallahan@179
|
1103 x = current_action.x,
|
jcallahan@179
|
1104 y = current_action.y,
|
jcallahan@179
|
1105 zone_data = current_action.zone_data,
|
jcallahan@179
|
1106 }
|
jcallahan@179
|
1107 table.wipe(current_action)
|
jcallahan@179
|
1108 GenericLootUpdate("zones")
|
jcallahan@179
|
1109 end,
|
jcallahan@179
|
1110 }
|
jcallahan@177
|
1111
|
jcallahan@177
|
1112
|
jcallahan@179
|
1113 function WDP:CHAT_MSG_LOOT(event_name, message)
|
jcallahan@179
|
1114 local category
|
jcallahan@177
|
1115
|
jcallahan@179
|
1116 if current_action.spell_label ~= "EXTRACT_GAS" then
|
jcallahan@179
|
1117 category = AF.ZONE
|
jcallahan@179
|
1118 elseif private.raid_finder_boss_id then
|
jcallahan@179
|
1119 category = AF.NPC
|
jcallahan@179
|
1120 end
|
jcallahan@179
|
1121 local update_func = CHAT_MSG_LOOT_UPDATE_FUNCS[category]
|
jcallahan@177
|
1122
|
jcallahan@179
|
1123 if not category or not update_func then
|
jcallahan@179
|
1124 return
|
jcallahan@179
|
1125 end
|
jcallahan@179
|
1126 local item_link, quantity = deformat(message, _G.LOOT_ITEM_PUSHED_SELF_MULTIPLE)
|
jcallahan@179
|
1127
|
jcallahan@179
|
1128 if not item_link then
|
jcallahan@179
|
1129 quantity, item_link = 1, deformat(message, _G.LOOT_ITEM_PUSHED_SELF)
|
jcallahan@179
|
1130 end
|
jcallahan@179
|
1131 local item_id = ItemLinkToID(item_link)
|
jcallahan@179
|
1132
|
jcallahan@179
|
1133 if not item_id then
|
jcallahan@179
|
1134 return
|
jcallahan@179
|
1135 end
|
jcallahan@179
|
1136 update_func(item_id, quantity)
|
jcallahan@177
|
1137 end
|
jcallahan@48
|
1138 end
|
jcallahan@48
|
1139
|
jcallahan@97
|
1140 function WDP:RecordQuote(event_name, message, source_name, language_name)
|
jcallahan@112
|
1141 if not ALLOWED_LOCALES[CLIENT_LOCALE] or not source_name or not name_to_id_map[source_name] or (language_name ~= "" and not languages_known[language_name]) then
|
jcallahan@97
|
1142 return
|
jcallahan@95
|
1143 end
|
jcallahan@97
|
1144 local npc = NPCEntry(name_to_id_map[source_name])
|
jcallahan@97
|
1145 npc.quotes = npc.quotes or {}
|
jcallahan@97
|
1146 npc.quotes[event_name] = npc.quotes[event_name] or {}
|
jcallahan@97
|
1147 npc.quotes[event_name][ReplaceKeywords(message)] = true
|
jcallahan@97
|
1148 end
|
jcallahan@95
|
1149
|
jcallahan@95
|
1150
|
jcallahan@95
|
1151 do
|
jcallahan@40
|
1152 local SOBER_MATCH = _G.DRUNK_MESSAGE_ITEM_SELF1:gsub("%%s", ".+")
|
jcallahan@40
|
1153
|
jcallahan@40
|
1154 local DRUNK_COMPARES = {
|
jcallahan@40
|
1155 _G.DRUNK_MESSAGE_SELF2,
|
jcallahan@40
|
1156 _G.DRUNK_MESSAGE_SELF3,
|
jcallahan@40
|
1157 _G.DRUNK_MESSAGE_SELF4,
|
jcallahan@40
|
1158 }
|
jcallahan@40
|
1159
|
jcallahan@40
|
1160 local DRUNK_MATCHES = {
|
jcallahan@254
|
1161 (_G.DRUNK_MESSAGE_SELF2:gsub("%%s", ".+")),
|
jcallahan@254
|
1162 (_G.DRUNK_MESSAGE_SELF3:gsub("%%s", ".+")),
|
jcallahan@254
|
1163 (_G.DRUNK_MESSAGE_SELF4:gsub("%%s", ".+")),
|
jcallahan@40
|
1164 }
|
jcallahan@40
|
1165
|
jcallahan@167
|
1166 local RECIPE_MATCH = _G.ERR_LEARN_RECIPE_S:gsub("%%s", "(.*)")
|
jcallahan@167
|
1167
|
jcallahan@167
|
1168
|
jcallahan@167
|
1169 local function RecordDiscovery(tradeskill_name, tradeskill_index)
|
jcallahan@167
|
1170 if tradeskill_name == private.discovered_recipe_name then
|
jcallahan@167
|
1171 DBEntry("spells", tonumber(_G.GetTradeSkillRecipeLink(tradeskill_index):match("^|c%x%x%x%x%x%x%x%x|H%w+:(%d+)"))).discovery = ("%d:%d"):format(private.previous_spell_id, private.profession_level)
|
jcallahan@167
|
1172
|
jcallahan@167
|
1173 private.discovered_recipe_name = nil
|
jcallahan@167
|
1174 private.profession_level = nil
|
jcallahan@167
|
1175 private.previous_spell_id = nil
|
jcallahan@169
|
1176
|
jcallahan@169
|
1177 return true
|
jcallahan@167
|
1178 end
|
jcallahan@167
|
1179 end
|
jcallahan@167
|
1180
|
jcallahan@167
|
1181
|
jcallahan@167
|
1182 local function IterativeRecordDiscovery()
|
jcallahan@167
|
1183 TradeSkillExecutePer(RecordDiscovery)
|
jcallahan@167
|
1184 end
|
jcallahan@167
|
1185
|
jcallahan@167
|
1186
|
jcallahan@92
|
1187 function WDP:CHAT_MSG_SYSTEM(event_name, message)
|
jcallahan@167
|
1188 if not private.trainer_shown then
|
jcallahan@167
|
1189 local recipe_name = message:match(RECIPE_MATCH)
|
jcallahan@167
|
1190
|
jcallahan@167
|
1191 if recipe_name and private.previous_spell_id then
|
jcallahan@167
|
1192 local profession_name, prof_level = _G.GetTradeSkillLine()
|
jcallahan@167
|
1193
|
jcallahan@167
|
1194 if profession_name == _G.UNKNOWN then
|
jcallahan@167
|
1195 return
|
jcallahan@167
|
1196 end
|
jcallahan@167
|
1197 private.discovered_recipe_name = recipe_name
|
jcallahan@167
|
1198 private.profession_level = prof_level
|
jcallahan@167
|
1199
|
jcallahan@167
|
1200 self:ScheduleTimer(IterativeRecordDiscovery, 0.2)
|
jcallahan@167
|
1201 end
|
jcallahan@167
|
1202 end
|
jcallahan@167
|
1203
|
jcallahan@40
|
1204 if currently_drunk then
|
jcallahan@40
|
1205 if message == _G.DRUNK_MESSAGE_SELF1 or message:match(SOBER_MATCH) then
|
jcallahan@40
|
1206 currently_drunk = nil
|
jcallahan@40
|
1207 end
|
jcallahan@40
|
1208 return
|
jcallahan@40
|
1209 end
|
jcallahan@40
|
1210
|
jcallahan@40
|
1211 for index = 1, #DRUNK_MATCHES do
|
jcallahan@40
|
1212 if message == DRUNK_COMPARES[index] or message:match(DRUNK_MATCHES[index]) then
|
jcallahan@40
|
1213 currently_drunk = true
|
jcallahan@40
|
1214 break
|
jcallahan@40
|
1215 end
|
jcallahan@40
|
1216 end
|
jcallahan@40
|
1217 end
|
jcallahan@40
|
1218 end
|
jcallahan@40
|
1219
|
jcallahan@40
|
1220 -- do-block
|
jcallahan@40
|
1221
|
jcallahan@40
|
1222 do
|
jcallahan@23
|
1223 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC)
|
jcallahan@23
|
1224 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC)
|
jcallahan@23
|
1225
|
jcallahan@23
|
1226 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name)
|
jcallahan@23
|
1227 if not spell_id then
|
jcallahan@23
|
1228 return
|
jcallahan@23
|
1229 end
|
jcallahan@34
|
1230 local source_type, source_id = ParseGUID(source_guid)
|
jcallahan@23
|
1231
|
jcallahan@171
|
1232 if not source_id or not UnitTypeIsNPC(source_type) then
|
jcallahan@23
|
1233 return
|
jcallahan@23
|
1234 end
|
jcallahan@23
|
1235
|
jcallahan@23
|
1236 if bit.band(FLAGS_NPC_CONTROL, source_flags) == FLAGS_NPC_CONTROL and bit.band(FLAGS_NPC, source_flags) ~= 0 then
|
jcallahan@248
|
1237 local encounter_data = NPCEntry(source_id):EncounterData(InstanceDifficultyToken())
|
jcallahan@28
|
1238 encounter_data.spells = encounter_data.spells or {}
|
jcallahan@28
|
1239 encounter_data.spells[spell_id] = (encounter_data.spells[spell_id] or 0) + 1
|
jcallahan@23
|
1240 end
|
jcallahan@23
|
1241 end
|
jcallahan@23
|
1242
|
jcallahan@115
|
1243 local HEAL_BATTLE_PETS_SPELL_ID = 125801
|
jcallahan@115
|
1244
|
jcallahan@246
|
1245 local previous_combat_event = {}
|
jcallahan@246
|
1246
|
jcallahan@23
|
1247 local COMBAT_LOG_FUNCS = {
|
jcallahan@23
|
1248 SPELL_AURA_APPLIED = RecordNPCSpell,
|
jcallahan@23
|
1249 SPELL_CAST_START = RecordNPCSpell,
|
jcallahan@115
|
1250 SPELL_CAST_SUCCESS = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name)
|
jcallahan@115
|
1251 if spell_id == HEAL_BATTLE_PETS_SPELL_ID then
|
jcallahan@115
|
1252 local unit_type, unit_idnum = ParseGUID(source_guid)
|
jcallahan@115
|
1253
|
jcallahan@171
|
1254 if unit_idnum and UnitTypeIsNPC(unit_type) then
|
jcallahan@115
|
1255 NPCEntry(unit_idnum).stable_master = true
|
jcallahan@115
|
1256 end
|
jcallahan@115
|
1257 end
|
jcallahan@115
|
1258 RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name)
|
jcallahan@115
|
1259 end,
|
jcallahan@65
|
1260 UNIT_DIED = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name)
|
jcallahan@65
|
1261 local unit_type, unit_idnum = ParseGUID(dest_guid)
|
jcallahan@65
|
1262
|
jcallahan@171
|
1263 if not unit_idnum or not UnitTypeIsNPC(unit_type) then
|
jcallahan@245
|
1264 Debug("%s: %s is not an NPC, or has no ID.", sub_event, dest_name or _G.UNKNOWN)
|
jcallahan@177
|
1265 ClearKilledNPC()
|
jcallahan@216
|
1266 ClearKilledBossID()
|
jcallahan@98
|
1267 private.harvesting = nil
|
jcallahan@65
|
1268 return
|
jcallahan@65
|
1269 end
|
jcallahan@177
|
1270
|
jcallahan@246
|
1271 if source_guid == "" then
|
jcallahan@246
|
1272 source_guid = nil
|
jcallahan@246
|
1273 end
|
jcallahan@246
|
1274 local killer_guid = source_guid or previous_combat_event.source_guid
|
jcallahan@246
|
1275 local killer_name = source_name or previous_combat_event.source_name
|
jcallahan@246
|
1276
|
jcallahan@246
|
1277 if not group_member_uids[killer_guid] and not group_pet_guids[killer_guid] then
|
jcallahan@217
|
1278 ClearKilledNPC()
|
jcallahan@217
|
1279 ClearKilledBossID()
|
jcallahan@217
|
1280 return
|
jcallahan@217
|
1281 end
|
jcallahan@217
|
1282
|
jcallahan@177
|
1283 if private.RAID_FINDER_BOSS_IDS[unit_idnum] then
|
jcallahan@245
|
1284 Debug("%s: Matching boss %s.", sub_event, dest_name)
|
jcallahan@216
|
1285 ClearKilledBossID()
|
jcallahan@184
|
1286 private.raid_finder_boss_id = unit_idnum
|
jcallahan@203
|
1287 elseif private.WORLD_BOSS_IDS[unit_idnum] then
|
jcallahan@245
|
1288 Debug("%s: Matching world boss %s.", sub_event, dest_name)
|
jcallahan@216
|
1289 ClearKilledBossID()
|
jcallahan@203
|
1290 private.world_boss_id = unit_idnum
|
jcallahan@182
|
1291 else
|
jcallahan@245
|
1292 Debug("%s: Killed NPC %s (ID: %d) is not in LFG or World boss list.", sub_event, dest_name, unit_idnum)
|
jcallahan@177
|
1293 end
|
jcallahan@183
|
1294
|
jcallahan@177
|
1295 killed_npc_id = unit_idnum
|
jcallahan@177
|
1296 WDP:ScheduleTimer(ClearKilledNPC, 0.1)
|
jcallahan@203
|
1297 WDP:ScheduleTimer(ClearKilledBossID, 1)
|
jcallahan@65
|
1298 end,
|
jcallahan@23
|
1299 }
|
jcallahan@23
|
1300
|
jcallahan@23
|
1301
|
jcallahan@246
|
1302 local NON_DAMAGE_EVENTS = {
|
jcallahan@246
|
1303 SPELL_AURA_APPLIED = true,
|
jcallahan@246
|
1304 SPELL_AURA_REMOVED = true,
|
jcallahan@246
|
1305 SPELL_AURA_REMOVED_DOSE = true,
|
jcallahan@246
|
1306 SPELL_CAST_FAILED = true,
|
jcallahan@246
|
1307 SWING_MISSED = true,
|
jcallahan@246
|
1308 }
|
jcallahan@246
|
1309
|
jcallahan@246
|
1310
|
jcallahan@92
|
1311 function WDP:COMBAT_LOG_EVENT_UNFILTERED(event_name, time_stamp, sub_event, hide_caster, source_guid, source_name, source_flags, source_raid_flags, dest_guid, dest_name, dest_flags, dest_raid_flags, ...)
|
jcallahan@23
|
1312 local combat_log_func = COMBAT_LOG_FUNCS[sub_event]
|
jcallahan@23
|
1313
|
jcallahan@23
|
1314 if not combat_log_func then
|
jcallahan@246
|
1315 if not NON_DAMAGE_EVENTS[sub_event] then
|
jcallahan@253
|
1316 -- Uncomment to look for other sub-events to blacklist.
|
jcallahan@253
|
1317 -- Debug("Recording for %s", sub_event)
|
jcallahan@246
|
1318 previous_combat_event.source_guid = source_guid
|
jcallahan@246
|
1319 previous_combat_event.source_name = source_name
|
jcallahan@246
|
1320 previous_combat_event.dest_guid = dest_guid
|
jcallahan@246
|
1321 previous_combat_event.dest_name = dest_name
|
jcallahan@246
|
1322 end
|
jcallahan@23
|
1323 return
|
jcallahan@23
|
1324 end
|
jcallahan@23
|
1325 combat_log_func(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, ...)
|
jcallahan@246
|
1326 table.wipe(previous_combat_event)
|
jcallahan@23
|
1327 end
|
jcallahan@23
|
1328
|
jcallahan@44
|
1329 local DIPLOMACY_SPELL_ID = 20599
|
jcallahan@44
|
1330 local MR_POP_RANK1_SPELL_ID = 78634
|
jcallahan@44
|
1331 local MR_POP_RANK2_SPELL_ID = 78635
|
jcallahan@44
|
1332
|
jcallahan@44
|
1333 local REP_BUFFS = {
|
jcallahan@44
|
1334 [_G.GetSpellInfo(30754)] = "CENARION_FAVOR",
|
jcallahan@44
|
1335 [_G.GetSpellInfo(24705)] = "GRIM_VISAGE",
|
jcallahan@44
|
1336 [_G.GetSpellInfo(32098)] = "HONOR_HOLD_FAVOR",
|
jcallahan@44
|
1337 [_G.GetSpellInfo(39913)] = "NAZGRELS_FERVOR",
|
jcallahan@44
|
1338 [_G.GetSpellInfo(39953)] = "SONG_OF_BATTLE",
|
jcallahan@44
|
1339 [_G.GetSpellInfo(61849)] = "SPIRIT_OF_SHARING",
|
jcallahan@44
|
1340 [_G.GetSpellInfo(32096)] = "THRALLMARS_FAVOR",
|
jcallahan@44
|
1341 [_G.GetSpellInfo(39911)] = "TROLLBANES_COMMAND",
|
jcallahan@44
|
1342 [_G.GetSpellInfo(95987)] = "UNBURDENED",
|
jcallahan@44
|
1343 [_G.GetSpellInfo(100951)] = "WOW_ANNIVERSARY",
|
jcallahan@44
|
1344 }
|
jcallahan@44
|
1345
|
jcallahan@44
|
1346
|
jcallahan@44
|
1347 local FACTION_NAMES = {
|
jcallahan@44
|
1348 CENARION_CIRCLE = _G.GetFactionInfoByID(609),
|
jcallahan@44
|
1349 HONOR_HOLD = _G.GetFactionInfoByID(946),
|
jcallahan@44
|
1350 THE_SHATAR = _G.GetFactionInfoByID(935),
|
jcallahan@44
|
1351 THRALLMAR = _G.GetFactionInfoByID(947),
|
jcallahan@44
|
1352 }
|
jcallahan@44
|
1353
|
jcallahan@44
|
1354
|
jcallahan@44
|
1355 local MODIFIERS = {
|
jcallahan@44
|
1356 CENARION_FAVOR = {
|
jcallahan@44
|
1357 faction = FACTION_NAMES.CENARION_CIRCLE,
|
jcallahan@44
|
1358 modifier = 0.25,
|
jcallahan@44
|
1359 },
|
jcallahan@44
|
1360 GRIM_VISAGE = {
|
jcallahan@44
|
1361 modifier = 0.1,
|
jcallahan@44
|
1362 },
|
jcallahan@44
|
1363 HONOR_HOLD_FAVOR = {
|
jcallahan@44
|
1364 faction = FACTION_NAMES.HONOR_HOLD,
|
jcallahan@44
|
1365 modifier = 0.25,
|
jcallahan@44
|
1366 },
|
jcallahan@44
|
1367 NAZGRELS_FERVOR = {
|
jcallahan@44
|
1368 faction = FACTION_NAMES.THRALLMAR,
|
jcallahan@44
|
1369 modifier = 0.1,
|
jcallahan@44
|
1370 },
|
jcallahan@44
|
1371 SONG_OF_BATTLE = {
|
jcallahan@44
|
1372 faction = FACTION_NAMES.THE_SHATAR,
|
jcallahan@44
|
1373 modifier = 0.1,
|
jcallahan@44
|
1374 },
|
jcallahan@44
|
1375 SPIRIT_OF_SHARING = {
|
jcallahan@44
|
1376 modifier = 0.1,
|
jcallahan@44
|
1377 },
|
jcallahan@44
|
1378 THRALLMARS_FAVOR = {
|
jcallahan@44
|
1379 faction = FACTION_NAMES.THRALLMAR,
|
jcallahan@44
|
1380 modifier = 0.25,
|
jcallahan@44
|
1381 },
|
jcallahan@44
|
1382 TROLLBANES_COMMAND = {
|
jcallahan@44
|
1383 faction = FACTION_NAMES.HONOR_HOLD,
|
jcallahan@44
|
1384 modifier = 0.1,
|
jcallahan@44
|
1385 },
|
jcallahan@44
|
1386 UNBURDENED = {
|
jcallahan@44
|
1387 modifier = 0.1,
|
jcallahan@44
|
1388 },
|
jcallahan@44
|
1389 WOW_ANNIVERSARY = {
|
jcallahan@44
|
1390 modifier = 0.08,
|
jcallahan@44
|
1391 }
|
jcallahan@44
|
1392 }
|
jcallahan@44
|
1393
|
jcallahan@44
|
1394
|
jcallahan@92
|
1395 function WDP:COMBAT_TEXT_UPDATE(event_name, message_type, faction_name, amount)
|
jcallahan@177
|
1396 if message_type ~= "FACTION" or not killed_npc_id then
|
jcallahan@44
|
1397 return
|
jcallahan@44
|
1398 end
|
jcallahan@44
|
1399 UpdateFactionData()
|
jcallahan@44
|
1400
|
jcallahan@46
|
1401 if not faction_name or not faction_standings[faction_name] then
|
jcallahan@46
|
1402 return
|
jcallahan@46
|
1403 end
|
jcallahan@177
|
1404 local npc = NPCEntry(killed_npc_id)
|
jcallahan@177
|
1405 ClearKilledNPC()
|
jcallahan@46
|
1406
|
jcallahan@44
|
1407 if not npc then
|
jcallahan@98
|
1408 private.harvesting = nil
|
jcallahan@44
|
1409 return
|
jcallahan@44
|
1410 end
|
jcallahan@98
|
1411 npc.harvested = private.harvesting
|
jcallahan@98
|
1412 private.harvesting = nil
|
jcallahan@98
|
1413
|
jcallahan@44
|
1414 local modifier = 1
|
jcallahan@44
|
1415
|
jcallahan@44
|
1416 if _G.IsSpellKnown(DIPLOMACY_SPELL_ID) then
|
jcallahan@44
|
1417 modifier = modifier + 0.1
|
jcallahan@44
|
1418 end
|
jcallahan@44
|
1419
|
jcallahan@44
|
1420 if _G.IsSpellKnown(MR_POP_RANK2_SPELL_ID) then
|
jcallahan@44
|
1421 modifier = modifier + 0.1
|
jcallahan@44
|
1422 elseif _G.IsSpellKnown(MR_POP_RANK1_SPELL_ID) then
|
jcallahan@44
|
1423 modifier = modifier + 0.05
|
jcallahan@44
|
1424 end
|
jcallahan@44
|
1425
|
jcallahan@44
|
1426 for buff_name, buff_label in pairs(REP_BUFFS) do
|
jcallahan@44
|
1427 if _G.UnitBuff("player", buff_name) then
|
jcallahan@44
|
1428 local modded_faction = MODIFIERS[buff_label].faction
|
jcallahan@44
|
1429
|
jcallahan@44
|
1430 if not modded_faction or faction_name == modded_faction then
|
jcallahan@44
|
1431 modifier = modifier + MODIFIERS[buff_label].modifier
|
jcallahan@44
|
1432 end
|
jcallahan@44
|
1433 end
|
jcallahan@44
|
1434 end
|
jcallahan@65
|
1435 npc.reputations = npc.reputations or {}
|
jcallahan@65
|
1436 npc.reputations[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier)
|
jcallahan@32
|
1437 end
|
jcallahan@44
|
1438 end -- do-block
|
jcallahan@18
|
1439
|
jcallahan@18
|
1440
|
jcallahan@140
|
1441 function WDP:CURSOR_UPDATE(event_name)
|
jcallahan@141
|
1442 if current_action.fishing_target or _G.Minimap:IsMouseOver() or current_action.spell_label ~= "FISHING" then
|
jcallahan@140
|
1443 return
|
jcallahan@140
|
1444 end
|
jcallahan@140
|
1445 local text = _G["GameTooltipTextLeft1"]:GetText()
|
jcallahan@140
|
1446
|
jcallahan@140
|
1447 if not text or text == "Fishing Bobber" then
|
jcallahan@140
|
1448 text = "NONE"
|
jcallahan@140
|
1449 else
|
jcallahan@140
|
1450 current_action.fishing_target = true
|
jcallahan@140
|
1451 end
|
jcallahan@140
|
1452 current_action.identifier = ("%s:%s"):format(current_action.spell_label, text)
|
jcallahan@140
|
1453 end
|
jcallahan@140
|
1454
|
jcallahan@140
|
1455
|
jcallahan@92
|
1456 function WDP:ITEM_TEXT_BEGIN(event_name)
|
jcallahan@42
|
1457 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
|
jcallahan@42
|
1458
|
jcallahan@42
|
1459 if not unit_idnum or unit_type ~= private.UNIT_TYPES.OBJECT or _G.UnitName("npc") ~= _G.ItemTextGetItem() then
|
jcallahan@42
|
1460 return
|
jcallahan@42
|
1461 end
|
jcallahan@42
|
1462 UpdateDBEntryLocation("objects", unit_idnum)
|
jcallahan@42
|
1463 end
|
jcallahan@42
|
1464
|
jcallahan@42
|
1465
|
jcallahan@13
|
1466 do
|
jcallahan@40
|
1467 local RE_GOLD = _G.GOLD_AMOUNT:gsub("%%d", "(%%d+)")
|
jcallahan@40
|
1468 local RE_SILVER = _G.SILVER_AMOUNT:gsub("%%d", "(%%d+)")
|
jcallahan@40
|
1469 local RE_COPPER = _G.COPPER_AMOUNT:gsub("%%d", "(%%d+)")
|
jcallahan@13
|
1470
|
jcallahan@13
|
1471
|
jcallahan@13
|
1472 local function _moneyMatch(money, re)
|
jcallahan@13
|
1473 return money:match(re) or 0
|
jcallahan@1
|
1474 end
|
jcallahan@1
|
1475
|
jcallahan@0
|
1476
|
jcallahan@13
|
1477 local function _toCopper(money)
|
jcallahan@13
|
1478 if not money then
|
jcallahan@13
|
1479 return 0
|
jcallahan@13
|
1480 end
|
jcallahan@40
|
1481 return _moneyMatch(money, RE_GOLD) * 10000 + _moneyMatch(money, RE_SILVER) * 100 + _moneyMatch(money, RE_COPPER)
|
jcallahan@1
|
1482 end
|
jcallahan@1
|
1483
|
jcallahan@1
|
1484
|
jcallahan@176
|
1485 local LOOT_OPENED_VERIFY_FUNCS = {
|
jcallahan@16
|
1486 [AF.ITEM] = function()
|
jcallahan@16
|
1487 local locked_item_id
|
jcallahan@16
|
1488
|
jcallahan@16
|
1489 for bag_index = 0, _G.NUM_BAG_FRAMES do
|
jcallahan@16
|
1490 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do
|
jcallahan@16
|
1491 local _, _, is_locked = _G.GetContainerItemInfo(bag_index, slot_index)
|
jcallahan@16
|
1492
|
jcallahan@16
|
1493 if is_locked then
|
jcallahan@16
|
1494 locked_item_id = ItemLinkToID(_G.GetContainerItemLink(bag_index, slot_index))
|
jcallahan@165
|
1495 break
|
jcallahan@16
|
1496 end
|
jcallahan@16
|
1497 end
|
jcallahan@165
|
1498
|
jcallahan@165
|
1499 if locked_item_id then
|
jcallahan@165
|
1500 break
|
jcallahan@165
|
1501 end
|
jcallahan@16
|
1502 end
|
jcallahan@16
|
1503
|
jcallahan@122
|
1504 if not locked_item_id or (current_action.identifier and current_action.identifier ~= locked_item_id) then
|
jcallahan@16
|
1505 return false
|
jcallahan@16
|
1506 end
|
jcallahan@122
|
1507 current_action.identifier = locked_item_id
|
jcallahan@16
|
1508 return true
|
jcallahan@16
|
1509 end,
|
jcallahan@13
|
1510 [AF.NPC] = function()
|
jcallahan@17
|
1511 if not _G.UnitExists("target") or _G.UnitIsFriend("player", "target") or _G.UnitIsPlayer("target") or _G.UnitPlayerControlled("target") then
|
jcallahan@15
|
1512 return false
|
jcallahan@13
|
1513 end
|
jcallahan@205
|
1514
|
jcallahan@205
|
1515 if not current_action.identifier then
|
jcallahan@205
|
1516 local unit_type, id_num = ParseGUID(_G.UnitGUID("target"))
|
jcallahan@205
|
1517 current_action.identifier = id_num
|
jcallahan@205
|
1518 end
|
jcallahan@13
|
1519 return true
|
jcallahan@13
|
1520 end,
|
jcallahan@14
|
1521 [AF.OBJECT] = true,
|
jcallahan@17
|
1522 [AF.ZONE] = function()
|
jcallahan@140
|
1523 current_action.zone_data = UpdateDBEntryLocation("zones", current_action.identifier)
|
jcallahan@210
|
1524 return _G.IsFishingLoot()
|
jcallahan@17
|
1525 end,
|
jcallahan@13
|
1526 }
|
jcallahan@13
|
1527
|
jcallahan@13
|
1528
|
jcallahan@176
|
1529 local LOOT_OPENED_UPDATE_FUNCS = {
|
jcallahan@16
|
1530 [AF.ITEM] = function()
|
jcallahan@28
|
1531 GenericLootUpdate("items")
|
jcallahan@28
|
1532 end,
|
jcallahan@28
|
1533 [AF.NPC] = function()
|
jcallahan@75
|
1534 local difficulty_token = InstanceDifficultyToken()
|
jcallahan@132
|
1535 local loot_type = current_loot.label
|
jcallahan@77
|
1536 local source_list = {}
|
jcallahan@75
|
1537
|
jcallahan@131
|
1538 for source_guid, loot_data in pairs(current_loot.sources) do
|
jcallahan@78
|
1539 local source_id = select(2, ParseGUID(source_guid))
|
jcallahan@75
|
1540 local npc = NPCEntry(source_id)
|
jcallahan@75
|
1541
|
jcallahan@75
|
1542 if npc then
|
jcallahan@248
|
1543 local encounter_data = npc:EncounterData(difficulty_token)
|
jcallahan@75
|
1544 encounter_data[loot_type] = encounter_data[loot_type] or {}
|
jcallahan@75
|
1545
|
jcallahan@78
|
1546 if not source_list[source_guid] then
|
jcallahan@77
|
1547 encounter_data.loot_counts = encounter_data.loot_counts or {}
|
jcallahan@77
|
1548 encounter_data.loot_counts[loot_type] = (encounter_data.loot_counts[loot_type] or 0) + 1
|
jcallahan@77
|
1549 source_list[source_id] = true
|
jcallahan@77
|
1550 end
|
jcallahan@77
|
1551
|
jcallahan@75
|
1552 for item_id, quantity in pairs(loot_data) do
|
jcallahan@75
|
1553 table.insert(encounter_data[loot_type], ("%d:%d"):format(item_id, quantity))
|
jcallahan@75
|
1554 end
|
jcallahan@75
|
1555 end
|
jcallahan@75
|
1556 end
|
jcallahan@75
|
1557
|
jcallahan@75
|
1558 -- TODO: Remove this when GetLootSourceInfo() has values for money
|
jcallahan@131
|
1559 if #current_loot.list <= 0 then
|
jcallahan@79
|
1560 return
|
jcallahan@79
|
1561 end
|
jcallahan@131
|
1562 local npc = NPCEntry(current_loot.identifier)
|
jcallahan@28
|
1563
|
jcallahan@28
|
1564 if not npc then
|
jcallahan@28
|
1565 return
|
jcallahan@28
|
1566 end
|
jcallahan@248
|
1567 local encounter_data = npc:EncounterData(difficulty_token)
|
jcallahan@29
|
1568 encounter_data[loot_type] = encounter_data[loot_type] or {}
|
jcallahan@16
|
1569
|
jcallahan@131
|
1570 if not source_list[current_loot.identifier] then
|
jcallahan@77
|
1571 encounter_data.loot_counts = encounter_data.loot_counts or {}
|
jcallahan@77
|
1572 encounter_data.loot_counts[loot_type] = (encounter_data.loot_counts[loot_type] or 0) + 1
|
jcallahan@77
|
1573 end
|
jcallahan@77
|
1574
|
jcallahan@131
|
1575 for index = 1, #current_loot.list do
|
jcallahan@131
|
1576 table.insert(encounter_data[loot_type], current_loot.list[index])
|
jcallahan@16
|
1577 end
|
jcallahan@16
|
1578 end,
|
jcallahan@13
|
1579 [AF.OBJECT] = function()
|
jcallahan@28
|
1580 GenericLootUpdate("objects", InstanceDifficultyToken())
|
jcallahan@17
|
1581 end,
|
jcallahan@17
|
1582 [AF.ZONE] = function()
|
jcallahan@141
|
1583 local location_token = ("%d:%d:%d"):format(current_loot.map_level, current_loot.x, current_loot.y)
|
jcallahan@41
|
1584
|
jcallahan@41
|
1585 -- This will start life as a boolean true.
|
jcallahan@131
|
1586 if _G.type(current_loot.zone_data[location_token]) ~= "table" then
|
jcallahan@131
|
1587 current_loot.zone_data[location_token] = {
|
jcallahan@41
|
1588 drops = {}
|
jcallahan@41
|
1589 }
|
jcallahan@41
|
1590 end
|
jcallahan@132
|
1591 local loot_count = ("%s_count"):format(current_loot.label)
|
jcallahan@131
|
1592 current_loot.zone_data[location_token][loot_count] = (current_loot.zone_data[location_token][loot_count] or 0) + 1
|
jcallahan@41
|
1593
|
jcallahan@131
|
1594 if current_loot.sources then
|
jcallahan@131
|
1595 for source_guid, loot_data in pairs(current_loot.sources) do
|
jcallahan@131
|
1596 for item_id, quantity in pairs(loot_data) do
|
jcallahan@131
|
1597 table.insert(current_loot.zone_data[location_token].drops, ("%d:%d"):format(item_id, quantity))
|
jcallahan@131
|
1598 end
|
jcallahan@131
|
1599 end
|
jcallahan@131
|
1600 end
|
jcallahan@131
|
1601
|
jcallahan@131
|
1602 if #current_loot.list <= 0 then
|
jcallahan@131
|
1603 return
|
jcallahan@131
|
1604 end
|
jcallahan@131
|
1605
|
jcallahan@131
|
1606 for index = 1, #current_loot.list do
|
jcallahan@131
|
1607 table.insert(current_loot.zone_data[location_token].drops, current_loot.loot_list[index])
|
jcallahan@41
|
1608 end
|
jcallahan@13
|
1609 end,
|
jcallahan@13
|
1610 }
|
jcallahan@13
|
1611
|
jcallahan@79
|
1612 -- Prevent opening the same loot window multiple times from recording data multiple times.
|
jcallahan@79
|
1613 local loot_guid_registry = {}
|
jcallahan@124
|
1614
|
jcallahan@124
|
1615
|
jcallahan@124
|
1616 function WDP:LOOT_CLOSED(event_name)
|
jcallahan@131
|
1617 current_loot = nil
|
jcallahan@131
|
1618 table.wipe(current_action)
|
jcallahan@124
|
1619 end
|
jcallahan@124
|
1620
|
jcallahan@13
|
1621
|
jcallahan@92
|
1622 function WDP:LOOT_OPENED(event_name)
|
jcallahan@132
|
1623 if current_loot then
|
jcallahan@18
|
1624 return
|
jcallahan@18
|
1625 end
|
jcallahan@151
|
1626
|
jcallahan@151
|
1627 if not current_action.target_type then
|
jcallahan@151
|
1628 return
|
jcallahan@151
|
1629 end
|
jcallahan@176
|
1630 local verify_func = LOOT_OPENED_VERIFY_FUNCS[current_action.target_type]
|
jcallahan@176
|
1631 local update_func = LOOT_OPENED_UPDATE_FUNCS[current_action.target_type]
|
jcallahan@13
|
1632
|
jcallahan@14
|
1633 if not verify_func or not update_func then
|
jcallahan@13
|
1634 return
|
jcallahan@13
|
1635 end
|
jcallahan@13
|
1636
|
jcallahan@14
|
1637 if _G.type(verify_func) == "function" and not verify_func() then
|
jcallahan@14
|
1638 return
|
jcallahan@14
|
1639 end
|
jcallahan@80
|
1640 local guids_used = {}
|
jcallahan@132
|
1641
|
jcallahan@131
|
1642 current_loot = {
|
jcallahan@131
|
1643 list = {},
|
jcallahan@131
|
1644 sources = {},
|
jcallahan@131
|
1645 identifier = current_action.identifier,
|
jcallahan@132
|
1646 label = current_action.loot_label or "drops",
|
jcallahan@131
|
1647 map_level = current_action.map_level,
|
jcallahan@131
|
1648 object_name = current_action.object_name,
|
jcallahan@131
|
1649 spell_label = current_action.spell_label,
|
jcallahan@131
|
1650 target_type = current_action.target_type,
|
jcallahan@131
|
1651 x = current_action.x,
|
jcallahan@131
|
1652 y = current_action.y,
|
jcallahan@131
|
1653 zone_data = current_action.zone_data,
|
jcallahan@131
|
1654 }
|
jcallahan@131
|
1655 table.wipe(current_action)
|
jcallahan@13
|
1656
|
jcallahan@217
|
1657 loot_guid_registry[current_loot.label] = loot_guid_registry[current_loot.label] or {}
|
jcallahan@217
|
1658
|
jcallahan@55
|
1659 for loot_slot = 1, _G.GetNumLootItems() do
|
jcallahan@55
|
1660 local icon_texture, item_text, quantity, quality, locked = _G.GetLootSlotInfo(loot_slot)
|
jcallahan@55
|
1661 local slot_type = _G.GetLootSlotType(loot_slot)
|
jcallahan@237
|
1662 local loot_info = {
|
jcallahan@237
|
1663 _G.GetLootSourceInfo(loot_slot)
|
jcallahan@237
|
1664 }
|
jcallahan@13
|
1665
|
jcallahan@237
|
1666 -- Odd index is GUID, even is count.
|
jcallahan@237
|
1667 for loot_index = 1, #loot_info, 2 do
|
jcallahan@237
|
1668 local source_guid = loot_info[loot_index]
|
jcallahan@75
|
1669
|
jcallahan@237
|
1670 if not loot_guid_registry[current_loot.label][source_guid] then
|
jcallahan@237
|
1671 local loot_quantity = loot_info[loot_index + 1]
|
jcallahan@237
|
1672 local source_type, source_id = ParseGUID(source_guid)
|
jcallahan@237
|
1673 local source_key = ("%s:%d"):format(private.UNIT_TYPE_NAMES[source_type + 1], source_id)
|
jcallahan@245
|
1674 Debug("GUID: %s - Type:ID: %s - Amount: %d", loot_info[loot_index], source_key, loot_quantity)
|
jcallahan@77
|
1675
|
jcallahan@237
|
1676 if slot_type == _G.LOOT_SLOT_ITEM then
|
jcallahan@79
|
1677 local item_id = ItemLinkToID(_G.GetLootSlotLink(loot_slot))
|
jcallahan@131
|
1678 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {}
|
jcallahan@131
|
1679 current_loot.sources[source_guid][item_id] = current_loot.sources[source_guid][item_id] or 0 + loot_quantity
|
jcallahan@80
|
1680 guids_used[source_guid] = true
|
jcallahan@237
|
1681 elseif slot_type == _G.LOOT_SLOT_MONEY then
|
jcallahan@245
|
1682 Debug("money:%d", _toCopper(item_text))
|
jcallahan@237
|
1683 table.insert(current_loot.list, ("money:%d"):format(_toCopper(item_text)))
|
jcallahan@237
|
1684 elseif slot_type == _G.LOOT_SLOT_CURRENCY then
|
jcallahan@245
|
1685 Debug("Found currency: %s", icon_texture)
|
jcallahan@237
|
1686 table.insert(current_loot.list, ("currency:%d:%s"):format(quantity, icon_texture:match("[^\\]+$"):lower()))
|
jcallahan@79
|
1687 end
|
jcallahan@75
|
1688 end
|
jcallahan@13
|
1689 end
|
jcallahan@13
|
1690 end
|
jcallahan@80
|
1691
|
jcallahan@81
|
1692 for guid in pairs(guids_used) do
|
jcallahan@217
|
1693 loot_guid_registry[current_loot.label][guid] = true
|
jcallahan@80
|
1694 end
|
jcallahan@13
|
1695 update_func()
|
jcallahan@1
|
1696 end
|
jcallahan@13
|
1697 end -- do-block
|
jcallahan@0
|
1698
|
jcallahan@0
|
1699
|
jcallahan@89
|
1700 function WDP:MAIL_SHOW(event_name)
|
jcallahan@89
|
1701 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
|
jcallahan@89
|
1702
|
jcallahan@89
|
1703 if not unit_idnum or unit_type ~= private.UNIT_TYPES.OBJECT then
|
jcallahan@89
|
1704 return
|
jcallahan@89
|
1705 end
|
jcallahan@89
|
1706 UpdateDBEntryLocation("objects", unit_idnum)
|
jcallahan@89
|
1707 end
|
jcallahan@89
|
1708
|
jcallahan@89
|
1709
|
jcallahan@44
|
1710 do
|
jcallahan@44
|
1711 local POINT_MATCH_PATTERNS = {
|
jcallahan@44
|
1712 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING:gsub("%%d", "(%%d+)")), -- May no longer be necessary
|
jcallahan@44
|
1713 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3:gsub("%%d", "(%%d+)")), -- May no longer be necessary
|
jcallahan@44
|
1714 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_5V5:gsub("%%d", "(%%d+)")), -- May no longer be necessary
|
jcallahan@44
|
1715 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_BG:gsub("%%d", "(%%d+)")),
|
jcallahan@44
|
1716 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3_BG:gsub("%%d", "(%%d+)")),
|
jcallahan@44
|
1717 }
|
jcallahan@5
|
1718
|
jcallahan@68
|
1719 local ITEM_REQ_REPUTATION_MATCH = "Requires (.-) %- (.*)"
|
jcallahan@87
|
1720 local ITEM_REQ_QUEST_MATCH1 = "Requires: .*"
|
jcallahan@87
|
1721 local ITEM_REQ_QUEST_MATCH2 = "Must have completed: .*"
|
jcallahan@68
|
1722
|
jcallahan@133
|
1723 local current_merchant
|
jcallahan@133
|
1724 local merchant_standing
|
jcallahan@133
|
1725
|
jcallahan@133
|
1726 function WDP:MERCHANT_CLOSED(event_name)
|
jcallahan@133
|
1727 current_merchant = nil
|
jcallahan@133
|
1728 merchant_standing = nil
|
jcallahan@133
|
1729 end
|
jcallahan@133
|
1730
|
jcallahan@133
|
1731
|
jcallahan@89
|
1732 function WDP:UpdateMerchantItems(event_name)
|
jcallahan@144
|
1733 if not current_merchant or event_name == "MERCHANT_SHOW" then
|
jcallahan@195
|
1734 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
|
jcallahan@4
|
1735
|
jcallahan@171
|
1736 if not unit_idnum or not UnitTypeIsNPC(unit_type) then
|
jcallahan@133
|
1737 return
|
jcallahan@133
|
1738 end
|
jcallahan@195
|
1739 merchant_standing = select(2, UnitFactionStanding("npc"))
|
jcallahan@133
|
1740 current_merchant = NPCEntry(unit_idnum)
|
jcallahan@133
|
1741 current_merchant.sells = current_merchant.sells or {}
|
jcallahan@44
|
1742 end
|
jcallahan@55
|
1743 local current_filters = _G.GetMerchantFilter()
|
jcallahan@57
|
1744 _G.SetMerchantFilter(_G.LE_LOOT_FILTER_ALL)
|
jcallahan@57
|
1745 _G.MerchantFrame_Update()
|
jcallahan@57
|
1746
|
jcallahan@150
|
1747 local num_items = _G.GetMerchantNumItems()
|
jcallahan@150
|
1748
|
jcallahan@44
|
1749 for item_index = 1, num_items do
|
jcallahan@44
|
1750 local _, _, copper_price, stack_size, num_available, _, extended_cost = _G.GetMerchantItemInfo(item_index)
|
jcallahan@44
|
1751 local item_id = ItemLinkToID(_G.GetMerchantItemLink(item_index))
|
jcallahan@5
|
1752
|
jcallahan@44
|
1753 if item_id and item_id > 0 then
|
jcallahan@44
|
1754 local price_string = ActualCopperCost(copper_price, merchant_standing)
|
jcallahan@5
|
1755
|
jcallahan@68
|
1756 DatamineTT:ClearLines()
|
jcallahan@68
|
1757 DatamineTT:SetMerchantItem(item_index)
|
jcallahan@68
|
1758
|
jcallahan@68
|
1759 local num_lines = DatamineTT:NumLines()
|
jcallahan@68
|
1760
|
jcallahan@68
|
1761 for line_index = 1, num_lines do
|
jcallahan@68
|
1762 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
|
jcallahan@68
|
1763
|
jcallahan@68
|
1764 if not current_line then
|
jcallahan@68
|
1765 break
|
jcallahan@68
|
1766 end
|
jcallahan@68
|
1767 local faction, reputation = current_line:GetText():match(ITEM_REQ_REPUTATION_MATCH)
|
jcallahan@68
|
1768
|
jcallahan@68
|
1769 if faction or reputation then
|
jcallahan@68
|
1770 DBEntry("items", item_id).req_reputation = ("%s:%s"):format(faction:gsub("-", ""), reputation:upper())
|
jcallahan@68
|
1771 break
|
jcallahan@68
|
1772 end
|
jcallahan@68
|
1773 end
|
jcallahan@68
|
1774
|
jcallahan@87
|
1775 for line_index = 1, num_lines do
|
jcallahan@87
|
1776 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
|
jcallahan@87
|
1777
|
jcallahan@87
|
1778 if not current_line then
|
jcallahan@87
|
1779 break
|
jcallahan@87
|
1780 end
|
jcallahan@87
|
1781 local line_text = current_line:GetText()
|
jcallahan@87
|
1782 local quest_name = line_text:match(ITEM_REQ_QUEST_MATCH1) or line_text:match(ITEM_REQ_QUEST_MATCH2)
|
jcallahan@87
|
1783
|
jcallahan@87
|
1784 if quest_name then
|
jcallahan@87
|
1785 DBEntry("items", item_id).req_quest = ("%s"):format(quest_name:gsub("(.+): ", ""), quest_name)
|
jcallahan@87
|
1786 break
|
jcallahan@87
|
1787 end
|
jcallahan@87
|
1788 end
|
jcallahan@87
|
1789
|
jcallahan@44
|
1790 if extended_cost then
|
jcallahan@53
|
1791 local battleground_rating = 0
|
jcallahan@53
|
1792 local personal_rating = 0
|
jcallahan@53
|
1793 local required_season_amount
|
jcallahan@5
|
1794
|
jcallahan@68
|
1795 for line_index = 1, num_lines do
|
jcallahan@44
|
1796 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
|
jcallahan@5
|
1797
|
jcallahan@44
|
1798 if not current_line then
|
jcallahan@44
|
1799 break
|
jcallahan@44
|
1800 end
|
jcallahan@53
|
1801 required_season_amount = current_line:GetText():match("Requires earning a total of (%d+)\n(.-) for the season.")
|
jcallahan@5
|
1802
|
jcallahan@44
|
1803 for match_index = 1, #POINT_MATCH_PATTERNS do
|
jcallahan@44
|
1804 local match1, match2 = current_line:GetText():match(POINT_MATCH_PATTERNS[match_index])
|
jcallahan@53
|
1805 personal_rating = personal_rating + (match1 or 0)
|
jcallahan@53
|
1806 battleground_rating = battleground_rating + (match2 or 0)
|
jcallahan@5
|
1807
|
jcallahan@44
|
1808 if match1 or match2 then
|
jcallahan@44
|
1809 break
|
jcallahan@44
|
1810 end
|
jcallahan@44
|
1811 end
|
jcallahan@5
|
1812 end
|
jcallahan@44
|
1813 local currency_list = {}
|
jcallahan@44
|
1814 local item_count = _G.GetMerchantItemCostInfo(item_index)
|
jcallahan@50
|
1815
|
jcallahan@50
|
1816 -- Keeping this around in case Blizzard makes the two points diverge at some point.
|
jcallahan@53
|
1817 -- price_string = ("%s:%s:%s:%s"):format(price_string, battleground_rating, personal_rating, required_season_amount or 0)
|
jcallahan@53
|
1818 price_string = ("%s:%s:%s"):format(price_string, personal_rating, required_season_amount or 0)
|
jcallahan@5
|
1819
|
jcallahan@44
|
1820 for cost_index = 1, item_count do
|
jcallahan@44
|
1821 local icon_texture, amount_required, currency_link = _G.GetMerchantItemCostItem(item_index, cost_index)
|
jcallahan@44
|
1822 local currency_id = currency_link and ItemLinkToID(currency_link) or nil
|
jcallahan@44
|
1823
|
jcallahan@44
|
1824 if (not currency_id or currency_id < 1) and icon_texture then
|
jcallahan@44
|
1825 currency_id = icon_texture:match("[^\\]+$"):lower()
|
jcallahan@44
|
1826 end
|
jcallahan@44
|
1827
|
jcallahan@44
|
1828 if currency_id then
|
jcallahan@44
|
1829 currency_list[#currency_list + 1] = ("(%s:%s)"):format(amount_required, currency_id)
|
jcallahan@44
|
1830 end
|
jcallahan@44
|
1831 end
|
jcallahan@44
|
1832
|
jcallahan@44
|
1833 for currency_index = 1, #currency_list do
|
jcallahan@44
|
1834 price_string = ("%s:%s"):format(price_string, currency_list[currency_index])
|
jcallahan@5
|
1835 end
|
jcallahan@5
|
1836 end
|
jcallahan@133
|
1837 current_merchant.sells[item_id] = ("%s:%s:[%s]"):format(num_available, stack_size, price_string)
|
jcallahan@44
|
1838 end
|
jcallahan@44
|
1839 end
|
jcallahan@5
|
1840
|
jcallahan@44
|
1841 if _G.CanMerchantRepair() then
|
jcallahan@133
|
1842 current_merchant.can_repair = true
|
jcallahan@5
|
1843 end
|
jcallahan@57
|
1844 _G.SetMerchantFilter(current_filters)
|
jcallahan@57
|
1845 _G.MerchantFrame_Update()
|
jcallahan@4
|
1846 end
|
jcallahan@44
|
1847 end -- do-block
|
jcallahan@4
|
1848
|
jcallahan@89
|
1849
|
jcallahan@92
|
1850 function WDP:PET_BAR_UPDATE(event_name)
|
jcallahan@122
|
1851 if current_action.spell_label ~= "MIND_CONTROL" then
|
jcallahan@25
|
1852 return
|
jcallahan@25
|
1853 end
|
jcallahan@34
|
1854 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("pet"))
|
jcallahan@25
|
1855
|
jcallahan@171
|
1856 if not unit_idnum or not UnitTypeIsNPC(unit_type) then
|
jcallahan@25
|
1857 return
|
jcallahan@25
|
1858 end
|
jcallahan@29
|
1859 NPCEntry(unit_idnum).mind_control = true
|
jcallahan@122
|
1860 table.wipe(current_action)
|
jcallahan@25
|
1861 end
|
jcallahan@25
|
1862
|
jcallahan@25
|
1863
|
jcallahan@115
|
1864 function WDP:PET_JOURNAL_LIST_UPDATE(event_name)
|
jcallahan@115
|
1865 local num_pets = LPJ:NumPets()
|
jcallahan@115
|
1866
|
jcallahan@115
|
1867 for index, pet_id in LPJ:IteratePetIDs() do
|
jcallahan@115
|
1868 local _, _, is_owned, _, level, _, _, name, icon, pet_type, npc_id, _, _, is_wild = _G.C_PetJournal.GetPetInfoByIndex(index)
|
jcallahan@115
|
1869
|
jcallahan@115
|
1870 if is_owned then
|
jcallahan@115
|
1871 local health, max_health, attack, speed, rarity = _G.C_PetJournal.GetPetStats(pet_id)
|
jcallahan@115
|
1872
|
jcallahan@139
|
1873 if rarity then
|
jcallahan@139
|
1874 local rarity_name = _G["BATTLE_PET_BREED_QUALITY" .. rarity]
|
jcallahan@139
|
1875 local npc = NPCEntry(npc_id)
|
jcallahan@139
|
1876 npc.wild_pet = is_wild or nil
|
jcallahan@139
|
1877 npc.battle_pet_data = npc.battle_pet_data or {}
|
jcallahan@139
|
1878 npc.battle_pet_data[rarity_name] = npc.battle_pet_data[rarity_name] or {}
|
jcallahan@139
|
1879 npc.battle_pet_data[rarity_name]["level_" .. level] = npc.battle_pet_data[rarity_name]["level_" .. level] or {}
|
jcallahan@139
|
1880
|
jcallahan@139
|
1881 local data = npc.battle_pet_data[rarity_name]["level_" .. level]
|
jcallahan@139
|
1882 data.max_health = max_health
|
jcallahan@139
|
1883 data.attack = attack
|
jcallahan@139
|
1884 data.speed = speed
|
jcallahan@139
|
1885 end
|
jcallahan@115
|
1886 end
|
jcallahan@115
|
1887 end
|
jcallahan@115
|
1888 end
|
jcallahan@115
|
1889
|
jcallahan@115
|
1890
|
jcallahan@156
|
1891 function WDP:PLAYER_REGEN_DISABLED(event_name)
|
jcallahan@156
|
1892 private.in_combat = true
|
jcallahan@156
|
1893 end
|
jcallahan@156
|
1894
|
jcallahan@156
|
1895
|
jcallahan@156
|
1896 function WDP:PLAYER_REGEN_ENABLED(event_name)
|
jcallahan@156
|
1897 private.in_combat = nil
|
jcallahan@156
|
1898
|
jcallahan@156
|
1899 if private.set_area_id then
|
jcallahan@156
|
1900 self:SetCurrentAreaID(event_name)
|
jcallahan@156
|
1901 private.set_area_id = nil
|
jcallahan@156
|
1902 end
|
jcallahan@156
|
1903 end
|
jcallahan@156
|
1904
|
jcallahan@156
|
1905
|
jcallahan@118
|
1906 function WDP:PLAYER_TARGET_CHANGED(event_name)
|
jcallahan@215
|
1907 if not TargetedNPC() then
|
jcallahan@118
|
1908 return
|
jcallahan@2
|
1909 end
|
jcallahan@151
|
1910 current_action.target_type = AF.NPC
|
jcallahan@118
|
1911 self:UpdateTargetLocation()
|
jcallahan@118
|
1912 end
|
jcallahan@2
|
1913
|
jcallahan@89
|
1914
|
jcallahan@12
|
1915 do
|
jcallahan@12
|
1916 local function UpdateQuestJuncture(point)
|
jcallahan@12
|
1917 local unit_name = _G.UnitName("questnpc")
|
jcallahan@9
|
1918
|
jcallahan@12
|
1919 if not unit_name then
|
jcallahan@12
|
1920 return
|
jcallahan@12
|
1921 end
|
jcallahan@34
|
1922 local unit_type, unit_id = ParseGUID(_G.UnitGUID("questnpc"))
|
jcallahan@9
|
1923
|
jcallahan@12
|
1924 if unit_type == private.UNIT_TYPES.OBJECT then
|
jcallahan@38
|
1925 UpdateDBEntryLocation("objects", unit_id)
|
jcallahan@12
|
1926 end
|
jcallahan@19
|
1927 local quest = DBEntry("quests", _G.GetQuestID())
|
jcallahan@12
|
1928 quest[point] = quest[point] or {}
|
jcallahan@12
|
1929 quest[point][("%s:%d"):format(private.UNIT_TYPE_NAMES[unit_type + 1], unit_id)] = true
|
jcallahan@24
|
1930
|
jcallahan@24
|
1931 return quest
|
jcallahan@12
|
1932 end
|
jcallahan@10
|
1933
|
jcallahan@12
|
1934
|
jcallahan@92
|
1935 function WDP:QUEST_COMPLETE(event_name)
|
jcallahan@97
|
1936 local quest = UpdateQuestJuncture("end")
|
jcallahan@97
|
1937
|
jcallahan@112
|
1938 if ALLOWED_LOCALES[CLIENT_LOCALE] then
|
jcallahan@112
|
1939 quest.reward_text = ReplaceKeywords(_G.GetRewardText())
|
jcallahan@112
|
1940 end
|
jcallahan@67
|
1941 -- Make sure the quest NPC isn't erroneously recorded as giving reputation for quests which award it.
|
jcallahan@177
|
1942 ClearKilledNPC()
|
jcallahan@10
|
1943 end
|
jcallahan@10
|
1944
|
jcallahan@12
|
1945
|
jcallahan@92
|
1946 function WDP:QUEST_DETAIL(event_name)
|
jcallahan@24
|
1947 local quest = UpdateQuestJuncture("begin")
|
jcallahan@24
|
1948
|
jcallahan@46
|
1949 if not quest then
|
jcallahan@46
|
1950 return
|
jcallahan@46
|
1951 end
|
jcallahan@24
|
1952 quest.classes = quest.classes or {}
|
jcallahan@27
|
1953 quest.classes[PLAYER_CLASS] = true
|
jcallahan@24
|
1954
|
jcallahan@24
|
1955 quest.races = quest.races or {}
|
jcallahan@100
|
1956 quest.races[(PLAYER_RACE == "Pandaren") and ("%s_%s"):format(PLAYER_RACE, PLAYER_FACTION or "Neutral") or PLAYER_RACE] = true
|
jcallahan@10
|
1957 end
|
jcallahan@12
|
1958 end -- do-block
|
jcallahan@9
|
1959
|
jcallahan@9
|
1960
|
jcallahan@92
|
1961 function WDP:QUEST_LOG_UPDATE(event_name)
|
jcallahan@38
|
1962 local selected_quest = _G.GetQuestLogSelection() -- Save current selection to be restored when we're done.
|
jcallahan@36
|
1963 local entry_index, processed_quests = 1, 0
|
jcallahan@36
|
1964 local _, num_quests = _G.GetNumQuestLogEntries()
|
jcallahan@36
|
1965
|
jcallahan@36
|
1966 while processed_quests <= num_quests do
|
jcallahan@36
|
1967 local _, _, _, _, is_header, _, _, _, quest_id = _G.GetQuestLogTitle(entry_index)
|
jcallahan@36
|
1968
|
jcallahan@84
|
1969 if quest_id == 0 then
|
jcallahan@84
|
1970 processed_quests = processed_quests + 1
|
jcallahan@84
|
1971 elseif not is_header then
|
jcallahan@36
|
1972 _G.SelectQuestLogEntry(entry_index);
|
jcallahan@36
|
1973
|
jcallahan@36
|
1974 local quest = DBEntry("quests", quest_id)
|
jcallahan@36
|
1975 quest.timer = _G.GetQuestLogTimeLeft()
|
jcallahan@37
|
1976 quest.can_share = _G.GetQuestLogPushable() and true or nil
|
jcallahan@36
|
1977 processed_quests = processed_quests + 1
|
jcallahan@36
|
1978 end
|
jcallahan@36
|
1979 entry_index = entry_index + 1
|
jcallahan@36
|
1980 end
|
jcallahan@36
|
1981 _G.SelectQuestLogEntry(selected_quest)
|
jcallahan@4
|
1982 self:UnregisterEvent("QUEST_LOG_UPDATE")
|
jcallahan@4
|
1983 end
|
jcallahan@4
|
1984
|
jcallahan@4
|
1985
|
jcallahan@97
|
1986 function WDP:QUEST_PROGRESS(event_name)
|
jcallahan@112
|
1987 if not ALLOWED_LOCALES[CLIENT_LOCALE] then
|
jcallahan@112
|
1988 return
|
jcallahan@112
|
1989 end
|
jcallahan@97
|
1990 DBEntry("quests", _G.GetQuestID()).progress_text = ReplaceKeywords(_G.GetProgressText())
|
jcallahan@97
|
1991 end
|
jcallahan@97
|
1992
|
jcallahan@97
|
1993
|
jcallahan@92
|
1994 function WDP:UNIT_QUEST_LOG_CHANGED(event_name, unit_id)
|
jcallahan@4
|
1995 if unit_id ~= "player" then
|
jcallahan@4
|
1996 return
|
jcallahan@4
|
1997 end
|
jcallahan@4
|
1998 self:RegisterEvent("QUEST_LOG_UPDATE")
|
jcallahan@4
|
1999 end
|
jcallahan@4
|
2000
|
jcallahan@4
|
2001
|
jcallahan@92
|
2002 do
|
jcallahan@92
|
2003 local TRADESKILL_TOOLS = {
|
jcallahan@92
|
2004 Anvil = anvil_spell_ids,
|
jcallahan@92
|
2005 Forge = forge_spell_ids,
|
jcallahan@92
|
2006 }
|
jcallahan@92
|
2007
|
jcallahan@92
|
2008
|
jcallahan@167
|
2009 local function RegisterTools(tradeskill_name, tradeskill_index)
|
jcallahan@167
|
2010 local spell_id = tonumber(_G.GetTradeSkillRecipeLink(tradeskill_index):match("^|c%x%x%x%x%x%x%x%x|H%w+:(%d+)"))
|
jcallahan@167
|
2011 local required_tool = _G.GetTradeSkillTools(tradeskill_index)
|
jcallahan@167
|
2012
|
jcallahan@167
|
2013 if required_tool then
|
jcallahan@167
|
2014 for tool_name, registry in pairs(TRADESKILL_TOOLS) do
|
jcallahan@167
|
2015 if required_tool:find(tool_name) then
|
jcallahan@167
|
2016 registry[spell_id] = true
|
jcallahan@167
|
2017 end
|
jcallahan@167
|
2018 end
|
jcallahan@167
|
2019 end
|
jcallahan@167
|
2020 end
|
jcallahan@167
|
2021
|
jcallahan@167
|
2022
|
jcallahan@92
|
2023 function WDP:TRADE_SKILL_SHOW(event_name)
|
jcallahan@92
|
2024 local profession_name, prof_level = _G.GetTradeSkillLine()
|
jcallahan@92
|
2025
|
jcallahan@92
|
2026 if profession_name == _G.UNKNOWN then
|
jcallahan@92
|
2027 return
|
jcallahan@92
|
2028 end
|
jcallahan@167
|
2029 TradeSkillExecutePer(RegisterTools)
|
jcallahan@92
|
2030 end
|
jcallahan@92
|
2031 end -- do-block
|
jcallahan@92
|
2032
|
jcallahan@92
|
2033
|
jcallahan@167
|
2034 function WDP:TRAINER_CLOSED(event_name)
|
jcallahan@167
|
2035 private.trainer_shown = nil
|
jcallahan@167
|
2036 end
|
jcallahan@167
|
2037
|
jcallahan@167
|
2038
|
jcallahan@92
|
2039 function WDP:TRAINER_SHOW(event_name)
|
jcallahan@232
|
2040 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
|
jcallahan@164
|
2041 local trainer = NPCEntry(unit_idnum)
|
jcallahan@58
|
2042
|
jcallahan@164
|
2043 if not trainer then
|
jcallahan@58
|
2044 return
|
jcallahan@58
|
2045 end
|
jcallahan@232
|
2046 local trainer_standing = select(2, UnitFactionStanding("npc"))
|
jcallahan@164
|
2047 trainer.teaches = trainer.teaches or {}
|
jcallahan@27
|
2048
|
jcallahan@167
|
2049 private.trainer_shown = true
|
jcallahan@167
|
2050
|
jcallahan@27
|
2051 -- Get the initial trainer filters
|
jcallahan@27
|
2052 local available = _G.GetTrainerServiceTypeFilter("available")
|
jcallahan@27
|
2053 local unavailable = _G.GetTrainerServiceTypeFilter("unavailable")
|
jcallahan@27
|
2054 local used = _G.GetTrainerServiceTypeFilter("used")
|
jcallahan@27
|
2055
|
jcallahan@27
|
2056 -- Clear the trainer filters
|
jcallahan@27
|
2057 _G.SetTrainerServiceTypeFilter("available", 1)
|
jcallahan@27
|
2058 _G.SetTrainerServiceTypeFilter("unavailable", 1)
|
jcallahan@27
|
2059 _G.SetTrainerServiceTypeFilter("used", 1)
|
jcallahan@27
|
2060
|
jcallahan@27
|
2061 for index = 1, _G.GetNumTrainerServices(), 1 do
|
jcallahan@27
|
2062 local spell_name, rank_name, _, _, required_level = _G.GetTrainerServiceInfo(index)
|
jcallahan@27
|
2063
|
jcallahan@27
|
2064 if spell_name then
|
jcallahan@27
|
2065 DatamineTT:ClearLines()
|
jcallahan@27
|
2066 DatamineTT:SetTrainerService(index)
|
jcallahan@27
|
2067
|
jcallahan@27
|
2068 local _, _, spell_id = DatamineTT:GetSpell()
|
jcallahan@27
|
2069
|
jcallahan@43
|
2070 if spell_id then
|
jcallahan@164
|
2071 local class_professions = trainer.teaches[PLAYER_CLASS]
|
jcallahan@164
|
2072
|
jcallahan@164
|
2073 if not class_professions then
|
jcallahan@164
|
2074 trainer.teaches[PLAYER_CLASS] = {}
|
jcallahan@164
|
2075 class_professions = trainer.teaches[PLAYER_CLASS]
|
jcallahan@164
|
2076 end
|
jcallahan@43
|
2077 local profession, min_skill = _G.GetTrainerServiceSkillReq(index)
|
jcallahan@43
|
2078 profession = profession or "General"
|
jcallahan@43
|
2079
|
jcallahan@164
|
2080 local profession_skills = class_professions[profession]
|
jcallahan@43
|
2081
|
jcallahan@43
|
2082 if not profession_skills then
|
jcallahan@43
|
2083 class_professions[profession] = {}
|
jcallahan@43
|
2084 profession_skills = class_professions[profession]
|
jcallahan@43
|
2085 end
|
jcallahan@173
|
2086 profession_skills[spell_id] = ("%d:%d:%d"):format(required_level, min_skill, _G.GetTrainerServiceCost(index))
|
jcallahan@27
|
2087 end
|
jcallahan@27
|
2088 end
|
jcallahan@27
|
2089 end
|
jcallahan@27
|
2090 -- Reset the filters to what they were before
|
jcallahan@27
|
2091 _G.SetTrainerServiceTypeFilter("available", available or 0)
|
jcallahan@27
|
2092 _G.SetTrainerServiceTypeFilter("unavailable", unavailable or 0)
|
jcallahan@27
|
2093 _G.SetTrainerServiceTypeFilter("used", used or 0)
|
jcallahan@27
|
2094 end
|
jcallahan@27
|
2095
|
jcallahan@27
|
2096
|
jcallahan@1
|
2097 function WDP:UNIT_SPELLCAST_SENT(event_name, unit_id, spell_name, spell_rank, target_name, spell_line)
|
jcallahan@1
|
2098 if private.tracked_line or unit_id ~= "player" then
|
jcallahan@1
|
2099 return
|
jcallahan@1
|
2100 end
|
jcallahan@1
|
2101 local spell_label = private.SPELL_LABELS_BY_NAME[spell_name]
|
jcallahan@1
|
2102
|
jcallahan@1
|
2103 if not spell_label then
|
jcallahan@1
|
2104 return
|
jcallahan@1
|
2105 end
|
jcallahan@150
|
2106 local item_name, item_link = _G.GameTooltip:GetItem()
|
jcallahan@150
|
2107 local unit_name, unit_id = _G.GameTooltip:GetUnit()
|
jcallahan@1
|
2108
|
jcallahan@150
|
2109 if not unit_name and _G.UnitName("target") == target_name then
|
jcallahan@150
|
2110 unit_name = target_name
|
jcallahan@150
|
2111 unit_id = "target"
|
jcallahan@1
|
2112 end
|
jcallahan@1
|
2113 local spell_flags = private.SPELL_FLAGS_BY_LABEL[spell_label]
|
jcallahan@28
|
2114 local zone_name, area_id, x, y, map_level, instance_token = CurrentLocationData()
|
jcallahan@28
|
2115
|
jcallahan@205
|
2116 table.wipe(current_action)
|
jcallahan@122
|
2117 current_action.instance_token = instance_token
|
jcallahan@122
|
2118 current_action.map_level = map_level
|
jcallahan@122
|
2119 current_action.x = x
|
jcallahan@122
|
2120 current_action.y = y
|
jcallahan@122
|
2121 current_action.zone_data = ("%s:%d"):format(zone_name, area_id)
|
jcallahan@122
|
2122 current_action.spell_label = spell_label
|
jcallahan@105
|
2123
|
jcallahan@105
|
2124 if not private.NON_LOOT_SPELL_LABELS[spell_label] then
|
jcallahan@122
|
2125 current_action.loot_label = spell_label:lower()
|
jcallahan@105
|
2126 end
|
jcallahan@1
|
2127
|
jcallahan@151
|
2128 if unit_name and unit_name == target_name and not item_name then
|
jcallahan@16
|
2129 if bit.band(spell_flags, AF.NPC) == AF.NPC then
|
jcallahan@150
|
2130 if not unit_id or unit_name ~= target_name then
|
jcallahan@16
|
2131 return
|
jcallahan@16
|
2132 end
|
jcallahan@123
|
2133 current_action.target_type = AF.NPC
|
jcallahan@16
|
2134 end
|
jcallahan@16
|
2135 elseif bit.band(spell_flags, AF.ITEM) == AF.ITEM then
|
jcallahan@123
|
2136 current_action.target_type = AF.ITEM
|
jcallahan@16
|
2137
|
jcallahan@150
|
2138 if item_name and item_name == target_name then
|
jcallahan@150
|
2139 current_action.identifier = ItemLinkToID(item_link)
|
jcallahan@16
|
2140 elseif target_name and target_name ~= "" then
|
jcallahan@150
|
2141 current_action.identifier = ItemLinkToID(select(2, _G.GetItemInfo(target_name)))
|
jcallahan@16
|
2142 end
|
jcallahan@150
|
2143 elseif not item_name and not unit_name then
|
jcallahan@1
|
2144 if bit.band(spell_flags, AF.OBJECT) == AF.OBJECT then
|
jcallahan@17
|
2145 if target_name == "" then
|
jcallahan@17
|
2146 return
|
jcallahan@17
|
2147 end
|
jcallahan@122
|
2148 current_action.object_name = target_name
|
jcallahan@123
|
2149 current_action.target_type = AF.OBJECT
|
jcallahan@1
|
2150 elseif bit.band(spell_flags, AF.ZONE) == AF.ZONE then
|
jcallahan@123
|
2151 current_action.target_type = AF.ZONE
|
jcallahan@1
|
2152 end
|
jcallahan@1
|
2153 end
|
jcallahan@1
|
2154 private.tracked_line = spell_line
|
jcallahan@0
|
2155 end
|
jcallahan@0
|
2156
|
jcallahan@94
|
2157
|
jcallahan@1
|
2158 function WDP:UNIT_SPELLCAST_SUCCEEDED(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id)
|
jcallahan@1
|
2159 if unit_id ~= "player" then
|
jcallahan@1
|
2160 return
|
jcallahan@1
|
2161 end
|
jcallahan@1
|
2162 private.tracked_line = nil
|
jcallahan@167
|
2163 private.previous_spell_id = spell_id
|
jcallahan@85
|
2164
|
jcallahan@86
|
2165 if spell_name:match("^Harvest.+") then
|
jcallahan@177
|
2166 killed_npc_id = current_target_id
|
jcallahan@98
|
2167 private.harvesting = true
|
jcallahan@85
|
2168 end
|
jcallahan@92
|
2169
|
jcallahan@92
|
2170 if anvil_spell_ids[spell_id] then
|
jcallahan@92
|
2171 UpdateDBEntryLocation("objects", OBJECT_ID_ANVIL)
|
jcallahan@92
|
2172 elseif forge_spell_ids[spell_id] then
|
jcallahan@92
|
2173 UpdateDBEntryLocation("objects", OBJECT_ID_FORGE)
|
jcallahan@92
|
2174 end
|
jcallahan@0
|
2175 end
|
jcallahan@0
|
2176
|
jcallahan@90
|
2177
|
jcallahan@1
|
2178 function WDP:HandleSpellFailure(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id)
|
jcallahan@1
|
2179 if unit_id ~= "player" then
|
jcallahan@1
|
2180 return
|
jcallahan@1
|
2181 end
|
jcallahan@0
|
2182
|
jcallahan@1
|
2183 if private.tracked_line == spell_line then
|
jcallahan@1
|
2184 private.tracked_line = nil
|
jcallahan@1
|
2185 end
|
jcallahan@147
|
2186 table.wipe(current_action)
|
jcallahan@0
|
2187 end
|
jcallahan@90
|
2188
|
jcallahan@90
|
2189
|
jcallahan@90
|
2190 do
|
jcallahan@90
|
2191 local function SetUnitField(field, required_type)
|
jcallahan@90
|
2192 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
|
jcallahan@90
|
2193
|
jcallahan@90
|
2194 if not unit_idnum or (required_type and unit_type ~= required_type) then
|
jcallahan@90
|
2195 return
|
jcallahan@90
|
2196 end
|
jcallahan@90
|
2197
|
jcallahan@171
|
2198 if UnitTypeIsNPC(unit_type) then
|
jcallahan@90
|
2199 NPCEntry(unit_idnum)[field] = true
|
jcallahan@90
|
2200 elseif unit_type == private.UNIT_TYPES.OBJECT then
|
jcallahan@90
|
2201 DBEntry("objects", unit_idnum)[field] = true
|
jcallahan@93
|
2202 UpdateDBEntryLocation("objects", unit_idnum)
|
jcallahan@90
|
2203 end
|
jcallahan@90
|
2204 end
|
jcallahan@90
|
2205
|
jcallahan@90
|
2206
|
jcallahan@90
|
2207 function WDP:AUCTION_HOUSE_SHOW(event_name)
|
jcallahan@90
|
2208 SetUnitField("auctioneer", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
2209 end
|
jcallahan@90
|
2210
|
jcallahan@90
|
2211
|
jcallahan@90
|
2212 function WDP:BANKFRAME_OPENED(event_name)
|
jcallahan@90
|
2213 SetUnitField("banker", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
2214 end
|
jcallahan@90
|
2215
|
jcallahan@90
|
2216
|
jcallahan@90
|
2217 function WDP:BATTLEFIELDS_SHOW(event_name)
|
jcallahan@90
|
2218 SetUnitField("battlemaster", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
2219 end
|
jcallahan@90
|
2220
|
jcallahan@90
|
2221
|
jcallahan@92
|
2222 function WDP:FORGE_MASTER_OPENED(event_name)
|
jcallahan@90
|
2223 SetUnitField("arcane_reforger", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
2224 end
|
jcallahan@90
|
2225
|
jcallahan@90
|
2226
|
jcallahan@92
|
2227 function WDP:GOSSIP_SHOW(event_name)
|
jcallahan@90
|
2228 local gossip_options = { _G.GetGossipOptions() }
|
jcallahan@90
|
2229
|
jcallahan@90
|
2230 for index = 2, #gossip_options, 2 do
|
jcallahan@90
|
2231 if gossip_options[index] == "binder" then
|
jcallahan@90
|
2232 SetUnitField("innkeeper", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
2233 return
|
jcallahan@90
|
2234 end
|
jcallahan@90
|
2235 end
|
jcallahan@90
|
2236 end
|
jcallahan@90
|
2237
|
jcallahan@90
|
2238
|
jcallahan@93
|
2239 function WDP:GUILDBANKFRAME_OPENED(event_name)
|
jcallahan@93
|
2240 SetUnitField("guild_bank", private.UNIT_TYPES.OBJECT)
|
jcallahan@93
|
2241 end
|
jcallahan@93
|
2242
|
jcallahan@93
|
2243
|
jcallahan@189
|
2244 function WDP:ITEM_UPGRADE_MASTER_OPENED(event_name)
|
jcallahan@189
|
2245 SetUnitField("item_upgrade_master", private.UNIT_TYPES.NPC)
|
jcallahan@189
|
2246 end
|
jcallahan@189
|
2247
|
jcallahan@189
|
2248
|
jcallahan@90
|
2249 function WDP:TAXIMAP_OPENED(event_name)
|
jcallahan@90
|
2250 SetUnitField("flight_master", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
2251 end
|
jcallahan@90
|
2252
|
jcallahan@90
|
2253
|
jcallahan@90
|
2254 function WDP:TRANSMOGRIFY_OPEN(event_name)
|
jcallahan@90
|
2255 SetUnitField("transmogrifier", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
2256 end
|
jcallahan@90
|
2257
|
jcallahan@90
|
2258
|
jcallahan@90
|
2259 function WDP:VOID_STORAGE_OPEN(event_name)
|
jcallahan@90
|
2260 SetUnitField("void_storage", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
2261 end
|
jcallahan@90
|
2262 end -- do-block
|