Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not warzoneConfig then
- warzoneConfig = {
- -- Warzone 1
- [1050] = {
- center = Position(33116, 31957, 11),
- rangeX = 18, rangeY = 14,
- boss = "Gnomevil",
- teleportTo = Position(x, y, z),
- locked = false,
- storage = 15151,
- interval = 10 * 60 * 60,
- exit = Position(x, y, z)
- }
- }
- warzoneConfig.findByName = function(name, last)
- local i, v = next(warzoneConfig, last)
- if type(v) == 'table' and v.boss == name then
- return v
- elseif not i then
- return nil
- end
- return warzoneConfig.findByName(name, i)
- end
- end
- local function filter(list, f, i)
- if i < #list then
- if f(list[i]) then
- return list[i], filter(list, f, i + 1)
- else
- return filter(list, f, i + 1)
- end
- elseif f(list[i]) then
- return list[i]
- end
- end
- function onStepIn(creature, item, pos, fromPosition)
- if not creature:isPlayer() then
- creature:teleportTo(fromPosition)
- return false
- end
- local info = warzoneConfig[item:getActionId()]
- if not info then
- return false
- end
- if creature:getStorageValue(info.storage) > os.time() then
- creature:sendTextMessage(MESSAGE_INFO_DESCR, "You have already cleared this warzone in the last ten hours.")
- creature:teleportTo(fromPosition)
- return false
- end
- if info.locked then
- creature:sendTextMessage(MESSAGE_INFO_DESCR, "Please, wait a minute until the room is cleared.")
- creature:teleportTo(fromPosition)
- return false
- end
- creature:teleportTo(info.teleportTo)
- local spectators = Game.getSpectators(info.center, false, false, 0, info.rangeX, 0, info.rangeY)
- if not filter(spectators, function(c) return c:isMonster() end, 1) then
- local boss = Game.createMonster(info.boss, info.center)
- boss:registerEvent('WarzoneBossDeath')
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement