Procedurally Generated Office Environments for a Top-Down Shooter


Hi, I’m Henri, the level designer of the project. Mainly I’ve been making rooms and the hand crafted special stages (if you’ve played the game, I’m sorry, I have most likely gotten you killed in all kinds of devious ways) but I also programmed one of the level generators, which is described in this post. Everything below will happen within one second or a bit more depending on the processing power.

Chapters 1, 3 and 4 in Neon Chrome use variations of a generator introduced earlier, but Office (chapter 2) and Hospital (chapter 5) have a different, somewhat simpler approach. This post is about the office generator, but Hospital has a similar approach, only the stage is split into 11×11 rooms (instead of office’s 16×16) and has multiple branches (office levels always have only one path).

Nexus-Release 2016-03-18 11-54-23-348
The basic layout on which we build

First off, the generator rounds the stage size to closest size divisible by 16, and adds one tile to each direction for outer walls and cityscape. Maximum size is 48×48, but playtesting showed those maps to be too long so. In the end office maps are usually 48×32 or 32×32.

After this the stage is split into 16×16 segments. In devspeak these were called “aggregates”, because they usually have smaller rooms within. One of the corners is chosen as the start and one of the appropriate directions as the starting direction.

The generator then travels in the starting direction until the stage ends, then turns. After this there is a 50% chance the path turns again or continues going forward in the new direction (if possible). Originally the path was to be always S-shaped (the maps were also always 48×48 – or 3×3 in “macroscale” if it makes more sense). This possibility of variance was born almost accidentally when trying to see if U-turns would work as a basic path shape.

Nexus-Release 2016-03-18 11-55-56-591
The aggregates are in place

In the next phase the generator picks suitable 16×16 rooms. There are three kinds of aggregates (large areas, which can contain smaller rooms): generic, turns and straights. Some aggregates are spawned “as is”, as in there are no markers for smaller rooms inside them. There’s no specific type for dead ends – they use generic types instead. Dead ends may have given even more variety, but the final product works nicely even without them. Generic types are the safe choice for all situations, as they can have a door in any direction. Straight pieces are always skybridges, for added visual and gameplay variety.

The small green circles around the edges are markers for possible door locations. Originally they were to be used to choose the door positions, but it turned out to be more difficult than anticipated. In the end the door positions is determined by basically splitting the wall into two parts, and checking the direction and shape of the room. The markers are still used as a failsafe if the main method fails to find a suitable door position.

Nexus-Release 2016-03-18 11-57-43-634
Still missing doors and loot, but we’re getting there

There are also some lone markers which are not on the edges. Those are for smaller rooms of varying size and type. Sizes range from 6×6 to 10×10, and are always square. Types are “open” and “closed”, difference being that the closed ones are always surrounded by walls and have a defined doorway direction. Closed types can vary from open office workstations to a supply closet and can be freely rotated in 90 degree angles.

aggregate_before_after
Here’s an example of a 16×16 aggregate before and after the process

Next up, the smaller rooms are placed as well as the thick walls. Office maps are usually more open than in the other chapters, especially as you can destroy most of the walls. The walls between each aggregate are thick, which are indestructible. This was done to keep some restraint on how much the player can cut corners.

If there’s a straight piece in the map, the building’s exterior wall will always be in that direction. Black ground tiles are added to the other directions to make it feel more like you’re in the middle of a huge building.

Nexus-Release 2016-03-18 12-00-09-612
Everything is in place, time to play!

All the placeholders are then replaced. Just like in the other generators this includes small and big placeholders for loot and decorative items, and enemies. For enemy placement we scan all the enemy positions, remove them, and then add new ones fitting the level scale and wanted total power. Enemy power is spread between all the aggregates unevenly, trying to make some breathing room between bigger concentrations of enemies.

And finally the doors and some details like ground decals and the cityscape are added. Now the level is ready to play.

Thanks for reading!

2 Comments

  • Hi. There are a couple visual bugs on the ps4 version. Aiming line is off centred and detatched from weapons, this is more noticeable when facing up or down the screen. Also enemies with a vision cone, the vision cone is detatched and off centred. You can see these bugs in action on youtube on the ps4 playthroughs. Will this be fixed at some point?

Comments are closed.