Seedable PRNG – Persisting your World

This plugin series does not persist generated maps. Instead, it uses a seedable PRNG. Every time you pass the same seed value to a command to generate a map, then the same map is generated again. We will use RPG Maker Variables to keep track of our seed value(s).

Why aren’t there any functions to persist maps? I decided not to, and when you think about it, it makes perfect sense. Any built-in function to save and regenerate maps will be limited at some point. In contrast, we have so much more control when using Variables, and they are safely stored and managed by our Save Games.

As you can manage your seed value(s) by using the standard RPG Maker Eventing, you can easily decide how the randomization will influence your world and, therefore, the gameplay. Do you want a simple dungeon crawler that randomizes only once on startup? Or every time you start a new mission? Or do you want to have a universe with randomized planets that own randomized fields and caves, too? It’s up to you!

This plugin uses an isolated RNG. Using the random function inside the Variable Management of the RPG Maker or any other invocation of Math.random will not interfere with it.

Generate and Pass a Seed Value

This plugin provides a small convenient function to generate a seed by passing a list of variables. In this example, the player has landed on a planet/world map and is now entering a cave. We are using a Global Seed Variable that is randomly set on „New Game,“ a Variable that keeps track of the planet the player has landed, and 2 Variables for X and Y coordinate of the player’s position on the world map. This way, we can have more than one cave entry, each leading to an individual-looking dungeon.

MZ only: Plugin Commands

The resulting seed value is inserted into a new Variable; in this example, it’s Variable No 5.

MV & MZ: JavaScript Call

const seed = MK.generateSeed(
    $gameVariables.value(1), // global Seed
    $gameVariables.value(2), // planet / worldmap Id
    $gameVariables.value(3), // X-coordinate
    $gameVariables.value(4)  // Y-coordinate

In JavaScript, everything that is right from a //-symbol is not used and therefore used to add comments.

With some knowledge in RPG Maker, you can replace $gameVariables.value(…) with any number or function call if you need to.

If you want to save the seed in a Variable, do:

const seed = MK.generateSeed(
$gameVariables.setValue(5, seed)  // <-- replace 5 with your Variable Id

The Meta Maze

The Meta Maze is an awesome feature for creating more complicated dungeons. It is not a map generator, but it assists you by creating connected randomly generated rooms. Technically, it auto-generates seed values for you and keeps track of the player’s position, which makes it possible for the player to go back to an already visited room, and it will retain its layout.

Self Switches

Self Switches are saved and managed when you use the Meta Maze. When you want to switch off Self Switches, you can do so (see: Self-Switches).

In detail, the plugin binds their data to the current Space Map. That means when you re-use a Space Map with a different seed and don’t reset Self Switches, their data may be corrupted. This will be improved in future releases.