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