How do I make wow add-on that check if enemy is in combat or not?

时间:2015-07-28 15:48:02

标签: lua add-on world-of-warcraft

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?

1 个答案:

答案 0 :(得分:1)

使用UNIT_COMBAT,您可以检查敌人什么时候进入战斗状态。

结合使用UNIT_HEALTHUnitAffectingCombat,您可以查看他的请假。

相关问题