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