How to randomize map transfers?

Hello all, just back from a long break with a new question:
Is there any possible way I can randomize map transfers? As in, a player touches an event e.g a door that transfers them to a random map. I understand that I could just use a random variable then add if/else statements, but I wanted to have around 100+ different maps (!scope creep alert!) that the player can transfer to. Is there an easier way to do this, or would I have to use a plugin?

Thanks
I would combine a variable gaining a random amount, conditional branches, and different teleport commands for each variable value.
Code:
$gamePlayer.reserveTransfer(mapId, x, y, direction, fade type);

MapID can be a Variable... Then you just make an array for the MapID. So something like this:

$gameVariables.setValue(1, [1,2,3,4,5])
Code:
$gamePlayer.reserveTransfer($gameVariables.value(1)[1], 7, 7, 8, 0);

Don't quote me on this array stuff.... I'm still learning how to do it, but I think it's pretty close to this.
Thank you both! I will try them out and see which works best for me
How do you want to determine the "spot" on the map where the player should land? Is it always a fixed coordinate (e.e. 5/5) or is it fully random as well? How do you want to verify the player will not stuck in a wall?
you don't even need script commands, because the transfer command allows the use of variables.

but as said above the biggest problem is to determine where on the map the player will arrive and to prevent getting stuck. I can see two ways around that:

1) map design - make sure that an entry spot is always in the same coordinates on the map

2) self-deleting transfer correction event on each map
basically fade-out before transfer, and on each map have a parallel process with wait(1), transfer to map specific coordinates, fade in, delete event
I have an old tutorial that may or may not be helpful for you. In the tutorial, there are 4 random locations in 4 directions from the test map. The first time you exit the map, a random location is set and you can return to the same spot on the test map. That exit is now fixed to that random location. Each time you exit the test map from a new direction, a new random location is selected.

So, in the end, you have 4 exits that lead to 4 different locations and they are saved so you can go back and forth.

Each time you played that test map, the locations would potentially be different but fixed once they are set.

I haven't looked at this in a long time and I would probably do it differently now that I have learned more, but it definitely works and might help you with a possible concept.

Anyway, here is the link. Good luck on your project!

I'm not sure why you'd use a script call for this…? Just use the "Designate by variables" option in the Transfer Player command. In my opinion, you shouldn't really use script calls for things that can pretty easily be done without them. It's less readable, it's more likely to break the Exclude Unused feature on deployment, and it probably has a bunch of other downsides as well.

That does mean you need to put the X and Y coordinate into variables too though. The easiest way to handle it would be to set up the maps so that the destination coordinate is the same on all maps, but I don't know if that fits your use-case. If not, you'd probably need to do a sequence of conditional branches like Banana_Duck suggested to set the coordinates.
The problem I see with this is how to define the coordinates of each map and the face direction.

It would be more feasible to create a dedicated plugin for this project where the data would be placed in the properties of each map using notes:
1768963270137.png
How do you want to determine the "spot" on the map where the player should land? Is it always a fixed coordinate (e.e. 5/5) or is it fully random as well? How do you want to verify the player will not stuck in a wall?
It will most likely be a fixed coordinate.

Just to clarify, in my case, I want a dungeon crawler type thing, once you exit a room, it chooses a random room and transfers you there, and once you enter that new room,m you can't go back to the old room. The only way to leave the new room is to go through a designated exit, in which it will transfer you to a different random room.

In short, I just need to have a way to randomize the map the player is transferring to, as the coordinates will likely be the same.
It would be more feasible to create a dedicated plugin for this project where the data would be placed in the properties of each map using notes:
That would be a little tricky, as map note tags aren't generally available. You'd have to preload the map data, check the note tag, then perform the transfer.

A less tricky option would be to put the note tag in the map name – not the display name, but the internal name. Those names are stored in the $dataMapInfos, so they're available at all times.

It will most likely be a fixed coordinate.
If you know the target coordinate will the same on every map, then all you need to do is something like this:

  • Control Variables : #0001 = Random 1...N (where N is the number of maps)
  • Control Variables : #0002 = 42 (the X coordinate)
  • Control Variables : #0003 = 56 (the Y coordinate)
  • Transfer Player : {#0001}, {#0002}, {#0003} (using Designate by Variables)

That assumes the map IDs form a contiguous range from 1 to the number of maps, but it's only slightly more complicated if they don't.
That would be a little tricky, as map note tags aren't generally available
Sorry... I must have gotten confused about the loading order in the transfer event. I thought the player was inserted into the map after the data was loaded.
That assumes the map IDs form a contiguous range from 1 to the number of maps, but it's only slightly more complicated if they don't.
Thanks you! One question: Can I change the map IDs, and if so, where?
Thanks you! One question: Can I change the map IDs, and if so, where?
You can, in your game fodder. (I don't recommend changing map IDs tho, because you'll need to change your previous teleport commands too.)
There are many ways to solve this problem, I think, it's essential to get an overview of the tools that you have, or can have when adding some plugins.

I would still go with the straightforward way: A common event with a huge set of Conditional Branches:

Code:
If Variable random room == 1
  Transfer to Map "Maze1"
End Branch
If Variable random room == 2
  Transfer to Map "Maze2"
End Branch

Of course, technically, you can have external txt or JSON files that holds a list of all rooms that a plugin reads on game start, or you can use notetags, but in the end, you must mantain a list of "variable -> map ID" anyway, so externalizing into scripting will only shift the problem, not solve it.

On the other hand, nice to know, plugins can actually read your map tree. Your game "knows" when a map is a child of another map. That means, you could have a "container" map and all of the potential candidates are just hanged below it. Then you can ask me, or any other programmer, to write a short script that returns a list of potential map IDs. That would still not resolve the problem of determining a starting spot on the maps, though.

TLDR:
Even with 100 of options, sometimes the Conditional Branches are still the best tool for you.
Sorry... I must have gotten confused about the loading order in the transfer event. I thought the player was inserted into the map after the data was loaded.
I see. Good to know that it works out for this case.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-randomize-map-transfers.182055/