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