Save Self-Switches

This article builds on top of the Seedable RNG. Given a Map setup, that allows you to revisit places, we had the problem that all Self Switches in this area were set to ‚false‘, making loot chests and enemies reset. While you maybe accept enemies to respawn, we don’t want to reset loot chests.

The feature described in this article will memorize Self Switches, with the ability to manually set these Switches to false, e.g. when the Player successfully finishs the dungeon, goes to the Worldmap and then eventually decides to revisit this place again.

This Tutorial is optional – when you don’t want to memorize Self Switches you can safely skip it.

Setup

Let’s say, the Player must reach the exit of a dungeon area 5 times, or in other words, we make 5 floors until the Player escapes from the dungeon, then we refer to each area as „floor„. We will assign each floor with an individual id, that is unique within its Space Map, or in other words, we just tell the Generator on which floor the Player is right now. Following the Tutorial „(Not) persist Maps“, we can just grab the Variable „Progression“ and give it to the Generator.

MZ only: Plugin Command

Do the Plugin Call „set Floor by Variable“ or „set Floor“ right before the Generator is called to generate the Dungeon and fill in its arguments.

MV and MZ: JavaScript Call

Do a Script Call right before the Generator is called to generate the Dungeon, or open/edit the Script Call that we put before to feed the RNG. Write this, and don’t forget to change the 5 to the variable that you are using to store the progression:

let floorId = $gameVariables.value(5);
$dungeonGenerator.setFloorId(floorId);

Resetting Self Switches

Do a Plugin Command „Reset Self Switches“ to set all Self Switches of Events in a Dungeon to „false“. Pass the Space Map’s Id as argument. The JS Code equivalent is:

$dungeonGenerator.resetSelfSwitches(2);

regardless of using Dungeon Generator or NoiseMap Generator, and „2“ is the Space Map’s Id.