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