Advertisement
NonSequitur

Untitled

Feb 3rd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. if not warzoneConfig then
  2.     warzoneConfig = {
  3.         -- Warzone 1
  4.         [1050] = {
  5.             center = Position(33116, 31957, 11),
  6.             rangeX = 18, rangeY = 14,
  7.  
  8.             boss = "Gnomevil",
  9.             teleportTo = Position(x, y, z),
  10.             locked = false,
  11.  
  12.             storage = 15151,
  13.             interval = 10 * 60 * 60,
  14.  
  15.             exit = Position(x, y, z)
  16.         }
  17.     }
  18.  
  19.     warzoneConfig.findByName = function(name, last)
  20.         local i, v = next(warzoneConfig, last)
  21.         if type(v) == 'table' and v.boss == name then
  22.             return v
  23.         elseif not i then
  24.             return nil
  25.         end
  26.         return warzoneConfig.findByName(name, i)
  27.     end
  28. end
  29.  
  30. local function filter(list, f, i)
  31.     if i < #list then
  32.         if f(list[i]) then
  33.             return list[i], filter(list, f, i + 1)
  34.         else
  35.             return filter(list, f, i + 1)
  36.         end
  37.     elseif f(list[i]) then
  38.         return list[i]
  39.     end
  40. end
  41.  
  42. function onStepIn(creature, item, pos, fromPosition)
  43.     if not creature:isPlayer() then
  44.         creature:teleportTo(fromPosition)
  45.         return false
  46.     end
  47.  
  48.     local info = warzoneConfig[item:getActionId()]
  49.     if not info then
  50.         return false
  51.     end
  52.  
  53.     if  creature:getStorageValue(info.storage) > os.time() then
  54.         creature:sendTextMessage(MESSAGE_INFO_DESCR, "You have already cleared this warzone in the last ten hours.")
  55.         creature:teleportTo(fromPosition)
  56.         return false
  57.     end
  58.  
  59.     if info.locked then
  60.         creature:sendTextMessage(MESSAGE_INFO_DESCR, "Please, wait a minute until the room is cleared.")
  61.         creature:teleportTo(fromPosition)
  62.         return false
  63.     end
  64.  
  65.     creature:teleportTo(info.teleportTo)
  66.     local spectators = Game.getSpectators(info.center, false, false, 0, info.rangeX, 0, info.rangeY)
  67.     if not filter(spectators, function(c) return c:isMonster() end, 1) then
  68.         local boss = Game.createMonster(info.boss, info.center)
  69.         boss:registerEvent('WarzoneBossDeath')
  70.     end
  71.  
  72.     return true
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement