local objectId = 1487 -- ID del objeto que se creará
local area = {
{x = pos.x - 3, y = pos.y - 3, z = pos.z},
{x = pos.x + 3, y = pos.y + 3, z = pos.z}
}
local function removeObject(creature)
local remove = false
for x = area[1].x, area[2].x do
for y = area[1].y, area[2].y do
local tile = Tile(x, y, area[1].z)
if tile then
for i = 1, #tile:getItems() do
local item = tile:getItem(i)
if item and item:getId() == objectId then
item:remove()
remove = true
end
end
end
end
end
end
local function checkHealth(creature)
if creature:getHealth() <= creature:getMaxHealth() * 0.9 and creature:getHealth() > creature:getMaxHealth() * 0.6 then
onCastSpell(creature, 0)
elseif creature:getHealth() <= creature:getMaxHealth() * 0.6 and creature:getHealth() > creature:getMaxHealth() * 0.3 then
onCastSpell(creature, 0)
elseif creature:getHealth() <= creature:getMaxHealth() * 0.3 then
onCastSpell(creature, 0)
end
end
function onCastSpell(creature, variant)
local pos = creature:getPosition()
for x = area[1].x, area[2].x do
for y = area[1].y, area[2].y do
local tile = Tile(x, y, area[1].z)
if tile then
local item = Game.createItem(objectId, 1, tile:getPosition())
if item then
item:setActionId(1000)
end
end
end
end
creature:registerEvent("removeObject")
creature:registerEvent("checkHealth")
return true
end
Put in your Bossmonster.xml
<script>
<event name="removeObject"/>
<event name="checkHealth"/>
</script>