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