-- Configuration
local monsterName = "Dragon"
local teleportPosition = Position(2500, 2500, 7)
local destinationPosition = Position(2500, 2505, 7)
local teleportItemId = 1949 -- ID of the teleport item
local removalDelay = 1 * 60 * 1000 -- 1 minutes in milliseconds
local function removeTeleport(position)
local tile = Tile(position)
if tile then
local teleport = tile:getItemById(teleportItemId)
if teleport then
teleport:remove()
end
end
end
local function createTeleport(position, destination, delay)
local tile = Tile(position)
if tile then
local teleport = Game.createItem(teleportItemId, 1, position)
if teleport then
teleport:setDestination(destination)
-- Schedule removal of the teleport
addEvent(removeTeleport, delay, position)
end
end
end
local dragonDeath = CreatureEvent("DragonDeath")
function dragonDeath.onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
if creature:getName():lower() == monsterName:lower() then
createTeleport(teleportPosition, destinationPosition, removalDelay)
end
return true
end
dragonDeath:register()