Mercurial > wow > wowdb-profiler
comparison Main.lua @ 347:fb1d08480f67 WoD
Added timer-based support for salvage crate drops. Hopefully only temporary while Blizzard fixes SHOW_LOOT_TOAST events for them.
author | MMOSimca <MMOSimca@gmail.com> |
---|---|
date | Fri, 03 Oct 2014 15:29:26 -0400 |
parents | 04343b25c612 |
children | 9f352e20204c |
comparison
equal
deleted
inserted
replaced
346:04343b25c612 | 347:fb1d08480f67 |
---|---|
49 local PLAYER_RACE = _G.select(2, _G.UnitRace("player")) | 49 local PLAYER_RACE = _G.select(2, _G.UnitRace("player")) |
50 | 50 |
51 -- Ignoring NPC casts of the following spells | 51 -- Ignoring NPC casts of the following spells |
52 local CHI_WAVE_SPELL_ID = 132464 | 52 local CHI_WAVE_SPELL_ID = 132464 |
53 local DISGUISE_SPELL_ID = 121308 | 53 local DISGUISE_SPELL_ID = 121308 |
54 | |
55 -- For timer-based loot gathering of abnormal containers (that don't use SHOW_LOOT_TOAST, sadly) | |
56 local CRATE_OF_SALVAGE_ITEM_ID = private.SALVAGE_SPELL_ID_TO_ITEM_ID_MAP[168179] | |
57 local BIG_CRATE_OF_SALVAGE_ITEM_ID = private.SALVAGE_SPELL_ID_TO_ITEM_ID_MAP[168180] | |
54 | 58 |
55 -- Constant for duplicate boss data; a dirty hack to get around world bosses that cannot be identified individually and cannot be linked on wowdb because they are not in a raid | 59 -- Constant for duplicate boss data; a dirty hack to get around world bosses that cannot be identified individually and cannot be linked on wowdb because they are not in a raid |
56 local DUPLICATE_WORLD_BOSS_IDS = { | 60 local DUPLICATE_WORLD_BOSS_IDS = { |
57 [71952] = { 71953, 71954, 71955, }, | 61 [71952] = { 71953, 71954, 71955, }, |
58 } | 62 } |
157 local name_to_id_map = {} | 161 local name_to_id_map = {} |
158 local killed_boss_id_timer_handle | 162 local killed_boss_id_timer_handle |
159 local killed_npc_id | 163 local killed_npc_id |
160 local target_location_timer_handle | 164 local target_location_timer_handle |
161 local last_timber_spell_id | 165 local last_timber_spell_id |
166 local chat_loot_timer_handle | |
162 local current_target_id | 167 local current_target_id |
163 local current_area_id | 168 local current_area_id |
164 local current_loot | 169 local current_loot |
165 | 170 |
166 | 171 |
298 end | 303 end |
299 end | 304 end |
300 return math.floor(copper_cost / modifier) | 305 return math.floor(copper_cost / modifier) |
301 end | 306 end |
302 end -- do-block | 307 end -- do-block |
303 | |
304 | |
305 -- Called on a timer | |
306 local function ClearKilledNPC() | |
307 killed_npc_id = nil | |
308 end | |
309 | |
310 | |
311 local function ClearKilledBossID() | |
312 if killed_boss_id_timer_handle then | |
313 WDP:CancelTimer(killed_boss_id_timer_handle) | |
314 killed_boss_id_timer_handle = nil | |
315 end | |
316 | |
317 table.wipe(boss_loot_toasting) | |
318 private.raid_boss_id = nil | |
319 end | |
320 | |
321 | |
322 local function ClearLootToastContainerID() | |
323 if loot_toast_container_timer_handle then | |
324 WDP:CancelTimer(loot_toast_container_timer_handle) | |
325 loot_toast_container_timer_handle = nil | |
326 end | |
327 | |
328 private.container_loot_toasting = false | |
329 private.loot_toast_container_id = nil | |
330 end | |
331 | |
332 | |
333 local function ClearLootToastData() | |
334 -- cancel existing timer if found | |
335 if loot_toast_data_timer_handle then | |
336 WDP:CancelTimer(loot_toast_data_timer_handle) | |
337 loot_toast_data_timer_handle = nil | |
338 end | |
339 | |
340 if loot_toast_data then | |
341 table.wipe(loot_toast_data) | |
342 end | |
343 end | |
344 | 308 |
345 | 309 |
346 local function InstanceDifficultyToken() | 310 local function InstanceDifficultyToken() |
347 local _, instance_type, instance_difficulty, _, _, _, is_dynamic = _G.GetInstanceInfo() | 311 local _, instance_type, instance_difficulty, _, _, _, is_dynamic = _G.GetInstanceInfo() |
348 | 312 |
854 zone_data = current_action.zone_data, | 818 zone_data = current_action.zone_data, |
855 } | 819 } |
856 | 820 |
857 table.wipe(current_action) | 821 table.wipe(current_action) |
858 end | 822 end |
823 | |
824 | |
825 -- TIMERS ------------------------------------------------------------- | |
826 | |
827 local function ClearKilledNPC() | |
828 killed_npc_id = nil | |
829 end | |
830 | |
831 | |
832 local function ClearKilledBossID() | |
833 if killed_boss_id_timer_handle then | |
834 WDP:CancelTimer(killed_boss_id_timer_handle) | |
835 killed_boss_id_timer_handle = nil | |
836 end | |
837 | |
838 table.wipe(boss_loot_toasting) | |
839 private.raid_boss_id = nil | |
840 end | |
841 | |
842 | |
843 local function ClearLootToastContainerID() | |
844 if loot_toast_container_timer_handle then | |
845 WDP:CancelTimer(loot_toast_container_timer_handle) | |
846 loot_toast_container_timer_handle = nil | |
847 end | |
848 | |
849 private.container_loot_toasting = false | |
850 private.loot_toast_container_id = nil | |
851 end | |
852 | |
853 | |
854 local function ClearLootToastData() | |
855 -- cancel existing timer if found | |
856 if loot_toast_data_timer_handle then | |
857 WDP:CancelTimer(loot_toast_data_timer_handle) | |
858 loot_toast_data_timer_handle = nil | |
859 end | |
860 | |
861 if loot_toast_data then | |
862 table.wipe(loot_toast_data) | |
863 end | |
864 end | |
865 | |
866 | |
867 local function ClearTimeBasedLootData() | |
868 if chat_loot_timer_handle then | |
869 WDP:CancelTimer(chat_loot_timer_handle) | |
870 chat_loot_timer_handle = nil | |
871 end | |
872 | |
873 if current_loot and current_loot.identifier and (current_loot.identifier == CRATE_OF_SALVAGE_ITEM_ID or current_loot.identifier == BIG_CRATE_OF_SALVAGE_ITEM_ID) then | |
874 GenericLootUpdate("items") | |
875 end | |
876 current_loot = nil | |
877 end | |
878 | |
859 | 879 |
860 -- METHODS ------------------------------------------------------------ | 880 -- METHODS ------------------------------------------------------------ |
861 | 881 |
862 function WDP:OnInitialize() | 882 function WDP:OnInitialize() |
863 local db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default") | 883 local db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default") |
1355 end | 1375 end |
1356 | 1376 |
1357 | 1377 |
1358 do | 1378 do |
1359 local CHAT_MSG_LOOT_UPDATE_FUNCS = { | 1379 local CHAT_MSG_LOOT_UPDATE_FUNCS = { |
1380 [AF.ITEM] = function(item_id, quantity) | |
1381 local container_id = current_action.identifier -- For faster access, since this is going to be called 9 times in the next 3 lines | |
1382 -- Verify that we're still assigning data to the right items | |
1383 if container_id and container_id == CRATE_OF_SALVAGE_ITEM_ID or container_id == BIG_CRATE_OF_SALVAGE_ITEM_ID then | |
1384 Debug("CHAT_MSG_LOOT: AF.ITEM %d (%d)", item_id, quantity) | |
1385 InitializeCurrentLoot() | |
1386 current_loot.sources[container_id] = current_loot.sources[container_id] or {} | |
1387 current_loot.sources[container_id][item_id] = current_loot.sources[container_id][item_id] or 0 + quantity | |
1388 else -- If not, cancel the timer and wipe the loot table early | |
1389 Debug("CHAT_MSG_LOOT: We would have assigned the wrong loot to salvage crates!") | |
1390 WDP:CancelTimer(chat_loot_timer_handle) | |
1391 chat_loot_timer_handle = nil | |
1392 table.wipe(current_action) | |
1393 current_loot = nil | |
1394 end | |
1395 end, | |
1360 [AF.NPC] = function(item_id, quantity) | 1396 [AF.NPC] = function(item_id, quantity) |
1361 Debug("CHAT_MSG_LOOT: AF.NPC %d (%d)", item_id, quantity) | 1397 Debug("CHAT_MSG_LOOT: AF.NPC %d (%d)", item_id, quantity) |
1362 end, | 1398 end, |
1363 [AF.OBJECT] = function(item_id, quantity) | 1399 [AF.OBJECT] = function(item_id, quantity) |
1364 Debug("CHAT_MSG_LOOT: AF.OBJECT %d (%d)", item_id, quantity) | 1400 Debug("CHAT_MSG_LOOT: AF.OBJECT %d (%d)", item_id, quantity) |
1407 -- Recently changed from ~= "EXTRACT_GAS" because of some occassional bad data, and, as far as I know, no benefit. | 1443 -- Recently changed from ~= "EXTRACT_GAS" because of some occassional bad data, and, as far as I know, no benefit. |
1408 elseif current_action.spell_label == "FISHING" then | 1444 elseif current_action.spell_label == "FISHING" then |
1409 category = AF.ZONE | 1445 category = AF.ZONE |
1410 elseif private.raid_boss_id then | 1446 elseif private.raid_boss_id then |
1411 category = AF.NPC | 1447 category = AF.NPC |
1448 elseif chat_loot_timer_handle then | |
1449 category = AF.ITEM | |
1412 end | 1450 end |
1413 | 1451 |
1414 -- Take action based on update category | 1452 -- Take action based on update category |
1415 local update_func = CHAT_MSG_LOOT_UPDATE_FUNCS[category] | 1453 local update_func = CHAT_MSG_LOOT_UPDATE_FUNCS[category] |
1416 if not category or not update_func then | 1454 if not category or not update_func then |
2614 private.loot_toast_container_id = private.LOOT_SPELL_ID_TO_ITEM_ID_MAP[spell_id] | 2652 private.loot_toast_container_id = private.LOOT_SPELL_ID_TO_ITEM_ID_MAP[spell_id] |
2615 loot_toast_container_timer_handle = WDP:ScheduleTimer(ClearLootToastContainerID, 1) -- we need to assign a handle here to cancel it later | 2653 loot_toast_container_timer_handle = WDP:ScheduleTimer(ClearLootToastContainerID, 1) -- we need to assign a handle here to cancel it later |
2616 return | 2654 return |
2617 end | 2655 end |
2618 | 2656 |
2657 -- For Crates of Salvage (and potentially other items based on spell casts in the future which need manual handling) | |
2658 if private.SALVAGE_SPELL_ID_TO_ITEM_ID_MAP[spell_id] then | |
2659 -- Set up timer | |
2660 chat_loot_timer_handle = WDP:ScheduleTimer(ClearTimeBasedLootData, 0.5) | |
2661 | |
2662 -- Standard item handling setup | |
2663 table.wipe(current_action) | |
2664 current_loot = nil | |
2665 current_action.target_type = AF.ITEM | |
2666 current_action.identifier = item_id | |
2667 current_action.loot_label = "contains" | |
2668 return | |
2669 end | |
2670 | |
2619 if anvil_spell_ids[spell_id] then | 2671 if anvil_spell_ids[spell_id] then |
2620 UpdateDBEntryLocation("objects", OBJECT_ID_ANVIL) | 2672 UpdateDBEntryLocation("objects", OBJECT_ID_ANVIL) |
2621 elseif forge_spell_ids[spell_id] then | 2673 elseif forge_spell_ids[spell_id] then |
2622 UpdateDBEntryLocation("objects", OBJECT_ID_FORGE) | 2674 UpdateDBEntryLocation("objects", OBJECT_ID_FORGE) |
2623 elseif spell_name:match("^Harvest.+") then | 2675 elseif spell_name:match("^Harvest.+") then |