• 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 Titles Quest

juansanchez

Advanced OT User
Joined
Apr 2, 2015
Messages
223
Reaction score
156


Hey otland people!
Today i need a help with a quest that i'm trying to do on my server. A friend of mine told me it's easy, but i just don't know how to do it.

So, first of all, when the player enter the quest, he starts in this room:

cpqIs4X.jpg


At the very center. No mobs around, nothing. As you can see there are the pressure titles around. When the player walks in the pressure title, he gets teleported to another room, just as the first one. But this time, there will be 8 monster around him (lets say we have, demons, dragons and hydras). When the player steps in the title, he gets teleported to a random room in the area (there will be lot's of rooms just like the first one), and when he gets teleported, 8 monster will spawn around him, either Demons, Dragons or Hydras, also random.

So basically, the player gets teleported to a random room in a certain area. Eight random monsters spawn around him, but not, eight random like, 2 dragons, 1 demon, 5 hydras. Like, it could be 8 demons, it could be 8 dragons or it could be 8 hydras.

I hope someone can help me out with this. If someone has any questions, just let me know. I'd really appreciate if someone could help me. Thanks for the attention.

 
0.3.7.. Untested.
Place actionID on any tile you want the script to function on. (aka; pressure tiles)
Code:
<movevent type="StepIn" actionid="45001" event="script" value="script.lua"/>
Code:
local pos = {
   [1] =  {x = 111111, y = 111111, z = 111},
   [2] =  {x = 111111, y = 111111, z = 111},
   [3] =  {x = 111111, y = 111111, z = 111}
}

local monsters = {
   [1] =  {"rat"},
   [2] =  {"cave rat"},
   [3] =  {"dragon"}
}

function onStepIn(cid, item, position, fromPosition)
   
   -- teleport random position
   local randP = pos[math.random(#pos)]
   doTeleportThing(cid, randP)
   
   -- area around the random position
   local topLeft = {x = randP.x - 5, y = randP.y + 4, z = randP.z}
   local botRight = {x = randP.x + 5, y = randP.y - 4, z = randP.z}
   
   -- choose random monster
   local randM = monsters[math.random(#monsters)]
   
   -- spawn 8 of selected random monster in area around random position
   for var = 1, 8 do
     doCreateMonster(randM, math.random(topLeft, botRight))
   end
   
   return true
end
 
I just updated the code to store the rooms that they already did & a reset storage with a tp out, of course it can be written better.
Code:
local pos = {
    [1] =  {x = 111111, y = 111111, z = 111},
    [2] =  {x = 111111, y = 111111, z = 111},
    [3] =  {x = 111111, y = 111111, z = 111},
    -- this will be the destination they are teleported to when they exit the areana
    [4] =  {x = 111111, y = 111111, z = 111}
}

local monsters = {
    [1] =  {"rat"},
    [2] =  {"cave rat"},
    [3] =  {"dragon"}
}

local roomStorageBase = 18000

-- this guarantees they don't enter the same room twice
function returnRandom(cid, pos, storage)
    local value = math.random(1, #pos - 1)
    local randomPosition = pos[value]
    if getPlayerStorageValue(cid, storage + value)  < 0 then
        setPlayerStorageValue(cid, storage + value, 1)
        return randomPosition
    end
    returnRandom(cid, pos, storage)
end

function onStepIn(cid, item, position, fromPosition)
    if not isPlayer(cid) then
        return false
    end
    -- teleport random position
    local randP = returnRandom(cid, pos, roomStorageBase)
    doTeleportThing(cid, randP)

    -- area around the random position
    local topLeft = {x = randP.x - 5, y = randP.y + 4, z = randP.z}
    local botRight = {x = randP.x + 5, y = randP.y - 4, z = randP.z}

    -- choose random monster
    local randM = monsters[math.random(1, #monsters)]

    -- spawn 8 of selected random monster in area around random position
    for var = 1, 8 do
        doCreateMonster(randM, math.random(topLeft, botRight))
    end

    return true
end

function onStepOut(cid, item, position, fromPosition)
    if isPlayer(cid) then
        local count = 0
        -- we are subtracting 1 because of the last coordinate in pos is for the destination on exit
        local positions = #pos - 1
        -- see if the player had all the storage values set to 1
        for i = 1, positions do
            count = count + getPlayerStorageValue(cid, storage + i)
        end
        -- if this is the case reset them
        if count == positions then
            for i = 1, positions do
                setPlayerStorageValue(cid, storage + i, -1)
            end
            -- then teleport them out
            doTeleportThing(cid, pos[#pos])
        end
    end
    return true
end
 
Last edited:
I just updated the code to store the rooms that they already did & a reset storage with a tp out, of course it can be written better.
Code:
local pos = {
    [1] =  {x = 111111, y = 111111, z = 111},
    [2] =  {x = 111111, y = 111111, z = 111},
    [3] =  {x = 111111, y = 111111, z = 111},
    -- this will be the destination they are teleported to when they exit the areana
    [4] =  {x = 111111, y = 111111, z = 111}
}

local monsters = {
    [1] =  {"rat"},
    [2] =  {"cave rat"},
    [3] =  {"dragon"}
}

local roomStorageBase = 18000

-- this guarantees they don't enter the same room twice
function returnRandom(cid, pos, storage)
    local value = math.random(1, #pos - 1)
    local randomPosition = pos[value]
    if getPlayerStorageValue(cid, storage + value)  < 0 then
        setPlayerStorageValue(cid, storage + value, 1)
        return randomPosition
    end
    returnRandom(pos, storage)
end

function onStepIn(cid, item, position, fromPosition)
    if not isPlayer(cid) then
        return false
    end
    -- teleport random position
    local randP = returnRandom(cid, pos, roomStorageBase)
    doTeleportThing(cid, randP)

    -- area around the random position
    local topLeft = {x = randP.x - 5, y = randP.y + 4, z = randP.z}
    local botRight = {x = randP.x + 5, y = randP.y - 4, z = randP.z}

    -- choose random monster
    local randM = monsters[math.random(1, #monsters)]

    -- spawn 8 of selected random monster in area around random position
    for var = 1, 8 do
        doCreateMonster(randM, math.random(topLeft, botRight))
    end

    return true
end

function onStepOut(cid, item, position, fromPosition)
    if isPlayer(cid) then
        local count = 0
        -- we are subtracting 1 because of the last coordinate in pos is for the destination on exit
        local positions = #pos - 1
        -- see if the player had all the storage values set to 1
        for i = 1, positions do
            count = count + getPlayerStorageValue(cid, storage + i)
        end
        -- if this is the case reset them
        if count == positions then
            for i = 1, positions do
                setPlayerStorageValue(cid, storage + i, -1)
            end
            -- then teleport them out
            doTeleportThing(cid, pos[#pos])
        end
    end
    return true
end

This Happend...
[17:16:01.725] [Error - Event::checkScript] Event onUse not found (data/actions/
scripts/pisoskingarmor.lua)
 
Sorry, i was using it in the actions.xml :P

Now i used in the Moveevents and this is what happens when i step in:

[17:31:38.822] [Error - MoveEvents Interface]
[17:31:38.822] data/movements/scripts/pisoskingarmor.lua:onStepIn
[17:31:38.823] Description:
[17:31:38.824] data/movements/scripts/pisoskingarmor.lua:46: bad argument #1 to
'random' (number expected, got table)
[17:31:38.825] stack traceback:
[17:31:38.826] [C]: in function 'random'
[17:31:38.827] data/movements/scripts/pisoskingarmor.lua:46: in function <data/
movements/scripts/pisoskingarmor.lua:29>

I Get teleported, but no monsters spawns.
 
Sorry, i was using it in the actions.xml :p

Now i used in the Moveevents and this is what happens when i step in:

[17:31:38.822] [Error - MoveEvents Interface]
[17:31:38.822] data/movements/scripts/pisoskingarmor.lua:eek:nStepIn
[17:31:38.823] Description:
[17:31:38.824] data/movements/scripts/pisoskingarmor.lua:46: bad argument #1 to
'random' (number expected, got table)
[17:31:38.825] stack traceback:
[17:31:38.826] [C]: in function 'random'
[17:31:38.827] data/movements/scripts/pisoskingarmor.lua:46: in function <data/
movements/scripts/pisoskingarmor.lua:29>

I Get teleported, but no monsters spawns.
Try the code again, it was missing an argument. The script may only work up to a certain point, you will need to add or edit the rest.
If you don't know how, see my signature to learn how.
 
Try the code again, it was missing an argument. The script may only work up to a certain point, you will need to add or edit the rest.
If you don't know how, see my signature to learn how.

Did you change anything? The same thing is still happening. It's like nothing has been changed '-'
 
Btw the name is Tiles lol.

So let me see if I understood correctly, each time the player steps in a tile he would be teleported to the next rooms out of finite rooms and in the end there would be something? If that is what you want I don't see why teleport the player to another rooms if they are identical, it could only teleport the player to the center position and spawn the monsters a finite number of times.

But as your picture had tiles at the north,east,south and west of the room I thought maybe you want something like a navigation method through a number of rooms maybe in a square shape and the player would have to find the right path to the final room.

So try to explain what you want again please :p
 
x
Btw the name is Tiles lol.

So let me see if I understood correctly, each time the player steps in a tile he would be teleported to the next rooms out of finite rooms and in the end there would be something? If that is what you want I don't see why teleport the player to another rooms if they are identical, it could only teleport the player to the center position and spawn the monsters a finite number of times.

But as your picture had tiles at the north,east,south and west of the room I thought maybe you want something like a navigation method through a number of rooms maybe in a square shape and the player would have to find the right path to the final room.

So try to explain what you want again please :p

Thanks for correcting me, sorry about the Titles...

Ok, so, it would be like this (just made the map real quick so i can explain):

nJbvjnA.jpg


All this rooms. The player starts in the middle one. He steps in the tile, and get's teleported to another one of the rooms. A random one. Then, when he gets teleported, 8 monsters would spawn around him. Like so:



It could be, Yetis, Grim Reapers or Morgaroths.

After trying a few time, he would finally, hit a random tiles, but this time he would be teleported to the final room:

UQ575fD.jpg



I don't want it be a specific tile, i don't want it to have a path for the player to follow, i want it to be actually random. He could be in the quest for 8 hours, steeping in tiles, to then go to the final room. Or he could enter the quest, step in a tile, and go to the final room in the first try.


I Dont know if i can explain it any better, but if you have any doubts still, just ask me, and i'll try to explain.
 
As I've said wouldn't it be simpler if you just teleport the player back again to the center and clean the room so it looks like it is another room?

The amount of effort to add an actionid to those tiles is just... '-'

Then if it was going to be 25 rooms, just set the chance of the tile teleporting the player to the final room to 1/25
 
Last edited:
Back
Top