Mercurial > wow > wowdb-profiler
comparison Main.lua @ 426:de0795cfbe56
Removed new kill count system for raid encounters while it undergoes further testing.
author | MMOSimca <MMOSimca@gmail.com> |
---|---|
date | Tue, 13 Jan 2015 02:51:55 -0500 |
parents | 5bd49f0b635c |
children | 181c7f8cd087 |
comparison
equal
deleted
inserted
replaced
425:5bd49f0b635c | 426:de0795cfbe56 |
---|---|
101 CHAT_MSG_MONSTER_YELL = "RecordQuote", | 101 CHAT_MSG_MONSTER_YELL = "RecordQuote", |
102 CHAT_MSG_SYSTEM = true, | 102 CHAT_MSG_SYSTEM = true, |
103 COMBAT_LOG_EVENT_UNFILTERED = true, | 103 COMBAT_LOG_EVENT_UNFILTERED = true, |
104 COMBAT_TEXT_UPDATE = true, | 104 COMBAT_TEXT_UPDATE = true, |
105 CURSOR_UPDATE = true, | 105 CURSOR_UPDATE = true, |
106 ENCOUNTER_END = true, | |
107 FORGE_MASTER_OPENED = true, | 106 FORGE_MASTER_OPENED = true, |
108 GARRISON_MISSION_BONUS_ROLL_COMPLETE = "HandleBadChatLootData", | 107 GARRISON_MISSION_BONUS_ROLL_COMPLETE = "HandleBadChatLootData", |
109 GARRISON_MISSION_COMPLETE_RESPONSE = "HandleBadChatLootData", | 108 GARRISON_MISSION_COMPLETE_RESPONSE = "HandleBadChatLootData", |
110 GOSSIP_SHOW = true, | 109 GOSSIP_SHOW = true, |
111 GROUP_ROSTER_UPDATE = true, | 110 GROUP_ROSTER_UPDATE = true, |
119 MERCHANT_CLOSED = true, | 118 MERCHANT_CLOSED = true, |
120 MERCHANT_SHOW = "UpdateMerchantItems", | 119 MERCHANT_SHOW = "UpdateMerchantItems", |
121 MERCHANT_UPDATE = "UpdateMerchantItems", | 120 MERCHANT_UPDATE = "UpdateMerchantItems", |
122 PET_BAR_UPDATE = true, | 121 PET_BAR_UPDATE = true, |
123 --PET_JOURNAL_LIST_UPDATE = true, | 122 --PET_JOURNAL_LIST_UPDATE = true, |
124 PLAYER_LOGOUT = true, | |
125 PLAYER_REGEN_DISABLED = true, | 123 PLAYER_REGEN_DISABLED = true, |
126 PLAYER_REGEN_ENABLED = true, | 124 PLAYER_REGEN_ENABLED = true, |
127 PLAYER_TARGET_CHANGED = true, | 125 PLAYER_TARGET_CHANGED = true, |
128 QUEST_COMPLETE = true, | 126 QUEST_COMPLETE = true, |
129 QUEST_DETAIL = true, | 127 QUEST_DETAIL = true, |
180 local chat_loot_data | 178 local chat_loot_data |
181 local chat_loot_timer_handle | 179 local chat_loot_timer_handle |
182 local current_target_id | 180 local current_target_id |
183 local current_area_id | 181 local current_area_id |
184 local current_loot | 182 local current_loot |
185 local saved_raid_encounter_data | |
186 local update_raid_encounter_timer_handle | |
187 local saved_difficulty_token | |
188 | 183 |
189 | 184 |
190 -- Data for our current action. Including possible values as a reference. | 185 -- Data for our current action. Including possible values as a reference. |
191 local current_action = { | 186 local current_action = { |
192 identifier = nil, | 187 identifier = nil, |
926 table.wipe(chat_loot_data) | 921 table.wipe(chat_loot_data) |
927 end | 922 end |
928 end | 923 end |
929 | 924 |
930 | 925 |
931 -- This wipes a timer as well | |
932 local UpdateRaidEncounterInfo | |
933 do | |
934 local fresh_raid_encounter_data = {} | |
935 | |
936 function UpdateRaidEncounterInfo() | |
937 -- Clear timer info | |
938 if update_raid_encounter_timer_handle then | |
939 update_raid_encounter_timer_handle:Cancel() | |
940 update_raid_encounter_timer_handle = nil | |
941 end | |
942 table.wipe(fresh_raid_encounter_data) | |
943 | |
944 -- Collect encounter data for LFR difficulty via RF functions | |
945 for i = 1, _G.GetNumRFDungeons() do | |
946 local dungeon_ID = _G.GetRFDungeonInfo(i) | |
947 fresh_raid_encounter_data[dungeon_ID] = fresh_raid_encounter_data[dungeon_ID] or {} | |
948 for j = 1, _G.GetLFGDungeonNumEncounters(dungeon_ID) do | |
949 local boss_name, _, is_killed = _G.GetLFGDungeonEncounterInfo(dungeon_ID, j) | |
950 fresh_raid_encounter_data[dungeon_ID][boss_name] = is_killed | |
951 end | |
952 end | |
953 | |
954 -- Collect encounter data for Normal/Heroic/Mythic difficulty via saved instance functions | |
955 for i = 1, _G.GetNumSavedInstances() do | |
956 local _, dungeon_ID, _, _, _, _, _, _, _, _, num_encounters = _G.GetSavedInstanceInfo(i) | |
957 fresh_raid_encounter_data[dungeon_ID] = fresh_raid_encounter_data[dungeon_ID] or {} | |
958 for j = 1, num_encounters do | |
959 local boss_name, _, is_killed = _G.GetSavedInstanceEncounterInfo(i, j) | |
960 fresh_raid_encounter_data[dungeon_ID][boss_name] = is_killed | |
961 end | |
962 end | |
963 | |
964 Debug("UpdateRaidEncounterInfo: Collected fresh raid encounter data.") | |
965 if saved_raid_encounter_data then | |
966 -- Compare old data vs new table to find changes | |
967 for dungeon_ID, sub_table in next, saved_raid_encounter_data do | |
968 for boss_name, is_killed in next, saved_raid_encounter_data[dungeon_ID] do | |
969 if private.RAID_ENCOUNTER_NAME_TO_NPC_ID_MAP[boss_name] and saved_raid_encounter_data[dungeon_ID][boss_name] == false and fresh_raid_encounter_data[dungeon_ID] and fresh_raid_encounter_data[dungeon_ID][boss_name] == true then | |
970 Debug("UpdateRaidEncounterInfo: Incrementing kill count for boss %s with ID %d.", boss_name, private.RAID_ENCOUNTER_NAME_TO_NPC_ID_MAP[boss_name]) | |
971 -- Increment kill count for NPC IDs with detected changes | |
972 local npc = NPCEntry(private.RAID_ENCOUNTER_NAME_TO_NPC_ID_MAP[boss_name]) | |
973 if npc then | |
974 local encounter_data = npc:EncounterData(saved_difficulty_token) | |
975 encounter_data["drops"] = encounter_data["drops"] or {} | |
976 encounter_data.loot_counts = encounter_data.loot_counts or {} | |
977 encounter_data.loot_counts["drops"] = (encounter_data.loot_counts["drops"] or 0) + 1 | |
978 end | |
979 end | |
980 end | |
981 end | |
982 end | |
983 | |
984 -- Assign new table over old one | |
985 saved_raid_encounter_data = fresh_raid_encounter_data | |
986 saved_difficulty_token = nil | |
987 end | |
988 end | |
989 | |
990 | |
991 -- METHODS ------------------------------------------------------------ | 926 -- METHODS ------------------------------------------------------------ |
992 | 927 |
993 function WDP:OnInitialize() | 928 function WDP:OnInitialize() |
994 local db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default") | 929 local db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default") |
995 private.db = db | 930 private.db = db |
1055 end, 100000) | 990 end, 100000) |
1056 target_location_timer_handle = C_Timer.NewTicker(0.5, function() | 991 target_location_timer_handle = C_Timer.NewTicker(0.5, function() |
1057 target_location_timer_handle._remainingIterations = 100000 | 992 target_location_timer_handle._remainingIterations = 100000 |
1058 WDP:UpdateTargetLocation() | 993 WDP:UpdateTargetLocation() |
1059 end, 100000) | 994 end, 100000) |
1060 | |
1061 if ALLOWED_LOCALES[CLIENT_LOCALE] then | |
1062 update_raid_encounter_timer_handle = C_Timer.NewTimer(10, UpdateRaidEncounterInfo) | |
1063 end | |
1064 | 995 |
1065 _G.hooksecurefunc("UseContainerItem", function(bag_index, slot_index, target_unit) | 996 _G.hooksecurefunc("UseContainerItem", function(bag_index, slot_index, target_unit) |
1066 if target_unit then | 997 if target_unit then |
1067 return | 998 return |
1068 end | 999 end |
1357 end | 1288 end |
1358 | 1289 |
1359 | 1290 |
1360 -- EVENT HANDLERS ----------------------------------------------------- | 1291 -- EVENT HANDLERS ----------------------------------------------------- |
1361 | 1292 |
1362 function WDP:ENCOUNTER_END(event_name) | |
1363 local loot_method = _G.GetLootMethod() | |
1364 -- This will only work for english clients due to questionable API design choices | |
1365 -- Currently only testing this method of kill count recording for personal loot. | |
1366 -- Master looting has too many edge cases, such as chest objects and multiple NPCs with split loot. | |
1367 if loot_method ~= "personalloot" or not ALLOWED_LOCALES[CLIENT_LOCALE] then | |
1368 return | |
1369 end | |
1370 | |
1371 saved_difficulty_token = InstanceDifficultyToken() | |
1372 update_raid_encounter_timer_handle = C_Timer.NewTimer(30, UpdateRaidEncounterInfo) | |
1373 end | |
1374 | |
1375 | |
1376 function WDP:PLAYER_LOGOUT(event_name) | |
1377 if update_raid_encounter_timer_handle then | |
1378 UpdateRaidEncounterInfo() | |
1379 end | |
1380 end | |
1381 | |
1382 -- 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. | 1293 -- 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. |
1383 function WDP:BONUS_ROLL_RESULT(event_name) | 1294 function WDP:BONUS_ROLL_RESULT(event_name) |
1384 Debug("%s: Bonus roll detected; stopping loot recording for this boss to avoid recording bonus loot.", event_name) | 1295 Debug("%s: Bonus roll detected; stopping loot recording for this boss to avoid recording bonus loot.", event_name) |
1385 ClearKilledBossID() | 1296 ClearKilledBossID() |
1386 ClearLootToastContainerID() | 1297 ClearLootToastContainerID() |
1474 end | 1385 end |
1475 else | 1386 else |
1476 Debug("%s: Currency texture is nil, from currency link %s", event_name, item_link) | 1387 Debug("%s: Currency texture is nil, from currency link %s", event_name, item_link) |
1477 end | 1388 end |
1478 elseif raid_boss_id then | 1389 elseif raid_boss_id then |
1479 local loot_method = _G.GetLootMethod() | |
1480 -- Slightly messy hack to workaround duplicate world bosses | 1390 -- Slightly messy hack to workaround duplicate world bosses |
1481 local upper_limit = 0 | 1391 local upper_limit = 0 |
1482 if DUPLICATE_WORLD_BOSS_IDS[raid_boss_id] then | 1392 if DUPLICATE_WORLD_BOSS_IDS[raid_boss_id] then |
1483 upper_limit = #DUPLICATE_WORLD_BOSS_IDS[raid_boss_id] | 1393 upper_limit = #DUPLICATE_WORLD_BOSS_IDS[raid_boss_id] |
1484 end | 1394 end |
1519 return | 1429 return |
1520 end | 1430 end |
1521 end | 1431 end |
1522 | 1432 |
1523 if not boss_loot_toasting[temp_npc_id] then | 1433 if not boss_loot_toasting[temp_npc_id] then |
1524 -- In some situations, we will increment kill count by watching what the player is saved to | 1434 encounter_data.loot_counts[loot_label] = (encounter_data.loot_counts[loot_label] or 0) + 1 |
1525 if not update_raid_encounter_timer_handle or not private.RAID_ENCOUNTER_NPC_ID_LIST[temp_npc_id] or loot_method ~= "personalloot" then | |
1526 encounter_data.loot_counts[loot_label] = (encounter_data.loot_counts[loot_label] or 0) + 1 | |
1527 else | |
1528 Debug("%s: Skipping incrementing kill count for NPC ID %d.", event_name, temp_npc_id) | |
1529 end | |
1530 boss_loot_toasting[temp_npc_id] = true -- Do not count further loots until timer expires or another boss is killed | 1435 boss_loot_toasting[temp_npc_id] = true -- Do not count further loots until timer expires or another boss is killed |
1531 end | 1436 end |
1532 end | 1437 end |
1533 end | 1438 end |
1534 elseif loot_toast_container_id then | 1439 elseif loot_toast_container_id then |
2104 local LOOT_OPENED_UPDATE_FUNCS = { | 2009 local LOOT_OPENED_UPDATE_FUNCS = { |
2105 [AF.ITEM] = function() | 2010 [AF.ITEM] = function() |
2106 GenericLootUpdate("items") | 2011 GenericLootUpdate("items") |
2107 end, | 2012 end, |
2108 [AF.NPC] = function() | 2013 [AF.NPC] = function() |
2109 local loot_method = _G.GetLootMethod() | |
2110 local difficulty_token = InstanceDifficultyToken() | 2014 local difficulty_token = InstanceDifficultyToken() |
2111 local loot_label = current_loot.label | 2015 local loot_label = current_loot.label |
2112 local source_list = {} | 2016 local source_list = {} |
2113 | 2017 |
2114 for source_guid, loot_data in pairs(current_loot.sources) do | 2018 for source_guid, loot_data in pairs(current_loot.sources) do |
2119 local encounter_data = npc:EncounterData(difficulty_token) | 2023 local encounter_data = npc:EncounterData(difficulty_token) |
2120 encounter_data[loot_label] = encounter_data[loot_label] or {} | 2024 encounter_data[loot_label] = encounter_data[loot_label] or {} |
2121 | 2025 |
2122 if not source_list[source_guid] then | 2026 if not source_list[source_guid] then |
2123 encounter_data.loot_counts = encounter_data.loot_counts or {} | 2027 encounter_data.loot_counts = encounter_data.loot_counts or {} |
2124 -- In some situations, we will increment kill count by watching what the player is saved to | 2028 encounter_data.loot_counts[loot_label] = (encounter_data.loot_counts[loot_label] or 0) + 1 |
2125 if not update_raid_encounter_timer_handle or not private.RAID_ENCOUNTER_NPC_ID_LIST[source_id] or loot_method ~= "personalloot" then | |
2126 encounter_data.loot_counts[loot_label] = (encounter_data.loot_counts[loot_label] or 0) + 1 | |
2127 else | |
2128 | |
2129 end | |
2130 source_list[source_guid] = true | 2029 source_list[source_guid] = true |
2131 end | 2030 end |
2132 | 2031 |
2133 for loot_token, quantity in pairs(loot_data) do | 2032 for loot_token, quantity in pairs(loot_data) do |
2134 local loot_type, currency_texture = (":"):split(loot_token) | 2033 local loot_type, currency_texture = (":"):split(loot_token) |