Mercurial > wow > wowdb-profiler
comparison Main.lua @ 307:c33ab3413737
Changes/fixes.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Sun, 28 Jul 2013 16:53:22 -0500 |
parents | 7feb687b1b22 |
children | 22e2e16318e5 |
comparison
equal
deleted
inserted
replaced
306:7feb687b1b22 | 307:c33ab3413737 |
---|---|
133 local item_process_timer_handle | 133 local item_process_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 loot_toast_container_timer_handle | 137 local loot_toast_container_timer_handle |
138 local loot_toast_data | |
139 local loot_toast_data_timer_handle | |
138 local name_to_id_map = {} | 140 local name_to_id_map = {} |
139 local killed_boss_id_timer_handle | 141 local killed_boss_id_timer_handle |
140 local killed_npc_id | 142 local killed_npc_id |
141 local target_location_timer_handle | 143 local target_location_timer_handle |
142 local current_target_id | 144 local current_target_id |
306 private.loot_toast_container_id = nil | 308 private.loot_toast_container_id = nil |
307 loot_toast_container_timer_handle = nil | 309 loot_toast_container_timer_handle = nil |
308 end | 310 end |
309 | 311 |
310 | 312 |
313 local function ClearLootToastData() | |
314 -- cancel existing timer if found | |
315 if loot_toast_data_timer_handle then | |
316 WDP:CancelTimer(loot_toast_data_timer_handle) | |
317 end | |
318 | |
319 if loot_toast_data then table.wipe(loot_toast_data) end | |
320 loot_toast_data_timer_handle = nil | |
321 end | |
322 | |
323 | |
311 local function InstanceDifficultyToken() | 324 local function InstanceDifficultyToken() |
312 local _, instance_type, instance_difficulty, _, _, _, is_dynamic = _G.GetInstanceInfo() | 325 local _, instance_type, instance_difficulty, _, _, _, is_dynamic = _G.GetInstanceInfo() |
313 | 326 |
314 if not instance_type or instance_type == "" then | 327 if not instance_type or instance_type == "" then |
315 instance_type = "NONE" | 328 instance_type = "NONE" |
666 if not entry then | 679 if not entry then |
667 return | 680 return |
668 end | 681 end |
669 local loot_table = LootTable(entry, loot_type, top_field) | 682 local loot_table = LootTable(entry, loot_type, top_field) |
670 | 683 |
671 if not source_list[current_loot.identifier] then | 684 if current_loot.identifier then |
672 if top_field then | 685 if not source_list[current_loot.identifier] then |
673 entry[top_field][loot_count] = (entry[top_field][loot_count] or 0) + 1 | 686 if top_field then |
674 else | 687 entry[top_field][loot_count] = (entry[top_field][loot_count] or 0) + 1 |
675 entry[loot_count] = (entry[loot_count] or 0) + 1 | 688 else |
676 end | 689 entry[loot_count] = (entry[loot_count] or 0) + 1 |
677 source_list[current_loot.identifier] = true | 690 end |
691 source_list[current_loot.identifier] = true | |
692 end | |
678 end | 693 end |
679 | 694 |
680 for index = 1, #current_loot.list do | 695 for index = 1, #current_loot.list do |
681 table.insert(loot_table, current_loot.list[index]) | 696 table.insert(loot_table, current_loot.list[index]) |
682 end | 697 end |
1144 local container_id = private.loot_toast_container_id | 1159 local container_id = private.loot_toast_container_id |
1145 local item_id = ItemLinkToID(item_link) | 1160 local item_id = ItemLinkToID(item_link) |
1146 local npc = NPCEntry(private.raid_finder_boss_id or private.world_boss_id) | 1161 local npc = NPCEntry(private.raid_finder_boss_id or private.world_boss_id) |
1147 | 1162 |
1148 if npc then | 1163 if npc then |
1149 if not item_id then | 1164 if loot_type == "item" and not item_id then |
1150 Debug("%s: ItemID is nil, from item link %s", event_name, item_link) | 1165 Debug("%s: ItemID is nil, from item link %s", event_name, item_link) |
1151 return | 1166 return |
1152 end | 1167 end |
1153 local loot_label = "drops" | 1168 local loot_label = "drops" |
1154 local encounter_data = npc:EncounterData(InstanceDifficultyToken()) | 1169 local encounter_data = npc:EncounterData(InstanceDifficultyToken()) |
1186 elseif loot_type == "money" then | 1201 elseif loot_type == "money" then |
1187 table.insert(current_loot.list, ("money:%d"):format(quantity)) | 1202 table.insert(current_loot.list, ("money:%d"):format(quantity)) |
1188 end | 1203 end |
1189 GenericLootUpdate("items") | 1204 GenericLootUpdate("items") |
1190 current_loot = nil | 1205 current_loot = nil |
1191 private.container_loot_toasting = true -- do not count further loots until timer expires or another container is opened | 1206 private.container_loot_toasting = true -- Do not count further loots until timer expires or another container is opened |
1192 else | 1207 else |
1193 Debug("%s: NPC and Container are nil.", event_name) | 1208 if loot_type == "item" and not item_id then |
1209 Debug("%s: ItemID is nil, from item link %s", event_name, item_link) | |
1210 return | |
1211 end | |
1212 Debug("%s: NPC and Container are nil, storing loot toast data for 5 seconds.", event_name) | |
1213 | |
1214 loot_toast_data = loot_toast_data or {} | |
1215 loot_toast_data[#loot_toast_data + 1] = {loot_type, item_link, quantity, item_id} | |
1216 | |
1217 loot_toast_data_timer_handle = WDP:ScheduleTimer(ClearLootToastData, 5) | |
1194 end | 1218 end |
1195 end | 1219 end |
1196 | 1220 |
1197 | 1221 |
1198 do | 1222 do |
1326 end | 1350 end |
1327 end | 1351 end |
1328 end | 1352 end |
1329 end | 1353 end |
1330 | 1354 |
1331 -- do-block | 1355 |
1332 | 1356 do -- do-block |
1333 do | |
1334 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC) | 1357 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC) |
1335 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC) | 1358 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC) |
1336 | 1359 |
1337 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) | 1360 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) |
1338 if not spell_id then | 1361 if not spell_id then |
2264 else | 2287 else |
2265 Debug("%s: Spell ID %d is not a known raid or world boss 'Bonus' spell.", event_name, spell_id) | 2288 Debug("%s: Spell ID %d is not a known raid or world boss 'Bonus' spell.", event_name, spell_id) |
2266 return | 2289 return |
2267 end | 2290 end |
2268 | 2291 |
2269 killed_boss_id_timer_handle = WDP:ScheduleTimer(ClearKilledBossID, 1) -- we need to assign a handle here to cancel it later | 2292 -- assign existing loot data to boss if it exists |
2293 if loot_toast_data then | |
2294 local npc = NPCEntry(private.raid_finder_boss_id or private.world_boss_id) | |
2295 | |
2296 if npc then | |
2297 -- create needed npc fields if required | |
2298 local loot_label = "drops" | |
2299 local encounter_data = npc:EncounterData(InstanceDifficultyToken()) | |
2300 encounter_data[loot_label] = encounter_data[loot_label] or {} | |
2301 encounter_data.loot_counts = encounter_data.loot_counts or {} | |
2302 encounter_data.loot_counts[loot_label] = (encounter_data.loot_counts[loot_label] or 0) + 1 | |
2303 | |
2304 for index = 1, #loot_toast_data do | |
2305 local data = loot_toast_data[index] | |
2306 local loot_type = data[1] | |
2307 local quantity = data[3] | |
2308 | |
2309 if loot_type == "item" then | |
2310 local item_id = data[4] | |
2311 | |
2312 Debug("%s: Stored loot data - %sX%d (%d)", event_name, data[2], quantity, item_id) | |
2313 table.insert(encounter_data[loot_label], ("%d:%d"):format(item_id, quantity)) | |
2314 elseif loot_type == "money" then | |
2315 Debug("%s: Stored loot data - money - %d", event_name, quantity) | |
2316 table.insert(encounter_data[loot_label], ("money:%d"):format(quantity)) | |
2317 end | |
2318 end | |
2319 private.boss_loot_toasting = true | |
2320 else | |
2321 Debug("%s: NPC is nil, but we have stored loot data...", event_name) | |
2322 end | |
2323 end | |
2324 | |
2325 ClearLootToastData() | |
2326 | |
2327 killed_boss_id_timer_handle = WDP:ScheduleTimer(ClearKilledBossID, 5) -- we need to assign a handle here to cancel it later | |
2270 end | 2328 end |
2271 | 2329 |
2272 | 2330 |
2273 function WDP:UNIT_SPELLCAST_SUCCEEDED(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id) | 2331 function WDP:UNIT_SPELLCAST_SUCCEEDED(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id) |
2274 if unit_id ~= "player" then | 2332 if unit_id ~= "player" then |
2278 private.previous_spell_id = spell_id | 2336 private.previous_spell_id = spell_id |
2279 | 2337 |
2280 if private.LOOT_SPELL_ID_TO_ITEM_ID_MAP[spell_id] then | 2338 if private.LOOT_SPELL_ID_TO_ITEM_ID_MAP[spell_id] then |
2281 ClearKilledBossID() | 2339 ClearKilledBossID() |
2282 ClearLootToastContainerID() | 2340 ClearLootToastContainerID() |
2341 ClearLootToastData() | |
2283 | 2342 |
2284 private.loot_toast_container_id = private.LOOT_SPELL_ID_TO_ITEM_ID_MAP[spell_id] | 2343 private.loot_toast_container_id = private.LOOT_SPELL_ID_TO_ITEM_ID_MAP[spell_id] |
2285 loot_toast_container_timer_handle = WDP:ScheduleTimer(ClearLootToastContainerID, 1) -- we need to assign a handle here to cancel it later | 2344 loot_toast_container_timer_handle = WDP:ScheduleTimer(ClearLootToastContainerID, 1) -- we need to assign a handle here to cancel it later |
2286 end | 2345 end |
2287 | 2346 |