Thread Tools Display Modes
01-18-12, 07:55 AM   #1
Animor
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Mar 2011
Posts: 136
Raid/dungeons event and data

Hello good people

I'm looking for two things related to raids/dungeons, which I couldn't find myself. Perhaps someone here will be able to assist me:

1. How do I know that a boss fight was ended, due to either boss kill or a wipe?
I can use INSTANCE_ENCOUNTER_ENGAGE_UNIT event for the boss fight start, but I coudn't find an event for boss fight end.

2. How can I know what is the current progress within the current raid/dungeon instance the player is doing? Meaning, how many bosses were killed out of the available bosses?

Thanks in advance!
  Reply With Quote
01-18-12, 07:57 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
1. At some point the same event will fire again; this is the event used by the default UI to determine when to show or hide the boss unit frames. However, most addons that care about boss encounters (eg. boss mods) do not use this event.

Instead, every time the player enters combat (PLAYER_REGEN_DISABLED), they scan the target of the player and all party/raid members. If anyone's target is classified as a worldboss (UnitClassification API) and is in combat (UnitAffectingCombat API), then a boss encounter has begun.

When a UNIT_DIED event occurs in the combat log (COMBAT_LOG_EVENT_UNFILTERED event), if it pertains to the boss, then the boss has been killed; you could also detect this occurrence by watching UNIT_HEALTH for the bossN unit(s). If all players in the group die before the boss dies, then a wipe has occurred.

2. See the GetInstanceLockTimeRemaining and GetInstanceLockTimeRemainingEncounter API documentation.
  Reply With Quote
01-19-12, 09:34 AM   #3
Animor
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Mar 2011
Posts: 136
Thank you for your answer!

So basically I should use COMBAT_LOG_EVENT_UNFILTERED, then:
1. if boss dies before all raid, then it's a kill.
2. if all raid players die before a boss, it's a wipe.

Is that what you meant?

Two more questions:
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.
2. Won't it be very CPU demanding to wait for "COMBAT_LOG_EVENT_UNFILTERED"?
  Reply With Quote
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
01-19-12, 08:25 PM   #5
Animor
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Mar 2011
Posts: 136
Thank you for your thorough answer!
  Reply With Quote
01-22-12, 02:13 AM   #6
Animor
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Mar 2011
Posts: 136
I'm sorry for the double post earlier, my bad.

I've checked the two functions GetInstanceLockTimeRemaining() and GetInstanceLockTimeRemainingEncounter(), and unfortunately they return valid result when a player is about to be saved to a partially done instance. If I just run them mid-raid, they return "0" for completed/dead bosses.

I thought of using GetSavedInstanceInfo, but this won't work for LFR or LFG instances.

If anyone knows a valid way to get current instance progress, I would be happy to get some help here.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Raid/dungeons event and data


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off