-
-
Notifications
You must be signed in to change notification settings - Fork 60
Dungeon Generator
The dungeon generator is an actor placed in your main level. It is responsible to generate the dungeon and spawn the room levels.
To create one, create a new blueprint, expand "All Classes" and type DungeonGenerator
.
The dungeon generator don't work directly by itself, you have to create data and levels for your rooms first.
To be able to generate a dungeon, you also have to override some minimal functions:
There are some other functions you can override:
Function | Description |
---|---|
Pre Generation | Called before anything else when the generator is about to generate a new dungeon. |
Post Generation | Called after loading and initializing all rooms of the dungeon. Use it to spawn or teleport players in the first room. |
Generation Init | Called each time the generation start over when Is Valid Dungeon returns false. Mostly used to reset all your custom generation variables. |
Generation Failed | Called when Is Valid Dungeon returned false after too many generation attempts. No dungeon is generated when this is called. |
On Room Added | Called when a room is successfully added to the dungeon (but not spawned yet). The added room is destroyed when Is Valid Dungeon returns false (you may have to use GenerationInit to reset variables changed from this call). |
Initialize Dungeon | Called after Continue To Add Room returned false. Allows you to initialize room instances before validating the dungeon with Is Valid Dungeon (useful if you want for example locking some rooms and putting keys in other ones). |
Function | Description |
---|---|
Generate | Launch the generation of the dungeon (for multiplayer games, it starts the generation when called on the server, and does nothing when called on clients). |
Unload | Unload all exiting rooms and clear the dungeon. |
Get Random Room Data | Returns a room data chosen randomly from the provided array (deterministic with the dungeon generator seed). |
Get Compatible Room Data | Returns all room data (from the provided list) having at least one door compatible with the provided door type. |
Get Random Stream | Returns the dungeon random stream (useful to generate deterministically other random stuff). |
Function | Description |
---|---|
Count | Return the current number of room instances during the generation, or total number of room instances after generation. |
Has Already Room Data | Returns whether the dungeon contains at least one room of the specified room data. |
Has Already One Room Data From | Returns whether the dungeon contains at least one room of one of the specified room data. |
Count Room Data | Returns the number of room instances of the specified room data. |
Count Total Room Data | Returns the total number of room instances of all the specified room data. |
Has Already Room Type | Returns whether the dungeon contains at least one room of the specified room data class. |
Has Already One Room Type From | Returns whether the dungeon contains at least one room of one of the specified room data classes. |
Count Room Type | Returns the number of room instances of the specified room data class. |
Count Total Room Type | Returns the total number of room instances of all the specified room data classes. |
Get All Rooms | Returns an array containing all room instances of the generated dungeon. |
Get All Rooms From Data | Returns an array containing all room instances of a specific room data. |
Get All Rooms From Data List | Returns an array containing all room instances of any of the provided room data. |
Get First Room From Data | Returns the first found room instances of a specific room data (no specific order, can be any room in the dungeon). |
Get All Rooms With Custom Data | Returns an array containing all the room instances having a specific custom room data. |
Get All Rooms With All Custom Data | Returns an array containing all the rooms instances having all custom data provided. |
Get All Rooms With Any Custom Data | Returns an array containing all the rooms instances having at least one of the custom data provided. |
Get Random Room | Returns a random room instance from a list of room instances (deterministic with the dungeon generator seed). |
Has Valid Path | Returns whether a path exists between 2 room instances. |
The Dungeon Generator
actor has some parameters grouped inside the Procedural Generation
category:
If checked, the dungeon will be offset and rotated using the dungeon generator actor's transform.
If unchecked, the first room will be placed at world's (0,0,0) and no rotation will be applied.
- The
depth first
will prioritize the last added room to continue the generation. This will result in a dungeon more linear with shorter dead ends. - The
breadth first
will prioritize the first added room to continue the generation. This will result in a more spread dungeon.
This is an example using the same very basic generation rules defined in this wiki. We just set a counter of 20 rooms to add the end room. So with depth first we have a lot of rooms to reach the end but dead-ends of only 1 room each. And with the breadth first, we have less rooms until the end, but the dead-ends are the same length of the path to reach the end (some dead-ends are shorter because the algorithm can't place a room after).
If checked, when a new room is placed in the dungeon, any door aligned with another door of other rooms will be connected.
If unchecked, only the door from the previous room (the one used to generate this room) will be connected.
This parameter is only used when Can Loop
from the project-wide settings is also checked.
-
Random
: at each generation, the seed is randomly chosen. -
Auto Increment
: the initial seed is used the first time, then a fixed number will be added at each generation. This will produce different dungeon at each generation, but you will have the same generation sequence each time you play. -
Fixed
: the initial seed is used each time you generate, so you will always get the same dungeon.
The initial seed you want to use if the Seed Type
is not Random
The number used to increment the seed if the Seed Type
is Auto Increment
When checked, the dungeon generator will test a box overlapping with world static actors in order to allow or not a room to be generated.
This can be CPU-intensive and should be used only when necessary. Though, it is only used during the generation process, not during gameplay.
You can join the Discord server dedicated to this plugin if you want to share, help or ask questions about it.
Installation
Getting Started
Room Architecture
Door
Plugin Settings
Packaging
Dungeon Generator
Choose First Room Data
Choose Next Room Data
Continue To Add Room
Is Valid Dungeon
Occlusion Culling
Door Types
Room Initialization
Room Custom Data
Room Visitor
Room Observer
Console Commands
Multiplayer
Navigation Mesh
Geometry Brushes
If you like my plugin, please consider tipping: