How can I teleport my Player to a random Map?

Hello,

I want to make a game where you have to fight yourself through random dungeons while simultaniously your oxygen runs out and you have to hurry, fighting yourself from room to room to find more oxygen tanks or loot and stuff. For this, I already installed an ABS and almost everything I need. For this project, I dont even need a random map generator, I am trying to make the rooms myself with different Puzzles and Enemies and Stuff. I still want to have control over the design of the rooms and dont wanna trust a random generator. But for this I am searching for something, that teleports the player randomly into one of the rooms I created. So basicly, I just need a script, that choses the map ID at random and then ports me to this room. The rooms are all identical in Size and Form, only with different Loot, Puzzles maybe and enemies. Does someone know how I can arrange that?

I added a screenshot to show how these maps will look. They will be bigger and look different, but this is an example of how it will principly look.
yes, you can - although it might require you to change some of the maps.

If you check out the event commands, you'll find that the transfer player command can receive its coordinates from variables instead of using a fixed target. Usually this is used for some kind of "return" teleport scroll, but you can also use it for random teleport.

the first thing to keep in mind is that this requires you an unbroken line of map IDs as the target maps.
If for example your first ten maps are town maps and the dungeons are the maps #11 to #99, then you can do a control variable giving a random number between 11 and 99 and then use that as the map ID of the transfer command.
If you have your town maps scattered between the dungeon maps, that is obviously a problem as you would have to detect and remove those IDs before the transfer.

The second part is that you'll need two X Y coordinates for the dungeon maps that are passable.
That is no problem if every map has a big center room at the same place, but if the maps are different then you need to find a spot where every map is passable (or a more complex event structure that gives different coordinates depending on map ID) because otherwise the player would be stuck on an impassible tile after the transfer.
the first thing to keep in mind is that this requires you an unbroken line of map IDs as the target maps.
If for example your first ten maps are town maps and the dungeons are the maps #11 to #99, then you can do a control variable giving a random number between 11 and 99 and then use that as the map ID of the transfer command.
If you have your town maps scattered between the dungeon maps, that is obviously a problem as you would have to detect and remove those IDs before the transfer.

Alternatively, if at least some of the intended teleport locations are numerically continuous, he could get fancy with the "Set Variable - Rand": let's say for example maps 11-17, 29-32, 48-71, and 95-101 are all target ranges, you could first use "Set Variable - Rand" to "roll a d4" to choose one of those ranges at random, then use "Set Variable - Rand" to set the Map ID to teleport to to one in those ranges. If the MAP IDs alternate constantly between dungeon and town or whatever this wouldn't work but...well, I've never set up MY maps that way for a project and I can't imagine why anyone would.

Anyway it sounds like the OP's game is all dungeon so that might not be an issue.
Thank you so much Andar and Crowstorm! With your help I did it, I just made a parallel process that set a few variables and then I was able to make it work with that.

Now I decided, that I just wanted 2 doors, one left and one right. So either you can go right to a new, random room or back to the last. I tried to use "map ID" as variable for going left. But it just ports me back to the same room I am in. Do you maybe know how I can change that, so I can go back to the last map I was on?

Anyway, you have already been a great help, thank you!
then we need a screenshot of your event.

you did something wrong with the variable, and to see what went wrong we need to see what you did, we can't read your mind;-)
Okay so this is the default room. To the right I enter a new random room, to the left I go back.

bandicam 2020-01-20 19-48-59-023.jpg


Here is my left event:

bandicam 2020-01-20 19-49-18-475.jpg


bandicam 2020-01-20 19-49-25-924.jpg


This is my parallel process running to set the variables:

bandicam 2020-01-20 19-49-43-589.jpg


And this is the variable that should teleport me back.

bandicam 2020-01-20 19-49-52-656.jpg


I read in a forum about someone, who also wanted help on how to teleport back to the previous map. The solution was given, that it can be done with "Map ID" in the variables. I tried, but I don't know how let the system take the last map ID I was on and not the current.
1) you should NOT have used a parallal process, the control variables should have been directly before the transfer command

2) Map ID from the game data is always the current map ID, there is nothing random about that.
to actually get a random number you need to use the random setting, not fixed data.

EDIT:
3) to keep the last ID in memory you need a different variable, and it needs to be set to map ID in the last room before the transfer. Again parallel process is wrong for that because that would constantly update the variable with current values
Thank you very much! Now I have everything running perfectly 🙂

Have a good day!
@Tiregs Are all your questions related to your thread answered?
Yes, all cleared.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-teleport-my-player-to-a-random-map.117417/