View Single Post
01-19-12, 07:13 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
If the boss dies at all, it's a kill. It doesn't matter if the whole raid is dead. Back in TBC, my guild's first Brutallus kill involved everyone dying with the boss at less than 1%, DoTs falling off before the paladin bubble expired and the paladin died, and then me (resto shaman) reincarnating and shooting a lightning bolt at the boss before he reset. It killed him, but he turned around and killed me while the lightning bolt was in the air, so technically the whole raid was dead before the boss died.

Otherwise, yes. I'd suggest taking a look at BigWigs. It's very modular, so all the boss encounter detection is in one file, and not much else is in that file, so it should be pretty easy to go through.

1. How do I handle a fight with more than one boss? Assuming I want a general code which will be compatible with all boss encounters.
Look at BigWigs for specifics, but I'd assume that you'd just make a table containing the NPC IDs for all of the bosses, start the encounter when any one of them was engaged, detect a wipe when all raid members died and at least one boss was still alive (I'd imagine you could easily detect when the boss reset by seeing when its health popped back up to 100% after all raid members died), and detect a kill when all bosses died.

2. Won't it be very CPU demanding to wait for "COMBAT_LOG_EVENT_UNFILTERED"?
1. You only register for the event after you detect that a boss has been engaged.

2. You can immediately discard any events that do not have the UNIT_DIED sub-event:

Code:
local f = CreateFrame("Frame")
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:SetScript("OnEvent", function(self, event, timestamp, subevent, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, ...)
    if subevent ~= "UNIT_DIED" then return end
    -- do stuff here
end)
Additionally, when you detected a boss engagement, you would want to store the GUID of the boss(es), and use that to determine if the event was relevant:

Code:
local bossesAlive = {} -- Populate this with boss GUIDs when an encounter starts or a new boss spawns during an encounter.

local f = CreateFrame("Frame")
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:SetScript("OnEvent", function(self, event, timestamp, subevent, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, ...)
    if subevent ~= "UNIT_DIED" then return end
    if bossesAlive[destGUID] then
        -- Boss mob that was alive
        bossesAlive[destGUID] = nil
   else
        -- Non-boss mob, or already dead
   end
end)
  Reply With Quote