View Single Post
01-07-21, 09:08 AM   #3
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Lua Code:
  1. local guids = {}
  2. local f = CreateFrame("Frame")
  3.  
  4. function f:NAME_PLATE_UNIT_ADDED(unit)
  5.     guids[UnitGUID(unit)] = unit
  6. end
  7.  
  8. function f:NAME_PLATE_UNIT_REMOVED(unit)
  9.     guids[UnitGUID(unit)] = nil
  10. end
  11.  
  12. function f:COMBAT_LOG_EVENT_UNFILTERED()
  13.     local timestamp, subevent, _, sourceGUID, sourceName, sourceFlags, _, destGUID, destName, _, _, spellID, spellName = CombatLogGetCurrentEventInfo()
  14.     if subevent == "SPELL_CAST_START" then
  15.         local unit = guids[sourceGUID]
  16.         if unit and UnitIsUnit(unit.."target", "player") and bit.band(sourceFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) > 0 then
  17.             print( format("%s is casting %s on me", sourceName, GetSpellLink(spellID)) )
  18.         end
  19.     end
  20. end
  21.  
  22. f:SetScript("OnEvent", function(self, event, ...)
  23.     f[event](self, ...)
  24. end)
  25.  
  26. f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  27. f:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
  28. f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  Reply With Quote