(Not) Persist Maps

You either want a Rogue-like game in which the maps are always re-generated or you want a game in which the world feels persisted, just like in ‚No Mans Sky‘. This plugin serves both variants. Although there are no functions to persist maps, this plugin instead uses a seedable randum number generator to generate worlds. This way dungeons can be created the same way when a player re-enters them – if you wish. This article shows some examples:

Randomize everytime the Player enters

If you want the dungeon to be randomly generated everytime the player enters it, uses this command right before you call the generator.

$dungeonGenerator.noSeedableRNG();

OR

$noiseMapGenerator.noSeedableRNG();

Use Seed Variables (persisted Map)

A more natural way to generate dungeons would be, that when a player leaves a dungeon to go to the world map, and then re-enters it, it still looks the same. For my own game project I use this strategy: When a new game is started, a globally seed variable is randomly chosen once and then stored for this save slot. When the player leaves the world map to visit a dungeon, then his X and Y coordinates are also used to feed the generator. Doing this, we can safely copy-paste the Dungeon Entrance to other spots on the Worldmap, and the Generator will be fed with a different seed.

Storing variables is done by using event commands as this is much more convenient.

Storing the Global Seed

Once the game starts, we call a „Change Variable Operation“ to set a global variable called „Seed“ with a random number.

Common Events

We will do a Dungeon that has two entrances from the Worldmap, one from the North and one from the South. We need 4 Common Events in total:

  • Enter Dungeon South (when the Player enters from the Worldmap)
  • Enter Dungeon North
  • Dungeon + (when the Player continues to the next level)
  • Dungeon –

Enter Dungeon

As soon as the player wants to enter a dungeon from the north entrance, we memorize his position and store his X and Y coordinates. For the south entrance, we must set the X and Y coordinates manually to match them with the actual position of the north entrance. We must ensure that the Generator is fed with the same seed when entering from north or from south, otherwise the Dungeon would look differently when entereing from south.

Dungeon + and Dungeon –

We use a Variable „Progression“ to save the player’s progression. This variable is also calculated into the seed.

Get a new seed by using this command:

const seed = (
      $gameVariables.value(1)
    * $gameVariables.value(2)
    * $gameVariables.value(3)
    * $gameVariables.value(4)
    ) % 255;
$dungeonGenerator.setSeed(seed);

While the numbers 1, 2 and 3 stand for the respective IDs in the global variables. Ensure to set them correctly. Feel free to add more variables or leave some out if you wish.