local bosses = {
["skeleton"] = {
teleportCreateDestination = Position(1019, 1027, 7), -- If you set this to false, the teleport will be created at the destination where the monster dies.
teleportDestination = Position(1021, 1024, 7),
teleportRemoveTime = 1, -- 1 minute
message = "You have killed the boss! The teleport will disappear in 1 minute.",
},
["bug"] = {
teleportCreateDestination = false, -- If you set this to false, the teleport will be created at the destination where the monster dies.
teleportDestination = Position(1021, 1024, 7),
teleportRemoveTime = 1, -- 1 minute(s)
message = "You have killed the boss! The teleport will disappear in 1 minute.",
},
}
local function removeTeleport(position)
local teleportItem = Tile(position):getItemById(1387)
if teleportItem then
teleportItem:remove()
position:sendMagicEffect(CONST_ME_POFF)
end
end
local event = CreatureEvent("BossKill")
function event.onKill(creature, target)
local bossName = target:getName():lower()
if not bosses[bossName] then
return true
end
local bossConfig = bosses[bossName]
local bossPosition = target:getPosition()
local teleportCreateDestination = bossConfig.teleportCreateDestination
if not teleportCreateDestination then
teleportCreateDestination = bossPosition
end
local teleport = Game.createItem(1387, 1, teleportCreateDestination)
if teleport:isTeleport() then
teleport:setDestination(bossConfig.teleportDestination)
end
teleportCreateDestination:sendMagicEffect(CONST_ME_TELEPORT)
target:say(bossConfig.message, TALKTYPE_MONSTER_SAY, 0, 0, bossPosition)
-- remove teleport
addEvent(removeTeleport, bossConfig.teleportRemoveTime * 60 * 1000, teleportCreateDestination)
return true
end
event:register()
local login = CreatureEvent("RegisterBossKill")
function login.onLogin(player)
player:registerEvent("BossKill")
return true
end
login:register()