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