Bosses room

Mera Mero

Guess Who?
Joined
Dec 27, 2014
Messages
416
Reaction score
83
Hey there,
I wanna script to summon a boss from 1/2/3 random bosses if a player enter the room,
then if player 2 enter the room after player 1 nothing happen so the boss will be summoned in the room when first player enter ONLY and if all players leave the room,
the boss get remove from the room automatically, got it? i can explain more if you wanna.

TFS 0.4
 

Xikini

I whore myself out for likes
Joined
Nov 17, 2010
Messages
3,928
Reaction score
2,048
Untested, but should work as expected.


Lua:
-- <movevent type="StepIn" actionid="111111111111111111111111" event="script" value="boss_room_xikini.lua"/>
-- actionid needs to be placed onto the "Tile to enter boss room".

local config = {
    -- this controls where the script will check for players and monsters in your arena.
    centre_of_arena = {x = 1000, y = 1000, z = 7},
    x_range = 10,
    y_range = 10,
    -- the rest is not as important as above.
    player_teleport_position = {x = 1000, y = 1000, z = 7},
    boss_spawn_position = {x = 1000, y = 1000, z = 7},
    bosses_that_can_spawn = {"rat", "cave rat"}
}

function onStepIn(cid, item, position, fromPosition)
    if not isPlayer(cid) then
        return true
    end
    local count, creatures = 0, getSpectators(config.centre_of_arena, config.x_range, config.y_range, false)
    if #creatures > 0 then
        for _, pid in ipairs(creatures) do
            if isPlayer(pid) then
                count = count + 1
            end
        end
    end
    if count == 0 then
        if #creatures > 0 then
            for _, pid in ipairs(creatures) do
                doRemoveCreature(pid)
            end
        end
        local rand = math.random(#config.bosses_that_can_spawn)
        doCreateMonster("" .. config.bosses_that_can_spawn[rand]:lower() .. "", config.boss_spawn_position)
    end
    doTeleportThing(cid, config.player_teleport_position)
    return true
end
 
OP
Mera Mero

Mera Mero

Guess Who?
Joined
Dec 27, 2014
Messages
416
Reaction score
83
Untested, but should work as expected.


Lua:
-- <movevent type="StepIn" actionid="111111111111111111111111" event="script" value="boss_room_xikini.lua"/>
-- actionid needs to be placed onto the "Tile to enter boss room".

local config = {
    -- this controls where the script will check for players and monsters in your arena.
    centre_of_arena = {x = 1000, y = 1000, z = 7},
    x_range = 10,
    y_range = 10,
    -- the rest is not as important as above.
    player_teleport_position = {x = 1000, y = 1000, z = 7},
    boss_spawn_position = {x = 1000, y = 1000, z = 7},
    bosses_that_can_spawn = {"rat", "cave rat"}
}

function onStepIn(cid, item, position, fromPosition)
    if not isPlayer(cid) then
        return true
    end
    local count, creatures = 0, getSpectators(config.centre_of_arena, config.x_range, config.y_range, false)
    if #creatures > 0 then
        for _, pid in ipairs(creatures) do
            if isPlayer(pid) then
                count = count + 1
            end
        end
    end
    if count == 0 then
        if #creatures > 0 then
            for _, pid in ipairs(creatures) do
                doRemoveCreature(pid)
            end
        end
        local rand = math.random(#config.bosses_that_can_spawn)
        doCreateMonster("" .. config.bosses_that_can_spawn[rand]:lower() .. "", config.boss_spawn_position)
    end
    doTeleportThing(cid, config.player_teleport_position)
    return true
end
Thanks for your help, But the script didn't work and gave me an error also i can't understand it, Isn't there X,Y,Z for top left, bottom right ?
And position of the players to get out? what is the purpose for it? I don't get it. I just wanna something like e.g
A player enter the room, the boss summons randomly from X amount of bosses that already in the list, if is it too hard for him then he get out from the tp then the boss removes automatically then he enter again to summon another boss from the list.
asasa.jpg
 

Xikini

I whore myself out for likes
Joined
Nov 17, 2010
Messages
3,928
Reaction score
2,048
hmm alright.
Change 2 lines with
Lua:
if #creatures > 0 then
to this
Lua:
if creatures ~= nil then
 

heba

Veteran OT User
Joined
Aug 5, 2011
Messages
1,333
Reaction score
165
u need it like masiyah server right ?
 
OP
Mera Mero

Mera Mero

Guess Who?
Joined
Dec 27, 2014
Messages
416
Reaction score
83
u need it like masiyah server right ?
I had the idea before but i saw it at Masyiah, Right.
Then you didn't change both lines, or you didn't save / reload correctly.
Ops, I changed only one line not both of them, May you add something more? Like chance for summoning every monster? and thanks it is worked good until now ;P.
EDIT:
And can you do kicktime for this area only instead of kickingtime at config.lua? For e.g
I am using 2h kicktime so i wanna like 5 minutes only at this area.
 
Last edited:

heba

Veteran OT User
Joined
Aug 5, 2011
Messages
1,333
Reaction score
165
go create file in creaturescript and add this
Code:
local config = {
    respawnSecs = 5, -- how many seconds until next boss spawns
    storage = 50300,
    bossspawnstorage = 50320,
    fromPosition = {x=976, y=1112, z=15}, -- top left cornor of the playground
    toPosition = {x=1001, y=1124, z=15} -- bottom right cornor of the playground
}

local monsters = {'morgaroth','Massacre','Ushuriel','Zugurosh'}

local function f()
      local pos = {x = math.random(config.fromPosition.x, config.toPosition.x), y = math.random(config.fromPosition.y, config.toPosition.y), z = math.random(config.fromPosition.z, config.toPosition.z)}
        doSummonCreature(monsters[math.random(#monsters)], pos)
        doSendMagicEffect(pos,CONST_ME_TELEPORT)
    doSetStorage(config.bossspawnstorage, 0)
end

function onKill(cid, target, damage, flags)
if isMonster(target) and getCreatureMaster(target) == nil and getCreatureStorage(cid,config.storage) >= 1 then
        local s = getCreatureName(target)
        if isInArray(monsters, s:lower())  then
            addEvent(f, config.respawnSecs*1000)
           
        end
    end
    return true
end
and in creaturescript.xml add
Code:
<event type="kill" name="BossKisll" event="script" value="bosskill.lua"/>
and in login add
Code:
    registerCreatureEvent(cid, "BossKisll")
and now go to movements and make 2 file
first file add
Code:
local config = {
flampos = {x=983,y=1101,z=15},
tppos = {x=983,y=1101,z=15}, -- WHERE TO TELEPORT TO.
monsterpos = {x=995,y=1119,z=15}, -- WHERE MONSTER TELEPORTS.
maxplayers = 90, -- HOW MANY PLAYERS CAN ENTER.
globalstorage = 50290,
monsterstorage = 50310,
enteredArea = 50300, -- EMPTY PLAYER STORAGE.
exhauststorage = 50340, -- EMPTY PLAYER STORAGE.
fromPosition = {x=976, y=1112, z=15}, -- top left cornor of the playground
  toPosition = {x=1001, y=1124, z=15} -- bottom right cornor of the playground -- top left cornor of the playground
}

local monsters = {'morgaroth','Massacre','Ushuriel','Zugurosh'}
function onStepIn(cid,item,pos,fromPos)
    if isPlayer(cid) then
        if getPlayerLevel(cid) < 250 then
            doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'You need to be of Level 250 or higher to enter.')
        else
            local g = math.max(0, getStorage(config.globalstorage)) + 1
            if g > config.maxplayers then
                doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'Too many players are participating already.')
            elseif exhaustion.check(cid,config.exhauststorage) then
                doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'You can\'t enter yet, you\'ll have to wait '..exhaustion.get(cid,config.exhauststorage)..' more seconds.')
            else
                doSetStorage(config.globalstorage, g)
                doCreatureSetStorage(cid,50300,1)
                doTeleportThing(cid,config.tppos)
                doSendMagicEffect(config.tppos, CONST_ME_TELEPORT)
                doSendMagicEffect(pos,CONST_ME_POFF)
                if getStorage(config.monsterstorage) < 1 then
                local pos = {x = math.random(config.fromPosition.x, config.toPosition.x), y = math.random(config.fromPosition.y, config.toPosition.y), z = math.random(config.fromPosition.z, config.toPosition.z)}
                    doSummonCreature(monsters[math.random(#monsters)],pos)
                    doSendMagicEffect(config.monsterpos,CONST_ME_TELEPORT)
                    doSetStorage(config.monsterstorage,1)
                end
                return
            end
        end
        doTeleportThing(cid, fromPos)
        doSendMagicEffect(fromPos, CONST_ME_TELEPORT)
    end
end

function onAddItem(moveitem, tileitem, pos)
    pos.x = pos.x + 3
    doTeleportThing(moveitem.uid, pos)
    doSendMagicEffect(pos, 12)
end
and infile number 2 add
Code:
local config = {
tppos = {x=1014,y=1011,z=7}, -- WHERE TO TELEPORT TO. (SHOULD BE CENTER OF THE ROOM)
maxplayers = 10, -- HOW MANY PLAYERS CAN ENTER.
globalstorage = 50290,
monsterstorage = 50310,
enteredArea = 50300,
from = {x=976, y=1096, z=15}, -- AREA UPPERLEFT CORNER.
to = {x=1001, y=1124, z=15}, -- AREA LOWERRIGHT CORNER.
bossspawnstorage = 50320,
exhausttimer = 0, -- EXHAUSTION IN MINUTES.
exhauststorage = 50340
}

local from, to = config.from, config.to

function onStepIn(cid,item,pos,fromPos)
    local v = getThingPos(cid)
    if isPlayer(cid) then
        if getStorage(config.bossspawnstorage) > 0 then
            doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'Please wait until the next boss is spawned before leaving.')
            doTeleportThing(cid, fromPos, true)
            return true
        end
        exhaustion.set(cid,config.exhauststorage,config.exhausttimer*60)
        local s = math.max(0, getStorage(config.globalstorage) - 1)
        doSetStorage(config.globalstorage, s)
        doTeleportThing(cid,config.tppos)
        doSendMagicEffect(pos,CONST_ME_POFF)
        doSendMagicEffect(config.tppos,CONST_ME_TELEPORT)
        doCreatureSetStorage(cid,config.enteredArea)
        if s == 0 then
            doSetStorage(config.monsterstorage,0)
            for x = from.x, to.x do
                for y = from.y, to.y do
                    local v = getTopCreature({x=x, y=y, z=from.z})
                    if v.type == 2 then
                        doRemoveCreature(v.uid)
                    end
                end
            end
        end
    end
    return true
end
and in movements.xml add
Code:
   <movevent type="StepIn" actionid="5002" event="script" value="bossarenatp.lua"/>
    <movevent type="StepIn" actionid="5003" event="script" value="bossarenatpout.lua"/>
any error post here and i will help you isa
its 95% like masiyah boss tp
 
OP
Mera Mero

Mera Mero

Guess Who?
Joined
Dec 27, 2014
Messages
416
Reaction score
83
go create file in creaturescript and add this
Code:
local config = {
    respawnSecs = 5, -- how many seconds until next boss spawns
    storage = 50300,
    bossspawnstorage = 50320,
    fromPosition = {x=976, y=1112, z=15}, -- top left cornor of the playground
    toPosition = {x=1001, y=1124, z=15} -- bottom right cornor of the playground
}

local monsters = {'morgaroth','Massacre','Ushuriel','Zugurosh'}

local function f()
      local pos = {x = math.random(config.fromPosition.x, config.toPosition.x), y = math.random(config.fromPosition.y, config.toPosition.y), z = math.random(config.fromPosition.z, config.toPosition.z)}
        doSummonCreature(monsters[math.random(#monsters)], pos)
        doSendMagicEffect(pos,CONST_ME_TELEPORT)
    doSetStorage(config.bossspawnstorage, 0)
end

function onKill(cid, target, damage, flags)
if isMonster(target) and getCreatureMaster(target) == nil and getCreatureStorage(cid,config.storage) >= 1 then
        local s = getCreatureName(target)
        if isInArray(monsters, s:lower())  then
            addEvent(f, config.respawnSecs*1000)
          
        end
    end
    return true
end
and in creaturescript.xml add
Code:
<event type="kill" name="BossKisll" event="script" value="bosskill.lua"/>
and in login add
Code:
    registerCreatureEvent(cid, "BossKisll")
and now go to movements and make 2 file
first file add
Code:
local config = {
flampos = {x=983,y=1101,z=15},
tppos = {x=983,y=1101,z=15}, -- WHERE TO TELEPORT TO.
monsterpos = {x=995,y=1119,z=15}, -- WHERE MONSTER TELEPORTS.
maxplayers = 90, -- HOW MANY PLAYERS CAN ENTER.
globalstorage = 50290,
monsterstorage = 50310,
enteredArea = 50300, -- EMPTY PLAYER STORAGE.
exhauststorage = 50340, -- EMPTY PLAYER STORAGE.
fromPosition = {x=976, y=1112, z=15}, -- top left cornor of the playground
  toPosition = {x=1001, y=1124, z=15} -- bottom right cornor of the playground -- top left cornor of the playground
}

local monsters = {'morgaroth','Massacre','Ushuriel','Zugurosh'}
function onStepIn(cid,item,pos,fromPos)
    if isPlayer(cid) then
        if getPlayerLevel(cid) < 250 then
            doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'You need to be of Level 250 or higher to enter.')
        else
            local g = math.max(0, getStorage(config.globalstorage)) + 1
            if g > config.maxplayers then
                doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'Too many players are participating already.')
            elseif exhaustion.check(cid,config.exhauststorage) then
                doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'You can\'t enter yet, you\'ll have to wait '..exhaustion.get(cid,config.exhauststorage)..' more seconds.')
            else
                doSetStorage(config.globalstorage, g)
                doCreatureSetStorage(cid,50300,1)
                doTeleportThing(cid,config.tppos)
                doSendMagicEffect(config.tppos, CONST_ME_TELEPORT)
                doSendMagicEffect(pos,CONST_ME_POFF)
                if getStorage(config.monsterstorage) < 1 then
                local pos = {x = math.random(config.fromPosition.x, config.toPosition.x), y = math.random(config.fromPosition.y, config.toPosition.y), z = math.random(config.fromPosition.z, config.toPosition.z)}
                    doSummonCreature(monsters[math.random(#monsters)],pos)
                    doSendMagicEffect(config.monsterpos,CONST_ME_TELEPORT)
                    doSetStorage(config.monsterstorage,1)
                end
                return
            end
        end
        doTeleportThing(cid, fromPos)
        doSendMagicEffect(fromPos, CONST_ME_TELEPORT)
    end
end

function onAddItem(moveitem, tileitem, pos)
    pos.x = pos.x + 3
    doTeleportThing(moveitem.uid, pos)
    doSendMagicEffect(pos, 12)
end
and infile number 2 add
Code:
local config = {
tppos = {x=1014,y=1011,z=7}, -- WHERE TO TELEPORT TO. (SHOULD BE CENTER OF THE ROOM)
maxplayers = 10, -- HOW MANY PLAYERS CAN ENTER.
globalstorage = 50290,
monsterstorage = 50310,
enteredArea = 50300,
from = {x=976, y=1096, z=15}, -- AREA UPPERLEFT CORNER.
to = {x=1001, y=1124, z=15}, -- AREA LOWERRIGHT CORNER.
bossspawnstorage = 50320,
exhausttimer = 0, -- EXHAUSTION IN MINUTES.
exhauststorage = 50340
}

local from, to = config.from, config.to

function onStepIn(cid,item,pos,fromPos)
    local v = getThingPos(cid)
    if isPlayer(cid) then
        if getStorage(config.bossspawnstorage) > 0 then
            doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'Please wait until the next boss is spawned before leaving.')
            doTeleportThing(cid, fromPos, true)
            return true
        end
        exhaustion.set(cid,config.exhauststorage,config.exhausttimer*60)
        local s = math.max(0, getStorage(config.globalstorage) - 1)
        doSetStorage(config.globalstorage, s)
        doTeleportThing(cid,config.tppos)
        doSendMagicEffect(pos,CONST_ME_POFF)
        doSendMagicEffect(config.tppos,CONST_ME_TELEPORT)
        doCreatureSetStorage(cid,config.enteredArea)
        if s == 0 then
            doSetStorage(config.monsterstorage,0)
            for x = from.x, to.x do
                for y = from.y, to.y do
                    local v = getTopCreature({x=x, y=y, z=from.z})
                    if v.type == 2 then
                        doRemoveCreature(v.uid)
                    end
                end
            end
        end
    end
    return true
end
and in movements.xml add
Code:
   <movevent type="StepIn" actionid="5002" event="script" value="bossarenatp.lua"/>
    <movevent type="StepIn" actionid="5003" event="script" value="bossarenatpout.lua"/>
any error post here and i will help you isa
its 95% like masiyah boss tp
Worked with summoning first boss then stopped and there aren't errors, Btw what is the difference between this one and Xikini's script? Because Xiniki's script works good as i need so why should i use tons of lines that you posted? Is there any good with them?
 

heba

Veteran OT User
Joined
Aug 5, 2011
Messages
1,333
Reaction score
165
Worked with summoning first boss then stopped and there aren't errors, Btw what is the difference between this one and Xikini's script? Because Xiniki's script works good as i need so why should i use tons of lines that you posted? Is there any good with them?
u told me, need it like masiyah boss tp, its work like masiyah boss tp .
i posted full system
 
Top