Creating Dungeons from Scratch

From PMDOWiki

This tutorial goes over the steps of creating a new EMPTY dungeon, and making it accessible from the rest of the game. If you want to learn how to edit details of the dungeon itself, read the Creating Dungeons tutorial. Before starting, it is highly recommended you begin with your game set to a mod in Modding Intro, so that you’re editing a mod instead of the base game. The tutorial will move forward with that assumption.


Adding the Dungeon

Begin by opening up the Zones list:


Click “Add” to add a new entry at the bottom.

Click OK for now.

Since the details of the dungeon aren’t important and we just want it to be accessible, we will copy the data from Faded Trail into this dungeon.

You can do this by opening up Faded Trail and right-clicking the window. It will give you the option to copy the data of the entire dungeon.

Then, open up the new dungeon and paste the data; all of the data will be filled.

Let’s change the name to differentiate this dungeon.

Accessing the Dungeon

With the dungeon created, it needs to be made accessible from an overworld map.

Let’s make it unlockable from Forest Camp. To do this, we need to edit the script of Forest Camp. Navigate to Data/Script/ground/ in your PMDO folder.

Copy the forest_camp folder, and paste the copy in the Data/Script/ground/ folder in your mod’s folder.

The scripts in the mod’s folder will overwrite the scripts in the base folder when the mod is running.

Next, Go into the forest_camp folder, and open init.lua in a text editor (Notepad++ recommended)

We are going to edit the north exit to include the new dungeon. Scroll down to the function forest_camp.North_Exit_Touch

The dungeon_entrances variable defines a list of dungeons (by index) that the North Exit can take the player to. Add the number 50 to the list, for Gauntlet Cave.

Save the file.

To bring these changes into effect, either restart the game or reload the scripts. You can use the Reload button in the Scripts tab:

If you enter Forest Camp from the title screen using the developer warp, you will be able to access the dungeon (as well as all other dungeons available in the north exit).

However, if you were to play this mod legitimately, you would find that the dungeon will not appear in the selection menu, and there is no way to unlock it.

This is because the debug save file that is created from the title screen is made with all dungeons automatically unlocked.

To make this dungeon accessible legally, we must call a script to unlock it.


Unlocking the Dungeon

There are several ways to unlock a dungeon once it has been added to an exit. If you just want to test the dungeon from a non-debug save file, run this command in the Script tab:

GAME:UnlockDungeon(<dungeon_id>)

You can also unlock a dungeon by making it available the moment you reach the hub map for it. Take a look at the init.lua script in Data/Script/ground/forest_camp, and scroll to the bottom of forest_camp.Enter:

  GAME:UnlockDungeon(3)
  GAME:UnlockDungeon(36)

With these statements, the dungeons for Faded Trail and Bramble Woods are automatically unlocked when you enter the ground map.

The two methods above are trivial; we will go over a different technique to unlocking that will prove more useful: unlocking the dungeon when completing dungeon #36: Bramble Woods.

Navigate to Data/Script/Zone/ in your PMDO folder.

Copy the folder for zone_36, and paste the copy in the Data/Script/zone/ folder in your mod’s folder.

The result should look like this. Open the folder zone_36, and open init.lua in a text editor (Notepad++ recommended)

ExitSegment currently checks to see if we completed the dungeon within a rescue mission (Line 30) Then it checks to see if the outcome of the segment wasn’t a success (Line 32). This block is for cases like fainting in a dungeon, escaping, or timing out due to wind. Lastly, after all those checks, we know that the player has completed the segment (Line 34). Within this block, we check which segment the player cleared, and act accordingly. We are interested in Line 38:

COMMON.UnlockWithFanfare(37, true)

This line unlocks Sickly Hollow after the player has completed the Bramble Thicket path of the dungeon. That path has a segmentID of 1, while the main path has a segmentID of 0. You can see that unlike the code for segment 1’s completion, the code for segment 0 just sends the player out of the dungeon. Line 36:

COMMON.EndDungeonDay(result, 1, -1, 3, 2)

Modify this code such that we unlock our new dungeon, dungeon #51, before ending the adventure:

COMMON.UnlockWithFanfare(50, true)
COMMON.EndDungeonDay(result, 1, -1, 3, 2)

Save the scripts and reload them, and then play the game legitimately until you complete Bramble Woods’s main path.

You should then see your new dungeon unlocked.