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