comparison Main.lua @ 48:4668938a63e5

Fixed gas extraction support using Black Magic Voodoo, since the UNIT_DISSIPATES sub-event no longer fires from COMBAT_LOG_EVENT_UNFILTERED.
author James D. Callahan III <jcallahan@curse.com>
date Wed, 27 Jun 2012 17:34:10 -0500
parents 768c5f3587c2
children 66034def453b
comparison
equal deleted inserted replaced
47:768c5f3587c2 48:4668938a63e5
16 ----------------------------------------------------------------------- 16 -----------------------------------------------------------------------
17 local ADDON_NAME, private = ... 17 local ADDON_NAME, private = ...
18 18
19 local LibStub = _G.LibStub 19 local LibStub = _G.LibStub
20 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceEvent-3.0", "AceTimer-3.0") 20 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceEvent-3.0", "AceTimer-3.0")
21
22 local deformat = LibStub("LibDeformat-3.0")
21 23
22 local DatamineTT = _G.CreateFrame("GameTooltip", "WDPDatamineTT", _G.UIParent, "GameTooltipTemplate") 24 local DatamineTT = _G.CreateFrame("GameTooltip", "WDPDatamineTT", _G.UIParent, "GameTooltipTemplate")
23 DatamineTT:SetOwner(_G.WorldFrame, "ANCHOR_NONE") 25 DatamineTT:SetOwner(_G.WorldFrame, "ANCHOR_NONE")
24 26
25 27
36 } 38 }
37 } 39 }
38 40
39 41
40 local EVENT_MAPPING = { 42 local EVENT_MAPPING = {
43 CHAT_MSG_LOOT = true,
41 CHAT_MSG_SYSTEM = true, 44 CHAT_MSG_SYSTEM = true,
42 COMBAT_LOG_EVENT_UNFILTERED = true, 45 COMBAT_LOG_EVENT_UNFILTERED = true,
43 COMBAT_TEXT_UPDATE = true, 46 COMBAT_TEXT_UPDATE = true,
44 ITEM_TEXT_BEGIN = true, 47 ITEM_TEXT_BEGIN = true,
45 LOOT_OPENED = true, 48 LOOT_OPENED = true,
364 end 367 end
365 end 368 end
366 end 369 end
367 end -- do-block 370 end -- do-block
368 371
372
373 local function GenericLootUpdate(data_type, top_field, inline_drops)
374 local entry = DBEntry(data_type, action_data.identifier)
375
376 if not entry then
377 return
378 end
379 local loot_type = action_data.label or "drops"
380 local loot_count = ("%s_count"):format(loot_type)
381 local loot_data
382
383 if top_field then
384 entry[top_field] = entry[top_field] or {}
385 entry[top_field][loot_count] = (entry[top_field][loot_count] or 0) + 1
386 entry[top_field][loot_type] = entry[top_field][loot_type] or {}
387 loot_data = entry[top_field][loot_type]
388 else
389 entry[loot_count] = (entry[loot_count] or 0) + 1
390 entry[loot_type] = entry[loot_type] or {}
391 loot_data = entry[loot_type]
392 end
393
394 for index = 1, #action_data.loot_list do
395 table.insert(loot_data, action_data.loot_list[index])
396 end
397 end
398
399
369 ----------------------------------------------------------------------- 400 -----------------------------------------------------------------------
370 -- Methods. 401 -- Methods.
371 ----------------------------------------------------------------------- 402 -----------------------------------------------------------------------
372 function WDP:OnInitialize() 403 function WDP:OnInitialize()
373 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global 404 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global
465 496
466 497
467 ----------------------------------------------------------------------- 498 -----------------------------------------------------------------------
468 -- Event handlers. 499 -- Event handlers.
469 ----------------------------------------------------------------------- 500 -----------------------------------------------------------------------
501 function WDP:CHAT_MSG_LOOT(event, message)
502 if action_data.spell_label ~= "EXTRACT_GAS" then
503 return
504 end
505 local item_link, quantity = deformat(message, _G.LOOT_ITEM_PUSHED_SELF_MULTIPLE)
506
507 if not item_link then
508 quantity, item_link = 1, deformat(message, _G.LOOT_ITEM_PUSHED_SELF)
509 end
510
511 if not item_link then
512 return
513 end
514 local item_id = ItemLinkToID(item_link)
515
516 if not item_id then
517 return
518 end
519 action_data.loot_list = {
520 ("%d:%d"):format(item_id, quantity)
521 }
522 GenericLootUpdate("zones")
523 table.wipe(action_data)
524 end
525
526
470 do 527 do
471 local SOBER_MATCH = _G.DRUNK_MESSAGE_ITEM_SELF1:gsub("%%s", ".+") 528 local SOBER_MATCH = _G.DRUNK_MESSAGE_ITEM_SELF1:gsub("%%s", ".+")
472 529
473 local DRUNK_COMPARES = { 530 local DRUNK_COMPARES = {
474 _G.DRUNK_MESSAGE_SELF2, 531 _G.DRUNK_MESSAGE_SELF2,
500 end 557 end
501 558
502 -- do-block 559 -- do-block
503 560
504 do 561 do
505 local EXTRACT_GAS_SPELL_ID = 30427
506 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC) 562 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC)
507 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC) 563 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC)
508 564
509 565
510 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) 566 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name)
525 end 581 end
526 582
527 local COMBAT_LOG_FUNCS = { 583 local COMBAT_LOG_FUNCS = {
528 SPELL_AURA_APPLIED = RecordNPCSpell, 584 SPELL_AURA_APPLIED = RecordNPCSpell,
529 SPELL_CAST_START = RecordNPCSpell, 585 SPELL_CAST_START = RecordNPCSpell,
530 SPELL_CAST_SUCCESS = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, ...) 586 SPELL_CAST_SUCCESS = RecordNPCSpell,
531 if spell_id == EXTRACT_GAS_SPELL_ID and source_guid == PLAYER_GUID then
532 table.wipe(action_data)
533 action_data.extracting_gas = true
534 action_data.timestamp = _G.GetTime()
535 else
536 RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, ...)
537 end
538 end,
539 UNIT_DISSIPATES = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags)
540 if action_data.extracting_gas and _G.GetTime() - action_data.timestamp <= 3 then
541 local unit_type, unit_idnum = ParseGUID(dest_guid)
542 UpdateNPCLocation(unit_idnum)
543 end
544 end,
545 } 587 }
546 588
547 589
548 function WDP:COMBAT_LOG_EVENT_UNFILTERED(event, time_stamp, sub_event, hide_caster, source_guid, source_name, source_flags, source_raid_flags, dest_guid, dest_name, dest_flags, dest_raid_flags, ...) 590 function WDP:COMBAT_LOG_EVENT_UNFILTERED(event, time_stamp, sub_event, hide_caster, source_guid, source_name, source_flags, source_raid_flags, dest_guid, dest_name, dest_flags, dest_raid_flags, ...)
549 local combat_log_func = COMBAT_LOG_FUNCS[sub_event] 591 local combat_log_func = COMBAT_LOG_FUNCS[sub_event]
732 return _G.IsFishingLoot() 774 return _G.IsFishingLoot()
733 end, 775 end,
734 } 776 }
735 777
736 778
737 local function GenericLootUpdate(data_type, top_field, inline_drops)
738 local entry = DBEntry(data_type, action_data.identifier)
739
740 if not entry then
741 return
742 end
743 local loot_type = action_data.label or "drops"
744 local loot_count = ("%s_count"):format(loot_type)
745 local loot_data
746
747 if top_field then
748 entry[top_field][loot_count] = (entry[top_field][loot_count] or 0) + 1
749 entry[top_field] = entry[top_field] or {}
750 entry[top_field][loot_type] = entry[top_field][loot_type] or {}
751 loot_data = entry[top_field][loot_type]
752 else
753 entry[loot_count] = (entry[loot_count] or 0) + 1
754 entry[loot_type] = entry[loot_type] or {}
755 loot_data = entry[loot_type]
756 end
757
758 for index = 1, #action_data.loot_list do
759 table.insert(loot_data, action_data.loot_list[index])
760 end
761 end
762
763
764 local LOOT_UPDATE_FUNCS = { 779 local LOOT_UPDATE_FUNCS = {
765 [AF.ITEM] = function() 780 [AF.ITEM] = function()
766 GenericLootUpdate("items") 781 GenericLootUpdate("items")
767 end, 782 end,
768 [AF.NPC] = function() 783 [AF.NPC] = function()
1222 1237
1223 action_data.type = AF.OBJECT 1238 action_data.type = AF.OBJECT
1224 action_data.identifier = identifier 1239 action_data.identifier = identifier
1225 elseif bit.band(spell_flags, AF.ZONE) == AF.ZONE then 1240 elseif bit.band(spell_flags, AF.ZONE) == AF.ZONE then
1226 local identifier = ("%s:%s"):format(spell_label, _G["GameTooltipTextLeft1"]:GetText() or "NONE") -- Possible fishing pool name. 1241 local identifier = ("%s:%s"):format(spell_label, _G["GameTooltipTextLeft1"]:GetText() or "NONE") -- Possible fishing pool name.
1227 action_data.zone_data = UpdateDBEntryLocation("zones", identifier, "fishing_locations") 1242 action_data.zone_data = UpdateDBEntryLocation("zones", identifier, (spell_label == "FISHING") and "fishing_locations" or nil)
1228 action_data.type = AF.ZONE 1243 action_data.type = AF.ZONE
1229 action_data.identifier = identifier 1244 action_data.identifier = identifier
1245 action_data.spell_label = spell_label
1230 end 1246 end
1231 end 1247 end
1232 private.tracked_line = spell_line 1248 private.tracked_line = spell_line
1233 end 1249 end
1234 1250