local config = {
actionId = 5900, -- ActionID da alavanca
bossName = "Dorufin [BOSS]",
bossPosition = Position(515, 963, 7), -- Posição onde o boss aparecerá
bossArea = {
fromPos = = { 511, 960, 7 }, -- Canto superior esquerdo da sala
toPos = { 520, 966, 7 }, -- Canto inferior direito da sala
entrancePos = Position(519, 961, 7), -- Posição onde os jogadores serão teleportados
exitPosition = Position(508, 971, 7) -- Posição para onde os jogadores serão expulsos se demorar demais
},
participantsPos = {
Position(510, 974, 7), -- Jogador 1, o que deve puxar a alavanca
Position(511, 974, 7), -- Jogador 2
Position(512, 974, 7), -- Jogador 3
Position(513, 974, 7) -- Jogador 4
},
attempts = {
level = 50, -- Nível necessário para entrar
storage = 20004 , -- Storage do tempo de espera
seconds = 72000 -- 20 horas
},
kickParticipantAfterSeconds = 60 * 1, -- 15 minutos
leverIds = {1945, 1946} -- Alavanca
}
local function getSpectators()
local spectators = {}
for x = config.bossArea.fromPos[1], config.bossArea.toPos[1] do
for y = config.bossArea.fromPos[2], config.bossArea.toPos[2] do
local tile = Tile(Position(x, y, config.bossArea.fromPos[3]))
if tile then
local creature = tile:getTopCreature()
if creature and creature:isPlayer() then
table.insert(spectators, creature)
end
end
end
end
return spectators
end
function onUse(player, item, fromPosition, target, toPosition)
local participants = {}
-- Verifica os participantes nas posições definidas
for _, pos in pairs(config.participantsPos) do
local tile = Tile(pos)
if tile then
local participant = tile:getTopCreature()
if participant and participant:isPlayer() then
if participant:getLevel() < config.attempts.level then
player:sendCancelMessage("O jogador " .. participant:getName() .. " não possui o nível necessário.")
return true
elseif participant:getStorageValue(config.attempts.storage) > os.time() then
player:sendCancelMessage("O jogador " .. participant:getName() .. " precisa esperar para entrar novamente.")
return true
end
table.insert(participants, participant)
end
end
end
if #participants == 0 then
player:sendCancelMessage("Você precisa de pelo menos um participante.")
return true
end
-- Verifica se a sala está ocupada
if #getSpectators() > 0 then
player:sendCancelMessage("A sala já está ocupada. Tente mais tarde.")
return true
end
-- Remove monstros restantes da sala
for _, monster in pairs(getSpectators()) do
if not monster:isPlayer() then
monster:remove()
end
end
-- Cria o boss
local boss = Game.createMonster(config.bossName, config.bossPosition)
if not boss then
player:sendCancelMessage("Não foi possível criar o boss.")
return true
end
boss:registerEvent("bossDeath") -- Evento de morte do boss
-- Teleporta participantes e registra o tempo de espera
for _, participant in pairs(participants) do
participant:teleportTo(config.bossArea.entrancePos)
participant:setStorageValue(config.attempts.storage, os.time() + config.attempts.seconds)
end
-- Alterna a alavanca
item:transform(item:getId() == config.leverIds[1] and config.leverIds[2] or config.leverIds[1])
return true
end