local config = {
firstboss = "scarlett etzel",
lowx = 33385,
lowy = 32638,
hix = 33406,
hiy = 32660,
z = 6,
topleft = -1, --Position(config.lowx, config.lowy, config.z),
bossPosition = Position(33396, 32641, 6),
centerRoom = Position(33364, 31318, 9), -- Center Room
exitPosition = Position(33396, 32668, 6),--Position(33297, 31285, 9)
newPosition = Position(33396, 32657, 6), -- Entrance to Boss Room
rangeX = -1, -- hix - lowx
rangeY = -1, -- hiy - lowy
time = 15, -- time in minutes to remove the player
leverspots = 5,
leverpos = {
Position(33396, 32661, 6),
Position(33395, 32662, 6),
Position(33397, 32662, 6),
Position(33396, 32662, 6),
Position(33396, 32663, 6),
}
}
local function clearRoom()
local spectators, spectator = Game.getSpectators(config.topleft, false, false, 0, config.rangeX, 0, config.rangeY)
for i = 1, #spectators do
spectator = spectators[i]
if spectator:isPlayer() and spectator.uid == playerId then
spectator:teleportTo(config.exitPosition)
exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
end
if spectator:isMonster() then
spectator:remove()
end
end
end
local function kick(playerid, topleft, exit)
local player = Player(playerid)
local position = player:getPosition()
if position.z ~= config.z then
return false
end
if position.x > config.lowx and position.x < config.hix then
if position.y > config.lowy and position.y < config.hiy then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You've exceeded your timelimit..")
player:teleportTo(config.exitPosition)
return true
end
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
config.topleft = Position(config.lowx, config.lowy, config.z)
config.rangeX = config.hix - config.lowx
config.rangeY = config.hiy - config.lowy
if item.itemid == 36319 then
if player:getPosition() ~= config.leverpos[1] then
player:say("You must be on the platform to pull this lever.", TALKTYPE_MONSTER_SAY)
return true
end
end
if item.itemid == 36319 then
-- Check if someone is currently in room
local specs, spec = Game.getSpectators(config.topleft, false, false, 0, config.rangeX, 0, config.rangeY)
for i = 1, #specs do
spec = specs[i]
if spec:isPlayer() then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There's someone fighting with Scarlett already.")
return false
end
end
-- Check if party is all off exhaust
local acceptable = true
local lvl = false
for i = 1, #config.leverpos do
local playerTile = Tile(config.leverpos[i]):getTopCreature()
if playerTile and playerTile:isPlayer() then
local timer = playerTile:getStorageValue(Storage.ScarlettTimer)
local timer2 = playerTile:getStorageValue(Storage.UrmaTimer)
if timer > os.time() or timer2 > os.time() then
local diff = timer - os.time()
local diff2 = timer - os.time()
if diff2 > diff then diff = diff2 end -- Uses the 2nd timer if it's higher
local minutes = math.floor(diff/60)
playerTile:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait " .. minutes .. " minutes to face Scarlett Etzel again.")
acceptable = false
end
if playerTile:getLevel() < 250 then
playerTile:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to be above level 250.")
acceptable = false
lvl = true
end
end
end
if acceptable == true then
clearRoom()
local monster = Game.createMonster(config.firstboss, config.bossPosition)
Game.setStorageValue(GlobalStorage.Bosses.Scarlett, 1)
for i = 1, #config.leverpos do
local playerTile = Tile(config.leverpos[i]):getTopCreature()
if playerTile and playerTile:isPlayer() then
playerTile:getPosition():sendMagicEffect(CONST_ME_POFF)
playerTile:teleportTo(config.newPosition)
playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
playerTile:setStorageValue(Storage.ScarlettTimer, os.time() + 2 * 3600)
playerTile:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have " ..
config.time .. " minutes to face Scarlett Etzel.")
addEvent(kick, config.time * 60 * 1000, playerTile:getId(), config.exitPosition)
end
end
--addEvent(clearOberonRoom, 60 * config.time * 1000, player:getId(), config.centerRoom, config.rangeX, config.rangeY, config.exitPosition)
else
if lvl == true then
player:say("Someone in your party is under level 250.")
else
player:say("Someone in your party faced Scarlett Etzel less than 2 hours ago.")
end
end
end
return true
end