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