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