Code:
local bosses = {}
local playerGUID
local f = CreateFrame("Frame")
f:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT")
f:SetScript("OnEvent", function(self, event, ...)
if event == "COMBAT_LOG_EVENT_UNFILTERED" then
local eventType, _, sourceGUID, sourceName, _, _, destGUID, destName, _, _, _, spellID, spellName, _, missType, _, missAmount = ...
if missType ~= "MISS" or destGUID ~= playerGUID or not bosses[sourceGUID] or not eventType:match("_MISSED$") then
-- This event is not a miss from a boss at the player. Quit.
return
end
-- This event is a miss coming from a boss we care about.
-- destName = boss name
-- sourceName = your name
-- spellID = ID of the spell/ability that missed
-- (you can use this to get an icon or link if you want)
-- spellName = name of the spell/ability that missed
-- missAmount = amount that it would have hit for
--
-- Insert code here to do whatever.
--
else
-- INSTANCE_ENCOUNTER_ENGAGE_UNIT
-- Player GUID isn't available at runtime, so get it here.
if not playerGUID then
playerGUID = UnitGUID("player")
end
-- Check to see if there are any bosses around.
if UnitExists("boss1") then
-- At least one boss exists.
-- Clear the list of boss GUIDs.
wipe(bosses)
-- Get a new list of boss GUIDs.
for i = 1, 4 do
local guid = UnitGuid("boss"..i)
if guid then
bosses[guid] = true
end
end
-- Register for combat log events.
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
else
-- No bosses exist.
-- Unregister for combat log events.
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
-- Clear the list of boss GUIDs.
wipe(bosses)
end
end
end)