In this tutorial we will transfer the Player out of the randomized area, but when he re-enters the Map, he will spawn at the exact position where he originally left the Map. For example, you can have a tent or a house on the randomized Map that the Player can enter and search through.
You should use a seedable RNG here.
Save Player’s Position
Let’s make a Common Event that stores the Player’s Position on command. We use the methods that RPG Maker already provides.
Go to the Decoration Map and let’s make a Decoration Object that transfers the Player to the tent, house, or secret room. Feel free to put multiple transfer events to get more variety.
Put a simple Transfer Event here. Just before the Transfer happens, we call our Common Event to save the Player’s Position.
Respawn at Memorized Position
You need to copy-paste your (Common) Event that generates the Dungeon, and you will see the reason soon. We need to change the command line that defines where the Player spawns; if you don’t have this line because you use a default value, then just add this line.
MZ only: Plugin Command
Insert the Plugin Command „spawn Player at“ right before „finalize“ or replace your already-existing „spawn Player at“ command. I recommend to add the y-coordinate by 1 so the Player spawns a little bit below the entrance.
Open your already-existing JS snippet and change it to something this:
// Example Code $dungeonGenerator.prims() .generate() .placeEntranceOn("bottom") .placeExitOn("top") .drawDecorations(); let x = $gameVariables.value(VARIABLE_ID_X); let y = $gameVariables.value(VARIABLE_ID_Y); $dungeonGenerator .spawnPlayerAt(x, y) .finalize();
Replace VARIABLE_ID_? with the respective Ids of the Variables that store the X and Y coordinates.