This code probably looks a bit better:
Lua Code:
local bossCount = 0
local bossUnitTags = {}
for i = 1, MAX_BOSSES do --global constant MAX_BOSSES = 6
bossTags[i] = "boss" .. i
end
local function OnBossesChanged()
bossCount = 0
for i, bossTag in ipairs(bossUnitTags) do
if DoesUnitExist(bossTag) then
bossCount = bossCount + 1
end
end
end
EVENT_MANAGER:RegisterForEvent("MyAddon", EVENT_BOSSES_CHANGED, OnBossesChanged)
--returns true if unit is boss
function IsUnitBoss(unitTag)
if bossCount > 0 and unitTag ~= nil then
for i, bossTag in ipairs(bossUnitTags) do
if GetUnitName(unitTag) == GetUnitName(bossTag) then
return true
end
end
end
return false
end