Floor Generation Overview

From PMDOWiki
Revision as of 23:19, 12 March 2023 by IDK (talk | contribs)

This page goes over the of generation a single floor of a dungeon segment.

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:

  • 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.
  • Generate Tiles directly.
  • Load a Pre-made Map.

The type of floor gen you choose in the editor will dictate which options you have:

Grid of Rooms

Grid Floors are the most common approach to dungeon generation, with a large number of unique templates for floor shape. To use this approach, make the floor a GridFloorGen.

  • It starts off by initializing a grid of cells using InitGridPlanStep:

  • Then, a path generator such as GridPathBranch is run to place rooms in the grid (blue) with connecting halls between them (yellow):

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 DrawGridToFloorStep.

It accomplishes this by first having each room algorithm then choose its size and location:

The rooms then signal their connection requirements to the halls, which then have their sizes chosen:

Then finally by writing it out to an actual list of rooms and halls:

  • Then, the list of room and halls are then translated into tiles, using DrawFloorToTileStep.

It accomplishes this by first asking each room to generate its tiles:

Then, the hall algorithms are asked to generate:

This leaves us with all floor tiles:

  • Lastly, the start and end tile are marked, by first selecting 2 separate rooms and then choosing a tile in each room to put the marker. The step responsible for this is FloorStairsStep


List of Rooms

To use this approach, make the floor a RoomFloorGen. 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.

Generating Tiles Directly

A direct tile generation algorithm would skip generating grids or rooms, and just generate the tiles directly, plus the start and end.


To use this approach, make the floor a StairsFloorGen. However, this algorithm has been rarely used and has existed mostly for debug rooms.

Pre-Made Map

To use this approach, make the floor a LoadGen. Pre-made maps are often used for fixed dungeon floors such as the reward rooms at the end of a dungeon, or secret rooms.

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 Data

Priority -6

Examples:

  • MapDataStep
  • MapEffectStep
  • MapNameIDStep
  • DefaultMapStatusStep

Grid Creation

Priority -5

File:DungeonProcess Cells.png

Examples:

  • InitGridPlanStep

Grid Path Generation

Priority -4

File:DungeonProcess Cells Chosen.png

Examples:

  • GridPathBranch
  • GridPathCircle
  • GridPathTwoSides
  • GridPathGrid
  • GridPathBeetle
  • GridPathTiered
  • SetGridDefaultsStep
  • ConnectGridBranchStep
  • CombineGridRoomStep

Room List Creation

Priority -3

Examples:

  • InitFloorPlanStep
  • DrawGridToFloorStep

File:DungeonProcess Cells To Rooms.png File:DungeonProcess Cells To Rooms Halls.png File:DungeonProcess Rooms Halls.png

Room List Generation

Priority -2

Examples:

  • FloorPathBranch

Tiles Creation

Priority -1

Examples:

  • InitTilesStep
  • DrawFloorToTileStep

File:DungeonProcess Rooms To Tiles.png File:DungeonProcess Rooms Halls To Tiles.png File:DungeonProcess Floor.png

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.

Examples:

  • DetectIsolatedStairsStep
  • DetectTileStep