View Single Post
10-14-20, 08:36 AM   #5
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
I have some prototype code. Right now, it reports everyone.
Lua Code:
  1. local DeathCounter,DeathData,PlayerGUID=CreateFrame("Frame"),{},UnitGUID("player");
  2. DeathCounter:RegisterEvent("GROUP_ROSTER_UPDATE");
  3. DeathCounter:SetScript("OnEvent",function(self,event,unit)
  4.     if event=="GROUP_ROSTER_UPDATE" then
  5.         if IsInRaid(LE_PARTY_CATEGORY_HOME) and not IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then--    Check for raid, but not battleground
  6.             for guid in next,DeathData do-- Remove members when they leave
  7.                 if guid~=PlayerGUID and not IsGUIDInGroup(guid) then
  8.                     DeathData[guid]=nil;--  Cleanup if no longer in group
  9.                 end
  10.             end
  11.             self:RegisterEvent("UNIT_HEALTH");--    Activate death watch (doesn't matter if it's already active)
  12.         else--  No longer in a valid group
  13.             table.wipe(DeathData);--    Clear all raid members
  14.             self:UnregisterEvent("UNIT_HEALTH");--  Deactivate death watch (saves performance)
  15.         end
  16.     elseif event=="UNIT_HEALTH" then
  17.         local guid,dead=UnitGUID(unit),UnitIsDead(unit);
  18.         if guid==PlayerGUID or IsGUIDInGroup(guid) then
  19.             local data=DeathData[guid]; if data then
  20.                 if dead and not data.WasDead then-- TLDR: Did unit just die?
  21.                     data.Deaths=data.Deaths+1;--    Increment deaths
  22.                     if UnitIsGroupLeader("player") or UnitIsGroupAssistant("player") then-- Can't send RAID_WARNING if not either of these
  23.                         SendChatMessage(("DeathCounter: %s has died %d time(s) so far."):format(UnitName(unit),data.Deaths),"RAID_WARNING");
  24.                     end
  25.                 end
  26.                 data.WasDead=dead;--    Update living state
  27.             else DeathData[guid]={WasDead=dead,Deaths=0}; end-- Using the first health update to initialize data (if they join while dead, it doesn't count)
  28.         end
  29.     end
  30. end);



PS: I may be one of those.
All I can say is I make the other casters go...
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 10-17-20 at 06:01 AM.
  Reply With Quote