This is an addon to the Random Dungeon Generator. It allows you to build multiple exits, while the current area is persisted, that means, when going back, the old area is re-created just as you left it. Now, a map can have up to 4 exits – one for each direction.
Using this addon we won’t differentiate between entrance and exit anymore, instead every way in and out is referred as exit. Players can leave and enter the area.
Limitations: At this time this Addon works only when using Entrances and Exits as Decoration, not when using MakeWayOut function. When walking back to a map that you already looted, all loot chests are reverted.
Include the js. file into your project. Check the Region Id in the Plugin’s parameters and change them if they are already in use by another plugin.
On the Decoration Map we draw one exit for each direction, i.e. to the top, right, bottom and left. If you already have the entrance and the exit from prior tutorials, you can keep and use them. Each snippet must have a Region Tile to let the Player spawn here. We fill the Events’ Command Lists later.
Lookup the Region Ids from the Table. It’s actually the same as in the picture above.
|Region ID||Spawn Point Region ID|
Place Region Ids on the regular snippets just as we did in the first tutorial.
Before we come to the part where we write the script call, we make a quick overview on how this Meta Maze would look like. See the picture. Each cell represents a dungeon map that we already know from before.
At this time the Plugin connects every cell with all its neighbours, without any randomization. This will be expanded in the future. You can set the number of cells and from which directions the Player can enter and leave the whole maze. You can even create multiple exits (max 4, so one in each direction) or just one, when you really want the troll the Player.
Be aware, such a maze will raise the complexity a lot! You should make each generated map a lot smaller than usual with only few forks and dead-ends.
Setup Script Call
We create a new Common Event for the Ice Dungeon and call it “Setup Ice Dungeon”. This contains another Script Call.
If you want to use a seeded RNG, e.g. for a Minecaft-like game, use this command:
var seed = $gameVariables.value(1); $dungeonGenerator_meta.setSeed(seed) .create() .asArea(3, 3) <-- this is your desired width / height value .ok() .withExit("north") .withExit("south") .apply() .enterAt("south") .finalize();
If you want to make a Rogue-like game, use this command:
$dungeonGenerator_meta.noSeedableRNG() .create() .asArea(3, 3) <-- this is your desired width / height value .ok() .withExit("north") .withExit("south") .apply() .enterAt("south") .finalize();
Call this Common Event when the Player enters the Dungeon from e.g. the World Map, right before we called the Generator.
Dungeon Generator Script Call
Alter your exiting Script Call to something like this. Insert “applyMeta()” and replace “placeEntranceAt” and “placeExitAt” calls. The Addon now takes control over exits and entrances. Don’t use any “setSeed” or “noSeedableRNG” commands here.
$dungeonGenerator.applyMeta() .prims() .mergeDeadEnds($mergeDeadEnds) .cutOffDeadEnds($cutOffDeadEnds) .generate() .placeExits() .drawDecorations([1, 2, 3, 4]) .drawDecorationXTimes(11, 1, 3) .finalize();
Exit Event Script Call
Now we fill the Events that we placed on the Exits. We need to consider, such an exit can transfer the Player to another generated Map, or he successfully find the true exit and escaped from your Maze.
So, you can see there are 4 similar Common Events: Goto North, Goto East, Goto South, Goto West. These Events starts with one from these Script Calls:
$dungeonGenerator_meta.goToNorth(); $dungeonGenerator_meta.goToEast(); $dungeonGenerator_meta.goToSouth(); $dungeonGenerator_meta.goToWest();
Then we check if we are still inside the Dungeon, or if we escaped. In a If-Condition, choose Script Call and insert
If so, call the Common Event to generate the Ice Dungeon. If not, you can transfer the Player to any destination you want him to go next.
Additional Script Calls
You can use these Script Calls to get some data to show them as e.g. images.
$dungeonGenerator_meta.getPosition().x $dungeonGenerator_meta.getPosition().y $dungeonGenerator_meta.width() $dungeonGenerator_meta.height() $dungeonGenerator_meta.isInsideDungeon() $dungeonGenerator_meta.hasLeftDungeon() $dungeonGenerator_meta.hasExitNorth() $dungeonGenerator_meta.hasExitEast() $dungeonGenerator_meta.hasExitSouth() $dungeonGenerator_meta.hasExitWest()