local monsters = {
["urso"] = {
chance = 10,
elites = {
{
name = "Urso Enfurecido",
effect = CONST_ME_TELEPORT,
skullType = SKULL_GREEN,
healthMultiplier = 1.2,
speedBonus = 10
},
{
name = "Urso Faminto",
effect = CONST_ME_TELEPORT,
skullType = SKULL_RED,
healthMultiplier = 1.5,
speedBonus = 20
},
}
},
["anão"] = {
chance = 10,
elites = {
{
name = "Anão Estressado",
effect = CONST_ME_TELEPORT,
skullType = SKULL_GREEN,
healthMultiplier = 1.2,
speedBonus = 10
},
{
name = "Anão Furioso",
effect = CONST_ME_TELEPORT,
skullType = SKULL_RED,
healthMultiplier = 1.5,
speedBonus = 20
},
}
},
["besouro roxo"] = {
chance = 10,
elites = {
{
name = "besouro roxo irritado",
effect = CONST_ME_TELEPORT,
skullType = SKULL_GREEN,
healthMultiplier = 1.2,
speedBonus = 10
},
{
name = "besouro roxo furioso",
effect = CONST_ME_TELEPORT,
skullType = SKULL_RED,
healthMultiplier = 1.5,
speedBonus = 20
},
}
}
}
local eliteNames = {}
for _, group in pairs(monsters) do
for _, elite in ipairs(group.elites) do
eliteNames[elite.name:lower()] = true
end
end
local function applyEliteAttributes(uid, elite)
local monster = Monster(uid)
if not monster then return end
monster:setSkull(elite.skullType)
if elite.healthMultiplier and elite.healthMultiplier > 1 then
local maxHealth = monster:getMaxHealth()
monster:setMaxHealth(maxHealth * elite.healthMultiplier)
monster:addHealth(monster:getMaxHealth())
end
if elite.speedBonus and elite.speedBonus ~= 0 then
monster:changeSpeed(elite.speedBonus)
end
end
local function spawnCreatureWithSkullAndAttributes(elite, position)
local monster = Game.createMonster(elite.name, position, true, true)
if monster then
addEvent(applyEliteAttributes, 100, monster:getId(), elite)
end
end
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
if not creature:isMonster() then
return true
end
local creatureName = creature:getName():lower():match("^%s*(.-)%s*$")
if eliteNames[creatureName] then
local player = nil
if killer and killer:isPlayer() then
player = killer
elseif mostDamageKiller and mostDamageKiller:isPlayer() then
player = mostDamageKiller
end
if player then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Você recebeu bônus de experiência por derrotar um Elite!")
end
return true
end
local group = monsters[creatureName]
if group and math.random(100) <= group.chance then
local elite = group.elites[math.random(#group.elites)]
local position = creature:getPosition()
position:sendMagicEffect(elite.effect)
addEvent(spawnCreatureWithSkullAndAttributes, 333, elite, position)
-- Enviar mensagem de bônus de experiência para o matador
if killer and killer:isPlayer() then
killer:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Criatura de Elite Apareceu!")
elseif mostDamageKiller and mostDamageKiller:isPlayer() then
mostDamageKiller:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Criatura de Elite Apareceu!")
end
end
return true
end