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