Mercurial > wow > wowdb-profiler
comparison Main.lua @ 177:2fdc940c1748
Added support for recording Raid Finder boss loot.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Sat, 03 Nov 2012 16:39:07 -0500 |
parents | 48b43068e2e0 |
children | ac673d315d61 |
comparison
equal
deleted
inserted
replaced
176:48b43068e2e0 | 177:2fdc940c1748 |
---|---|
133 local durability_timer_handle | 133 local durability_timer_handle |
134 local faction_standings = {} | 134 local faction_standings = {} |
135 local forge_spell_ids = {} | 135 local forge_spell_ids = {} |
136 local languages_known = {} | 136 local languages_known = {} |
137 local name_to_id_map = {} | 137 local name_to_id_map = {} |
138 local last_killed_npc_id | 138 local killed_npc_id |
139 local target_location_timer_handle | 139 local target_location_timer_handle |
140 local current_target_id | 140 local current_target_id |
141 local current_area_id | 141 local current_area_id |
142 local current_loot | 142 local current_loot |
143 | 143 |
274 end | 274 end |
275 end -- do-block | 275 end -- do-block |
276 | 276 |
277 | 277 |
278 -- Called on a timer | 278 -- Called on a timer |
279 local function ClearLastKilledNPC() | 279 local function ClearKilledNPC() |
280 Debug("Clearing last_killed_npc_id") | 280 Debug("Clearing last_killed_npc_id") |
281 last_killed_npc_id = nil | 281 killed_npc_id = nil |
282 end | |
283 | |
284 | |
285 local function IsRaidFinderInstance(instance_type, instance_difficulty) | |
286 return instance_type == "raid" and instance_difficulty == 2 and _G.IsPartyLFG() and _G.IsInLFGDungeon() | |
282 end | 287 end |
283 | 288 |
284 | 289 |
285 local function InstanceDifficultyToken() | 290 local function InstanceDifficultyToken() |
286 local _, instance_type, instance_difficulty, difficulty_name, _, _, is_dynamic = _G.GetInstanceInfo() | 291 local _, instance_type, instance_difficulty, difficulty_name, _, _, is_dynamic = _G.GetInstanceInfo() |
291 if not instance_type or instance_type == "" then | 296 if not instance_type or instance_type == "" then |
292 instance_type = "NONE" | 297 instance_type = "NONE" |
293 end | 298 end |
294 | 299 |
295 -- Raid difficulty of 2 is 25-man | 300 -- Raid difficulty of 2 is 25-man |
296 if instance_type == "raid" and instance_difficulty == 2 and _G.IsPartyLFG() and _G.IsInLFGDungeon() then | 301 if IsRaidFinderInstance(instance_type, instance_difficulty) then |
297 difficulty_name = "LOOKING_FOR_RAID" | 302 difficulty_name = "LOOKING_FOR_RAID" |
298 end | 303 end |
299 return ("%s:%s:%s"):format(instance_type:upper(), difficulty_name:upper():gsub(" ", "_"), _G.tostring(is_dynamic)) | 304 return ("%s:%s:%s"):format(instance_type:upper(), difficulty_name:upper():gsub(" ", "_"), _G.tostring(is_dynamic)) |
300 end | 305 end |
301 | 306 |
968 end | 973 end |
969 end | 974 end |
970 end | 975 end |
971 | 976 |
972 | 977 |
978 local CHAT_MSG_LOOT_UPDATE_FUNCS = { | |
979 [AF.NPC] = function(item_id, quantity) | |
980 local npc = NPCEntry(private.raid_finder_boss_id) | |
981 | |
982 if not npc then | |
983 return | |
984 end | |
985 local loot_type = "raid_finder_loot" | |
986 local encounter_data = npc.encounter_data[InstanceDifficultyToken()] | |
987 encounter_data[loot_type] = encounter_data[loot_type] or {} | |
988 encounter_data.loot_counts = encounter_data.loot_counts or {} | |
989 encounter_data.loot_counts[loot_type] = (encounter_data.loot_counts[loot_type] or 0) + 1 | |
990 | |
991 table.insert(encounter_data[loot_type], ("%d:%d"):format(item_id, quantity)) | |
992 end, | |
993 [AF.ZONE] = function(item_id, quantity) | |
994 current_loot = { | |
995 list = { | |
996 ("%d:%d"):format(item_id, quantity) | |
997 }, | |
998 identifier = current_action.identifier, | |
999 label = current_action.loot_label or "drops", | |
1000 map_level = current_action.map_level, | |
1001 object_name = current_action.object_name, | |
1002 spell_label = current_action.spell_label, | |
1003 target_type = current_action.target_type, | |
1004 x = current_action.x, | |
1005 y = current_action.y, | |
1006 zone_data = current_action.zone_data, | |
1007 } | |
1008 table.wipe(current_action) | |
1009 GenericLootUpdate("zones") | |
1010 end, | |
1011 } | |
1012 | |
1013 | |
973 function WDP:CHAT_MSG_LOOT(event_name, message) | 1014 function WDP:CHAT_MSG_LOOT(event_name, message) |
1015 local category | |
1016 | |
1017 Debug(event_name) | |
1018 | |
974 if current_action.spell_label ~= "EXTRACT_GAS" then | 1019 if current_action.spell_label ~= "EXTRACT_GAS" then |
1020 category = AF.ZONE | |
1021 elseif private.raid_finder_boss_id then | |
1022 category = AF.NPC | |
1023 end | |
1024 local update_func = CHAT_MSG_LOOT_UPDATE_FUNCS[category] | |
1025 | |
1026 if not category or not update_func then | |
975 return | 1027 return |
976 end | 1028 end |
977 local item_link, quantity = deformat(message, _G.LOOT_ITEM_PUSHED_SELF_MULTIPLE) | 1029 local item_link, quantity = deformat(message, _G.LOOT_ITEM_PUSHED_SELF_MULTIPLE) |
978 | 1030 |
979 if not item_link then | 1031 if not item_link then |
980 quantity, item_link = 1, deformat(message, _G.LOOT_ITEM_PUSHED_SELF) | 1032 quantity, item_link = 1, deformat(message, _G.LOOT_ITEM_PUSHED_SELF) |
981 end | 1033 end |
982 | |
983 if not item_link then | |
984 return | |
985 end | |
986 local item_id = ItemLinkToID(item_link) | 1034 local item_id = ItemLinkToID(item_link) |
987 | 1035 |
988 if not item_id then | 1036 if not item_id then |
989 return | 1037 return |
990 end | 1038 end |
991 current_loot = { | 1039 update_func(item_id, quantity) |
992 list = { | |
993 ("%d:%d"):format(item_id, quantity) | |
994 }, | |
995 identifier = current_action.identifier, | |
996 label = current_action.loot_label or "drops", | |
997 map_level = current_action.map_level, | |
998 object_name = current_action.object_name, | |
999 spell_label = current_action.spell_label, | |
1000 target_type = current_action.target_type, | |
1001 x = current_action.x, | |
1002 y = current_action.y, | |
1003 zone_data = current_action.zone_data, | |
1004 } | |
1005 table.wipe(current_action) | |
1006 GenericLootUpdate("zones") | |
1007 end | 1040 end |
1008 | 1041 |
1009 | 1042 |
1010 function WDP:RecordQuote(event_name, message, source_name, language_name) | 1043 function WDP:RecordQuote(event_name, message, source_name, language_name) |
1011 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 | 1044 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 |
1106 if bit.band(FLAGS_NPC_CONTROL, source_flags) == FLAGS_NPC_CONTROL and bit.band(FLAGS_NPC, source_flags) ~= 0 then | 1139 if bit.band(FLAGS_NPC_CONTROL, source_flags) == FLAGS_NPC_CONTROL and bit.band(FLAGS_NPC, source_flags) ~= 0 then |
1107 local encounter_data = NPCEntry(source_id).encounter_data[InstanceDifficultyToken()] | 1140 local encounter_data = NPCEntry(source_id).encounter_data[InstanceDifficultyToken()] |
1108 encounter_data.spells = encounter_data.spells or {} | 1141 encounter_data.spells = encounter_data.spells or {} |
1109 encounter_data.spells[spell_id] = (encounter_data.spells[spell_id] or 0) + 1 | 1142 encounter_data.spells[spell_id] = (encounter_data.spells[spell_id] or 0) + 1 |
1110 end | 1143 end |
1144 end | |
1145 | |
1146 local function ClearKilledBossID() | |
1147 private.raid_finder_boss_id = nil | |
1111 end | 1148 end |
1112 | 1149 |
1113 local HEAL_BATTLE_PETS_SPELL_ID = 125801 | 1150 local HEAL_BATTLE_PETS_SPELL_ID = 125801 |
1114 | 1151 |
1115 local COMBAT_LOG_FUNCS = { | 1152 local COMBAT_LOG_FUNCS = { |
1129 if dest_guid ~= _G.UnitGUID("target") then | 1166 if dest_guid ~= _G.UnitGUID("target") then |
1130 return | 1167 return |
1131 end | 1168 end |
1132 local unit_type, unit_idnum = ParseGUID(dest_guid) | 1169 local unit_type, unit_idnum = ParseGUID(dest_guid) |
1133 | 1170 |
1171 Debug(sub_event) | |
1172 | |
1134 if not unit_idnum or not UnitTypeIsNPC(unit_type) then | 1173 if not unit_idnum or not UnitTypeIsNPC(unit_type) then |
1135 last_killed_npc_id = nil | 1174 ClearKilledNPC() |
1136 private.harvesting = nil | 1175 private.harvesting = nil |
1137 return | 1176 return |
1138 end | 1177 end |
1139 last_killed_npc_id = unit_idnum | 1178 |
1140 WDP:ScheduleTimer(ClearLastKilledNPC, 0.1) | 1179 if private.RAID_FINDER_BOSS_IDS[unit_idnum] then |
1180 local _, instance_type, instance_difficulty = _G.GetInstanceInfo() | |
1181 | |
1182 if IsRaidFinderInstance(instance_type, instance_difficulty) then | |
1183 private.raid_finder_boss_id = unit_idnum | |
1184 WDP:ScheduleTimer(ClearKilledBossID, 0.5) | |
1185 end | |
1186 end | |
1187 killed_npc_id = unit_idnum | |
1188 WDP:ScheduleTimer(ClearKilledNPC, 0.1) | |
1141 end, | 1189 end, |
1142 } | 1190 } |
1143 | 1191 |
1144 | 1192 |
1145 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, ...) | 1193 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, ...) |
1216 } | 1264 } |
1217 } | 1265 } |
1218 | 1266 |
1219 | 1267 |
1220 function WDP:COMBAT_TEXT_UPDATE(event_name, message_type, faction_name, amount) | 1268 function WDP:COMBAT_TEXT_UPDATE(event_name, message_type, faction_name, amount) |
1221 if message_type ~= "FACTION" or not last_killed_npc_id then | 1269 if message_type ~= "FACTION" or not killed_npc_id then |
1222 return | 1270 return |
1223 end | 1271 end |
1224 UpdateFactionData() | 1272 UpdateFactionData() |
1225 | 1273 |
1226 if not faction_name or not faction_standings[faction_name] then | 1274 if not faction_name or not faction_standings[faction_name] then |
1227 return | 1275 return |
1228 end | 1276 end |
1229 local npc = NPCEntry(last_killed_npc_id) | 1277 local npc = NPCEntry(killed_npc_id) |
1230 last_killed_npc_id = nil | 1278 ClearKilledNPC() |
1231 | 1279 |
1232 if not npc then | 1280 if not npc then |
1233 private.harvesting = nil | 1281 private.harvesting = nil |
1234 return | 1282 return |
1235 end | 1283 end |
1767 | 1815 |
1768 if ALLOWED_LOCALES[CLIENT_LOCALE] then | 1816 if ALLOWED_LOCALES[CLIENT_LOCALE] then |
1769 quest.reward_text = ReplaceKeywords(_G.GetRewardText()) | 1817 quest.reward_text = ReplaceKeywords(_G.GetRewardText()) |
1770 end | 1818 end |
1771 -- Make sure the quest NPC isn't erroneously recorded as giving reputation for quests which award it. | 1819 -- Make sure the quest NPC isn't erroneously recorded as giving reputation for quests which award it. |
1772 last_killed_npc_id = nil | 1820 ClearKilledNPC() |
1773 end | 1821 end |
1774 | 1822 |
1775 | 1823 |
1776 function WDP:QUEST_DETAIL(event_name) | 1824 function WDP:QUEST_DETAIL(event_name) |
1777 local quest = UpdateQuestJuncture("begin") | 1825 local quest = UpdateQuestJuncture("begin") |
1998 end | 2046 end |
1999 private.tracked_line = nil | 2047 private.tracked_line = nil |
2000 private.previous_spell_id = spell_id | 2048 private.previous_spell_id = spell_id |
2001 | 2049 |
2002 if spell_name:match("^Harvest.+") then | 2050 if spell_name:match("^Harvest.+") then |
2003 last_killed_npc_id = current_target_id | 2051 killed_npc_id = current_target_id |
2004 private.harvesting = true | 2052 private.harvesting = true |
2005 end | 2053 end |
2006 | 2054 |
2007 if anvil_spell_ids[spell_id] then | 2055 if anvil_spell_ids[spell_id] then |
2008 UpdateDBEntryLocation("objects", OBJECT_ID_ANVIL) | 2056 UpdateDBEntryLocation("objects", OBJECT_ID_ANVIL) |