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