Procedural Prefab Generation part 2
More work the prefab tool this week. I have some preset layouts on which I can try and apply any prefabs. In that video I'm selecting some cavern area preset and I'm applying a prefab that puts a rectangular carpet, statues along its longest axis and a throne away from the entrance. I can regenerate layout, connections or prefab placement with a key, so I can quickly see behaviour in different cases, that's shown in the video. So far so good, placement algorithm is demonstrated to work on a number of simplistic layouts (rectangular room, rectangular cave), so what's next?
End goal of prefab system
Sometimes I miss the forest for the trees, as I like delving at low level algorithms, so ... why am I making the prefab system again? And how many procedural systems do I have? So ...
- Procedural layout generator (water/wall/floor/connections)
- supports a fixed layout "prefab" generator
- supports embedding generators inside other generators, as "zones" (zones are thematic areas)
- Optional procedural placement of "features" in an entire zone. Features are more generic elements, like "trap"/"encounter"/"treasure", but can also be specific like "fountain".
- Optional explicit placement of exact elements in a zone (e.g. a particular creature, etc).
- Any procedural layout generator that supports "rooms" (e.g. a basic dungeon), also supports room prefabs: pregenerated fixed rooms with fixed dimensions and content
- Now I'm adding support for procedural prefabs in given areas (zones or rooms), which is a different algorithmic approach to the "features" approach above.
If it's not clear: the above system is messy. I'm effectively creating generators and I'm trying to mix them together. There's duplication and duct-taping as needed. There are certain elements that are still missing, so I can't create all the scenarios that I wish, yet. I'm going to list them below, and how I will imagine they'll fit into the system (with adjustments of the system)
- Boss lair
- It's a zone embedded in a level (so, a bigger zone, e.g. a dungeon)
- The layout should be procedural (using a layout generator)
- The contents should be themed, but procedurally generated (so it should use the procedural prefabs that I'm adding now)
- Hunter's lodge area (see image)
- It's an open zone embedded in certain wilderness zones, containing a small building/room, a campfire, maybe a crate or two.
- The area layout should be procedural, but nothing complex ( open, roughly rectangularly shaped area, with enough space to put all required elements)
- The area contents (campfire, crates) should use some special procedural prefab code
- The lodge itself should be a sub-zone, using a simple generator, e.g. called HUNTERS_LODGE
- The layout of the lodge should be procedural, but possibly as simple as a rectangular room, but it needs to be themed (e.g. wooden)
- The contents of the lodge should use some special procedural prefab generator, e.g. some LODGE preset/algorithm that adds a bed, a kitchen, anything else needed for a cabin in the woods.
- Wolf cave area
- It's an open zone embedded in certain wilderness zones, containing a small cavernous area, and some skulls near the area entrance
- The area layout should be procedural, but nothing complex ( open, roughly rectangularly shaped area, with enough space to put all required elements)
- The area contents (skulls) should use some special procedural prefab code
- The cave itself should be a sub-zone, using a simple generator, e.g. called BEAST_CAVE
- The layout of the cave should be procedural, using a simple cave generator
- The contents of the cave should use some special procedural prefab generator that can place skulls, blood and a "beast pack" encounter, which will be evaluated (somehow somehow, in C#) to wolves
So, hopefully you can see the pattern. A part that's tough is to make the generators ... generic, whereas when we're evaluating the prefabs, we map those generic results to anything themed that're required. That's still heavy WIP.
Next steps
After tinkering with the prefab editor and realising that the iteration speed can be superfast (no unity whatsoever), I need to do two things:
- Improve the prefab tool to support any sort of layouts. Any that can be used for level/zone generation. This means reading the same config files that C# reads to be able to generate dungeons, caverns and so on. This is useful for themed procedural placement of specific things (e.g. rows of statues along a carpeted area) in larger-than-a-room areas (or just more complex).
- Make another tool to test out interactively the zone embedding. I've shown results in the past, but those were generated from some mega loop that created variations. I want something interactive where I can quickly select what zone should be in what zone, and click click generate and visualize many variations of the map. It's easier than it sounds, if the different zones are specified already as presets and I just say "Make a wilderness that contains a dungeon that contains a temple" using either some simplistic json and re-loading in the app, or using some basic UI