Updated procedural gen & mini-map

This week I updated my procedural generation system. I fixed previously undiscovered bugs and allowed for the placement of treasure rooms and boss rooms. Alongside this I added a prototype mini-map to stop people from getting as lost as before.

This week the devlog is coming 1 day early because I’ll be busy tomorrow.

End room detection

I hadn’t noticed it until recently but my “detect end room” method was extremely flawed. I hadn’t noticed because it successfully worked on single tiled rooms but would automatically eliminate 2×2 rooms and 1×2 rooms not jutting out. This makes sense as the method checked how many neighbour tiles were occupied. In a 2×2 it is guaranteed to have 2 neighbour tiles. That being itself.

This new system differentiates from multi-tile rooms and single tile rooms and changes accordingly. Single tile end rooms are calculated exactly the same but now the multi-tile rooms do not classify themselves as a neighbour.

However this causes another issue. Now one of the corners of a 2×2 room can call itself an end room if no other room directly attaches to it. As of yet this is a non-issue as the only application for end rooms is determining which should be turned into treasure rooms and which can have a boss room attached to them. As the boss room will take the furthest end room and then go to the adjacent slot furthest from that the chance of an issue occurring is extremely low. Below is a diagram of the end rooms and the current issue.

A way to solve the fraudulent end rooms is to have adjacent self-tiles also check adjacent tiles but I will not do this for now. The reason is because it is wholly unnecessary, and few issues can arise.

Generation Failure

So, what happens when the generation fails. If there aren’t enough 1×1 end rooms for treasure, the boss room can’t spawn for whatever reason? What happens is the generation re-tries. This isn’t efficient but the success rate is high enough I have never seen more than 2 generation attempts. Theoretically if the stars aligned, a level may never generate locking players into an endless loading screen. But I believe the odds of this are so low it shouldn’t be a problem. I have heard that the game “Binding of Isaac” uses this exact retry method but I have no official source for that.

Treasure room

I added the greybox for the treasure room and adjusted the function in charge of spawning it. The thing that differentiates the design of the treasure room from the others is it only has 1 door. The spawning method has been adjusted to account for this and orientate the room towards its 1 lone neighbour. This should serve to differentiate the room from others and which should let uninformed players know something is special with the room. Below is a greybox for treasure room.

Boss Room

The boss room is an empty room for now. The boss room also has a maximum of 1 door. Utilising the same method as the treasure room the spawning method has been changed to orientate that room towards its intended entrance. However due to the size of the room it’s intended entrance may not be its sole adjacent room. This would cause issues as the function in charge of opening the doors does not care what type of room is next to it, only that there is a room.

This is because the doors are opened using a raycast. The solution used is to give the walls of the boss room their own layer (except for the section of wall with the door). I dislike this solution a lot. I have thought for a long time about how to convey the information from the spawning system to the rooms themselves and I couldn’t come up with an elegant solution. So, if my opens are 2 highly inelegant solutions but 1 has the potential to be a heavy performance tax, I’ll go with the cheaper solution. However, the mini-map may force me to connect the rooms to the spawning system.

Inside the boss room sits a placeholder “boss” this is technically a different enemy but it is just that one enemy I have x5 the size and speed.

This prototype mini-map uses exclusively renders a layer called mini-map. This layer contains only in world UI that float Y level 100+ above their respective objects. An orthographic camera rendering only that layer sits above all watching down. This is then cast to a render texture and placed on the screen.

The mini-map works fine for what it is, but I’ll need some sort of world map eventually because the level is still rather confusing.

The current mini-map uses same system as the combat zones to detect when a player enters a room. Doing so causes the rooms UI element to appear, thus appearing on the mini-map.

A major issue with this system is the doors to unexplored areas aren’t marked. Meaning the only way to check if it is truly a dead end is to look at where the door would be. This isn’t optimal as backtracking would be extremely tedious. My solution to this is have the aesthetic doorways also have UI elements that indicate doors on the map. The biggest issue with this system is determining when to show these elements. These doorframes are not attached to the room spawner nor the individual rooms. The only way I can conceivably imagine this happening is attaching both them and the rooms to the spawning system so a doorway can be assigned its 2 connected rooms.

The other method is to forgo the rooms appearing when entering method and go for a fog of war method. Both these methods will work for the game thematically and I have no strong preference for either, so it comes down to difficulty. I’ll need to look further into it, but it at least gives me an out if one proves especially difficult. However the spawning integrated system can give greater flexibility in map interaction.

Next, I’m going to get the more complete mini-map system working. Whether that be fog or doorways its going to happen. I will try doorways first because my mind’s eye says it’ll look great.

I assume this will take a very long time to complete but as stretch goals I will add a boss health bar and a dialogue system.

A boss health bar will also entail moving a large amount of enemy NPC variables to a scriptable object so that will come with the cleaning of code. A dialogue system is also necessary for a playtest as I need an in-game way of telling players what to do. I require the one NPC in the spawn area to tell the player “go attack the fancy tomb to start the game” of course not like that but in effect.

Leave a comment