View Single Post
10-10-14, 06:46 AM   #5
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Here's a dry-coded example, so I have no idea if it works.
Lua Code:
  1. -- todo: Track that someone in the raid is actually capable of battle rezzing and alive
  2. local WhoDead, SecondsPerRez, ElapsedTime, NumRezzed = {}, 1, 0, 0
  3. local f = CreateFrame('frame') f:Hide()
  4. f:SetScript('OnEvent', function(self, event, ...) return self[event] and self[event](self, ...) end)
  5.  
  6. function f:ENCOUNTER_START(encounterID, encounterName, difficultyID, raidSize)
  7.     if difficultyID < 3 then return end
  8.     wipe(WhoDead)
  9.     SecondsPerRez, ElapsedTime, NumRezzed = 5400 / raidSize, 0, 0
  10.     self:RegisterEvent('INCOMING_RESURRECT_CHANGED')
  11.     self:Show()
  12. end
  13. f:RegisterEvent('ENCOUNTER_START')
  14.  
  15. function f:ENCOUNTER_END()
  16.     self:Hide()
  17.     self:UnregisterEvent('INCOMING_RESURRECT_CHANGED')
  18. end
  19. f:RegisterEvent('ENCOUNTER_END')
  20.  
  21. function f:INCOMING_RESURRECT_CHANGED(unit) -- Track who has received a rez within range
  22.     local name = UnitName(unit)
  23.     if name and not WhoDead[name] and UnitHasIncomingResurrection(unit) then
  24.         WhoDead[name] = true
  25.     end
  26. end
  27.  
  28. f:SetScript('OnUpdate', function(self, elapsed)
  29.     ElapsedTime = ElapsedTime + elapsed
  30.    
  31.     for name in pairs(WhoDead) do
  32.         if not UnitIsDeadOrGhost(name) and UnitIsConnected(name) then -- Dead unit is no longer dead
  33.             WhoDead[name] = nil
  34.             NumRezzed = NumRezzed + 1
  35.         end
  36.     end
  37.    
  38.     local availableRezzes = 1 + floor(ElapsedTime / SecondsPerRez) - NumRezzed
  39.     -- Do something to display this number somewhere..
  40. end)
It doesn't actually do anything with the "availableRezzes" number, so if you want this for an LDB display or something you'll need to add the appropriate code for that.

I have no idea how reincarnation is factored into the new rules, and I don't know if reincarnation or soulstones trigger an incoming rez event, so it might just be simpler to check UNIT_HEALTH to track when they've died or rezzed.

Last edited by semlar : 10-10-14 at 07:55 AM.