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