comparison Main.lua @ 436:05a4002dd924

Now blocks item container loot recording in the following situations: using the Auction House, using the bank, using the mission table, gossiping with an NPC, using a guild bank, using a mailbox, and trading items with a merchant.
author MMOSimca <MMOSimca@gmail.com>
date Wed, 25 Feb 2015 16:45:09 -0500
parents b220bc8dd3a8
children 0a83510474bc
comparison
equal deleted inserted replaced
435:b220bc8dd3a8 436:05a4002dd924
82 zones = {}, 82 zones = {},
83 } 83 }
84 } 84 }
85 85
86 local EVENT_MAPPING = { 86 local EVENT_MAPPING = {
87 AUCTION_HOUSE_SHOW = true, 87 AUCTION_HOUSE_CLOSED = "ResumeChatLootRecording",
88 BANKFRAME_OPENED = true, 88 AUCTION_HOUSE_SHOW = true, -- also triggers StopChatLootRecording
89 BANKFRAME_CLOSED = "ResumeChatLootRecording",
90 BANKFRAME_OPENED = true, -- also triggers StopChatLootRecording
89 BATTLEFIELDS_SHOW = true, 91 BATTLEFIELDS_SHOW = true,
90 BLACK_MARKET_ITEM_UPDATE = true, 92 BLACK_MARKET_ITEM_UPDATE = true,
91 BONUS_ROLL_RESULT = true, 93 BONUS_ROLL_RESULT = true,
92 CHAT_MSG_CURRENCY = true, 94 CHAT_MSG_CURRENCY = true,
93 CHAT_MSG_LOOT = true, 95 CHAT_MSG_LOOT = true,
97 CHAT_MSG_SYSTEM = true, 99 CHAT_MSG_SYSTEM = true,
98 COMBAT_LOG_EVENT_UNFILTERED = true, 100 COMBAT_LOG_EVENT_UNFILTERED = true,
99 COMBAT_TEXT_UPDATE = true, 101 COMBAT_TEXT_UPDATE = true,
100 CURSOR_UPDATE = true, 102 CURSOR_UPDATE = true,
101 FORGE_MASTER_OPENED = true, 103 FORGE_MASTER_OPENED = true,
102 GARRISON_MISSION_BONUS_ROLL_COMPLETE = "HandleBadChatLootData", 104 GARRISON_MISSION_NPC_CLOSED = "ResumeChatLootRecording",
103 GARRISON_MISSION_COMPLETE_RESPONSE = "HandleBadChatLootData", 105 GARRISON_MISSION_NPC_OPENED = "StopChatLootRecording",
104 GOSSIP_SHOW = true, 106 GOSSIP_CLOSED = "ResumeChatLootRecording",
107 GOSSIP_SHOW = true, -- also triggers StopChatLootRecording
105 GROUP_ROSTER_UPDATE = true, 108 GROUP_ROSTER_UPDATE = true,
106 GUILDBANKFRAME_OPENED = true, 109 GUILDBANKFRAME_CLOSED = "ResumeChatLootRecording",
110 GUILDBANKFRAME_OPENED = true, -- also triggers StopChatLootRecording
107 ITEM_TEXT_BEGIN = true, 111 ITEM_TEXT_BEGIN = true,
108 ITEM_UPGRADE_MASTER_OPENED = true, 112 ITEM_UPGRADE_MASTER_OPENED = true,
109 LOOT_CLOSED = true, 113 LOOT_CLOSED = true,
110 LOOT_OPENED = true, 114 LOOT_OPENED = true,
111 LOOT_SLOT_CLEARED = "HandleBadChatLootData", 115 LOOT_SLOT_CLEARED = "HandleBadChatLootData",
112 MAIL_SHOW = true, 116 MAIL_CLOSED = "ResumeChatLootRecording",
113 MERCHANT_CLOSED = true, 117 MAIL_SHOW = true, -- also triggers StopChatLootRecording
114 MERCHANT_SHOW = "UpdateMerchantItems", 118 MERCHANT_CLOSED = true, -- also triggers ResumeChatLootRecording
119 MERCHANT_SHOW = "UpdateMerchantItems", -- also triggers StopChatLootRecording
115 MERCHANT_UPDATE = "UpdateMerchantItems", 120 MERCHANT_UPDATE = "UpdateMerchantItems",
116 PET_BAR_UPDATE = true, 121 PET_BAR_UPDATE = true,
117 --PET_JOURNAL_LIST_UPDATE = true, 122 --PET_JOURNAL_LIST_UPDATE = true,
118 PLAYER_REGEN_DISABLED = true, 123 PLAYER_REGEN_DISABLED = true,
119 PLAYER_REGEN_ENABLED = true, 124 PLAYER_REGEN_ENABLED = true,
168 local killed_boss_id_timer_handle 173 local killed_boss_id_timer_handle
169 local killed_npc_id 174 local killed_npc_id
170 local target_location_timer_handle 175 local target_location_timer_handle
171 local last_timber_spell_id 176 local last_timber_spell_id
172 local last_garrison_cache_object_id 177 local last_garrison_cache_object_id
178 local block_chat_loot_data
173 local chat_loot_data = {} 179 local chat_loot_data = {}
174 local chat_loot_timer_handle 180 local chat_loot_timer_handle
175 local current_target_id 181 local current_target_id
176 local current_area_id 182 local current_area_id
177 local current_loot 183 local current_loot
589 -- Check if we've marked this item as one Blizzard provides bad is_lootable data for 595 -- Check if we've marked this item as one Blizzard provides bad is_lootable data for
590 if private.CONTAINER_ITEM_ID_LIST[item_id] ~= nil then 596 if private.CONTAINER_ITEM_ID_LIST[item_id] ~= nil then
591 any_loot = true 597 any_loot = true
592 end 598 end
593 599
594 if any_loot then 600 -- Going to block 'chat-loot data' at this level for now because I don't think we actually want normal item containers being recorded in these scenarios either.
601 if any_loot and not block_chat_loot_data then
595 -- For item containers that open instantly with no spell cast 602 -- For item containers that open instantly with no spell cast
596 if (private.CONTAINER_ITEM_ID_LIST[item_id] == true) and ((not _G.GetNumLootItems()) or (_G.GetNumLootItems() == 0)) then 603 if (private.CONTAINER_ITEM_ID_LIST[item_id] == true) and ((not _G.GetNumLootItems()) or (_G.GetNumLootItems() == 0)) then
597 ClearChatLootData() 604 ClearChatLootData()
598 Debug("HandleItemUse: Beginning chat-based loot timer for item with ID %d.", item_id) 605 Debug("HandleItemUse: Beginning chat-based loot timer for item with ID %d.", item_id)
599 chat_loot_timer_handle = C_Timer.NewTimer(1.5, ClearChatLootData) 606 chat_loot_timer_handle = C_Timer.NewTimer(1.5, ClearChatLootData)
1279 ClearChatLootData() 1286 ClearChatLootData()
1280 end 1287 end
1281 1288
1282 1289
1283 -- EVENT HANDLERS ----------------------------------------------------- 1290 -- EVENT HANDLERS -----------------------------------------------------
1291
1292 -- This function (and the following function) are to stop 'HandleItemUse' from triggering when you put an item that would normally be opened into the bank, guild bank, etc.
1293 function WDP:StopChatLootRecording(event_name)
1294 if not block_chat_loot_data then
1295 Debug("%s: Detected event that will taint chat-based loot recording. Pausing data collection.", event_name)
1296 ClearChatLootData()
1297 block_chat_loot_data = true
1298 end
1299 end
1300
1301
1302 function WDP:ResumeChatLootRecording(event_name)
1303 if block_chat_loot_data then
1304 Debug("%s: Detected event that signals the end of taint issues with chat-based loot recording. Resuming data collection.", event_name)
1305 block_chat_loot_data = false
1306 end
1307 end
1308
1284 1309
1285 -- For now, bonus roll data only pollutes the true drop percentages. We still want to capture the data from SPELL_CONFIRMATION_PROMPT because of legendary quest items though. 1310 -- For now, bonus roll data only pollutes the true drop percentages. We still want to capture the data from SPELL_CONFIRMATION_PROMPT because of legendary quest items though.
1286 function WDP:BONUS_ROLL_RESULT(event_name) 1311 function WDP:BONUS_ROLL_RESULT(event_name)
1287 Debug("%s: Bonus roll detected; stopping loot recording for this boss to avoid recording bonus loot.", event_name) 1312 Debug("%s: Bonus roll detected; stopping loot recording for this boss to avoid recording bonus loot.", event_name)
1288 ClearKilledBossID() 1313 ClearKilledBossID()
2290 end 2315 end
2291 end -- do-block 2316 end -- do-block
2292 2317
2293 2318
2294 function WDP:MAIL_SHOW(event_name) 2319 function WDP:MAIL_SHOW(event_name)
2320 WDP:StopChatLootRecording(event_name)
2295 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc")) 2321 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
2296 2322
2297 if not unit_idnum or unit_type ~= private.UNIT_TYPES.OBJECT then 2323 if not unit_idnum or unit_type ~= private.UNIT_TYPES.OBJECT then
2298 return 2324 return
2299 end 2325 end
2316 2342
2317 local current_merchant 2343 local current_merchant
2318 local merchant_standing 2344 local merchant_standing
2319 2345
2320 function WDP:MERCHANT_CLOSED(event_name) 2346 function WDP:MERCHANT_CLOSED(event_name)
2347 WDP:ResumeChatLootRecording(event_name)
2321 current_merchant = nil 2348 current_merchant = nil
2322 merchant_standing = nil 2349 merchant_standing = nil
2323 end 2350 end
2324 2351
2325 2352
2326 function WDP:UpdateMerchantItems(event_name) 2353 function WDP:UpdateMerchantItems(event_name)
2327 if not current_merchant or event_name == "MERCHANT_SHOW" then 2354 if not current_merchant or event_name == "MERCHANT_SHOW" then
2355 WDP:StopChatLootRecording(event_name)
2328 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc")) 2356 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
2329 2357
2330 if not unit_idnum or not UnitTypeIsNPC(unit_type) then 2358 if not unit_idnum or not UnitTypeIsNPC(unit_type) then
2331 return 2359 return
2332 end 2360 end
2851 loot_toast_container_timer_handle = C_Timer.NewTimer(1, ClearLootToastContainerID) -- we need to assign a handle here to cancel it later 2879 loot_toast_container_timer_handle = C_Timer.NewTimer(1, ClearLootToastContainerID) -- we need to assign a handle here to cancel it later
2852 return 2880 return
2853 end 2881 end
2854 2882
2855 -- For spells cast by items that don't usually trigger loot toasts 2883 -- For spells cast by items that don't usually trigger loot toasts
2856 if private.DELAYED_CONTAINER_SPELL_ID_TO_ITEM_ID_MAP[spell_id] then 2884 if private.DELAYED_CONTAINER_SPELL_ID_TO_ITEM_ID_MAP[spell_id] and not block_chat_loot_data then
2857 -- Set up timer 2885 -- Set up timer
2858 ClearChatLootData() 2886 ClearChatLootData()
2859 Debug("%s: Beginning chat-based loot timer for spellID %d", event_name, spell_id) 2887 Debug("%s: Beginning chat-based loot timer for spellID %d", event_name, spell_id)
2860 chat_loot_timer_handle = C_Timer.NewTimer(1.5, ClearChatLootData) 2888 chat_loot_timer_handle = C_Timer.NewTimer(1.5, ClearChatLootData)
2861 chat_loot_data.identifier = private.DELAYED_CONTAINER_SPELL_ID_TO_ITEM_ID_MAP[spell_id] 2889 chat_loot_data.identifier = private.DELAYED_CONTAINER_SPELL_ID_TO_ITEM_ID_MAP[spell_id]
2901 end 2929 end
2902 end 2930 end
2903 2931
2904 2932
2905 function WDP:AUCTION_HOUSE_SHOW(event_name) 2933 function WDP:AUCTION_HOUSE_SHOW(event_name)
2934 WDP:StopChatLootRecording(event_name)
2906 SetUnitField("auctioneer", private.UNIT_TYPES.NPC) 2935 SetUnitField("auctioneer", private.UNIT_TYPES.NPC)
2907 end 2936 end
2908 2937
2909 2938
2910 function WDP:BANKFRAME_OPENED(event_name) 2939 function WDP:BANKFRAME_OPENED(event_name)
2940 WDP:StopChatLootRecording(event_name)
2911 SetUnitField("banker", private.UNIT_TYPES.NPC) 2941 SetUnitField("banker", private.UNIT_TYPES.NPC)
2912 end 2942 end
2913 2943
2914 2944
2915 function WDP:BATTLEFIELDS_SHOW(event_name) 2945 function WDP:BATTLEFIELDS_SHOW(event_name)
2938 end, 2968 end,
2939 } 2969 }
2940 2970
2941 2971
2942 function WDP:GOSSIP_SHOW(event_name) 2972 function WDP:GOSSIP_SHOW(event_name)
2973 WDP:StopChatLootRecording(event_name)
2943 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc")) 2974 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
2944 if not unit_idnum then 2975 if not unit_idnum then
2945 return 2976 return
2946 end 2977 end
2947 2978
2950 end 2981 end
2951 end 2982 end
2952 2983
2953 2984
2954 function WDP:GUILDBANKFRAME_OPENED(event_name) 2985 function WDP:GUILDBANKFRAME_OPENED(event_name)
2986 WDP:StopChatLootRecording(event_name)
2955 SetUnitField("guild_bank", private.UNIT_TYPES.OBJECT) 2987 SetUnitField("guild_bank", private.UNIT_TYPES.OBJECT)
2956 end 2988 end
2957 2989
2958 2990
2959 function WDP:ITEM_UPGRADE_MASTER_OPENED(event_name) 2991 function WDP:ITEM_UPGRADE_MASTER_OPENED(event_name)