Mercurial > wow > wowdb-profiler
comparison Main.lua @ 301:216f807df434
Support for Heroic Scenerio Cache and Battle Pet Supply loot.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Mon, 01 Jul 2013 17:49:49 -0500 |
parents | e5c2dc3c7f6f |
children | ca7abdbda078 |
comparison
equal
deleted
inserted
replaced
300:e5c2dc3c7f6f | 301:216f807df434 |
---|---|
733 in_instance = _G.IsInInstance() | 733 in_instance = _G.IsInInstance() |
734 SetCurrentAreaID() | 734 SetCurrentAreaID() |
735 end | 735 end |
736 end | 736 end |
737 | 737 |
738 local function InitializeCurrentLoot() | |
739 current_loot = { | |
740 list = {}, | |
741 sources = {}, | |
742 identifier = current_action.identifier, | |
743 label = current_action.loot_label or "drops", | |
744 map_level = current_action.map_level, | |
745 object_name = current_action.object_name, | |
746 spell_label = current_action.spell_label, | |
747 target_type = current_action.target_type, | |
748 x = current_action.x, | |
749 y = current_action.y, | |
750 zone_data = current_action.zone_data, | |
751 } | |
752 | |
753 table.wipe(current_action) | |
754 end | |
738 | 755 |
739 -- METHODS ------------------------------------------------------------ | 756 -- METHODS ------------------------------------------------------------ |
740 | 757 |
741 function WDP:OnInitialize() | 758 function WDP:OnInitialize() |
742 local db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default") | 759 local db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default") |
1100 UpdateUnitPet(_G.UnitGUID(unit_id), unit_id) | 1117 UpdateUnitPet(_G.UnitGUID(unit_id), unit_id) |
1101 end | 1118 end |
1102 | 1119 |
1103 | 1120 |
1104 function WDP:SHOW_LOOT_TOAST(event_name, loot_type, item_link, quantity) | 1121 function WDP:SHOW_LOOT_TOAST(event_name, loot_type, item_link, quantity) |
1105 if loot_type ~= "item" then | 1122 local container_id = private.loot_toast_container_id |
1106 return | 1123 local item_id = ItemLinkToID(item_link) |
1107 end | |
1108 local npc = NPCEntry(private.raid_finder_boss_id or private.world_boss_id) | 1124 local npc = NPCEntry(private.raid_finder_boss_id or private.world_boss_id) |
1109 ClearKilledBossID() | 1125 ClearKilledBossID() |
1110 | 1126 |
1111 if not npc then | 1127 if npc then |
1112 Debug("%s: NPC is nil.", event_name) | 1128 if not item_id then |
1113 return | 1129 Debug("%s: ItemID is nil, from item link %s", event_name, item_link) |
1114 end | 1130 return |
1115 local item_id = ItemLinkToID(item_link) | 1131 end |
1116 | 1132 local loot_type = "drops" |
1117 if not item_id then | 1133 local encounter_data = npc:EncounterData(InstanceDifficultyToken()) |
1118 Debug("%s: ItemID is nil, from item link %s", event_name, item_link) | 1134 encounter_data[loot_type] = encounter_data[loot_type] or {} |
1119 return | 1135 encounter_data.loot_counts = encounter_data.loot_counts or {} |
1120 end | 1136 encounter_data.loot_counts[loot_type] = (encounter_data.loot_counts[loot_type] or 0) + 1 |
1121 local loot_type = "drops" | 1137 |
1122 local encounter_data = npc:EncounterData(InstanceDifficultyToken()) | 1138 table.insert(encounter_data[loot_type], ("%d:%d"):format(item_id, quantity)) |
1123 encounter_data[loot_type] = encounter_data[loot_type] or {} | 1139 Debug("%s: %sX%d (%d)", event_name, item_link, quantity, item_id) |
1124 encounter_data.loot_counts = encounter_data.loot_counts or {} | 1140 elseif container_id then |
1125 encounter_data.loot_counts[loot_type] = (encounter_data.loot_counts[loot_type] or 0) + 1 | 1141 private.loot_toast_container_id = nil |
1126 | 1142 |
1127 table.insert(encounter_data[loot_type], ("%d:%d"):format(item_id, quantity)) | 1143 if loot_type == "item" then |
1128 Debug("%s: %sX%d (%d)", event_name, item_link, quantity, item_id) | 1144 if not item_id then |
1145 Debug("%s: ItemID is nil, from item link %s", event_name, item_link) | |
1146 return | |
1147 end | |
1148 InitializeCurrentLoot() | |
1149 current_loot.sources[container_id] = { | |
1150 [item_id] = quantity, | |
1151 } | |
1152 elseif loot_type == "money" then | |
1153 table.insert(current_loot.list, ("money:%d"):format(quantity)) | |
1154 end | |
1155 GenericLootUpdate("items") | |
1156 current_loot = nil | |
1157 else | |
1158 Debug("%s: NPC and Container are nil.", event_name) | |
1159 end | |
1129 end | 1160 end |
1130 | 1161 |
1131 | 1162 |
1132 do | 1163 do |
1133 local CHAT_MSG_LOOT_UPDATE_FUNCS = { | 1164 local CHAT_MSG_LOOT_UPDATE_FUNCS = { |
1693 if _G.type(verify_func) == "function" and not verify_func() then | 1724 if _G.type(verify_func) == "function" and not verify_func() then |
1694 return | 1725 return |
1695 end | 1726 end |
1696 local guids_used = {} | 1727 local guids_used = {} |
1697 | 1728 |
1698 current_loot = { | 1729 InitializeCurrentLoot() |
1699 list = {}, | |
1700 sources = {}, | |
1701 identifier = current_action.identifier, | |
1702 label = current_action.loot_label or "drops", | |
1703 map_level = current_action.map_level, | |
1704 object_name = current_action.object_name, | |
1705 spell_label = current_action.spell_label, | |
1706 target_type = current_action.target_type, | |
1707 x = current_action.x, | |
1708 y = current_action.y, | |
1709 zone_data = current_action.zone_data, | |
1710 } | |
1711 table.wipe(current_action) | |
1712 | |
1713 loot_guid_registry[current_loot.label] = loot_guid_registry[current_loot.label] or {} | 1730 loot_guid_registry[current_loot.label] = loot_guid_registry[current_loot.label] or {} |
1714 | 1731 |
1715 for loot_slot = 1, _G.GetNumLootItems() do | 1732 for loot_slot = 1, _G.GetNumLootItems() do |
1716 local icon_texture, item_text, quantity, quality, locked = _G.GetLootSlotInfo(loot_slot) | 1733 local icon_texture, item_text, quantity, quality, locked = _G.GetLootSlotInfo(loot_slot) |
1717 local slot_type = _G.GetLootSlotType(loot_slot) | 1734 local slot_type = _G.GetLootSlotType(loot_slot) |
2209 end | 2226 end |
2210 private.tracked_line = spell_line | 2227 private.tracked_line = spell_line |
2211 end | 2228 end |
2212 | 2229 |
2213 | 2230 |
2214 function WDP:UNIT_SPELLCAST_SUCCEEDED(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id) | 2231 do |
2215 if unit_id ~= "player" then | 2232 local LOOT_SPELL_ID_TO_ITEM_ID_MAP = { |
2216 return | 2233 [142397] = 98134, -- Heroic Cache of Treasures |
2217 end | 2234 [143506] = 98095, -- Brawler's Pet Supplies |
2218 private.tracked_line = nil | 2235 [143507] = 94207, -- Fabled Pandaren Pet Supplies |
2219 private.previous_spell_id = spell_id | 2236 [143512] = 93148, -- Pandaren Spirit Pet Supplies |
2220 | 2237 [143511] = 93149, -- Pandaren Spirit Pet Supplies |
2221 if spell_name:match("^Harvest.+") then | 2238 [143510] = 93147, -- Pandaren Spirit Pet Supplies |
2222 killed_npc_id = current_target_id | 2239 [143509] = 93146, -- Pandaren Spirit Pet Supplies |
2223 private.harvesting = true | 2240 [143508] = 89125, -- Sack of Pet Supplies |
2224 end | 2241 } |
2225 | 2242 |
2226 if anvil_spell_ids[spell_id] then | 2243 function WDP:UNIT_SPELLCAST_SUCCEEDED(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id) |
2227 UpdateDBEntryLocation("objects", OBJECT_ID_ANVIL) | 2244 if unit_id ~= "player" then |
2228 elseif forge_spell_ids[spell_id] then | 2245 return |
2229 UpdateDBEntryLocation("objects", OBJECT_ID_FORGE) | 2246 end |
2230 end | 2247 private.tracked_line = nil |
2231 end | 2248 private.previous_spell_id = spell_id |
2249 private.loot_toast_container_id = LOOT_SPELL_ID_TO_ITEM_ID_MAP[spell_id] | |
2250 | |
2251 if anvil_spell_ids[spell_id] then | |
2252 UpdateDBEntryLocation("objects", OBJECT_ID_ANVIL) | |
2253 elseif forge_spell_ids[spell_id] then | |
2254 UpdateDBEntryLocation("objects", OBJECT_ID_FORGE) | |
2255 elseif spell_name:match("^Harvest.+") then | |
2256 killed_npc_id = current_target_id | |
2257 private.harvesting = true | |
2258 end | |
2259 end | |
2260 end -- do-block | |
2232 | 2261 |
2233 | 2262 |
2234 function WDP:HandleSpellFailure(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id) | 2263 function WDP:HandleSpellFailure(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id) |
2235 if unit_id ~= "player" then | 2264 if unit_id ~= "player" then |
2236 return | 2265 return |