-- in creaturescripts.xml add:
-- <event type="kill" name="BossKill" script="BossKill.lua" />
-- in login.lua add:
-- player:registerEvent("BossKill")
local teleportToPosition = Position(1000, 1000, 7)
local teleportCreatePosition = Position(2000, 2000, 7)
local bossName = "boss monster"
local killMessage = "You have killed Boss Monster! A teleport has been created but it will disappear in 5 minutes!"
-- Function that will remove the teleport after a given time
local function removeTeleport(position)
local teleportItem = Tile(position):getItemById(1387)
if teleportItem then
teleportItem:remove()
position:sendMagicEffect(CONST_ME_POFF)
end
end
function onKill(creature, target)
if target:isPlayer() or target:getMaster() or target:getName():lower() ~= bossName then
return true
end
local position = target:getPosition()
position:sendMagicEffect(CONST_ME_TELEPORT)
local item = Game.createItem(1387, 1, teleportCreatePosition)
if item:isTeleport() then
item:setDestination(teleportToPosition)
end
target:say(killMessage, TALKTYPE_MONSTER_SAY, 0, 0, position)
-- Remove portal after 5 minutes
addEvent(removeTeleport, 5 * 60 * 1000, position)
return true
end