• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

GlobalEvent [TFS 1.x] Custom raid system in lua

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,684
Solutions
127
Reaction score
2,129
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:
hey nice alot, we can edit this to work like: ferumbras only 1x per month, if he spawned today only will chance to spawn after 30 days?
 
Hi,
I used this script on TFS 1.4.2 but already spawn duplicate.
In one place sometimes have 4 - 10 bossess :(
 
Back
Top