jcallahan@0
|
1 -----------------------------------------------------------------------
|
jcallahan@0
|
2 -- Upvalued Lua API.
|
jcallahan@0
|
3 -----------------------------------------------------------------------
|
jcallahan@0
|
4 local _G = getfenv(0)
|
jcallahan@0
|
5
|
jcallahan@0
|
6 local pairs = _G.pairs
|
jcallahan@1
|
7 local tonumber = _G.tonumber
|
jcallahan@1
|
8
|
jcallahan@1
|
9 local bit = _G.bit
|
jcallahan@1
|
10 local math = _G.math
|
jcallahan@1
|
11 local table = _G.table
|
jcallahan@1
|
12
|
jcallahan@78
|
13 local select = _G.select
|
jcallahan@78
|
14
|
jcallahan@0
|
15
|
jcallahan@0
|
16 -----------------------------------------------------------------------
|
jcallahan@0
|
17 -- AddOn namespace.
|
jcallahan@0
|
18 -----------------------------------------------------------------------
|
jcallahan@0
|
19 local ADDON_NAME, private = ...
|
jcallahan@0
|
20
|
jcallahan@0
|
21 local LibStub = _G.LibStub
|
jcallahan@0
|
22 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceEvent-3.0", "AceTimer-3.0")
|
jcallahan@0
|
23
|
jcallahan@48
|
24 local deformat = LibStub("LibDeformat-3.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@0
|
30 -----------------------------------------------------------------------
|
jcallahan@0
|
31 -- Local constants.
|
jcallahan@0
|
32 -----------------------------------------------------------------------
|
jcallahan@74
|
33 local DB_VERSION = 4
|
jcallahan@63
|
34
|
jcallahan@92
|
35
|
jcallahan@0
|
36 local DATABASE_DEFAULTS = {
|
jcallahan@0
|
37 global = {
|
jcallahan@0
|
38 items = {},
|
jcallahan@0
|
39 npcs = {},
|
jcallahan@0
|
40 objects = {},
|
jcallahan@0
|
41 quests = {},
|
jcallahan@17
|
42 zones = {},
|
jcallahan@0
|
43 }
|
jcallahan@0
|
44 }
|
jcallahan@0
|
45
|
jcallahan@0
|
46
|
jcallahan@1
|
47 local EVENT_MAPPING = {
|
jcallahan@90
|
48 AUCTION_HOUSE_SHOW = true,
|
jcallahan@90
|
49 BANKFRAME_OPENED = true,
|
jcallahan@90
|
50 BATTLEFIELDS_SHOW = true,
|
jcallahan@56
|
51 BLACK_MARKET_ITEM_UPDATE = true,
|
jcallahan@48
|
52 CHAT_MSG_LOOT = true,
|
jcallahan@40
|
53 CHAT_MSG_SYSTEM = true,
|
jcallahan@23
|
54 COMBAT_LOG_EVENT_UNFILTERED = true,
|
jcallahan@18
|
55 COMBAT_TEXT_UPDATE = true,
|
jcallahan@90
|
56 FORGE_MASTER_OPENED = true,
|
jcallahan@90
|
57 GOSSIP_SHOW = true,
|
jcallahan@42
|
58 ITEM_TEXT_BEGIN = true,
|
jcallahan@1
|
59 LOOT_OPENED = true,
|
jcallahan@89
|
60 MAIL_SHOW = true,
|
jcallahan@7
|
61 MERCHANT_SHOW = "UpdateMerchantItems",
|
jcallahan@61
|
62 MERCHANT_UPDATE = "UpdateMerchantItems",
|
jcallahan@25
|
63 PET_BAR_UPDATE = true,
|
jcallahan@2
|
64 PLAYER_TARGET_CHANGED = true,
|
jcallahan@9
|
65 QUEST_COMPLETE = true,
|
jcallahan@9
|
66 QUEST_DETAIL = true,
|
jcallahan@9
|
67 QUEST_LOG_UPDATE = true,
|
jcallahan@88
|
68 TAXIMAP_OPENED = true,
|
jcallahan@92
|
69 TRADE_SKILL_SHOW = true,
|
jcallahan@27
|
70 TRAINER_SHOW = true,
|
jcallahan@90
|
71 TRANSMOGRIFY_OPEN = true,
|
jcallahan@4
|
72 UNIT_QUEST_LOG_CHANGED = true,
|
jcallahan@1
|
73 UNIT_SPELLCAST_FAILED = "HandleSpellFailure",
|
jcallahan@1
|
74 UNIT_SPELLCAST_FAILED_QUIET = "HandleSpellFailure",
|
jcallahan@1
|
75 UNIT_SPELLCAST_INTERRUPTED = "HandleSpellFailure",
|
jcallahan@1
|
76 UNIT_SPELLCAST_SENT = true,
|
jcallahan@1
|
77 UNIT_SPELLCAST_SUCCEEDED = true,
|
jcallahan@90
|
78 VOID_STORAGE_OPEN = true,
|
jcallahan@0
|
79 }
|
jcallahan@0
|
80
|
jcallahan@4
|
81
|
jcallahan@92
|
82 local OBJECT_ID_ANVIL = 192628
|
jcallahan@92
|
83 local OBJECT_ID_FORGE = 1685
|
jcallahan@92
|
84
|
jcallahan@92
|
85
|
jcallahan@1
|
86 local AF = private.ACTION_TYPE_FLAGS
|
jcallahan@0
|
87
|
jcallahan@4
|
88
|
jcallahan@27
|
89 local PLAYER_CLASS = _G.select(2, _G.UnitClass("player"))
|
jcallahan@34
|
90 local PLAYER_GUID = _G.UnitGUID("player")
|
jcallahan@39
|
91 local PLAYER_RACE = _G.select(2, _G.UnitRace("player"))
|
jcallahan@27
|
92
|
jcallahan@0
|
93 -----------------------------------------------------------------------
|
jcallahan@0
|
94 -- Local variables.
|
jcallahan@0
|
95 -----------------------------------------------------------------------
|
jcallahan@92
|
96 local anvil_spell_ids = {}
|
jcallahan@92
|
97 local action_data = {}
|
jcallahan@92
|
98 local currently_drunk
|
jcallahan@0
|
99 local db
|
jcallahan@0
|
100 local durability_timer_handle
|
jcallahan@92
|
101 local faction_standings = {}
|
jcallahan@92
|
102 local forge_spell_ids = {}
|
jcallahan@92
|
103 local reputation_npc_id
|
jcallahan@2
|
104 local target_location_timer_handle
|
jcallahan@86
|
105 local current_target_id
|
jcallahan@1
|
106
|
jcallahan@92
|
107
|
jcallahan@1
|
108 -----------------------------------------------------------------------
|
jcallahan@1
|
109 -- Helper Functions.
|
jcallahan@1
|
110 -----------------------------------------------------------------------
|
jcallahan@39
|
111 local ActualCopperCost
|
jcallahan@39
|
112 do
|
jcallahan@39
|
113 local BARTERING_SPELL_ID = 83964
|
jcallahan@39
|
114
|
jcallahan@39
|
115 local STANDING_DISCOUNTS = {
|
jcallahan@39
|
116 HATED = 0,
|
jcallahan@39
|
117 HOSTILE = 0,
|
jcallahan@39
|
118 UNFRIENDLY = 0,
|
jcallahan@39
|
119 NEUTRAL = 0,
|
jcallahan@39
|
120 FRIENDLY = 0.05,
|
jcallahan@39
|
121 HONORED = 0.1,
|
jcallahan@39
|
122 REVERED = 0.15,
|
jcallahan@39
|
123 EXALTED = 0.2,
|
jcallahan@39
|
124 }
|
jcallahan@39
|
125
|
jcallahan@39
|
126
|
jcallahan@39
|
127 function ActualCopperCost(copper_cost, rep_standing)
|
jcallahan@39
|
128 if not copper_cost or copper_cost == 0 then
|
jcallahan@39
|
129 return 0
|
jcallahan@39
|
130 end
|
jcallahan@39
|
131 local modifier = 1
|
jcallahan@39
|
132
|
jcallahan@39
|
133 if _G.IsSpellKnown(BARTERING_SPELL_ID) then
|
jcallahan@39
|
134 modifier = modifier - 0.1
|
jcallahan@39
|
135 end
|
jcallahan@39
|
136
|
jcallahan@39
|
137 if rep_standing then
|
jcallahan@39
|
138 if PLAYER_RACE == "Goblin" then
|
jcallahan@39
|
139 modifier = modifier - STANDING_DISCOUNTS["EXALTED"]
|
jcallahan@39
|
140 elseif STANDING_DISCOUNTS[rep_standing] then
|
jcallahan@39
|
141 modifier = modifier - STANDING_DISCOUNTS[rep_standing]
|
jcallahan@39
|
142 end
|
jcallahan@39
|
143 end
|
jcallahan@39
|
144 return math.floor(copper_cost / modifier)
|
jcallahan@39
|
145 end
|
jcallahan@39
|
146 end -- do-block
|
jcallahan@39
|
147
|
jcallahan@39
|
148
|
jcallahan@29
|
149 local function InstanceDifficultyToken()
|
jcallahan@29
|
150 local _, instance_type, instance_difficulty, difficulty_name, _, _, is_dynamic = _G.GetInstanceInfo()
|
jcallahan@59
|
151 if not difficulty_name or difficulty_name == "" then
|
jcallahan@29
|
152 difficulty_name = "NONE"
|
jcallahan@29
|
153 end
|
jcallahan@59
|
154
|
jcallahan@59
|
155 if not instance_type or instance_type == "" then
|
jcallahan@59
|
156 instance_type = "NONE"
|
jcallahan@59
|
157 end
|
jcallahan@29
|
158 return ("%s:%s:%s"):format(instance_type:upper(), difficulty_name:upper():gsub(" ", "_"), _G.tostring(is_dynamic))
|
jcallahan@29
|
159 end
|
jcallahan@29
|
160
|
jcallahan@29
|
161
|
jcallahan@19
|
162 local function DBEntry(data_type, unit_id)
|
jcallahan@19
|
163 if not data_type or not unit_id then
|
jcallahan@6
|
164 return
|
jcallahan@6
|
165 end
|
jcallahan@19
|
166 local unit = db[data_type][unit_id]
|
jcallahan@6
|
167
|
jcallahan@10
|
168 if not unit then
|
jcallahan@19
|
169 db[data_type][unit_id] = {}
|
jcallahan@19
|
170 unit = db[data_type][unit_id]
|
jcallahan@6
|
171 end
|
jcallahan@10
|
172 return unit
|
jcallahan@6
|
173 end
|
jcallahan@6
|
174
|
jcallahan@6
|
175
|
jcallahan@29
|
176 local function NPCEntry(identifier)
|
jcallahan@29
|
177 local npc = DBEntry("npcs", identifier)
|
jcallahan@29
|
178
|
jcallahan@29
|
179 if not npc then
|
jcallahan@29
|
180 return
|
jcallahan@22
|
181 end
|
jcallahan@29
|
182 local instance_token = InstanceDifficultyToken()
|
jcallahan@29
|
183 npc.encounter_data = npc.encounter_data or {}
|
jcallahan@29
|
184 npc.encounter_data[instance_token] = npc.encounter_data[instance_token] or {}
|
jcallahan@30
|
185 npc.encounter_data[instance_token].stats = npc.encounter_data[instance_token].stats or {}
|
jcallahan@29
|
186 return npc
|
jcallahan@22
|
187 end
|
jcallahan@22
|
188
|
jcallahan@22
|
189
|
jcallahan@1
|
190 local function CurrentLocationData()
|
jcallahan@1
|
191 local map_level = _G.GetCurrentMapDungeonLevel() or 0
|
jcallahan@1
|
192 local x, y = _G.GetPlayerMapPosition("player")
|
jcallahan@1
|
193
|
jcallahan@1
|
194 x = x or 0
|
jcallahan@1
|
195 y = y or 0
|
jcallahan@1
|
196
|
jcallahan@1
|
197 if x == 0 and y == 0 then
|
jcallahan@1
|
198 for level_index = 1, _G.GetNumDungeonMapLevels() do
|
jcallahan@1
|
199 _G.SetDungeonMapLevel(level_index)
|
jcallahan@1
|
200 x, y = _G.GetPlayerMapPosition("player")
|
jcallahan@1
|
201
|
jcallahan@1
|
202 if x and y and (x > 0 or y > 0) then
|
jcallahan@1
|
203 _G.SetDungeonMapLevel(map_level)
|
jcallahan@1
|
204 map_level = level_index
|
jcallahan@1
|
205 break
|
jcallahan@1
|
206 end
|
jcallahan@1
|
207 end
|
jcallahan@1
|
208 end
|
jcallahan@1
|
209
|
jcallahan@1
|
210 if _G.DungeonUsesTerrainMap() then
|
jcallahan@1
|
211 map_level = map_level - 1
|
jcallahan@1
|
212 end
|
jcallahan@31
|
213 local x = _G.floor(x * 1000)
|
jcallahan@31
|
214 local y = _G.floor(y * 1000)
|
jcallahan@28
|
215
|
jcallahan@31
|
216 if x % 2 ~= 0 then
|
jcallahan@31
|
217 x = x + 1
|
jcallahan@28
|
218 end
|
jcallahan@28
|
219
|
jcallahan@31
|
220 if y % 2 ~= 0 then
|
jcallahan@31
|
221 y = y + 1
|
jcallahan@28
|
222 end
|
jcallahan@31
|
223 return _G.GetRealZoneText(), _G.GetCurrentMapAreaID(), x, y, map_level, InstanceDifficultyToken()
|
jcallahan@1
|
224 end
|
jcallahan@1
|
225
|
jcallahan@1
|
226
|
jcallahan@1
|
227 local function ItemLinkToID(item_link)
|
jcallahan@1
|
228 if not item_link then
|
jcallahan@1
|
229 return
|
jcallahan@1
|
230 end
|
jcallahan@7
|
231 return tonumber(item_link:match("item:(%d+)"))
|
jcallahan@1
|
232 end
|
jcallahan@0
|
233
|
jcallahan@4
|
234
|
jcallahan@34
|
235 local ParseGUID
|
jcallahan@4
|
236 do
|
jcallahan@4
|
237 local UNIT_TYPE_BITMASK = 0x007
|
jcallahan@4
|
238
|
jcallahan@34
|
239 function ParseGUID(guid)
|
jcallahan@5
|
240 if not guid then
|
jcallahan@5
|
241 return
|
jcallahan@5
|
242 end
|
jcallahan@4
|
243 local types = private.UNIT_TYPES
|
jcallahan@4
|
244 local unit_type = _G.bit.band(tonumber(guid:sub(1, 5)), UNIT_TYPE_BITMASK)
|
jcallahan@4
|
245
|
jcallahan@10
|
246 if unit_type ~= types.PLAYER and unit_type ~= types.PET then
|
jcallahan@66
|
247 return unit_type, tonumber(guid:sub(6, 10), 16)
|
jcallahan@4
|
248 end
|
jcallahan@4
|
249 return unit_type
|
jcallahan@4
|
250 end
|
jcallahan@4
|
251 end -- do-block
|
jcallahan@4
|
252
|
jcallahan@4
|
253
|
jcallahan@34
|
254 local UpdateNPCLocation
|
jcallahan@34
|
255 do
|
jcallahan@34
|
256 local COORD_MAX = 5
|
jcallahan@34
|
257
|
jcallahan@34
|
258 function UpdateNPCLocation(unit_idnum)
|
jcallahan@34
|
259 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData()
|
jcallahan@34
|
260 local npc_data = NPCEntry(unit_idnum).encounter_data[difficulty_token].stats[("level_%d"):format(_G.UnitLevel("target"))]
|
jcallahan@34
|
261 local zone_token = ("%s:%d"):format(zone_name, area_id)
|
jcallahan@34
|
262 npc_data.locations = npc_data.locations or {}
|
jcallahan@34
|
263
|
jcallahan@34
|
264 local zone_data = npc_data.locations[zone_token]
|
jcallahan@34
|
265
|
jcallahan@34
|
266 if not zone_data then
|
jcallahan@34
|
267 zone_data = {}
|
jcallahan@34
|
268 npc_data.locations[zone_token] = zone_data
|
jcallahan@34
|
269 end
|
jcallahan@34
|
270
|
jcallahan@34
|
271 for location_token in pairs(zone_data) do
|
jcallahan@34
|
272 local loc_level, loc_x, loc_y = (":"):split(location_token)
|
jcallahan@34
|
273 loc_level = tonumber(loc_level)
|
jcallahan@34
|
274
|
jcallahan@34
|
275 if map_level == loc_level and math.abs(x - loc_x) <= COORD_MAX and math.abs(y - loc_y) <= COORD_MAX then
|
jcallahan@34
|
276 return
|
jcallahan@34
|
277 end
|
jcallahan@34
|
278 end
|
jcallahan@34
|
279 zone_data[("%s:%s:%s"):format(map_level, x, y)] = true
|
jcallahan@34
|
280 end
|
jcallahan@34
|
281 end -- do-block
|
jcallahan@34
|
282
|
jcallahan@34
|
283
|
jcallahan@52
|
284 local function UpdateDBEntryLocation(entry_type, identifier)
|
jcallahan@10
|
285 if not identifier then
|
jcallahan@10
|
286 return
|
jcallahan@10
|
287 end
|
jcallahan@31
|
288 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData()
|
jcallahan@41
|
289 local entry = DBEntry(entry_type, identifier)
|
jcallahan@41
|
290 entry[difficulty_token] = entry[difficulty_token] or {}
|
jcallahan@52
|
291 entry[difficulty_token].locations = entry[difficulty_token].locations or {}
|
jcallahan@10
|
292
|
jcallahan@31
|
293 local zone_token = ("%s:%d"):format(zone_name, area_id)
|
jcallahan@52
|
294 local zone_data = entry[difficulty_token].locations[zone_token]
|
jcallahan@24
|
295
|
jcallahan@31
|
296 if not zone_data then
|
jcallahan@31
|
297 zone_data = {}
|
jcallahan@52
|
298 entry[difficulty_token].locations[zone_token] = zone_data
|
jcallahan@10
|
299 end
|
jcallahan@41
|
300 local location_token = ("%s:%s:%s"):format(map_level, x, y)
|
jcallahan@41
|
301 zone_data[location_token] = zone_data[location_token] or true
|
jcallahan@41
|
302 return zone_data
|
jcallahan@10
|
303 end
|
jcallahan@10
|
304
|
jcallahan@10
|
305
|
jcallahan@19
|
306 local function HandleItemUse(item_link, bag_index, slot_index)
|
jcallahan@19
|
307 if not item_link then
|
jcallahan@19
|
308 return
|
jcallahan@19
|
309 end
|
jcallahan@19
|
310 local item_id = ItemLinkToID(item_link)
|
jcallahan@19
|
311
|
jcallahan@19
|
312 if not bag_index or not slot_index then
|
jcallahan@19
|
313 for new_bag_index = 0, _G.NUM_BAG_FRAMES do
|
jcallahan@19
|
314 for new_slot_index = 1, _G.GetContainerNumSlots(new_bag_index) do
|
jcallahan@19
|
315 if item_id == ItemLinkToID(_G.GetContainerItemLink(new_bag_index, new_slot_index)) then
|
jcallahan@19
|
316 bag_index = new_bag_index
|
jcallahan@19
|
317 slot_index = new_slot_index
|
jcallahan@19
|
318 break
|
jcallahan@19
|
319 end
|
jcallahan@19
|
320 end
|
jcallahan@19
|
321 end
|
jcallahan@19
|
322 end
|
jcallahan@19
|
323
|
jcallahan@19
|
324 if not bag_index or not slot_index then
|
jcallahan@19
|
325 return
|
jcallahan@19
|
326 end
|
jcallahan@19
|
327 local _, _, _, _, _, is_lootable = _G.GetContainerItemInfo(bag_index, slot_index)
|
jcallahan@19
|
328
|
jcallahan@19
|
329 if not is_lootable then
|
jcallahan@19
|
330 return
|
jcallahan@19
|
331 end
|
jcallahan@19
|
332 DatamineTT:ClearLines()
|
jcallahan@19
|
333 DatamineTT:SetBagItem(bag_index, slot_index)
|
jcallahan@19
|
334
|
jcallahan@19
|
335 for line_index = 1, DatamineTT:NumLines() do
|
jcallahan@19
|
336 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
|
jcallahan@19
|
337
|
jcallahan@19
|
338 if not current_line then
|
jcallahan@19
|
339 break
|
jcallahan@19
|
340 end
|
jcallahan@19
|
341
|
jcallahan@19
|
342 if current_line:GetText() == _G.ITEM_OPENABLE then
|
jcallahan@19
|
343 table.wipe(action_data)
|
jcallahan@19
|
344 action_data.type = AF.ITEM
|
jcallahan@28
|
345 action_data.identifier = item_id
|
jcallahan@25
|
346 action_data.label = "contains"
|
jcallahan@19
|
347 break
|
jcallahan@19
|
348 end
|
jcallahan@19
|
349 end
|
jcallahan@19
|
350 end
|
jcallahan@19
|
351
|
jcallahan@19
|
352
|
jcallahan@39
|
353 local UnitFactionStanding
|
jcallahan@32
|
354 local UpdateFactionData
|
jcallahan@32
|
355 do
|
jcallahan@32
|
356 local MAX_FACTION_INDEX = 1000
|
jcallahan@20
|
357
|
jcallahan@32
|
358 local STANDING_NAMES = {
|
jcallahan@32
|
359 "HATED",
|
jcallahan@32
|
360 "HOSTILE",
|
jcallahan@32
|
361 "UNFRIENDLY",
|
jcallahan@32
|
362 "NEUTRAL",
|
jcallahan@32
|
363 "FRIENDLY",
|
jcallahan@32
|
364 "HONORED",
|
jcallahan@32
|
365 "REVERED",
|
jcallahan@32
|
366 "EXALTED",
|
jcallahan@32
|
367 }
|
jcallahan@32
|
368
|
jcallahan@39
|
369
|
jcallahan@39
|
370 function UnitFactionStanding(unit)
|
jcallahan@39
|
371 UpdateFactionData()
|
jcallahan@39
|
372 DatamineTT:ClearLines()
|
jcallahan@39
|
373 DatamineTT:SetUnit(unit)
|
jcallahan@39
|
374
|
jcallahan@39
|
375 for line_index = 1, DatamineTT:NumLines() do
|
jcallahan@64
|
376 local faction_name = _G["WDPDatamineTTTextLeft" .. line_index]:GetText():trim()
|
jcallahan@39
|
377
|
jcallahan@39
|
378 if faction_name and faction_standings[faction_name] then
|
jcallahan@39
|
379 return faction_name, faction_standings[faction_name]
|
jcallahan@39
|
380 end
|
jcallahan@39
|
381 end
|
jcallahan@39
|
382 end
|
jcallahan@39
|
383
|
jcallahan@39
|
384
|
jcallahan@32
|
385 function UpdateFactionData()
|
jcallahan@32
|
386 for faction_index = 1, MAX_FACTION_INDEX do
|
jcallahan@32
|
387 local faction_name, _, current_standing, _, _, _, _, _, is_header = _G.GetFactionInfo(faction_index)
|
jcallahan@32
|
388
|
jcallahan@86
|
389 if faction_name then
|
jcallahan@32
|
390 faction_standings[faction_name] = STANDING_NAMES[current_standing]
|
jcallahan@32
|
391 elseif not faction_name then
|
jcallahan@32
|
392 break
|
jcallahan@32
|
393 end
|
jcallahan@20
|
394 end
|
jcallahan@20
|
395 end
|
jcallahan@32
|
396 end -- do-block
|
jcallahan@20
|
397
|
jcallahan@48
|
398
|
jcallahan@75
|
399 local GenericLootUpdate
|
jcallahan@75
|
400 do
|
jcallahan@77
|
401 local function LootTable(entry, loot_type, top_field)
|
jcallahan@75
|
402 if top_field then
|
jcallahan@75
|
403 entry[top_field] = entry[top_field] or {}
|
jcallahan@75
|
404 entry[top_field][loot_type] = entry[top_field][loot_type] or {}
|
jcallahan@75
|
405 return entry[top_field][loot_type]
|
jcallahan@75
|
406 end
|
jcallahan@48
|
407 entry[loot_type] = entry[loot_type] or {}
|
jcallahan@75
|
408 return entry[loot_type]
|
jcallahan@48
|
409 end
|
jcallahan@48
|
410
|
jcallahan@75
|
411 function GenericLootUpdate(data_type, top_field)
|
jcallahan@75
|
412 local loot_type = action_data.label or "drops"
|
jcallahan@75
|
413 local loot_count = ("%s_count"):format(loot_type)
|
jcallahan@77
|
414 local source_list = {}
|
jcallahan@75
|
415
|
jcallahan@78
|
416 for source_guid, loot_data in pairs(action_data.loot_sources) do
|
jcallahan@78
|
417 local entry, source_id
|
jcallahan@78
|
418
|
jcallahan@78
|
419 if action_data.type == AF.ITEM then
|
jcallahan@78
|
420 -- Items return the player as the source, so we need to use the item's ID (disenchant, milling, etc)
|
jcallahan@78
|
421 source_id = action_data.identifier
|
jcallahan@78
|
422 entry = DBEntry(data_type, source_id)
|
jcallahan@78
|
423 elseif action_data.type == AF.OBJECT then
|
jcallahan@78
|
424 source_id = ("%s:%s"):format(action_data.spell_label, select(2, ParseGUID(source_guid)))
|
jcallahan@78
|
425 entry = DBEntry(data_type, source_id)
|
jcallahan@78
|
426 else
|
jcallahan@78
|
427 source_id = select(2, ParseGUID(source_guid))
|
jcallahan@78
|
428 entry = DBEntry(data_type, source_id)
|
jcallahan@78
|
429 end
|
jcallahan@75
|
430
|
jcallahan@75
|
431 if entry then
|
jcallahan@77
|
432 local loot_table = LootTable(entry, loot_type, top_field)
|
jcallahan@77
|
433
|
jcallahan@78
|
434 if not source_list[source_guid] then
|
jcallahan@77
|
435 if top_field then
|
jcallahan@77
|
436 entry[top_field][loot_count] = (entry[top_field][loot_count] or 0) + 1
|
jcallahan@77
|
437 else
|
jcallahan@77
|
438 entry[loot_count] = (entry[loot_count] or 0) + 1
|
jcallahan@77
|
439 end
|
jcallahan@78
|
440 source_list[source_guid] = true
|
jcallahan@77
|
441 end
|
jcallahan@75
|
442 UpdateDBEntryLocation(data_type, source_id)
|
jcallahan@75
|
443
|
jcallahan@75
|
444 for item_id, quantity in pairs(loot_data) do
|
jcallahan@75
|
445 table.insert(loot_table, ("%d:%d"):format(item_id, quantity))
|
jcallahan@75
|
446 end
|
jcallahan@75
|
447 end
|
jcallahan@75
|
448 end
|
jcallahan@75
|
449 -- TODO: Remove this when GetLootSourceInfo() has values for money
|
jcallahan@82
|
450 if #action_data.loot_list <= 0 then
|
jcallahan@78
|
451 return
|
jcallahan@78
|
452 end
|
jcallahan@82
|
453 local entry
|
jcallahan@82
|
454
|
jcallahan@82
|
455 -- At this point we only have a name if it's an object.
|
jcallahan@82
|
456 if action_data.type == AF.OBJECT then
|
jcallahan@82
|
457 entry = DBEntry(data_type, ("%s:%s"):format(action_data.spell_label, action_data.target_name))
|
jcallahan@82
|
458 else
|
jcallahan@82
|
459 entry = DBEntry(data_type, action_data.identifier)
|
jcallahan@82
|
460 end
|
jcallahan@75
|
461
|
jcallahan@75
|
462 if not entry then
|
jcallahan@75
|
463 return
|
jcallahan@75
|
464 end
|
jcallahan@77
|
465 local loot_table = LootTable(entry, loot_type, top_field)
|
jcallahan@77
|
466
|
jcallahan@77
|
467 if not source_list[action_data.identifier] then
|
jcallahan@77
|
468 if top_field then
|
jcallahan@77
|
469 entry[top_field][loot_count] = (entry[top_field][loot_count] or 0) + 1
|
jcallahan@77
|
470 else
|
jcallahan@77
|
471 entry[loot_count] = (entry[loot_count] or 0) + 1
|
jcallahan@77
|
472 end
|
jcallahan@77
|
473 end
|
jcallahan@75
|
474
|
jcallahan@75
|
475 for index = 1, #action_data.loot_list do
|
jcallahan@75
|
476 table.insert(loot_table, action_data.loot_list[index])
|
jcallahan@75
|
477 end
|
jcallahan@48
|
478 end
|
jcallahan@75
|
479 end -- do-block
|
jcallahan@48
|
480
|
jcallahan@0
|
481 -----------------------------------------------------------------------
|
jcallahan@0
|
482 -- Methods.
|
jcallahan@0
|
483 -----------------------------------------------------------------------
|
jcallahan@0
|
484 function WDP:OnInitialize()
|
jcallahan@0
|
485 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global
|
jcallahan@14
|
486
|
jcallahan@14
|
487 local raw_db = _G["WoWDBProfilerData"]
|
jcallahan@18
|
488 local build_num = tonumber(private.build_num)
|
jcallahan@14
|
489
|
jcallahan@74
|
490 -- TODO: Merge this with the DB version check when MoP goes live.
|
jcallahan@35
|
491 -- if raw_db.build_num and raw_db.build_num < build_num then
|
jcallahan@74
|
492 if raw_db.version and raw_db.version < DB_VERSION then
|
jcallahan@74
|
493 for entry in pairs(DATABASE_DEFAULTS.global) do
|
jcallahan@74
|
494 db[entry] = {}
|
jcallahan@74
|
495 end
|
jcallahan@74
|
496 end
|
jcallahan@35
|
497 raw_db.build_num = build_num
|
jcallahan@63
|
498 raw_db.version = DB_VERSION
|
jcallahan@0
|
499 end
|
jcallahan@0
|
500
|
jcallahan@0
|
501
|
jcallahan@0
|
502 function WDP:OnEnable()
|
jcallahan@0
|
503 for event_name, mapping in pairs(EVENT_MAPPING) do
|
jcallahan@1
|
504 self:RegisterEvent(event_name, (_G.type(mapping) ~= "boolean") and mapping or nil)
|
jcallahan@0
|
505 end
|
jcallahan@0
|
506 durability_timer_handle = self:ScheduleRepeatingTimer("ProcessDurability", 30)
|
jcallahan@31
|
507 target_location_timer_handle = self:ScheduleRepeatingTimer("UpdateTargetLocation", 0.5)
|
jcallahan@19
|
508
|
jcallahan@19
|
509 _G.hooksecurefunc("UseContainerItem", function(bag_index, slot_index, target_unit)
|
jcallahan@19
|
510 if target_unit then
|
jcallahan@19
|
511 return
|
jcallahan@19
|
512 end
|
jcallahan@19
|
513 HandleItemUse(_G.GetContainerItemLink(bag_index, slot_index), bag_index, slot_index)
|
jcallahan@19
|
514 end)
|
jcallahan@19
|
515
|
jcallahan@19
|
516 _G.hooksecurefunc("UseItemByName", function(identifier, target_unit)
|
jcallahan@19
|
517 if target_unit then
|
jcallahan@19
|
518 return
|
jcallahan@19
|
519 end
|
jcallahan@19
|
520 local _, item_link = _G.GetItemInfo(identifier)
|
jcallahan@19
|
521 HandleItemUse(item_link)
|
jcallahan@19
|
522 end)
|
jcallahan@0
|
523 end
|
jcallahan@0
|
524
|
jcallahan@0
|
525
|
jcallahan@0
|
526 local function RecordDurability(item_id, durability)
|
jcallahan@0
|
527 if not durability or durability <= 0 then
|
jcallahan@0
|
528 return
|
jcallahan@0
|
529 end
|
jcallahan@0
|
530
|
jcallahan@0
|
531 if not db.items[item_id] then
|
jcallahan@0
|
532 db.items[item_id] = {}
|
jcallahan@0
|
533 end
|
jcallahan@0
|
534 db.items[item_id].durability = durability
|
jcallahan@0
|
535 end
|
jcallahan@0
|
536
|
jcallahan@0
|
537
|
jcallahan@0
|
538 function WDP:ProcessDurability()
|
jcallahan@0
|
539 for slot_index = 0, _G.INVSLOT_LAST_EQUIPPED do
|
jcallahan@1
|
540 local item_id = _G.GetInventoryItemID("player", slot_index)
|
jcallahan@0
|
541
|
jcallahan@0
|
542 if item_id and item_id > 0 then
|
jcallahan@1
|
543 local _, max_durability = _G.GetInventoryItemDurability(slot_index)
|
jcallahan@0
|
544 RecordDurability(item_id, max_durability)
|
jcallahan@0
|
545 end
|
jcallahan@0
|
546 end
|
jcallahan@0
|
547
|
jcallahan@0
|
548 for bag_index = 0, _G.NUM_BAG_SLOTS do
|
jcallahan@0
|
549 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do
|
jcallahan@1
|
550 local item_id = _G.GetContainerItemID(bag_index, slot_index)
|
jcallahan@0
|
551
|
jcallahan@0
|
552 if item_id and item_id > 0 then
|
jcallahan@1
|
553 local _, max_durability = _G.GetContainerItemDurability(bag_index, slot_index)
|
jcallahan@0
|
554 RecordDurability(item_id, max_durability)
|
jcallahan@0
|
555 end
|
jcallahan@0
|
556 end
|
jcallahan@0
|
557 end
|
jcallahan@0
|
558 end
|
jcallahan@0
|
559
|
jcallahan@0
|
560
|
jcallahan@2
|
561 function WDP:UpdateTargetLocation()
|
jcallahan@40
|
562 if currently_drunk or not _G.UnitExists("target") or _G.UnitPlayerControlled("target") or (_G.UnitIsTapped("target") and not _G.UnitIsDead("target")) then
|
jcallahan@2
|
563 return
|
jcallahan@2
|
564 end
|
jcallahan@2
|
565
|
jcallahan@2
|
566 for index = 1, 4 do
|
jcallahan@2
|
567 if not _G.CheckInteractDistance("target", index) then
|
jcallahan@2
|
568 return
|
jcallahan@2
|
569 end
|
jcallahan@2
|
570 end
|
jcallahan@40
|
571 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target"))
|
jcallahan@2
|
572
|
jcallahan@40
|
573 if not unit_idnum or unit_type ~= private.UNIT_TYPES.NPC then
|
jcallahan@2
|
574 return
|
jcallahan@2
|
575 end
|
jcallahan@34
|
576 UpdateNPCLocation(unit_idnum)
|
jcallahan@2
|
577 end
|
jcallahan@2
|
578
|
jcallahan@2
|
579
|
jcallahan@0
|
580 -----------------------------------------------------------------------
|
jcallahan@0
|
581 -- Event handlers.
|
jcallahan@0
|
582 -----------------------------------------------------------------------
|
jcallahan@90
|
583 function WDP:BLACK_MARKET_ITEM_UPDATE(event_name)
|
jcallahan@56
|
584 local num_items = _G.C_BlackMarket.GetNumItems()
|
jcallahan@56
|
585
|
jcallahan@56
|
586 for index = 1, num_items do
|
jcallahan@56
|
587 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
|
588
|
jcallahan@56
|
589 if item_link then
|
jcallahan@56
|
590 DBEntry("items", ItemLinkToID(item_link)).black_market = seller_name or "UNKNOWN"
|
jcallahan@56
|
591 end
|
jcallahan@56
|
592 end
|
jcallahan@56
|
593 end
|
jcallahan@56
|
594
|
jcallahan@56
|
595
|
jcallahan@75
|
596 function WDP:CHAT_MSG_LOOT(event_name, message)
|
jcallahan@48
|
597 if action_data.spell_label ~= "EXTRACT_GAS" then
|
jcallahan@48
|
598 return
|
jcallahan@48
|
599 end
|
jcallahan@48
|
600 local item_link, quantity = deformat(message, _G.LOOT_ITEM_PUSHED_SELF_MULTIPLE)
|
jcallahan@48
|
601
|
jcallahan@48
|
602 if not item_link then
|
jcallahan@48
|
603 quantity, item_link = 1, deformat(message, _G.LOOT_ITEM_PUSHED_SELF)
|
jcallahan@48
|
604 end
|
jcallahan@48
|
605
|
jcallahan@48
|
606 if not item_link then
|
jcallahan@48
|
607 return
|
jcallahan@48
|
608 end
|
jcallahan@48
|
609 local item_id = ItemLinkToID(item_link)
|
jcallahan@48
|
610
|
jcallahan@48
|
611 if not item_id then
|
jcallahan@48
|
612 return
|
jcallahan@48
|
613 end
|
jcallahan@48
|
614 action_data.loot_list = {
|
jcallahan@48
|
615 ("%d:%d"):format(item_id, quantity)
|
jcallahan@48
|
616 }
|
jcallahan@48
|
617 GenericLootUpdate("zones")
|
jcallahan@48
|
618 table.wipe(action_data)
|
jcallahan@48
|
619 end
|
jcallahan@48
|
620
|
jcallahan@48
|
621
|
jcallahan@23
|
622 do
|
jcallahan@40
|
623 local SOBER_MATCH = _G.DRUNK_MESSAGE_ITEM_SELF1:gsub("%%s", ".+")
|
jcallahan@40
|
624
|
jcallahan@40
|
625 local DRUNK_COMPARES = {
|
jcallahan@40
|
626 _G.DRUNK_MESSAGE_SELF2,
|
jcallahan@40
|
627 _G.DRUNK_MESSAGE_SELF3,
|
jcallahan@40
|
628 _G.DRUNK_MESSAGE_SELF4,
|
jcallahan@40
|
629 }
|
jcallahan@40
|
630
|
jcallahan@40
|
631 local DRUNK_MATCHES = {
|
jcallahan@40
|
632 _G.DRUNK_MESSAGE_SELF2:gsub("%%s", ".+"),
|
jcallahan@40
|
633 _G.DRUNK_MESSAGE_SELF3:gsub("%%s", ".+"),
|
jcallahan@40
|
634 _G.DRUNK_MESSAGE_SELF4:gsub("%%s", ".+"),
|
jcallahan@40
|
635 }
|
jcallahan@40
|
636
|
jcallahan@92
|
637 function WDP:CHAT_MSG_SYSTEM(event_name, message)
|
jcallahan@40
|
638 if currently_drunk then
|
jcallahan@40
|
639 if message == _G.DRUNK_MESSAGE_SELF1 or message:match(SOBER_MATCH) then
|
jcallahan@40
|
640 currently_drunk = nil
|
jcallahan@40
|
641 end
|
jcallahan@40
|
642 return
|
jcallahan@40
|
643 end
|
jcallahan@40
|
644
|
jcallahan@40
|
645 for index = 1, #DRUNK_MATCHES do
|
jcallahan@40
|
646 if message == DRUNK_COMPARES[index] or message:match(DRUNK_MATCHES[index]) then
|
jcallahan@40
|
647 currently_drunk = true
|
jcallahan@40
|
648 break
|
jcallahan@40
|
649 end
|
jcallahan@40
|
650 end
|
jcallahan@40
|
651 end
|
jcallahan@40
|
652 end
|
jcallahan@40
|
653
|
jcallahan@40
|
654 -- do-block
|
jcallahan@40
|
655
|
jcallahan@40
|
656 do
|
jcallahan@23
|
657 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC)
|
jcallahan@23
|
658 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC)
|
jcallahan@23
|
659
|
jcallahan@23
|
660 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name)
|
jcallahan@23
|
661 if not spell_id then
|
jcallahan@23
|
662 return
|
jcallahan@23
|
663 end
|
jcallahan@34
|
664 local source_type, source_id = ParseGUID(source_guid)
|
jcallahan@23
|
665
|
jcallahan@23
|
666 if not source_id or source_type ~= private.UNIT_TYPES.NPC then
|
jcallahan@23
|
667 return
|
jcallahan@23
|
668 end
|
jcallahan@23
|
669
|
jcallahan@23
|
670 if bit.band(FLAGS_NPC_CONTROL, source_flags) == FLAGS_NPC_CONTROL and bit.band(FLAGS_NPC, source_flags) ~= 0 then
|
jcallahan@29
|
671 local encounter_data = NPCEntry(source_id).encounter_data[InstanceDifficultyToken()]
|
jcallahan@28
|
672 encounter_data.spells = encounter_data.spells or {}
|
jcallahan@28
|
673 encounter_data.spells[spell_id] = (encounter_data.spells[spell_id] or 0) + 1
|
jcallahan@23
|
674 end
|
jcallahan@23
|
675 end
|
jcallahan@23
|
676
|
jcallahan@23
|
677 local COMBAT_LOG_FUNCS = {
|
jcallahan@23
|
678 SPELL_AURA_APPLIED = RecordNPCSpell,
|
jcallahan@23
|
679 SPELL_CAST_START = RecordNPCSpell,
|
jcallahan@48
|
680 SPELL_CAST_SUCCESS = RecordNPCSpell,
|
jcallahan@65
|
681 UNIT_DIED = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name)
|
jcallahan@65
|
682 local unit_type, unit_idnum = ParseGUID(dest_guid)
|
jcallahan@65
|
683
|
jcallahan@65
|
684 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
|
jcallahan@67
|
685 reputation_npc_id = nil
|
jcallahan@65
|
686 return
|
jcallahan@65
|
687 end
|
jcallahan@67
|
688 reputation_npc_id = unit_idnum
|
jcallahan@65
|
689 end,
|
jcallahan@23
|
690 }
|
jcallahan@23
|
691
|
jcallahan@23
|
692
|
jcallahan@92
|
693 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
|
694 local combat_log_func = COMBAT_LOG_FUNCS[sub_event]
|
jcallahan@23
|
695
|
jcallahan@23
|
696 if not combat_log_func then
|
jcallahan@23
|
697 return
|
jcallahan@23
|
698 end
|
jcallahan@23
|
699 combat_log_func(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, ...)
|
jcallahan@23
|
700 end
|
jcallahan@23
|
701
|
jcallahan@44
|
702 local DIPLOMACY_SPELL_ID = 20599
|
jcallahan@44
|
703 local MR_POP_RANK1_SPELL_ID = 78634
|
jcallahan@44
|
704 local MR_POP_RANK2_SPELL_ID = 78635
|
jcallahan@44
|
705
|
jcallahan@44
|
706 local REP_BUFFS = {
|
jcallahan@44
|
707 [_G.GetSpellInfo(30754)] = "CENARION_FAVOR",
|
jcallahan@44
|
708 [_G.GetSpellInfo(24705)] = "GRIM_VISAGE",
|
jcallahan@44
|
709 [_G.GetSpellInfo(32098)] = "HONOR_HOLD_FAVOR",
|
jcallahan@44
|
710 [_G.GetSpellInfo(39913)] = "NAZGRELS_FERVOR",
|
jcallahan@44
|
711 [_G.GetSpellInfo(39953)] = "SONG_OF_BATTLE",
|
jcallahan@44
|
712 [_G.GetSpellInfo(61849)] = "SPIRIT_OF_SHARING",
|
jcallahan@44
|
713 [_G.GetSpellInfo(32096)] = "THRALLMARS_FAVOR",
|
jcallahan@44
|
714 [_G.GetSpellInfo(39911)] = "TROLLBANES_COMMAND",
|
jcallahan@44
|
715 [_G.GetSpellInfo(95987)] = "UNBURDENED",
|
jcallahan@44
|
716 [_G.GetSpellInfo(100951)] = "WOW_ANNIVERSARY",
|
jcallahan@44
|
717 }
|
jcallahan@44
|
718
|
jcallahan@44
|
719
|
jcallahan@44
|
720 local FACTION_NAMES = {
|
jcallahan@44
|
721 CENARION_CIRCLE = _G.GetFactionInfoByID(609),
|
jcallahan@44
|
722 HONOR_HOLD = _G.GetFactionInfoByID(946),
|
jcallahan@44
|
723 THE_SHATAR = _G.GetFactionInfoByID(935),
|
jcallahan@44
|
724 THRALLMAR = _G.GetFactionInfoByID(947),
|
jcallahan@44
|
725 }
|
jcallahan@44
|
726
|
jcallahan@44
|
727
|
jcallahan@44
|
728 local MODIFIERS = {
|
jcallahan@44
|
729 CENARION_FAVOR = {
|
jcallahan@44
|
730 faction = FACTION_NAMES.CENARION_CIRCLE,
|
jcallahan@44
|
731 modifier = 0.25,
|
jcallahan@44
|
732 },
|
jcallahan@44
|
733 GRIM_VISAGE = {
|
jcallahan@44
|
734 modifier = 0.1,
|
jcallahan@44
|
735 },
|
jcallahan@44
|
736 HONOR_HOLD_FAVOR = {
|
jcallahan@44
|
737 faction = FACTION_NAMES.HONOR_HOLD,
|
jcallahan@44
|
738 modifier = 0.25,
|
jcallahan@44
|
739 },
|
jcallahan@44
|
740 NAZGRELS_FERVOR = {
|
jcallahan@44
|
741 faction = FACTION_NAMES.THRALLMAR,
|
jcallahan@44
|
742 modifier = 0.1,
|
jcallahan@44
|
743 },
|
jcallahan@44
|
744 SONG_OF_BATTLE = {
|
jcallahan@44
|
745 faction = FACTION_NAMES.THE_SHATAR,
|
jcallahan@44
|
746 modifier = 0.1,
|
jcallahan@44
|
747 },
|
jcallahan@44
|
748 SPIRIT_OF_SHARING = {
|
jcallahan@44
|
749 modifier = 0.1,
|
jcallahan@44
|
750 },
|
jcallahan@44
|
751 THRALLMARS_FAVOR = {
|
jcallahan@44
|
752 faction = FACTION_NAMES.THRALLMAR,
|
jcallahan@44
|
753 modifier = 0.25,
|
jcallahan@44
|
754 },
|
jcallahan@44
|
755 TROLLBANES_COMMAND = {
|
jcallahan@44
|
756 faction = FACTION_NAMES.HONOR_HOLD,
|
jcallahan@44
|
757 modifier = 0.1,
|
jcallahan@44
|
758 },
|
jcallahan@44
|
759 UNBURDENED = {
|
jcallahan@44
|
760 modifier = 0.1,
|
jcallahan@44
|
761 },
|
jcallahan@44
|
762 WOW_ANNIVERSARY = {
|
jcallahan@44
|
763 modifier = 0.08,
|
jcallahan@44
|
764 }
|
jcallahan@44
|
765 }
|
jcallahan@44
|
766
|
jcallahan@44
|
767
|
jcallahan@92
|
768 function WDP:COMBAT_TEXT_UPDATE(event_name, message_type, faction_name, amount)
|
jcallahan@67
|
769 if message_type ~= "FACTION" or not reputation_npc_id then
|
jcallahan@44
|
770 return
|
jcallahan@44
|
771 end
|
jcallahan@44
|
772 UpdateFactionData()
|
jcallahan@44
|
773
|
jcallahan@46
|
774 if not faction_name or not faction_standings[faction_name] then
|
jcallahan@46
|
775 return
|
jcallahan@46
|
776 end
|
jcallahan@67
|
777 local npc = NPCEntry(reputation_npc_id)
|
jcallahan@46
|
778
|
jcallahan@44
|
779 if not npc then
|
jcallahan@44
|
780 return
|
jcallahan@44
|
781 end
|
jcallahan@44
|
782 local modifier = 1
|
jcallahan@44
|
783
|
jcallahan@44
|
784 if _G.IsSpellKnown(DIPLOMACY_SPELL_ID) then
|
jcallahan@44
|
785 modifier = modifier + 0.1
|
jcallahan@44
|
786 end
|
jcallahan@44
|
787
|
jcallahan@44
|
788 if _G.IsSpellKnown(MR_POP_RANK2_SPELL_ID) then
|
jcallahan@44
|
789 modifier = modifier + 0.1
|
jcallahan@44
|
790 elseif _G.IsSpellKnown(MR_POP_RANK1_SPELL_ID) then
|
jcallahan@44
|
791 modifier = modifier + 0.05
|
jcallahan@44
|
792 end
|
jcallahan@44
|
793
|
jcallahan@44
|
794 for buff_name, buff_label in pairs(REP_BUFFS) do
|
jcallahan@44
|
795 if _G.UnitBuff("player", buff_name) then
|
jcallahan@44
|
796 local modded_faction = MODIFIERS[buff_label].faction
|
jcallahan@44
|
797
|
jcallahan@44
|
798 if not modded_faction or faction_name == modded_faction then
|
jcallahan@44
|
799 modifier = modifier + MODIFIERS[buff_label].modifier
|
jcallahan@44
|
800 end
|
jcallahan@44
|
801 end
|
jcallahan@44
|
802 end
|
jcallahan@65
|
803 npc.reputations = npc.reputations or {}
|
jcallahan@65
|
804 npc.reputations[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier)
|
jcallahan@67
|
805 reputation_npc_id = nil
|
jcallahan@32
|
806 end
|
jcallahan@44
|
807 end -- do-block
|
jcallahan@18
|
808
|
jcallahan@18
|
809
|
jcallahan@92
|
810 function WDP:ITEM_TEXT_BEGIN(event_name)
|
jcallahan@42
|
811 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
|
jcallahan@42
|
812
|
jcallahan@42
|
813 if not unit_idnum or unit_type ~= private.UNIT_TYPES.OBJECT or _G.UnitName("npc") ~= _G.ItemTextGetItem() then
|
jcallahan@42
|
814 return
|
jcallahan@42
|
815 end
|
jcallahan@42
|
816 UpdateDBEntryLocation("objects", unit_idnum)
|
jcallahan@42
|
817 end
|
jcallahan@42
|
818
|
jcallahan@42
|
819
|
jcallahan@13
|
820 do
|
jcallahan@40
|
821 local RE_GOLD = _G.GOLD_AMOUNT:gsub("%%d", "(%%d+)")
|
jcallahan@40
|
822 local RE_SILVER = _G.SILVER_AMOUNT:gsub("%%d", "(%%d+)")
|
jcallahan@40
|
823 local RE_COPPER = _G.COPPER_AMOUNT:gsub("%%d", "(%%d+)")
|
jcallahan@13
|
824
|
jcallahan@13
|
825
|
jcallahan@13
|
826 local function _moneyMatch(money, re)
|
jcallahan@13
|
827 return money:match(re) or 0
|
jcallahan@1
|
828 end
|
jcallahan@1
|
829
|
jcallahan@0
|
830
|
jcallahan@13
|
831 local function _toCopper(money)
|
jcallahan@13
|
832 if not money then
|
jcallahan@13
|
833 return 0
|
jcallahan@13
|
834 end
|
jcallahan@40
|
835 return _moneyMatch(money, RE_GOLD) * 10000 + _moneyMatch(money, RE_SILVER) * 100 + _moneyMatch(money, RE_COPPER)
|
jcallahan@1
|
836 end
|
jcallahan@1
|
837
|
jcallahan@1
|
838
|
jcallahan@13
|
839 local LOOT_VERIFY_FUNCS = {
|
jcallahan@16
|
840 [AF.ITEM] = function()
|
jcallahan@16
|
841 local locked_item_id
|
jcallahan@16
|
842
|
jcallahan@16
|
843 for bag_index = 0, _G.NUM_BAG_FRAMES do
|
jcallahan@16
|
844 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do
|
jcallahan@16
|
845 local _, _, is_locked = _G.GetContainerItemInfo(bag_index, slot_index)
|
jcallahan@16
|
846
|
jcallahan@16
|
847 if is_locked then
|
jcallahan@16
|
848 locked_item_id = ItemLinkToID(_G.GetContainerItemLink(bag_index, slot_index))
|
jcallahan@16
|
849 end
|
jcallahan@16
|
850 end
|
jcallahan@16
|
851 end
|
jcallahan@16
|
852
|
jcallahan@28
|
853 if not locked_item_id or (action_data.identifier and action_data.identifier ~= locked_item_id) then
|
jcallahan@16
|
854 return false
|
jcallahan@16
|
855 end
|
jcallahan@28
|
856 action_data.identifier = locked_item_id
|
jcallahan@16
|
857 return true
|
jcallahan@16
|
858 end,
|
jcallahan@13
|
859 [AF.NPC] = function()
|
jcallahan@17
|
860 if not _G.UnitExists("target") or _G.UnitIsFriend("player", "target") or _G.UnitIsPlayer("target") or _G.UnitPlayerControlled("target") then
|
jcallahan@15
|
861 return false
|
jcallahan@13
|
862 end
|
jcallahan@34
|
863 local unit_type, id_num = ParseGUID(_G.UnitGUID("target"))
|
jcallahan@27
|
864 action_data.identifier = id_num
|
jcallahan@13
|
865 return true
|
jcallahan@13
|
866 end,
|
jcallahan@14
|
867 [AF.OBJECT] = true,
|
jcallahan@17
|
868 [AF.ZONE] = function()
|
jcallahan@38
|
869 return _G.IsFishingLoot()
|
jcallahan@17
|
870 end,
|
jcallahan@13
|
871 }
|
jcallahan@13
|
872
|
jcallahan@13
|
873
|
jcallahan@13
|
874 local LOOT_UPDATE_FUNCS = {
|
jcallahan@16
|
875 [AF.ITEM] = function()
|
jcallahan@28
|
876 GenericLootUpdate("items")
|
jcallahan@28
|
877 end,
|
jcallahan@28
|
878 [AF.NPC] = function()
|
jcallahan@75
|
879 local difficulty_token = InstanceDifficultyToken()
|
jcallahan@75
|
880 local loot_type = action_data.label or "drops"
|
jcallahan@77
|
881 local source_list = {}
|
jcallahan@75
|
882
|
jcallahan@78
|
883 for source_guid, loot_data in pairs(action_data.loot_sources) do
|
jcallahan@78
|
884 local source_id = select(2, ParseGUID(source_guid))
|
jcallahan@75
|
885 local npc = NPCEntry(source_id)
|
jcallahan@75
|
886
|
jcallahan@75
|
887 if npc then
|
jcallahan@75
|
888 local encounter_data = npc.encounter_data[difficulty_token]
|
jcallahan@75
|
889 encounter_data[loot_type] = encounter_data[loot_type] or {}
|
jcallahan@75
|
890
|
jcallahan@78
|
891 if not source_list[source_guid] then
|
jcallahan@77
|
892 encounter_data.loot_counts = encounter_data.loot_counts or {}
|
jcallahan@77
|
893 encounter_data.loot_counts[loot_type] = (encounter_data.loot_counts[loot_type] or 0) + 1
|
jcallahan@77
|
894 source_list[source_id] = true
|
jcallahan@77
|
895 end
|
jcallahan@77
|
896
|
jcallahan@75
|
897 for item_id, quantity in pairs(loot_data) do
|
jcallahan@75
|
898 table.insert(encounter_data[loot_type], ("%d:%d"):format(item_id, quantity))
|
jcallahan@75
|
899 end
|
jcallahan@75
|
900 end
|
jcallahan@75
|
901 end
|
jcallahan@75
|
902
|
jcallahan@75
|
903 -- TODO: Remove this when GetLootSourceInfo() has values for money
|
jcallahan@79
|
904 if #action_data.loot_list <= 0 then
|
jcallahan@79
|
905 return
|
jcallahan@79
|
906 end
|
jcallahan@29
|
907 local npc = NPCEntry(action_data.identifier)
|
jcallahan@28
|
908
|
jcallahan@28
|
909 if not npc then
|
jcallahan@28
|
910 return
|
jcallahan@28
|
911 end
|
jcallahan@75
|
912 local encounter_data = npc.encounter_data[difficulty_token]
|
jcallahan@29
|
913 encounter_data[loot_type] = encounter_data[loot_type] or {}
|
jcallahan@16
|
914
|
jcallahan@77
|
915 if not source_list[action_data.identifier] then
|
jcallahan@77
|
916 encounter_data.loot_counts = encounter_data.loot_counts or {}
|
jcallahan@77
|
917 encounter_data.loot_counts[loot_type] = (encounter_data.loot_counts[loot_type] or 0) + 1
|
jcallahan@77
|
918 end
|
jcallahan@77
|
919
|
jcallahan@17
|
920 for index = 1, #action_data.loot_list do
|
jcallahan@29
|
921 table.insert(encounter_data[loot_type], action_data.loot_list[index])
|
jcallahan@16
|
922 end
|
jcallahan@16
|
923 end,
|
jcallahan@13
|
924 [AF.OBJECT] = function()
|
jcallahan@28
|
925 GenericLootUpdate("objects", InstanceDifficultyToken())
|
jcallahan@17
|
926 end,
|
jcallahan@17
|
927 [AF.ZONE] = function()
|
jcallahan@41
|
928 local location_token = ("%s:%s:%s"):format(action_data.map_level, action_data.x, action_data.y)
|
jcallahan@41
|
929
|
jcallahan@41
|
930 -- This will start life as a boolean true.
|
jcallahan@41
|
931 if _G.type(action_data.zone_data[location_token]) ~= "table" then
|
jcallahan@41
|
932 action_data.zone_data[location_token] = {
|
jcallahan@41
|
933 drops = {}
|
jcallahan@41
|
934 }
|
jcallahan@41
|
935 end
|
jcallahan@41
|
936 local loot_count = ("%s_count"):format(action_data.label or "drops")
|
jcallahan@41
|
937 action_data.zone_data[location_token][loot_count] = (action_data.zone_data[location_token][loot_count] or 0) + 1
|
jcallahan@41
|
938
|
jcallahan@41
|
939 for index = 1, #action_data.loot_list do
|
jcallahan@41
|
940 table.insert(action_data.zone_data[location_token].drops, action_data.loot_list[index])
|
jcallahan@41
|
941 end
|
jcallahan@13
|
942 end,
|
jcallahan@13
|
943 }
|
jcallahan@13
|
944
|
jcallahan@79
|
945 -- Prevent opening the same loot window multiple times from recording data multiple times.
|
jcallahan@79
|
946 local loot_guid_registry = {}
|
jcallahan@13
|
947
|
jcallahan@92
|
948 function WDP:LOOT_OPENED(event_name)
|
jcallahan@18
|
949 if action_data.looting then
|
jcallahan@18
|
950 return
|
jcallahan@18
|
951 end
|
jcallahan@18
|
952
|
jcallahan@13
|
953 if not action_data.type then
|
jcallahan@13
|
954 action_data.type = AF.NPC
|
jcallahan@1
|
955 end
|
jcallahan@13
|
956 local verify_func = LOOT_VERIFY_FUNCS[action_data.type]
|
jcallahan@13
|
957 local update_func = LOOT_UPDATE_FUNCS[action_data.type]
|
jcallahan@13
|
958
|
jcallahan@14
|
959 if not verify_func or not update_func then
|
jcallahan@13
|
960 return
|
jcallahan@13
|
961 end
|
jcallahan@13
|
962
|
jcallahan@14
|
963 if _G.type(verify_func) == "function" and not verify_func() then
|
jcallahan@14
|
964 return
|
jcallahan@14
|
965 end
|
jcallahan@80
|
966 local guids_used = {}
|
jcallahan@17
|
967 action_data.loot_list = {}
|
jcallahan@75
|
968 action_data.loot_sources = {}
|
jcallahan@18
|
969 action_data.looting = true
|
jcallahan@13
|
970
|
jcallahan@55
|
971 for loot_slot = 1, _G.GetNumLootItems() do
|
jcallahan@55
|
972 local icon_texture, item_text, quantity, quality, locked = _G.GetLootSlotInfo(loot_slot)
|
jcallahan@55
|
973 local slot_type = _G.GetLootSlotType(loot_slot)
|
jcallahan@13
|
974
|
jcallahan@77
|
975 -- TODO: Move LOOT_SLOT_X checks within loop when money is detectable via GetLootSourceInfo
|
jcallahan@77
|
976 if slot_type == _G.LOOT_SLOT_ITEM then
|
jcallahan@78
|
977 local loot_info = {
|
jcallahan@77
|
978 _G.GetLootSourceInfo(loot_slot)
|
jcallahan@77
|
979 }
|
jcallahan@75
|
980
|
jcallahan@75
|
981 -- TODO: Remove debugging
|
jcallahan@77
|
982 -- print(("Loot slot %d: Source count: %d"):format(loot_slot, floor((#sources / 2) + 0.5)))
|
jcallahan@75
|
983
|
jcallahan@77
|
984 -- Odd index is GUID, even is count.
|
jcallahan@78
|
985 for loot_index = 1, #loot_info, 2 do
|
jcallahan@78
|
986 local source_guid = loot_info[loot_index]
|
jcallahan@77
|
987
|
jcallahan@79
|
988 if not loot_guid_registry[source_guid] then
|
jcallahan@79
|
989 local loot_quantity = loot_info[loot_index + 1]
|
jcallahan@79
|
990 local source_type, source_id = ParseGUID(source_guid)
|
jcallahan@79
|
991 -- TODO: Remove debugging
|
jcallahan@79
|
992 -- local source_key = ("%s:%d"):format(private.UNIT_TYPE_NAMES[source_type + 1], source_id)
|
jcallahan@79
|
993 -- print(("GUID: %s - Type:ID: %s - Amount: %d"):format(loot_info[loot_index], source_key, loot_quantity))
|
jcallahan@79
|
994
|
jcallahan@79
|
995 local item_id = ItemLinkToID(_G.GetLootSlotLink(loot_slot))
|
jcallahan@79
|
996 action_data.loot_sources[source_guid] = action_data.loot_sources[source_guid] or {}
|
jcallahan@79
|
997 action_data.loot_sources[source_guid][item_id] = action_data.loot_sources[source_guid][item_id] or 0 + loot_quantity
|
jcallahan@80
|
998 guids_used[source_guid] = true
|
jcallahan@79
|
999 end
|
jcallahan@75
|
1000 end
|
jcallahan@82
|
1001 -- elseif slot_type == _G.LOOT_SLOT_MONEY then
|
jcallahan@82
|
1002 -- table.insert(action_data.loot_list, ("money:%d"):format(_toCopper(item_text)))
|
jcallahan@77
|
1003 elseif slot_type == _G.LOOT_SLOT_CURRENCY then
|
jcallahan@77
|
1004 table.insert(action_data.loot_list, ("currency:%d:%s"):format(quantity, icon_texture:match("[^\\]+$"):lower()))
|
jcallahan@13
|
1005 end
|
jcallahan@13
|
1006 end
|
jcallahan@80
|
1007
|
jcallahan@81
|
1008 for guid in pairs(guids_used) do
|
jcallahan@80
|
1009 loot_guid_registry[guid] = true
|
jcallahan@80
|
1010 end
|
jcallahan@13
|
1011 update_func()
|
jcallahan@1
|
1012 end
|
jcallahan@13
|
1013 end -- do-block
|
jcallahan@0
|
1014
|
jcallahan@0
|
1015
|
jcallahan@89
|
1016 function WDP:MAIL_SHOW(event_name)
|
jcallahan@89
|
1017 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
|
jcallahan@89
|
1018
|
jcallahan@89
|
1019 if not unit_idnum or unit_type ~= private.UNIT_TYPES.OBJECT then
|
jcallahan@89
|
1020 return
|
jcallahan@89
|
1021 end
|
jcallahan@89
|
1022 UpdateDBEntryLocation("objects", unit_idnum)
|
jcallahan@89
|
1023 end
|
jcallahan@89
|
1024
|
jcallahan@89
|
1025
|
jcallahan@44
|
1026 do
|
jcallahan@44
|
1027 local POINT_MATCH_PATTERNS = {
|
jcallahan@44
|
1028 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING:gsub("%%d", "(%%d+)")), -- May no longer be necessary
|
jcallahan@44
|
1029 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3:gsub("%%d", "(%%d+)")), -- May no longer be necessary
|
jcallahan@44
|
1030 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_5V5:gsub("%%d", "(%%d+)")), -- May no longer be necessary
|
jcallahan@44
|
1031 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_BG:gsub("%%d", "(%%d+)")),
|
jcallahan@44
|
1032 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3_BG:gsub("%%d", "(%%d+)")),
|
jcallahan@44
|
1033 }
|
jcallahan@5
|
1034
|
jcallahan@68
|
1035 local ITEM_REQ_REPUTATION_MATCH = "Requires (.-) %- (.*)"
|
jcallahan@87
|
1036 local ITEM_REQ_QUEST_MATCH1 = "Requires: .*"
|
jcallahan@87
|
1037 local ITEM_REQ_QUEST_MATCH2 = "Must have completed: .*"
|
jcallahan@68
|
1038
|
jcallahan@89
|
1039 function WDP:UpdateMerchantItems(event_name)
|
jcallahan@44
|
1040 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target"))
|
jcallahan@4
|
1041
|
jcallahan@44
|
1042 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
|
jcallahan@44
|
1043 return
|
jcallahan@44
|
1044 end
|
jcallahan@55
|
1045 local current_filters = _G.GetMerchantFilter()
|
jcallahan@44
|
1046 local _, merchant_standing = UnitFactionStanding("target")
|
jcallahan@44
|
1047 local merchant = NPCEntry(unit_idnum)
|
jcallahan@44
|
1048 merchant.sells = merchant.sells or {}
|
jcallahan@5
|
1049
|
jcallahan@57
|
1050 _G.SetMerchantFilter(_G.LE_LOOT_FILTER_ALL)
|
jcallahan@57
|
1051 _G.MerchantFrame_Update()
|
jcallahan@57
|
1052
|
jcallahan@57
|
1053 local num_items = _G.GetMerchantNumItems()
|
jcallahan@35
|
1054
|
jcallahan@44
|
1055 for item_index = 1, num_items do
|
jcallahan@44
|
1056 local _, _, copper_price, stack_size, num_available, _, extended_cost = _G.GetMerchantItemInfo(item_index)
|
jcallahan@44
|
1057 local item_id = ItemLinkToID(_G.GetMerchantItemLink(item_index))
|
jcallahan@5
|
1058
|
jcallahan@44
|
1059 if item_id and item_id > 0 then
|
jcallahan@44
|
1060 local price_string = ActualCopperCost(copper_price, merchant_standing)
|
jcallahan@5
|
1061
|
jcallahan@68
|
1062 DatamineTT:ClearLines()
|
jcallahan@68
|
1063 DatamineTT:SetMerchantItem(item_index)
|
jcallahan@68
|
1064
|
jcallahan@68
|
1065 local num_lines = DatamineTT:NumLines()
|
jcallahan@68
|
1066
|
jcallahan@68
|
1067 for line_index = 1, num_lines do
|
jcallahan@68
|
1068 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
|
jcallahan@68
|
1069
|
jcallahan@68
|
1070 if not current_line then
|
jcallahan@68
|
1071 break
|
jcallahan@68
|
1072 end
|
jcallahan@68
|
1073 local faction, reputation = current_line:GetText():match(ITEM_REQ_REPUTATION_MATCH)
|
jcallahan@68
|
1074
|
jcallahan@68
|
1075 if faction or reputation then
|
jcallahan@68
|
1076 DBEntry("items", item_id).req_reputation = ("%s:%s"):format(faction:gsub("-", ""), reputation:upper())
|
jcallahan@68
|
1077 break
|
jcallahan@68
|
1078 end
|
jcallahan@68
|
1079 end
|
jcallahan@68
|
1080
|
jcallahan@87
|
1081 for line_index = 1, num_lines do
|
jcallahan@87
|
1082 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
|
jcallahan@87
|
1083
|
jcallahan@87
|
1084 if not current_line then
|
jcallahan@87
|
1085 break
|
jcallahan@87
|
1086 end
|
jcallahan@87
|
1087 local line_text = current_line:GetText()
|
jcallahan@87
|
1088 local quest_name = line_text:match(ITEM_REQ_QUEST_MATCH1) or line_text:match(ITEM_REQ_QUEST_MATCH2)
|
jcallahan@87
|
1089
|
jcallahan@87
|
1090 if quest_name then
|
jcallahan@87
|
1091 DBEntry("items", item_id).req_quest = ("%s"):format(quest_name:gsub("(.+): ", ""), quest_name)
|
jcallahan@87
|
1092 break
|
jcallahan@87
|
1093 end
|
jcallahan@87
|
1094 end
|
jcallahan@87
|
1095
|
jcallahan@44
|
1096 if extended_cost then
|
jcallahan@53
|
1097 local battleground_rating = 0
|
jcallahan@53
|
1098 local personal_rating = 0
|
jcallahan@53
|
1099 local required_season_amount
|
jcallahan@5
|
1100
|
jcallahan@68
|
1101 for line_index = 1, num_lines do
|
jcallahan@44
|
1102 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
|
jcallahan@5
|
1103
|
jcallahan@44
|
1104 if not current_line then
|
jcallahan@44
|
1105 break
|
jcallahan@44
|
1106 end
|
jcallahan@53
|
1107 required_season_amount = current_line:GetText():match("Requires earning a total of (%d+)\n(.-) for the season.")
|
jcallahan@5
|
1108
|
jcallahan@44
|
1109 for match_index = 1, #POINT_MATCH_PATTERNS do
|
jcallahan@44
|
1110 local match1, match2 = current_line:GetText():match(POINT_MATCH_PATTERNS[match_index])
|
jcallahan@53
|
1111 personal_rating = personal_rating + (match1 or 0)
|
jcallahan@53
|
1112 battleground_rating = battleground_rating + (match2 or 0)
|
jcallahan@5
|
1113
|
jcallahan@44
|
1114 if match1 or match2 then
|
jcallahan@44
|
1115 break
|
jcallahan@44
|
1116 end
|
jcallahan@44
|
1117 end
|
jcallahan@5
|
1118 end
|
jcallahan@44
|
1119 local currency_list = {}
|
jcallahan@44
|
1120 local item_count = _G.GetMerchantItemCostInfo(item_index)
|
jcallahan@50
|
1121
|
jcallahan@50
|
1122 -- Keeping this around in case Blizzard makes the two points diverge at some point.
|
jcallahan@53
|
1123 -- price_string = ("%s:%s:%s:%s"):format(price_string, battleground_rating, personal_rating, required_season_amount or 0)
|
jcallahan@53
|
1124 price_string = ("%s:%s:%s"):format(price_string, personal_rating, required_season_amount or 0)
|
jcallahan@5
|
1125
|
jcallahan@44
|
1126 for cost_index = 1, item_count do
|
jcallahan@44
|
1127 local icon_texture, amount_required, currency_link = _G.GetMerchantItemCostItem(item_index, cost_index)
|
jcallahan@44
|
1128 local currency_id = currency_link and ItemLinkToID(currency_link) or nil
|
jcallahan@44
|
1129
|
jcallahan@44
|
1130 if (not currency_id or currency_id < 1) and icon_texture then
|
jcallahan@44
|
1131 currency_id = icon_texture:match("[^\\]+$"):lower()
|
jcallahan@44
|
1132 end
|
jcallahan@44
|
1133
|
jcallahan@44
|
1134 if currency_id then
|
jcallahan@44
|
1135 currency_list[#currency_list + 1] = ("(%s:%s)"):format(amount_required, currency_id)
|
jcallahan@44
|
1136 end
|
jcallahan@44
|
1137 end
|
jcallahan@44
|
1138
|
jcallahan@44
|
1139 for currency_index = 1, #currency_list do
|
jcallahan@44
|
1140 price_string = ("%s:%s"):format(price_string, currency_list[currency_index])
|
jcallahan@5
|
1141 end
|
jcallahan@5
|
1142 end
|
jcallahan@61
|
1143 merchant.sells[item_id] = ("%s:%s:[%s]"):format(num_available, stack_size, price_string)
|
jcallahan@44
|
1144 end
|
jcallahan@44
|
1145 end
|
jcallahan@5
|
1146
|
jcallahan@44
|
1147 if _G.CanMerchantRepair() then
|
jcallahan@44
|
1148 merchant.can_repair = true
|
jcallahan@5
|
1149 end
|
jcallahan@57
|
1150 _G.SetMerchantFilter(current_filters)
|
jcallahan@57
|
1151 _G.MerchantFrame_Update()
|
jcallahan@4
|
1152 end
|
jcallahan@44
|
1153 end -- do-block
|
jcallahan@4
|
1154
|
jcallahan@89
|
1155
|
jcallahan@92
|
1156 function WDP:PET_BAR_UPDATE(event_name)
|
jcallahan@25
|
1157 if not action_data.label or not action_data.label == "mind_control" then
|
jcallahan@25
|
1158 return
|
jcallahan@25
|
1159 end
|
jcallahan@34
|
1160 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("pet"))
|
jcallahan@25
|
1161
|
jcallahan@25
|
1162 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
|
jcallahan@25
|
1163 return
|
jcallahan@25
|
1164 end
|
jcallahan@29
|
1165 NPCEntry(unit_idnum).mind_control = true
|
jcallahan@25
|
1166 table.wipe(action_data)
|
jcallahan@25
|
1167 end
|
jcallahan@25
|
1168
|
jcallahan@25
|
1169
|
jcallahan@18
|
1170 do
|
jcallahan@18
|
1171 local GENDER_NAMES = {
|
jcallahan@18
|
1172 "UNKNOWN",
|
jcallahan@18
|
1173 "MALE",
|
jcallahan@18
|
1174 "FEMALE",
|
jcallahan@18
|
1175 }
|
jcallahan@2
|
1176
|
jcallahan@2
|
1177
|
jcallahan@18
|
1178 local REACTION_NAMES = {
|
jcallahan@18
|
1179 "HATED",
|
jcallahan@18
|
1180 "HOSTILE",
|
jcallahan@18
|
1181 "UNFRIENDLY",
|
jcallahan@18
|
1182 "NEUTRAL",
|
jcallahan@18
|
1183 "FRIENDLY",
|
jcallahan@18
|
1184 "HONORED",
|
jcallahan@18
|
1185 "REVERED",
|
jcallahan@18
|
1186 "EXALTED",
|
jcallahan@18
|
1187 }
|
jcallahan@2
|
1188
|
jcallahan@2
|
1189
|
jcallahan@18
|
1190 local POWER_TYPE_NAMES = {
|
jcallahan@18
|
1191 ["0"] = "MANA",
|
jcallahan@18
|
1192 ["1"] = "RAGE",
|
jcallahan@18
|
1193 ["2"] = "FOCUS",
|
jcallahan@18
|
1194 ["3"] = "ENERGY",
|
jcallahan@18
|
1195 ["6"] = "RUNIC_POWER",
|
jcallahan@18
|
1196 }
|
jcallahan@2
|
1197
|
jcallahan@2
|
1198
|
jcallahan@92
|
1199 function WDP:PLAYER_TARGET_CHANGED(event_name)
|
jcallahan@40
|
1200 if not _G.UnitExists("target") or _G.UnitPlayerControlled("target") or currently_drunk then
|
jcallahan@86
|
1201 current_target_id = nil
|
jcallahan@18
|
1202 return
|
jcallahan@18
|
1203 end
|
jcallahan@34
|
1204 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target"))
|
jcallahan@2
|
1205
|
jcallahan@18
|
1206 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
|
jcallahan@18
|
1207 return
|
jcallahan@18
|
1208 end
|
jcallahan@86
|
1209 current_target_id = unit_idnum
|
jcallahan@86
|
1210
|
jcallahan@29
|
1211 local npc = NPCEntry(unit_idnum)
|
jcallahan@18
|
1212 local _, class_token = _G.UnitClass("target")
|
jcallahan@18
|
1213 npc.class = class_token
|
jcallahan@39
|
1214 npc.faction = UnitFactionStanding("target")
|
jcallahan@26
|
1215 npc.genders = npc.genders or {}
|
jcallahan@26
|
1216 npc.genders[GENDER_NAMES[_G.UnitSex("target")] or "UNDEFINED"] = true
|
jcallahan@18
|
1217 npc.is_pvp = _G.UnitIsPVP("target") and true or nil
|
jcallahan@18
|
1218 npc.reaction = ("%s:%s:%s"):format(_G.UnitLevel("player"), _G.UnitFactionGroup("player"), REACTION_NAMES[_G.UnitReaction("player", "target")])
|
jcallahan@2
|
1219
|
jcallahan@30
|
1220 local encounter_data = npc.encounter_data[InstanceDifficultyToken()].stats
|
jcallahan@18
|
1221 local npc_level = ("level_%d"):format(_G.UnitLevel("target"))
|
jcallahan@3
|
1222
|
jcallahan@28
|
1223 if not encounter_data[npc_level] then
|
jcallahan@28
|
1224 encounter_data[npc_level] = {
|
jcallahan@18
|
1225 max_health = _G.UnitHealthMax("target"),
|
jcallahan@18
|
1226 }
|
jcallahan@3
|
1227
|
jcallahan@18
|
1228 local max_power = _G.UnitManaMax("target")
|
jcallahan@18
|
1229
|
jcallahan@18
|
1230 if max_power > 0 then
|
jcallahan@18
|
1231 local power_type = _G.UnitPowerType("target")
|
jcallahan@28
|
1232 encounter_data[npc_level].power = ("%s:%d"):format(POWER_TYPE_NAMES[_G.tostring(power_type)] or power_type, max_power)
|
jcallahan@18
|
1233 end
|
jcallahan@3
|
1234 end
|
jcallahan@21
|
1235 table.wipe(action_data)
|
jcallahan@21
|
1236 action_data.type = AF.NPC
|
jcallahan@27
|
1237 action_data.identifier = unit_idnum
|
jcallahan@21
|
1238 action_data.npc_level = npc_level
|
jcallahan@31
|
1239 self:UpdateTargetLocation()
|
jcallahan@2
|
1240 end
|
jcallahan@18
|
1241 end -- do-block
|
jcallahan@2
|
1242
|
jcallahan@89
|
1243
|
jcallahan@12
|
1244 do
|
jcallahan@12
|
1245 local function UpdateQuestJuncture(point)
|
jcallahan@12
|
1246 local unit_name = _G.UnitName("questnpc")
|
jcallahan@9
|
1247
|
jcallahan@12
|
1248 if not unit_name then
|
jcallahan@12
|
1249 return
|
jcallahan@12
|
1250 end
|
jcallahan@34
|
1251 local unit_type, unit_id = ParseGUID(_G.UnitGUID("questnpc"))
|
jcallahan@9
|
1252
|
jcallahan@12
|
1253 if unit_type == private.UNIT_TYPES.OBJECT then
|
jcallahan@38
|
1254 UpdateDBEntryLocation("objects", unit_id)
|
jcallahan@12
|
1255 end
|
jcallahan@19
|
1256 local quest = DBEntry("quests", _G.GetQuestID())
|
jcallahan@12
|
1257 quest[point] = quest[point] or {}
|
jcallahan@12
|
1258 quest[point][("%s:%d"):format(private.UNIT_TYPE_NAMES[unit_type + 1], unit_id)] = true
|
jcallahan@24
|
1259
|
jcallahan@24
|
1260 return quest
|
jcallahan@12
|
1261 end
|
jcallahan@10
|
1262
|
jcallahan@12
|
1263
|
jcallahan@92
|
1264 function WDP:QUEST_COMPLETE(event_name)
|
jcallahan@67
|
1265 -- Make sure the quest NPC isn't erroneously recorded as giving reputation for quests which award it.
|
jcallahan@67
|
1266 reputation_npc_id = nil
|
jcallahan@12
|
1267 UpdateQuestJuncture("end")
|
jcallahan@10
|
1268 end
|
jcallahan@10
|
1269
|
jcallahan@12
|
1270
|
jcallahan@92
|
1271 function WDP:QUEST_DETAIL(event_name)
|
jcallahan@24
|
1272 local quest = UpdateQuestJuncture("begin")
|
jcallahan@24
|
1273
|
jcallahan@46
|
1274 if not quest then
|
jcallahan@46
|
1275 return
|
jcallahan@46
|
1276 end
|
jcallahan@24
|
1277 quest.classes = quest.classes or {}
|
jcallahan@27
|
1278 quest.classes[PLAYER_CLASS] = true
|
jcallahan@24
|
1279
|
jcallahan@24
|
1280 local _, race = _G.UnitRace("player")
|
jcallahan@24
|
1281 quest.races = quest.races or {}
|
jcallahan@24
|
1282 quest.races[race] = true
|
jcallahan@10
|
1283 end
|
jcallahan@12
|
1284 end -- do-block
|
jcallahan@9
|
1285
|
jcallahan@9
|
1286
|
jcallahan@92
|
1287 function WDP:QUEST_LOG_UPDATE(event_name)
|
jcallahan@38
|
1288 local selected_quest = _G.GetQuestLogSelection() -- Save current selection to be restored when we're done.
|
jcallahan@36
|
1289 local entry_index, processed_quests = 1, 0
|
jcallahan@36
|
1290 local _, num_quests = _G.GetNumQuestLogEntries()
|
jcallahan@36
|
1291
|
jcallahan@36
|
1292 while processed_quests <= num_quests do
|
jcallahan@36
|
1293 local _, _, _, _, is_header, _, _, _, quest_id = _G.GetQuestLogTitle(entry_index)
|
jcallahan@36
|
1294
|
jcallahan@84
|
1295 if quest_id == 0 then
|
jcallahan@84
|
1296 processed_quests = processed_quests + 1
|
jcallahan@84
|
1297 elseif not is_header then
|
jcallahan@36
|
1298 _G.SelectQuestLogEntry(entry_index);
|
jcallahan@36
|
1299
|
jcallahan@36
|
1300 local quest = DBEntry("quests", quest_id)
|
jcallahan@36
|
1301 quest.timer = _G.GetQuestLogTimeLeft()
|
jcallahan@37
|
1302 quest.can_share = _G.GetQuestLogPushable() and true or nil
|
jcallahan@36
|
1303 processed_quests = processed_quests + 1
|
jcallahan@36
|
1304 end
|
jcallahan@36
|
1305 entry_index = entry_index + 1
|
jcallahan@36
|
1306 end
|
jcallahan@36
|
1307 _G.SelectQuestLogEntry(selected_quest)
|
jcallahan@4
|
1308 self:UnregisterEvent("QUEST_LOG_UPDATE")
|
jcallahan@4
|
1309 end
|
jcallahan@4
|
1310
|
jcallahan@4
|
1311
|
jcallahan@92
|
1312 function WDP:UNIT_QUEST_LOG_CHANGED(event_name, unit_id)
|
jcallahan@4
|
1313 if unit_id ~= "player" then
|
jcallahan@4
|
1314 return
|
jcallahan@4
|
1315 end
|
jcallahan@4
|
1316 self:RegisterEvent("QUEST_LOG_UPDATE")
|
jcallahan@4
|
1317 end
|
jcallahan@4
|
1318
|
jcallahan@4
|
1319
|
jcallahan@92
|
1320 do
|
jcallahan@92
|
1321 local TRADESKILL_TOOLS = {
|
jcallahan@92
|
1322 Anvil = anvil_spell_ids,
|
jcallahan@92
|
1323 Forge = forge_spell_ids,
|
jcallahan@92
|
1324 }
|
jcallahan@92
|
1325
|
jcallahan@92
|
1326
|
jcallahan@92
|
1327 function WDP:TRADE_SKILL_SHOW(event_name)
|
jcallahan@92
|
1328 local profession_name, prof_level = _G.GetTradeSkillLine()
|
jcallahan@92
|
1329
|
jcallahan@92
|
1330 if profession_name == _G.UNKNOWN then
|
jcallahan@92
|
1331 return
|
jcallahan@92
|
1332 end
|
jcallahan@92
|
1333
|
jcallahan@92
|
1334 if _G.TradeSkillFrame and _G.TradeSkillFrame:IsVisible() then
|
jcallahan@92
|
1335 -- Clear the search box focus so the scan will have correct results.
|
jcallahan@92
|
1336 local search_box = _G.TradeSkillFrameSearchBox
|
jcallahan@92
|
1337 search_box:SetText("")
|
jcallahan@92
|
1338 _G.TradeSkillSearch_OnTextChanged(search_box)
|
jcallahan@92
|
1339 search_box:ClearFocus()
|
jcallahan@92
|
1340 search_box:GetScript("OnEditFocusLost")(search_box)
|
jcallahan@92
|
1341 end
|
jcallahan@92
|
1342 local header_list = {}
|
jcallahan@92
|
1343
|
jcallahan@92
|
1344 -- Save the current state of the TradeSkillFrame so it can be restored after we muck with it.
|
jcallahan@92
|
1345 local have_materials = _G.TradeSkillFrame.filterTbl.hasMaterials
|
jcallahan@92
|
1346 local have_skillup = _G.TradeSkillFrame.filterTbl.hasSkillUp
|
jcallahan@92
|
1347
|
jcallahan@92
|
1348 if have_materials then
|
jcallahan@92
|
1349 _G.TradeSkillFrame.filterTbl.hasMaterials = false
|
jcallahan@92
|
1350 _G.TradeSkillOnlyShowMakeable(false)
|
jcallahan@92
|
1351 end
|
jcallahan@92
|
1352
|
jcallahan@92
|
1353 if have_skillup then
|
jcallahan@92
|
1354 _G.TradeSkillFrame.filterTbl.hasSkillUp = false
|
jcallahan@92
|
1355 _G.TradeSkillOnlyShowSkillUps(false)
|
jcallahan@92
|
1356 end
|
jcallahan@92
|
1357 _G.SetTradeSkillInvSlotFilter(0, 1, 1)
|
jcallahan@92
|
1358 _G.TradeSkillUpdateFilterBar()
|
jcallahan@92
|
1359 _G.TradeSkillFrame_Update()
|
jcallahan@92
|
1360
|
jcallahan@92
|
1361 -- Expand all headers so we can see all the recipes there are
|
jcallahan@92
|
1362 for tradeskill_index = 1, _G.GetNumTradeSkills() do
|
jcallahan@92
|
1363 local name, tradeskill_type, _, is_expanded = _G.GetTradeSkillInfo(tradeskill_index)
|
jcallahan@92
|
1364
|
jcallahan@92
|
1365 if tradeskill_type == "header" then
|
jcallahan@92
|
1366 if not is_expanded then
|
jcallahan@92
|
1367 header_list[name] = true
|
jcallahan@92
|
1368 _G.ExpandTradeSkillSubClass(tradeskill_index)
|
jcallahan@92
|
1369 end
|
jcallahan@92
|
1370 else
|
jcallahan@92
|
1371 local spell_id = tonumber(_G.GetTradeSkillRecipeLink(tradeskill_index):match("^|c%x%x%x%x%x%x%x%x|H%w+:(%d+)"))
|
jcallahan@92
|
1372 local required_tool = _G.GetTradeSkillTools(tradeskill_index)
|
jcallahan@92
|
1373
|
jcallahan@92
|
1374 if required_tool then
|
jcallahan@92
|
1375 for tool_name, registry in pairs(TRADESKILL_TOOLS) do
|
jcallahan@92
|
1376 if required_tool:find(tool_name) then
|
jcallahan@92
|
1377 print(("Set %s spell: %d"):format(tool_name, spell_id))
|
jcallahan@92
|
1378 registry[spell_id] = true
|
jcallahan@92
|
1379 end
|
jcallahan@92
|
1380 end
|
jcallahan@92
|
1381 end
|
jcallahan@92
|
1382 end
|
jcallahan@92
|
1383 end
|
jcallahan@92
|
1384
|
jcallahan@92
|
1385 -- Restore the state of the things we changed.
|
jcallahan@92
|
1386 for tradeskill_index = 1, _G.GetNumTradeSkills() do
|
jcallahan@92
|
1387 local name, tradeskill_type, _, is_expanded = _G.GetTradeSkillInfo(tradeskill_index)
|
jcallahan@92
|
1388
|
jcallahan@92
|
1389 if header_list[name] then
|
jcallahan@92
|
1390 _G.CollapseTradeSkillSubClass(tradeskill_index)
|
jcallahan@92
|
1391 end
|
jcallahan@92
|
1392 end
|
jcallahan@92
|
1393 _G.TradeSkillFrame.filterTbl.hasMaterials = have_materials
|
jcallahan@92
|
1394 _G.TradeSkillOnlyShowMakeable(have_materials)
|
jcallahan@92
|
1395 _G.TradeSkillFrame.filterTbl.hasSkillUp = have_skillup
|
jcallahan@92
|
1396 _G.TradeSkillOnlyShowSkillUps(have_skillup)
|
jcallahan@92
|
1397
|
jcallahan@92
|
1398 _G.TradeSkillUpdateFilterBar()
|
jcallahan@92
|
1399 _G.TradeSkillFrame_Update()
|
jcallahan@92
|
1400 end
|
jcallahan@92
|
1401 end -- do-block
|
jcallahan@92
|
1402
|
jcallahan@92
|
1403
|
jcallahan@92
|
1404 function WDP:TRAINER_SHOW(event_name)
|
jcallahan@34
|
1405 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target"))
|
jcallahan@29
|
1406 local npc = NPCEntry(unit_idnum)
|
jcallahan@58
|
1407
|
jcallahan@58
|
1408 if not npc then
|
jcallahan@58
|
1409 return
|
jcallahan@58
|
1410 end
|
jcallahan@27
|
1411 npc.teaches = npc.teaches or {}
|
jcallahan@27
|
1412
|
jcallahan@27
|
1413 -- Get the initial trainer filters
|
jcallahan@27
|
1414 local available = _G.GetTrainerServiceTypeFilter("available")
|
jcallahan@27
|
1415 local unavailable = _G.GetTrainerServiceTypeFilter("unavailable")
|
jcallahan@27
|
1416 local used = _G.GetTrainerServiceTypeFilter("used")
|
jcallahan@27
|
1417
|
jcallahan@27
|
1418 -- Clear the trainer filters
|
jcallahan@27
|
1419 _G.SetTrainerServiceTypeFilter("available", 1)
|
jcallahan@27
|
1420 _G.SetTrainerServiceTypeFilter("unavailable", 1)
|
jcallahan@27
|
1421 _G.SetTrainerServiceTypeFilter("used", 1)
|
jcallahan@27
|
1422
|
jcallahan@27
|
1423 for index = 1, _G.GetNumTrainerServices(), 1 do
|
jcallahan@27
|
1424 local spell_name, rank_name, _, _, required_level = _G.GetTrainerServiceInfo(index)
|
jcallahan@27
|
1425
|
jcallahan@27
|
1426 if spell_name then
|
jcallahan@27
|
1427 DatamineTT:ClearLines()
|
jcallahan@27
|
1428 DatamineTT:SetTrainerService(index)
|
jcallahan@27
|
1429
|
jcallahan@27
|
1430 local _, _, spell_id = DatamineTT:GetSpell()
|
jcallahan@27
|
1431
|
jcallahan@43
|
1432 if spell_id then
|
jcallahan@43
|
1433 local profession, min_skill = _G.GetTrainerServiceSkillReq(index)
|
jcallahan@43
|
1434 profession = profession or "General"
|
jcallahan@43
|
1435
|
jcallahan@43
|
1436 local class_professions = npc.teaches[PLAYER_CLASS]
|
jcallahan@43
|
1437 if not class_professions then
|
jcallahan@43
|
1438 npc.teaches[PLAYER_CLASS] = {}
|
jcallahan@43
|
1439 class_professions = npc.teaches[PLAYER_CLASS]
|
jcallahan@43
|
1440 end
|
jcallahan@43
|
1441
|
jcallahan@43
|
1442 local profession_skills = class_professions[profession]
|
jcallahan@43
|
1443 if not profession_skills then
|
jcallahan@43
|
1444 class_professions[profession] = {}
|
jcallahan@43
|
1445 profession_skills = class_professions[profession]
|
jcallahan@43
|
1446 end
|
jcallahan@43
|
1447 profession_skills[spell_id] = ("%d:%d"):format(required_level, min_skill)
|
jcallahan@27
|
1448 end
|
jcallahan@27
|
1449 end
|
jcallahan@27
|
1450 end
|
jcallahan@27
|
1451
|
jcallahan@27
|
1452 -- Reset the filters to what they were before
|
jcallahan@27
|
1453 _G.SetTrainerServiceTypeFilter("available", available or 0)
|
jcallahan@27
|
1454 _G.SetTrainerServiceTypeFilter("unavailable", unavailable or 0)
|
jcallahan@27
|
1455 _G.SetTrainerServiceTypeFilter("used", used or 0)
|
jcallahan@27
|
1456 end
|
jcallahan@27
|
1457
|
jcallahan@27
|
1458
|
jcallahan@1
|
1459 function WDP:UNIT_SPELLCAST_SENT(event_name, unit_id, spell_name, spell_rank, target_name, spell_line)
|
jcallahan@1
|
1460 if private.tracked_line or unit_id ~= "player" then
|
jcallahan@1
|
1461 return
|
jcallahan@1
|
1462 end
|
jcallahan@1
|
1463 local spell_label = private.SPELL_LABELS_BY_NAME[spell_name]
|
jcallahan@1
|
1464
|
jcallahan@1
|
1465 if not spell_label then
|
jcallahan@1
|
1466 return
|
jcallahan@1
|
1467 end
|
jcallahan@18
|
1468 table.wipe(action_data)
|
jcallahan@1
|
1469
|
jcallahan@1
|
1470 local tt_item_name, tt_item_link = _G.GameTooltip:GetItem()
|
jcallahan@1
|
1471 local tt_unit_name, tt_unit_id = _G.GameTooltip:GetUnit()
|
jcallahan@1
|
1472
|
jcallahan@1
|
1473 if not tt_unit_name and _G.UnitName("target") == target_name then
|
jcallahan@1
|
1474 tt_unit_name = target_name
|
jcallahan@1
|
1475 tt_unit_id = "target"
|
jcallahan@1
|
1476 end
|
jcallahan@1
|
1477 local spell_flags = private.SPELL_FLAGS_BY_LABEL[spell_label]
|
jcallahan@28
|
1478 local zone_name, area_id, x, y, map_level, instance_token = CurrentLocationData()
|
jcallahan@28
|
1479
|
jcallahan@28
|
1480 action_data.instance_token = instance_token
|
jcallahan@28
|
1481 action_data.map_level = map_level
|
jcallahan@28
|
1482 action_data.x = x
|
jcallahan@28
|
1483 action_data.y = y
|
jcallahan@28
|
1484 action_data.zone = ("%s:%d"):format(zone_name, area_id)
|
jcallahan@76
|
1485 action_data.spell_label = spell_label
|
jcallahan@76
|
1486 action_data.label = spell_label:lower()
|
jcallahan@1
|
1487
|
jcallahan@16
|
1488 if tt_unit_name and not tt_item_name then
|
jcallahan@16
|
1489 if bit.band(spell_flags, AF.NPC) == AF.NPC then
|
jcallahan@16
|
1490 if not tt_unit_id or tt_unit_name ~= target_name then
|
jcallahan@16
|
1491 return
|
jcallahan@16
|
1492 end
|
jcallahan@16
|
1493 action_data.type = AF.NPC
|
jcallahan@25
|
1494 action_data.unit_name = tt_unit_name
|
jcallahan@16
|
1495 end
|
jcallahan@16
|
1496 elseif bit.band(spell_flags, AF.ITEM) == AF.ITEM then
|
jcallahan@16
|
1497 action_data.type = AF.ITEM
|
jcallahan@16
|
1498
|
jcallahan@16
|
1499 if tt_item_name and tt_item_name == target_name then
|
jcallahan@28
|
1500 action_data.identifier = ItemLinkToID(tt_item_link)
|
jcallahan@16
|
1501 elseif target_name and target_name ~= "" then
|
jcallahan@16
|
1502 local _, target_item_link = _G.GetItemInfo(target_name)
|
jcallahan@28
|
1503 action_data.identifier = ItemLinkToID(target_item_link)
|
jcallahan@16
|
1504 end
|
jcallahan@16
|
1505 elseif not tt_item_name and not tt_unit_name then
|
jcallahan@17
|
1506 action_data.name = target_name
|
jcallahan@17
|
1507
|
jcallahan@1
|
1508 if bit.band(spell_flags, AF.OBJECT) == AF.OBJECT then
|
jcallahan@17
|
1509 if target_name == "" then
|
jcallahan@17
|
1510 return
|
jcallahan@17
|
1511 end
|
jcallahan@82
|
1512 action_data.target_name = target_name
|
jcallahan@1
|
1513 action_data.type = AF.OBJECT
|
jcallahan@1
|
1514 elseif bit.band(spell_flags, AF.ZONE) == AF.ZONE then
|
jcallahan@38
|
1515 local identifier = ("%s:%s"):format(spell_label, _G["GameTooltipTextLeft1"]:GetText() or "NONE") -- Possible fishing pool name.
|
jcallahan@52
|
1516 action_data.zone_data = UpdateDBEntryLocation("zones", identifier)
|
jcallahan@17
|
1517 action_data.type = AF.ZONE
|
jcallahan@38
|
1518 action_data.identifier = identifier
|
jcallahan@1
|
1519 end
|
jcallahan@1
|
1520 end
|
jcallahan@1
|
1521 private.tracked_line = spell_line
|
jcallahan@0
|
1522 end
|
jcallahan@0
|
1523
|
jcallahan@1
|
1524 function WDP:UNIT_SPELLCAST_SUCCEEDED(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id)
|
jcallahan@1
|
1525 if unit_id ~= "player" then
|
jcallahan@1
|
1526 return
|
jcallahan@1
|
1527 end
|
jcallahan@1
|
1528 private.tracked_line = nil
|
jcallahan@85
|
1529
|
jcallahan@86
|
1530 if spell_name:match("^Harvest.+") then
|
jcallahan@86
|
1531 reputation_npc_id = current_target_id
|
jcallahan@85
|
1532 end
|
jcallahan@92
|
1533
|
jcallahan@92
|
1534 if anvil_spell_ids[spell_id] then
|
jcallahan@92
|
1535 UpdateDBEntryLocation("objects", OBJECT_ID_ANVIL)
|
jcallahan@92
|
1536 elseif forge_spell_ids[spell_id] then
|
jcallahan@92
|
1537 UpdateDBEntryLocation("objects", OBJECT_ID_FORGE)
|
jcallahan@92
|
1538 end
|
jcallahan@0
|
1539 end
|
jcallahan@0
|
1540
|
jcallahan@90
|
1541
|
jcallahan@1
|
1542 function WDP:HandleSpellFailure(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id)
|
jcallahan@1
|
1543 if unit_id ~= "player" then
|
jcallahan@1
|
1544 return
|
jcallahan@1
|
1545 end
|
jcallahan@0
|
1546
|
jcallahan@1
|
1547 if private.tracked_line == spell_line then
|
jcallahan@1
|
1548 private.tracked_line = nil
|
jcallahan@1
|
1549 end
|
jcallahan@0
|
1550 end
|
jcallahan@90
|
1551
|
jcallahan@90
|
1552
|
jcallahan@90
|
1553 do
|
jcallahan@90
|
1554 local function SetUnitField(field, required_type)
|
jcallahan@90
|
1555 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
|
jcallahan@90
|
1556
|
jcallahan@90
|
1557 if not unit_idnum or (required_type and unit_type ~= required_type) then
|
jcallahan@90
|
1558 return
|
jcallahan@90
|
1559 end
|
jcallahan@90
|
1560
|
jcallahan@90
|
1561 if unit_type == private.UNIT_TYPES.NPC then
|
jcallahan@90
|
1562 NPCEntry(unit_idnum)[field] = true
|
jcallahan@90
|
1563 elseif unit_type == private.UNIT_TYPES.OBJECT then
|
jcallahan@90
|
1564 DBEntry("objects", unit_idnum)[field] = true
|
jcallahan@90
|
1565 end
|
jcallahan@90
|
1566 end
|
jcallahan@90
|
1567
|
jcallahan@90
|
1568
|
jcallahan@90
|
1569 function WDP:AUCTION_HOUSE_SHOW(event_name)
|
jcallahan@90
|
1570 SetUnitField("auctioneer", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
1571 end
|
jcallahan@90
|
1572
|
jcallahan@90
|
1573
|
jcallahan@90
|
1574 function WDP:BANKFRAME_OPENED(event_name)
|
jcallahan@90
|
1575 SetUnitField("banker", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
1576 end
|
jcallahan@90
|
1577
|
jcallahan@90
|
1578
|
jcallahan@90
|
1579 function WDP:BATTLEFIELDS_SHOW(event_name)
|
jcallahan@90
|
1580 SetUnitField("battlemaster", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
1581 end
|
jcallahan@90
|
1582
|
jcallahan@90
|
1583
|
jcallahan@92
|
1584 function WDP:FORGE_MASTER_OPENED(event_name)
|
jcallahan@90
|
1585 SetUnitField("arcane_reforger", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
1586 end
|
jcallahan@90
|
1587
|
jcallahan@90
|
1588
|
jcallahan@92
|
1589 function WDP:GOSSIP_SHOW(event_name)
|
jcallahan@90
|
1590 local gossip_options = { _G.GetGossipOptions() }
|
jcallahan@90
|
1591
|
jcallahan@90
|
1592 for index = 2, #gossip_options, 2 do
|
jcallahan@90
|
1593 if gossip_options[index] == "binder" then
|
jcallahan@90
|
1594 SetUnitField("innkeeper", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
1595 return
|
jcallahan@90
|
1596 end
|
jcallahan@90
|
1597 end
|
jcallahan@90
|
1598 end
|
jcallahan@90
|
1599
|
jcallahan@90
|
1600
|
jcallahan@90
|
1601 function WDP:TAXIMAP_OPENED(event_name)
|
jcallahan@90
|
1602 SetUnitField("flight_master", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
1603 end
|
jcallahan@90
|
1604
|
jcallahan@90
|
1605
|
jcallahan@90
|
1606 function WDP:TRANSMOGRIFY_OPEN(event_name)
|
jcallahan@90
|
1607 SetUnitField("transmogrifier", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
1608 end
|
jcallahan@90
|
1609
|
jcallahan@90
|
1610
|
jcallahan@90
|
1611 function WDP:VOID_STORAGE_OPEN(event_name)
|
jcallahan@90
|
1612 SetUnitField("void_storage", private.UNIT_TYPES.NPC)
|
jcallahan@90
|
1613 end
|
jcallahan@90
|
1614 end -- do-block
|