2

I've just started learning to make wow addons. I haven't learned lua much yet but I am trying to make one now. and I can make a simple thing that check whether I get into combat or leave combat like following.

local f = CreateFram("Frame")
f:RegisterEvent("PLAYER_REGEN_DISABLED")
f:RegisterEvent("PLAYER_REGEN_ENABLED")

f:SetScript("OnEvent", function(self, event, ...)
   if event == "PLAYER_REGEN_DISABLED" then
          print("You are in combat")
   end
   if event == "PLAYER_REGEN_ENABLED" then
          print("You've left combat")
   end
end)

My question is "How do you do this on someone else"? I'd like to check enemy players in battleground whether anyone of them left combat during the game. How do you get event from enemy players?

Jin kim
  • 155
  • 1
  • 2
  • 8

1 Answers1

1

With UNIT_COMBAT you can check when an enemy enters combat.

With a combination of UNIT_HEALTH and UnitAffectingCombat you can check for his leave.

Youka
  • 2,646
  • 21
  • 33
  • Thank you, and how do I find unitid of that player? could you explain a little bit more? – Jin kim Jul 29 '15 at 21:41
  • Just read the event references, first argument is in both cases [unitid](http://wowwiki.wikia.com/API_TYPE_UnitId) and with [UnitName](http://wowwiki.wikia.com/API_UnitName) you get the real name. You just have to filter. – Youka Jul 30 '15 at 07:16