Carpet, statues and throne generated procedurally based on script
Carpet, statues and throne generated procedurally based on script
I've started working on refactoring the room/zone prefab code in the dungeon generation process. Just to get the terms out of the way, a level map can be comprised by different zones which can be embedded in each other, e.g. a dungeon zone could be part of wilderness-forest zone, and inside the dungeon zone we could have some cathedral zone, and so on (if one can stomach all the configuration to set that up, which is manual atm). On the other hand, certain dungeon generators use "rooms" as the units to place (e.g. your typical dungeon, rather than the wilderness).

Rooms or zones can be prefabs or completely procedural. The problem is that currently, prefabs are quite static: There's some allowance to procedurally generate generic things like encounters, treasures, traps, etc in them, but there's no thematic/structured generation really.

What I want to do (and I am doing now) is a hybrid prefab model, where I can specify some parameters and generate a thematic prefab, e.g. I want a throne room with statues, but it should be able to be placed in arbitrary sized rooms, and ideally I should be able to generate infinite variations: keep the "structure" but change the flavor and positions of things. We're amazing at detecting patterns, so copy-paste prefabs are easily identifiable and break the immersion.

This procedural prefab work is currently done at the native plugin level: the algorithms do not know much about game elements etc, but only about rules. I want to place a "thing" that is a blocker (chair, table, statue) so I can't place it on top of other blockers, or in a way that's blocking a narrow passage, etc. Or I want to place a carpet in the room, in the largest possible clear rectangle. Or place things (like statues, or a throne, or tables) along such a rectangle. The algorithm input includes some identifiers, specified dynamically from the game, so that during the game we can tell the algorithm "generate a creature somewhere there next to the throne" and in the place of the creature we can put Gormm the bloodthirsty barbarian king. And also include another algorithm that says "generate some object in the back of the room" and these can be mapped to chests in the game. The algorithm does not know about chests, it only knows that it's a blocker object.

Script for above figure
Script for above figure



At the moment I have a few such algorithms set up, and I'm setting up a better toolchain in C++ (that I love to work in anyway). This will include a procedural prefab editor to see results immediately, so that I'll be able to quickly generate procedural prefabs. At the moment the C++ side of things does not include autotile rules, so visualisation is a bit primitive.

After I've explored this space a bit, I need to hook it up to the rest of the dungeon generation, and this will include refactoring of some of the C++ dungeon generation, some of the C# post-dungeon-generation code , and the data transmission format which needs to include this new procedural prefab generated data.