Could someone please convert this script to 0.4?
Would save my day.
Script from @Stigma
Thanks in advance.
Would save my day.
Script from @Stigma
Thanks in advance.
Lua:
-- <event type="death" name="boss death" script="filename.lua"/>
local rewardRoom = Position(x, y, z)
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified)
killer:teleportTo(rewardRoom)
rewardRoom:sendMagicEffect(CONST_ME_TELEPORT)
killer:unregisterEvent("bossroom death")
bossRoom.player = nil
bossRoom.boss = nil
return true
end
Lua:
-- <movevent event="StepIn" actionid="77745" script="filename.lua"/>
local cfg = {
destination = Position(x, y, z),
boss = {
name = "Demon",
spawnPos = Position(x, y, z)
}
}
bossRoom = {player = nil, boss = nil} -- global, accessible from other files
function onStepIn(creature, item, toPosition, fromPosition)
local player = creature:getPlayer()
if not player then
return false
end
-- there is a player still in the room
if bossRoom.player then
return false
end
local boss = Game.createMonster(cfg.boss.name, cfg.boss.spawnPos, true)
if not boss then
return false
end
player:teleportTo(cfg.destination)
cfg.destination:sendMagicEffect(CONST_ME_TELEPORT)
boss:registerEvent("boss death")
player:registerEvent("bossroom death")
bossRoom.player = player
bossRoom.boss = boss
return true
end
Lua:
-- <event type="preparedeath" name="bossroom death" script="filename.lua"/>
function onPrepareDeath(creature, killer)
bossRoom.player = nil
bossRoom.boss:remove()
bossRoom.boss = nil
return true
end