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

Random Boss Room

sebbe hbk

Mapper - Hoster
Joined
Sep 1, 2009
Messages
164
Reaction score
3
Location
I ditt garage
Hello!

I came up with a idea that can be pretty usefull.

There is a teleport to a boss room. In the boss room there is a boss. Every 5min it spawns a random boss, example ghazbaran or morgaroth.
I want the script to know if the boss have not been killed during the 5min that not one more boss spawns and one more. So not the room is full with bosses.

I will repp the one that can help me with this script request :)

Mean that's what masiyah.se have?
 
Last edited by a moderator:
Solution
globalevents/scripts/random_boss.lua
Lua:
function onThink(interval)

local start = {x = 1033, y = 882, z = 5} -- the start of the area
local endd = {x = 1037, y = 886, z = 5} -- the end of the area
local monsterpos = {x = 1035, y = 884, z = 5} -- the monster spawn point

	for x = start.x, endd.x do
		for y = start.y, endd.y do
			if getTopCreature({x=x, y=y, z=start.z}).type == 2 then
				return true
			end
		end
	end	

	local m = math.random(1,3)

	if m == 1 then
		doSummonCreature("Frost Dragon", monsterpos) -- change to your bosses
	elseif m == 2 then
		doSummonCreature("Ghastly Dragon", monsterpos) -- change to your bosses
	elseif m == 3 then
		doSummonCreature("Dragon Lord", monsterpos) -- change to your bosses
	end
	return...
globalevents/scripts/random_boss.lua
Lua:
function onThink(interval)

local start = {x = 1033, y = 882, z = 5} -- the start of the area
local endd = {x = 1037, y = 886, z = 5} -- the end of the area
local monsterpos = {x = 1035, y = 884, z = 5} -- the monster spawn point

	for x = start.x, endd.x do
		for y = start.y, endd.y do
			if getTopCreature({x=x, y=y, z=start.z}).type == 2 then
				return true
			end
		end
	end	

	local m = math.random(1,3)

	if m == 1 then
		doSummonCreature("Frost Dragon", monsterpos) -- change to your bosses
	elseif m == 2 then
		doSummonCreature("Ghastly Dragon", monsterpos) -- change to your bosses
	elseif m == 3 then
		doSummonCreature("Dragon Lord", monsterpos) -- change to your bosses
	end
	return true
end
-- sizaro(at)otland.net

globalevents/globalevents.xml
XML:
<globalevent name="randomboss" interval="300000" event="script" value="random_boss.lua"/>
 
Solution
So, ive been tweaking this a little, but there is one thing i cant figure out how to do. I made it so that it spawns a monster within a random square of coordinates. But i would like the room to spawn more than 1 monster, but as soon as i change "type == 2 then" to like 3 or any number at all it just starts summoning monsters until the room is completely full, its probably easy to fix but im clueless :p
 
