- Joined
- Sep 7, 2015
- Messages
- 2,685
- Solutions
- 127
- Reaction score
- 2,133
Just basic raid system, bosses and normal raids fromPos, toPos. It will check if boss is already spawned and won't spawn duplicate.
Code:
local raids = {
-- Bosses
[1] = {type = 'BOSS', position = Position(32960, 32075, 6), 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},
}
local spawnedBosses = {}
local function isSpawned(name)
for i = 1, #spawnedBosses do
local monster = Monster(spawnedBosses[i])
if monster and monster:getName():lower() == name then
return true
else
spawnedBosses[i] = nil
end
end
return false
end
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
if not isSpawned(table.monster:lower()) then
local boss = Game.createMonster(table.monster, table.position, true, false)
if boss then
spawnedBosses[#spawnedBosses + 1] = boss:getId()
end
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
Last edited by a moderator: