Floor Generation Overview: Difference between revisions

From PMDOWiki
IDK (talk | contribs)
floor plans
Imbion (talk | contribs)
 
(32 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Floor generation is performed as a list of steps, which allows. This page covers the basics in what each step is responsible for, and why it is needed.
Floor generation is performed as a list of steps, which allows a developer to customize their floor layout at every part of the pipeline. This page covers the basics of what each step is responsible for and why it is needed.
 
For information on what steps are required to create a floor from scratch, see [[Creating Dungeons from Scratch]].


== Overview ==
== Overview ==


A dungeon map can generate without items, enemies, or traps.  But at a bare minimum, a dungeon map must generate terrain (plus entrance/exit) in order to complete without errors. There are 4 main options on how to do this:
A dungeon map can be generated without items, enemies, or traps.  But at a bare minimum, a dungeon map must generate [[terrain]] (plus entrance/exit) in order to complete without errors. There are 4 main options on how to do this.
 
{| class="wikitable"
* Generate a Grid of Rooms, which is them converted into a connected List of Rooms, which are then used to generate tiles.
|-
* Generate a connected List of Rooms, and then use those rooms to generate tiles.
! Type !! Example !! Description !! Usage
* Generate Tiles directly.
|-
* Load a Pre-made Map.
| [[Grid of Rooms Generation]] || [[File:FloorGen_Grid_Tiles.png|Frameless]] || Rooms generate inside of a grid with cells. ||Most dungeon floors
 
|-
The type of floor gen you choose in the editor will dictate which options you have:
| [[List of Rooms Generation]] || [[File:FloorGen_Floor_Tiles.png|Frameless]] || Rooms generate freely, spreading out from defined halls and rooms. || Uncommon, but used for some dungeon floors
 
|-
[[File:FloorGen_Type.png|frameless]]
| [[Stairs Floor Generation]] || [[File:FloorGen_Tiles_Tiles.png |Frameless]] || Tiles are generated directly on a base of walls. || Rare, primarily debugging
 
|-
 
| [[Load Generation]] || Anything! || Load a pre-made map. || Secret rooms, final floor treasure rooms
=== Generating Tiles Directly ===
|}
 
To learn more about the technical details of how they generate, visit their pages.
Direct tile generation will randomly generate wall and floor tiles, and then add a start and end point somewhere in the result.  To use this approach, make the floor a <code>StairsFloorGen</code>.
 
* The first step needed is <code>InitTilesStep</code>, which specifies the dimensions of the floor in tiles and initializes a grid of wall tiles.
 
[[File:FloorGen_Tiles_Empty.png|frameless]]
 
* Then an algorithm is used to carve out floor tiles out of the dungeon, such as <code>SpecificTilesStep</code> or <code>PerlinWaterStep</code>.
 
[[File:FloorGen_Tiles_Tiles.png|frameless]]
 
* Finally, <code>StairsStep</code> is used to choose a start and end tile on a walkable tile(purple).
 
[[File:FloorGen_Tiles_Start_End.png|frameless]]
 
While this approach theoretically works has been used in some debug room tests, it has never shown up in practice due to its inflexibility compared to the Grid or List of Rooms methods that follow.
 
=== List of Rooms ===
 
List of Rooms is an approach that splits generation into rooms and hallways, planning out their dimensions before filling in the tile details. To use this approach, make the floor a <code>RoomFloorGen</code>. 
 
 
* The first step needed is <code>InitFloorPlanStep</code>, which initializes a space for which to plan out rooms and halls:
 
[[File:FloorGen_Tiles_Empty.png|frameless]]
 
* Then, a path generator such as <code>FloorPathBranch</code> is run to place the rooms with connecting halls between them (yellow):
 
[[File:FloorGen_Floor_Rooms_Halls.png|frameless]]
 
* Then, the list of room and halls are then translated into tiles, using <code>DrawFloorToTileStep</code>.
 
It accomplishes this by first asking each room to generate its tiles:
 
[[File:FloorGen_Floor_Rooms_To_Tiles.png|frameless]]
 
Then, the hall algorithms are asked to generate:
 
[[File:FloorGen_Floor_Rooms_Halls_To_Tiles.png|frameless]]
 
This leaves us with all floor tiles:
 
[[File:FloorGen_Floor_Tiles.png|frameless]]
 
* Lastly, the start and end tile are marked, by first selecting 2 separate rooms (pink) and then choosing a tile (purple) in each room to put the marker.  The step responsible for this is <code>FloorStairsStep</code>
 
[[File:FloorGen_Floor_Start_End.png|frameless]]
 
Room Floors are somewhat uncommon and has few templates to choose from for floor shape.  However it's possible to vary the floor shape a lot simply by choosing different room types to generate with.


 
== About Steps ==
=== Grid of Rooms ===
 
Grid of Rooms is an approach that starts generation off with a grid of rooms, before planning out their dimensions and then filling in the tile details.  It is basically the List of Rooms approach with extra steps. To use this approach, make the floor a <code>GridFloorGen</code>.
 
* The first step needed is <code>InitGridPlanStep</code>, which initializes a grid of cells:
 
[[File:FloorGen_Grid_Cells.png|frameless]]
 
* Then, a path generator such as <code>GridPathBranch</code> is run to place rooms in the grid (blue) with connecting halls between them (yellow):
 
[[File:FloorGen_Grid_Cells_Chosen.png|frameless]]
 
Each room and hall filled in here are also assigned an algorithm at this step.
 
* The grid rooms and grid connectors are then translated into a list of rooms and halls, using <code>DrawGridToFloorStep</code>.
 
It accomplishes this by first having each room algorithm then choose its size and location:
 
[[File:FloorGen_Grid_Cells_To_Rooms.png|frameless]]
 
The rooms then signal their connection requirements to the halls, which then have their sizes chosen:
 
[[File:FloorGen_Grid_Cells_To_Rooms_Halls.png|frameless]]
 
Then finally by writing it out to an actual list of rooms and halls:
 
[[File:FloorGen_Grid_Rooms_Halls.png|frameless]]
 
* Then, the list of room and halls are then translated into tiles, using <code>DrawFloorToTileStep</code>.
 
It accomplishes this by first asking each room to generate its tiles:
 
[[File:FloorGen_Grid_Rooms_To_Tiles.png|frameless]]
 
Then, the hall algorithms are asked to generate:
 
[[File:FloorGen_Grid_Rooms_Halls_To_Tiles.png|frameless]]
 
This leaves us with all floor tiles:
 
[[File:FloorGen_Grid_Tiles.png|frameless]]
 
* Lastly, the start and end tile are marked, by first selecting 2 separate rooms (pink) and then choosing a tile (purple) in each room to put the marker.  The step responsible for this is <code>FloorStairsStep</code>
 
[[File:FloorGen_Grid_Start_End.png|frameless]]
 
Grid Floors are the most common approach to dungeon generation, with a large number of unique templates for floor shape.
 
=== Pre-Made Map ===
 
Pre-made maps directly load a file from the Data/Maps/ directory to be used as a dungeon map.  To use this approach, make the floor a <code>LoadGen</code>.
 
Only one step is needed, which is the file-loading step: <code>MappedRoomStep</code>
 
Pre-made maps are often used for fixed dungeon floors such as the reward rooms at the end of a dungeon, or secret rooms.
 
== Important Steps ==
 
While the Overview section covers the bare minimum steps to generate without error, you may notice that generating a map only with those steps will have no name, no music, no time limit, and even no textures, forcing you to rely on the minimap to understand the terrain.  This section covers steps whose absence will not cause errors, but are still essential to
 
== Priority System ==


Floor generation is broken down into an ordered list of steps, each assigned a priority.  The priority determines at what point in the generation process the step should be performed, with a lower number means a step will execute earlier.  While these priority numbers do not need to be obeyed for modding, they are the numbers that base PMDO uses.
Floor generation is broken down into an ordered list of steps, each assigned a priority.  The priority determines at what point in the generation process the step should be performed, with a lower number means a step will execute earlier.  While these priority numbers do not need to be obeyed for modding, they are the numbers that base PMDO uses.


Priority becomes especially handy when using [[Zone Steps]] to plan out dungeon features across multiple floors, rather than a single one.


To view each step that exists and what they do, see [[Floor Generation Steps]].


== Floor Data ==
== Priority Brackets ==
 
Each range of priority is generally used to perform different tasks. These are each bracket present in PMDO, and what they are generally used for.
Priority -6
{| class="wikitable"
 
|-
Examples:
! Priority !! Bracket !! Purpose
 
|-
* MapDataStep
| -7 || File Load || Loading a pre-loaded map.
* MapEffectStep
|-
* MapNameIDStep
| -6 || Floor Data || Setting the initial data of a floor.
* DefaultMapStatusStep
|-
* MapTimeLimitStep
| -5 || Grid Creation || Initializing the grid for [[GridFloorGen]].
 
|-
== Grid Creation ==
| -4 || Grid Path Generation || Generating the initial rooms and halls for [[GridFloorGen]].
 
|-
Priority -5
| -4.1 || Grid Special Generation || Generates special rooms outside of the general generation for [[GridFloorGen]].
 
|-
[[File:DungeonProcess_Cells.png|frameless]]
| -3 || Room List Creation|| Initializing the floorpan for [[RoomFloorGen]].
 
|-
Examples:
| -2 || Room List Generation || Generating the rooms and halls for [[RoomFloorGen]].
 
|-
* InitGridPlanStep
| -2.1 || Vault Pregen || Generation prior to special gen for [[RoomFloorGen]].
 
|-
== Grid Path Generation ==
| -2.2 || Room List Special || Generates special rooms for [[RoomFloorGen]].
 
|-
Priority -4
| -2.5 || Pre-Vault Clamp || Clamping of the map for vaults.{{Unverified}}
 
|-
[[File:DungeonProcess_Cells_Chosen.png|frameless]]
| -1 || Init Map || Initialize the size of the map.
 
|-
Examples:
| 0 || Draw Tiles || Draw tiles to the actual map.
 
|-
* GridPathBranch
| 0.1 || Unbreakable Layers || Create the unbreakable border around the map borders.
* GridPathCircle
|-
* GridPathTwoSides
| 0.2 || Floor Extras 1 || Add extra floor changes. This is one layer to perform them for priority reasons. Usually has vaults and barriers.
* GridPathGrid
|-
* GridPathBeetle
| 0.3 || Floor Extras 2 || Add extra floor changes. This is one layer to perform them for priority reasons. Usually has tunnels.
* GridPathTiered
|-
 
| 1 || Spawn Tables || Defining spawn tables for the floor.
* SetGridDefaultsStep
|-
* ConnectGridBranchStep
| 2 || Exits || Placement of entrances and exists.
* CombineGridRoomStep
|-
 
| 2.1 || Save Variables || Things that change depending on save variabes, such as rescues.
== Room List Creation ==
|-
 
| 2.2 || Sealed Detours || Generation for sealed detours.
Priority -3
|-
 
| 3 || Extra Terrain || The placement of extra terrain types, such as water and tall grass.
Examples:
|-
 
| 3.1 || Drop Diagonal || Uses [[DropDiagonalBlockStep]] on the extra terrain if needed.
* InitFloorPlanStep
|-
* DrawGridToFloorStep
| 3.2 || Erase Isolated || Uses [[EraseIsolatedStep]] on the extra terrain if needed.
 
|-
[[File:DungeonProcess_Cells_To_Rooms.png|frameless]]
| 4 || Textures || Assigns textures to the map.<br>At 4 because textures were formerly placed during this step, but are now placed after all steps are done.
[[File:DungeonProcess_Cells_To_Rooms_Halls.png|frameless]]
|-
[[File:DungeonProcess_Rooms_Halls.png|frameless]]
| 4.1|| Houses || Placement of [[houses]].
 
|-
== Room List Generation ==
| 4.2|| Shops || Placement of [[shops]].
 
|-
Priority -2
| 5 || Tile Spawns || Spawning tiles, such as traps.
 
|-
Examples:
| 5.1 || Compass Spawns || The spawning of [[compass tiles]] specifically.
 
|-
* FloorPathBranch
| 6 || Spawn Money || The spawning of money.
 
|-
== Tiles Creation ==
| 6.1 || Spawn Items || The spawning of items.
 
|-
Priority -1
| 6.2 || Spawn Extra Items || The spawning of additional items with other steps.
 
|-
Examples:
| 6.2 || Spawn Mobs|| The spawning of mobs.
 
|-
* InitTilesStep
| 6.2.1 || Spawn Extra Mobs|| The spawning of additional mobs outside of the base spawn steps.
* DrawFloorToTileStep
|-
 
| 7|| Debug Checks || Steps that check the dungeon for issues, throwing an error if one is found.<br>Useful for [[Stress Testing]].
[[File:DungeonProcess_Rooms_To_Tiles.png|frameless]]
|}
[[File:DungeonProcess_Rooms_Halls_To_Tiles.png|frameless]]
[[File:DungeonProcess_Floor.png|frameless]]
 
== Tiles Generation ==
 
Priority 0
 
Examples:
 
* SpecificTilesStep
 
== Spawn Tables ==
 
Priority 1
 
Examples:
 
* MoneySpawnStep
* ItemSpawnStep (Priority 1.1)
* MobSpawnStep (Priority 1.2)
* TileSpawnStep (Priority 1.3)
 
 
== Exits ==
 
Priority 2
 
Examples:
 
* FloorStairsStep
* StairsStep
 
== Water ==
 
Priority 3
 
Examples:
 
* PerlinWaterStep
* BlobWaterStep
 
== Textures ==
 
Priority 4
 
Used to be here because textures were actually placed here, but now only assigns textures to the map itself and lets the map compute them after ALL steps are done.  Thus, this step is the least dependent on its current position in the steps.
 
Examples:
 
* MapTextureStep
* MapDictTextureStep
 
== Tile Spawns ==
 
Priority 5
 
Examples:
 
* RandomSpawnStep
* DueSpawnStep
* TerminalSpawnStep
 
== Spawns ==
 
Priority 6
 
Examples:
 
* All steps in Tile Spawns
* PlaceRandomMobsStep
* PlaceDisconnectedMobsStep
* PlaceNoLocMobsStep
 
== Debug Checks ==
 
Priority 7
 
These gen steps are used to check the dungeon for issues, and throw an error if they're found. Useful for [[Stress Testing Dungeons|stress testing]].
 
Examples:
 
* DetectIsolatedStairsStep
* DetectTileStep


[[Category:Modding Data]]
[[Category:Dungeon Generation]]

Latest revision as of 00:28, 17 August 2025

Floor generation is performed as a list of steps, which allows a developer to customize their floor layout at every part of the pipeline. This page covers the basics of what each step is responsible for and why it is needed.

For information on what steps are required to create a floor from scratch, see Creating Dungeons from Scratch.

Overview

A dungeon map can be generated without items, enemies, or traps. But at a bare minimum, a dungeon map must generate terrain (plus entrance/exit) in order to complete without errors. There are 4 main options on how to do this.

Type Example Description Usage
Grid of Rooms Generation Frameless Rooms generate inside of a grid with cells. Most dungeon floors
List of Rooms Generation Frameless Rooms generate freely, spreading out from defined halls and rooms. Uncommon, but used for some dungeon floors
Stairs Floor Generation Frameless Tiles are generated directly on a base of walls. Rare, primarily debugging
Load Generation Anything! Load a pre-made map. Secret rooms, final floor treasure rooms

To learn more about the technical details of how they generate, visit their pages.

About Steps

Floor generation is broken down into an ordered list of steps, each assigned a priority. The priority determines at what point in the generation process the step should be performed, with a lower number means a step will execute earlier. While these priority numbers do not need to be obeyed for modding, they are the numbers that base PMDO uses.

Priority becomes especially handy when using Zone Steps to plan out dungeon features across multiple floors, rather than a single one.

To view each step that exists and what they do, see Floor Generation Steps.

Priority Brackets

Each range of priority is generally used to perform different tasks. These are each bracket present in PMDO, and what they are generally used for.

Priority Bracket Purpose
-7 File Load Loading a pre-loaded map.
-6 Floor Data Setting the initial data of a floor.
-5 Grid Creation Initializing the grid for GridFloorGen.
-4 Grid Path Generation Generating the initial rooms and halls for GridFloorGen.
-4.1 Grid Special Generation Generates special rooms outside of the general generation for GridFloorGen.
-3 Room List Creation Initializing the floorpan for RoomFloorGen.
-2 Room List Generation Generating the rooms and halls for RoomFloorGen.
-2.1 Vault Pregen Generation prior to special gen for RoomFloorGen.
-2.2 Room List Special Generates special rooms for RoomFloorGen.
-2.5 Pre-Vault Clamp Clamping of the map for vaults.(unverified)
-1 Init Map Initialize the size of the map.
0 Draw Tiles Draw tiles to the actual map.
0.1 Unbreakable Layers Create the unbreakable border around the map borders.
0.2 Floor Extras 1 Add extra floor changes. This is one layer to perform them for priority reasons. Usually has vaults and barriers.
0.3 Floor Extras 2 Add extra floor changes. This is one layer to perform them for priority reasons. Usually has tunnels.
1 Spawn Tables Defining spawn tables for the floor.
2 Exits Placement of entrances and exists.
2.1 Save Variables Things that change depending on save variabes, such as rescues.
2.2 Sealed Detours Generation for sealed detours.
3 Extra Terrain The placement of extra terrain types, such as water and tall grass.
3.1 Drop Diagonal Uses DropDiagonalBlockStep on the extra terrain if needed.
3.2 Erase Isolated Uses EraseIsolatedStep on the extra terrain if needed.
4 Textures Assigns textures to the map.
At 4 because textures were formerly placed during this step, but are now placed after all steps are done.
4.1 Houses Placement of houses.
4.2 Shops Placement of shops.
5 Tile Spawns Spawning tiles, such as traps.
5.1 Compass Spawns The spawning of compass tiles specifically.
6 Spawn Money The spawning of money.
6.1 Spawn Items The spawning of items.
6.2 Spawn Extra Items The spawning of additional items with other steps.
6.2 Spawn Mobs The spawning of mobs.
6.2.1 Spawn Extra Mobs The spawning of additional mobs outside of the base spawn steps.
7 Debug Checks Steps that check the dungeon for issues, throwing an error if one is found.
Useful for Stress Testing.