Bom dia, teste assim:
ferumbras_lever
local config = AscendingFerumbrasConfig
local function clearFerumbrasRoom()
local spectators = Game.getSpectators(config.bossPos, false, false, 20, 20, 20, 20)
for i = 1, #spectators do
local spectator = spectators[i]
if spectator:isPlayer() then
spectator:teleportTo(config.exitPosition)
spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
spectator:say("Time out! You were teleported out by strange forces.", TALKTYPE_MONSTER_SAY)
elseif spectator:isMonster() then
spectator:remove()
end
end
end
local ferumbrasAscendantLever = Action()
function ferumbrasAscendantLever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 8911 then
if player:getPosition() ~= config.leverPos then
return true
end
for x = 33269, 33271 do
for y = 31477, 31481 do
local playerTile = Tile(Position(x, y, 14)):getTopCreature()
if playerTile and playerTile:isPlayer() then
if not playerTile:canFightBoss("Ferumbras Mortal Shell") then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You or a member in your team have to wait %d days to face Ferumbras again!", config.days))
item:transform(8912)
return true
end
end
end
end
local specs, spec = Game.getSpectators(config.centerRoom, false, false, 15, 15, 15, 15)
for i = 1, #specs do
spec = specs[i]
if spec:isPlayer() then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There's someone fighting with Ferumbras.")
return true
end
end
local spectators = Game.getSpectators(config.bossPos, false, false, 15, 15, 15, 15)
for i = 1, #spectators do
local spectator = spectators[i]
if spectator:isMonster() then
spectator:remove()
end
end
for x = 33269, 33271 do
for y = 31477, 31481 do
local playerTile = Tile(Position(x, y, 14)):getTopCreature()
if playerTile and playerTile:isPlayer() then
playerTile:getPosition():sendMagicEffect(CONST_ME_POFF)
playerTile:teleportTo(config.newPos)
playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
playerTile:setBossCooldown("Ferumbras Mortal Shell", os.time() + config.days * 24 * 3600)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have %d minutes to kill and loot this boss. Otherwise you will lose that chance and will be kicked out.", config.time))
addEvent(clearFerumbrasRoom, config.time * 60 * 1000, player:getId(), config.centerRoom, config.range, config.range, config.exitPosition)
for b = 1, config.maxSummon do
local xrand = math.random(-4, 4)
local yrand = math.random(-4, 4)
local position = Position(33392 + xrand, 31473 + yrand, 14)
if not Game.createMonster(config.summonName, position) then
logger.error("[ferumbrasAscendantLever.onUse] can't create monster {}, on position {}", config.summonName, position:toString())
end
end
Game.createMonster(config.bossName, config.bossPos, true, true)
item:transform(8912)
end
end
end
elseif item.itemid == 8912 then
item:transform(8911)
return true
end
end
ferumbrasAscendantLever:uid(1021)
ferumbrasAscendantLever:register()
rift_invader_death
local crystals = {
[1] = { fromPosition = Position(33389, 31467, 14), toPosition = Position(33391, 31469, 14), crystalPosition = Position(33390, 31468, 14), globalStorage = GlobalStorage.FerumbrasAscendant.Crystals.Crystal1 },
[2] = { fromPosition = Position(33393, 31467, 14), toPosition = Position(33395, 31469, 14), crystalPosition = Position(33394, 31468, 14), globalStorage = GlobalStorage.FerumbrasAscendant.Crystals.Crystal2 },
[3] = { fromPosition = Position(33396, 31470, 14), toPosition = Position(33398, 31472, 14), crystalPosition = Position(33397, 31471, 14), globalStorage = GlobalStorage.FerumbrasAscendant.Crystals.Crystal3 },
[4] = { fromPosition = Position(33396, 31474, 14), toPosition = Position(33398, 31476, 14), crystalPosition = Position(33397, 31475, 14), globalStorage = GlobalStorage.FerumbrasAscendant.Crystals.Crystal4 },
[5] = { fromPosition = Position(33393, 31477, 14), toPosition = Position(33395, 31479, 14), crystalPosition = Position(33394, 31478, 14), globalStorage = GlobalStorage.FerumbrasAscendant.Crystals.Crystal5 },
[6] = { fromPosition = Position(33389, 31477, 14), toPosition = Position(33391, 31479, 14), crystalPosition = Position(33390, 31478, 14), globalStorage = GlobalStorage.FerumbrasAscendant.Crystals.Crystal6 },
[7] = { fromPosition = Position(33386, 31474, 14), toPosition = Position(33388, 31476, 14), crystalPosition = Position(33387, 31475, 14), globalStorage = GlobalStorage.FerumbrasAscendant.Crystals.Crystal7 },
[8] = { fromPosition = Position(33386, 31470, 14), toPosition = Position(33388, 31472, 14), crystalPosition = Position(33387, 31471, 14), globalStorage = GlobalStorage.FerumbrasAscendant.Crystals.Crystal8 },
}
local config = AscendingFerumbrasConfig
local riftInvaderDeath = CreatureEvent("RiftInvaderDeath")
function riftInvaderDeath.onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
local pos = Position(33392 + math.random(-4, 4), 31473 + math.random(-4, 4), 14)
local name = creature:getName():lower()
if name ~= "rift invader" then
return true
end
Game.createMonster(name, pos)
for i = 1, #crystals do
local crystal = crystals[i]
if creature:getPosition():isInRange(crystal.fromPosition, crystal.toPosition) then
if Game.getStorageValue(crystal.globalStorage) > 6 then
local item = Tile(crystal.crystalPosition):getItemById(14955)
if not item then
return true
end
item:transform(14961)
Game.setStorageValue(GlobalStorage.FerumbrasAscendant.Crystals.AllCrystals, Game.getStorageValue(GlobalStorage.FerumbrasAscendant.Crystals.AllCrystals) + 1)
end
if Game.getStorageValue(GlobalStorage.FerumbrasAscendant.Crystals.AllCrystals) == 8 then
local creature = Tile(config.bossPos):getTopCreature()
if creature then
creature:say("NOOOOOOOOOOO!", TALKTYPE_MONSTER_YELL)
creature:say("FERUMBRAS BURSTS INTO SOUL SPLINTERS!", TALKTYPE_MONSTER_YELL, nil, nil, Position(33392, 31475, 14))
creature:remove()
end
for a = 1, #crystals do
local crystalEffect = crystals[a]
crystalEffect.crystalPosition:sendMagicEffect(CONST_ME_FERUMBRAS)
Game.createMonster("Ferumbras Soul Splinter", Position(33392, 31473, 14), false, true)
end
end
Game.setStorageValue(crystal.globalStorage, Game.getStorageValue(crystal.globalStorage) + 1)
lasthitkiller:say("The negative energy of the rift creature is absorbed by the crystal!", TALKTYPE_MONSTER_SAY, nil, nil, crystal.crystalPosition)
lasthitkiller:say("ARGH!", TALKTYPE_MONSTER_SAY, nil, nil, Position(33392, 31473, 14))
end
end
local pool = Tile(creature:getPosition()):getItemById(2886)
if pool then
pool:remove()
end
local vortex = Game.createItem(config.vortex, 1, creature:getPosition())
if vortex then
addEvent(function(creaturePos)
local tile = Tile(creaturePos)
if tile then
local vortexItem = tile:getItemById(config.vortex)
if vortexItem then
vortexItem:remove(1)
end
end
end, 10 * 1000, creature:getPosition())
end
return true
end
riftInvaderDeath:register()
Vortex:
local vortex = MoveEvent()
local config = AscendingFerumbrasConfig
function vortex.onStepIn(creature, item, position, fromPosition)
local monster = creature:getMonster()
if not monster or monster:getName():lower() ~= "ferumbras essence" then
return true
end
monster:remove()
position:sendMagicEffect(CONST_ME_POFF)
local essenceCount = Game.getStorageValue(GlobalStorage.FerumbrasAscendant.FerumbrasEssence)
if essenceCount < 0 then
essenceCount = 0
end
Game.setStorageValue(GlobalStorage.FerumbrasAscendant.FerumbrasEssence, essenceCount + 1)
if essenceCount + 1 >= 8 then
Game.createMonster("Destabilized Ferumbras", config.bossPos, true, true)
for i = 1, config.maxSummon do
local summonPos = Position(math.random(33381, 33403), math.random(31462, 31483), 14)
if not Game.createMonster("Rift Fragment", summonPos, true, true) then
print(string.format("Error: Could not create Rift Fragment at position %s", summonPos))
end
end
end
return true
end
vortex:type("stepin")
vortex:id(config.vortex)
vortex:register()