• 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...
What exactly do i type in if i want it to randomly select the type then? Since its now baked into one big function, could u show me what it could look like?
 
What exactly do i type in if i want it to randomly select the type then? Since its now baked into one big function, could u show me what it could look like?
Lua:
local centerpos = {x = 32395, y = 32194, z = 7}

local monsters = {
    [1] = "Rotworm",
    [2] = "Bug",
    -- etc monsters here
}

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
                    doSummonCreature(monsters[math.random(#monsters)], centerpos)
                else
                    return true
                end
            end
        end
    end
    return true
end
just change the monsters inside of local monsters
add more, remove, w/e
 
Nothing happens when i fire that thing off sadly :/ Could it be that something in the script isnt recognized by my Tfs 1.2 or similar?
 
i never saw you said tfs 1.2
Lua:
local centerpos = Position(32395, 32194, 7)

local monsters = {
    [1] = "Rotworm",
    [2] = "Bug",
    -- etc monsters here
}

function onThink(interval)
    local monsterCount = 0
    local maxMonsters = math.random(11)
    local specs = Game.getSpectators(centerpos, false, false, 7, 7, 7, 7)
    if #specs > 0 then
        for i = 1, #specs do
            if specs[i]:isMonster() and not specs[i]:getMaster() then
                if monsterCount < maxMonsters then
                    monsterCount = monsterCount + 1
                    Game.createMonster(monsters[math.random(#monsters)], centerpos)
                else
                    return true
                end
            end
        end
    end
    return true
end
 
I really appreciate all the help you are providing, its really amazing but it still isnt doing anything, you dont happen to have the ability to test it our yourself? :)
 
i don't feel the need to test it because i know it should work.
do you have it registered to globalevents.xml?
if so, post it here
 
Yep its in globalevents.xml
XML:
<globalevent name="randomboss" interval="30000" script="random_boss.lua"/>
The file in scripts is named random_boss.lua just like its supposed to be.

Edit: i just noticed that if i spawn something inside that area (/m), then it starts summoning more but stops the moment the area gets cleared.
 
Last edited:
Yep its in globalevents.xml
XML:
<globalevent name="randomboss" interval="30000" script="random_boss.lua"/>
The file in scripts is named random_boss.lua just like its supposed to be.

Edit: i just noticed that if i spawn something inside that area (/m), then it starts summoning more but stops the moment the area gets cleared.
Code:
local centerpos = Position(32395, 32194, 7)
local maxMonsters = 10

local monsters = {
 [1] = "Rotworm",
 [2] = "Bug",
 -- etc monsters here
}

function onThink(interval)
 local monsterCount = 0
 local specs = Game.getSpectators(centerpos, false, false, 7, 7, 7, 7)
 if #specs > 0 then
  for i = 1, #specs do
   if specs[i]:isMonster() and not specs[i]:getMaster() then
    monsterCount = monsterCount + 1
   end
  end
 end
 if monsterCount < maxMonsters then
  for i = 1, (maxMonsters - monsterCount) do
   Game.createMonster(monsters[math.random(#monsters)], centerpos)
  end
 end
 return true
end
 
Back
Top