local bconfig = {
boss = 'The Old Widow', -- BOSS Name
storagend = 9000, -- Storage Needed for kill the boss
storagday = 9001, -- Storage for limiting each player per day.
bossposition = Position(1442, 1058, 7), -- Where boss will respaw?
destination = Position(1428, 1059, 7), -- Where player will teleport at enter
exitposition = Position(1304, 1051, 7), -- Where player will teleport at kicked/exit
areacenter = Position(1436, 1059, 7), -- Center where boss will created
areascan = { -- width and height boss area
minx = 20,
maxx = 20,
miny = 20,
maxy = 20
},
timekill = 10, -- Time to kill a boss or will get kicked
timeopen = 1, -- Time to another player can enter
aidenter = 65535, -- Action ID enter tile
aidexit = 65534, -- Action ID exit tile
global = 50737, -- stores the global delay before boss can spawn again
throttle = 20 * 60 * 60 -- Setting for personal delay before player can visit again -- 20 hours
}
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Not a player')
return true
end
if item.actionid == bconfig.aidenter then
local secs = getGlobalStorageValue(bconfig.global)
local psecs = player:getStorageValue(bconfig.storagday)
if player:getStorageValue(bconfig.storagend) == -1 then
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'You cant enter now.')
player:teleportTo(fromPosition, true)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
return true
end
if psecs > os.time() then
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Back tomorrow!')
player:teleportTo(fromPosition, true)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
return true
end
if secs < os.time() then
local boss = Game.createMonster(bconfig.boss, bconfig.bossposition)
setGlobalStorageValue(bconfig.global, os.time() + (60 * bconfig.timeopen))
player:setStorageValue(bconfig.storagday, os.time() + bconfig.throttle)
player:teleportTo(bconfig.destination)
position:sendMagicEffect(CONST_ME_TELEPORT)
bconfig.destination:sendMagicEffect(CONST_ME_TELEPORT)
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Wait ' .. bconfig.timekill .. ' minutes to kill again.')
addEvent(function()
local spectators = Game.getSpectators(bconfig.areacenter, false, false, bconfig.areascan.minx, bconfig.areascan.maxx, bconfig.areascan.miny, bconfig.areascan.maxy)
for i = 1, #spectators, 1 do
if spectators[i]:isMonster() then
spectators[i]:remove()
elseif spectators[i]:isPlayer() then
exitPlayer(player)
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Time finished.')
end
end
end, (60 * 1000) * bconfig.timekill)
else
local remain = secs - os.time()
local minutes = string.format("%d", math.floor(remain/60))
local seconds = string.format("%d", remain-(math.floor(remain/60)*60))
player:teleportTo(fromPosition, true)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'The portal will open in' .. minutes .. ' minute(s) and ' .. seconds .. ' second(s).')
end
elseif item.actionid == bconfig.aidexit then
exitPlayer(player)
end
return true
end
function exitPlayer(player)
player:setStorageValue(bconfig.storagend, -1)
player:teleportTo(bconfig.exitposition)
bconfig.exitposition:sendMagicEffect(CONST_ME_TELEPORT)
end