local raids = {
-- Bosses
[1] = {type = 'BOSS', position = Position(998, 1006, 7), monster = 'demodras', message = 'Demodras has spawned', chance = 30},
[2] = {type = 'BOSS', position = Position(998, 1006, 7), monster = 'orshabaal', chance = 40},
[3] = {type = 'BOSS', position = Position(998, 1006, 7), monster = 'ferumbras', chance = 30},
-- Raids fromPos, toPos
[4] = {type = 'NORMAL', fromPos = Position(997, 1005, 7), toPos = Position(1009, 1014, 7), monsters = {'orc', 'orc Spearman', 'orc warrior'}, count = 10, message = 'orcs raid', chance = 20},
[5] = {type = 'NORMAL', fromPos = Position(997, 1005, 7), toPos = Position(1009, 1014, 7), monsters = 'demon', count = 10, message = 'demons raid', chance = 50},
}
function onThink(interval, lastExecution, thinkInterval)
local table = raids[math.random(#raids)]
if math.random(100) > table.chance then
return true
end
if table.type == 'BOSS' then
local tileCreature = Tile(table.position):getTopCreature()
if tileCreature and tileCreature:isMonster() and tileCreature:getName():lower() == table.monster then
return true
else
Game.createMonster(table.monsters, table.position, true, false)
if table.message ~= nil then
broadcastMessage(table.message, MESSAGE_EVENT_ADVANCE)
end
end
elseif table.type == 'NORMAL' then
for i = 1, table.count do
local randomPosition = Position(math.random(table.fromPos.x, table.toPos.x), math.random(table.fromPos.y, table.toPos.y), table.fromPos.z)
if type(table.monsters) == 'string' then
Game.createMonster(table.monsters, randomPosition, true, false)
else
Game.createMonster(table.monsters[math.random(#table.monsters)], randomPosition, true, false)
end
end
if table.message ~= nil then
broadcastMessage(table.message, MESSAGE_EVENT_ADVANCE)
end
end
return true
end