So, ive been tweaking this a little, but there is one thing i cant figure out how to do. I made it so that it spawns a monster within a random square of coordinates. But i would like the room to spawn more than 1 monster, but as soon as i change "type == 2 then" to like 3 or any number at all it just starts summoning monsters until the room is completely full, its probably easy to fix but im clueless :p
You just need to add a counter of some sort.
type 2, basically means that the thing found was a monster, not a player/npc
(I've never used 'type' in conjunction with creatures before, but based on the issue you received, it's a fair guess I'd imagine.)
Lua:
local monster_count = 0
for x = start.x, endd.x do
   for y = start.y, endd.y do
       if getTopCreature({x=x, y=y, z=start.z}).type == 2 then
           if monster_count < 5 then
               monster_count = monster_count + 1
           else
               return true
           end
       end
   end
end
 
use getSpectators(centerPos, rangex, rangey[, multifloor = false])
Lua:
local centerpos = {x = 1035, y = 884, z = 5}
local monsterCount = 0
local specs = getSpectators(centerpos, 7, 7)
if #specs > 0 then
    for i = 1, #specs do
        if isMonster(specs[i]) then
            if monsterCount < 5 then
                monsterCount = monsterCount + 1
            else
                return true
            end
        end
    end
end
 
So that basicalliy means that from the centerpos and a radius of 7 sqm outwards in all directions is where it will check for spawned monsters, and if the count doesnt match up, it will continue spawning? And btw @Xikini, ur fix seems to do the job for me thanks alot! I'm going to try out ur thing there static_ when i get the possibility to but does 'mounstercount' also count summons or will it ignore if i have summons on those sqms?
 
So that basicalliy means that from the centerpos and a radius of 7 sqm outwards in all directions is where it will check for spawned monsters, and if the count doesnt match up, it will continue spawning? And btw @Xikini, ur fix seems to do the job for me thanks alot! I'm going to try out ur thing there static_ when i get the possibility to but does 'mounstercount' also count summons or will it ignore if i have summons on those sqms?
yes you're correct
monstercount will count summons, if you don't want it to count summons you can use
Lua:
if isMonster(specs[i]) and not getCreatureMaster(specs[i]) then
 
So im trying to use your script now static, but i cant get it to work, i will post what it looks like currently :
Lua:
function onThink(interval)
local centerpos = {x = 32395, y = 32194, z = 7}
local monsterCount = 0
local specs = getSpectators(centerpos, 7, 7)
if #specs > 0 then
    for i = 1, #specs do
        if isMonster(specs[i]) and not getCreatureMaster(specs[i]) then
            if monsterCount < 5 then
                monsterCount = monsterCount + 1
            else
                return true
            end
        end
    end
end

    local m = math.random(1,11)
the mathrandom at the end is my pool of monsters that i want to spawn. The error i get in the console is : Gyazo - 270a8199f36b80200579c6d54312988b.png
 
So im trying to use your script now static, but i cant get it to work, i will post what it looks like currently :
Lua:
function onThink(interval)
local centerpos = {x = 32395, y = 32194, z = 7}
local monsterCount = 0
local specs = getSpectators(centerpos, 7, 7)
if #specs > 0 then
    for i = 1, #specs do
        if isMonster(specs[i]) and not getCreatureMaster(specs[i]) then
            if monsterCount < 5 then
                monsterCount = monsterCount + 1
            else
                return true
            end
        end
    end
end

    local m = math.random(1,11)
the mathrandom at the end is my pool of monsters that i want to spawn. The error i get in the console is : Gyazo - 270a8199f36b80200579c6d54312988b.png
Lua:
local centerpos = {x = 32395, y = 32194, z = 7}

function onThink(interval)
    local monsterCount = 0
    local maxMonsters = math.random(11)
    local specs = getSpectators(centerpos, 7, 7)
    if specs and #specs > 0 then
        for i = 1, #specs do
            if isMonster(specs[i]) and not getCreatureMaster(specs[i]) then
                if monsterCount < maxMonsters then
                    monsterCount = monsterCount + 1
                    -- spawn monster here
                else
                    return true
                end
            end
        end
    end
    return true
end
 
Im usining TFS 1.2, doesnt say a rev anywhere as far as i can see though. About the script, there are no more errors but it doesnt seem to spawn any monsters at all.
Lua:
local centerpos = {x = 32395, y = 32194, z = 7}

function onThink(interval)
    local monsterCount = 0
    local maxMonsters = 11
    local specs = getSpectators(centerpos, 7, 7)
    if specs and #specs > 0 then
        for i = 1, #specs do
            if isMonster(specs[i]) and not getCreatureMaster(specs[i]) then
                if monsterCount < maxMonsters then
                    monsterCount = monsterCount + 1
                    -- spawn monster here
                else
                    return true
                end
            end
        end
    end
    return true
end

    local m = math.random(1,11)

    if m == 1 then
        doSummonCreature("Rotworm", centerpos)
    elseif m == 2 then
        doSummonCreature("Bug", centerpos)
    elseif m == 3 then
        doSummonCreature("Wasp", centerpos)
    elseif m == 4 then
        doSummonCreature("Valkyrie", centerpos)
    elseif m == 5 then
        doSummonCreature("Mutated Human", centerpos)
    elseif m == 6 then
        doSummonCreature("Slime", centerpos)
    elseif m == 7 then
        doSummonCreature("Cave Rat", centerpos)
    elseif m == 8 then
        doSummonCreature("Cyclops Smith", centerpos)
    elseif m == 9 then
        doSummonCreature("Cyclops", centerpos)
    elseif m == 10 then
        doSummonCreature("Rotworm", centerpos)
    elseif m == 11 then
        doSummonCreature("Rat", centerpos)
    end
    return true

That is the current look in all its glory. My idea for it is to randomly in that 14 x 14 area spawn any of those monsters above until a certain cap is reached, if anything dies it should automatically spawn until the cap is reached once again. Sorry if im being annoying with all my problems.
 
Im usining TFS 1.2, doesnt say a rev anywhere as far as i can see though. About the script, there are no more errors but it doesnt seem to spawn any monsters at all.
Lua:
local centerpos = {x = 32395, y = 32194, z = 7}

function onThink(interval)
    local monsterCount = 0
    local maxMonsters = 11
    local specs = getSpectators(centerpos, 7, 7)
    if specs and #specs > 0 then
        for i = 1, #specs do
            if isMonster(specs[i]) and not getCreatureMaster(specs[i]) then
                if monsterCount < maxMonsters then
                    monsterCount = monsterCount + 1
                    -- spawn monster here
                else
                    return true
                end
            end
        end
    end
    return true
end

    local m = math.random(1,11)

    if m == 1 then
        doSummonCreature("Rotworm", centerpos)
    elseif m == 2 then
        doSummonCreature("Bug", centerpos)
    elseif m == 3 then
        doSummonCreature("Wasp", centerpos)
    elseif m == 4 then
        doSummonCreature("Valkyrie", centerpos)
    elseif m == 5 then
        doSummonCreature("Mutated Human", centerpos)
    elseif m == 6 then
        doSummonCreature("Slime", centerpos)
    elseif m == 7 then
        doSummonCreature("Cave Rat", centerpos)
    elseif m == 8 then
        doSummonCreature("Cyclops Smith", centerpos)
    elseif m == 9 then
        doSummonCreature("Cyclops", centerpos)
    elseif m == 10 then
        doSummonCreature("Rotworm", centerpos)
    elseif m == 11 then
        doSummonCreature("Rat", centerpos)
    end
    return true

That is the current look in all its glory. My idea for it is to randomly in that 14 x 14 area spawn any of those monsters above until a certain cap is reached, if anything dies it should automatically spawn until the cap is reached once again. Sorry if im being annoying with all my problems.
i put a place for you to spawn monsters, you're doing it wrong.
this is completely out of the scope of onThink, so it won't do anything
 
Back
Top