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