Random map after entering a cave

Hey!

So I want to do a following scenario - let's say I have six maps. First one is called MainMap and the rest of maps are called X1, X2, X3, X4, X5.

In the MainMap let's say there is an entrance to the cave and when Player reaches it, Player gets teleported to one of the X maps listed above however the map which Player will enter is chosen randomly.

So for example one Player after reaching the cave entrance will be teleported to map X1 however another Player doing the same thing will be teleported for example to map X4.

Is there an easy way to do it? Do I need plugins to do it?

Thanks for answers!
You can do that without plugins; I have the same feature in my game.

When using the "transfer player" command, you can select Variables for map ID, X and Y coord of your destination. So all you need is to fill up these variables with your map information.

A very simple approach would be

Code:
      ◆Control Variables:#0071  MapID next room = Random 25..31

Set the random range to the possible MapIDs of your dungeon.

Spoiler: Several Floors with several rooms
I've got a more complex system that will pick the location mathematically, as I use one event for all dungeons. I have several floors per dungeon and they get randomly selected, every time you find stairs.

You need a variable, that stores the amount of possible rooms per floor (e.g. 5, if there are 5 rooms per floor). Multiply it with a random 0~(x-1), while (x-1) is the amount of floors-1 (e.g. random 0~6, if you have 7 floors).
Then add +random 1~5, as we have 5 rooms.
Finally, add the "Dungeon MapID" to your result (which is the first map of your dungeon -1) - think of it like an empty headline-map.
You might also want to add a system to avoid selecting the same room you're coming from. (reroll, if old room = new room).

Examples:
We have 7 floors with 5 rooms each. Starting MapID is 320.
We rolled floor 0 and room 4:
5*0 = 0
0+4 = 4
4+320 = MapID 324

We rolled floor 3 and room 2:
5*3 = 15
15+2 = 17
17+320 = MapID 337

If you have random start positions, you have to figure out a way to pick valid X and Y coords, as you don't want to spawn randomly in a wall. I do that with region IDs.

PS:
Make sure that all mapIDs of your dungeon are numbered consecutively. If you have some maps inbetween that don't belong to the dungeon, you'll have more trouble to make it work.

Original thread: https://forums.rpgmakerweb.com/threads/random-map-after-entering-a-cave.173586/