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