local c = {
[90] = {count = 2, name = "demon", storage = 90},
[50] = {count = 3, name = "demon", storage = 50},
[20] = {count = 5, name = "demon", storage = 20},
}
Boss = {}
local bossName = "orshabaal"
local function percentage(n, p)
return math.ceil((n * p) / 100)
end
local function getHealthPercent(maxhealth, currenthealth)
for perc, tble in pairs(c) do
if percentage(maxhealth, perc) <= currenthealth and not Boss[tble.storage] then
return tble
end
end
return nil
end
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if creature and creature:getName():lower() == bossName then
local health = creature:getHealth()
if health <= 0 then
Boss = {}
else
local t = getHealthPercent(creature:getMaxHealth(), health)
if t then
for i = 1, t.count do
doConvinceCreature(doSummonCreature(t.name, creature:getPosition()), creature:getId())
Boss[t.storage] = 1
end
end
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end