• 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!

[TFS 1.2] Create monsters in a range

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
Hi folks, I got stucked while I was creating a script, and I really don't know how to the fuck I'll do it.
How I create a spawnArea for up 100 monsters and on this area will have different types of monsters for example earth, water and fire. The most important thing is that cannot have fire monsters with earth monsters. Can someone help me with it?

Please check the config that I created below:

Code:
local config = {
    spawnArea = {
        fromPosition = Position(2500, 3142, 7),
        toPosition = Position(2684, 3185, 7)
    },
    monsters = {
        [1] = {"Snake", "Medusa"}, -- earth
        [2] = {"Quara Predicator", "Water Elemental"}, -- water
        [3] = {"Ghazbaran", "Morgaroth"}, -- fire
    },

    maxMonsters = 100
}

Thanks everyone.
 
Last edited:
You can try adding this to your script
Code:
function SpawnCreaturesRandomly(from, to, chance, name)
    for x = from.x, to.x do
        for y = from.y, to.y do
            for z = from.z, to.z do
                if math.random(100) == chance and creatureCheck({x, y, z}, name) then
                    Game.createMonster(name, {x, y, z})
                end
            end
        end
    end
end


function creatureCheck(pos, name)
    local count = 0
    local from = {x = pos.x - 1, y = pos.y - 1}
    local to = {x = pos.x + 1, y = pos.y + 1}
    for x = from.x, to.x do
        for y = from.y, to.y do
            local creature = getTopCreature({x, y, pos.z})
            if creature then
                if creature:getName() ~= name then
                    count = count + 1
                end
            end
        end
    end
    return count == 0
end
 
Back
Top