So, I’ve been wondering, how would I go about creating a map generation system that coincides with a seed the user can input? No, not terrain generation, I mean generation involving manmade structures, with hallways that turn the direction of a hallway connected to it. If you have ever played SCP: Containment Breach, you should know what I mean by so.
I’m quite stumped on this and need some ideas and tips to get me started in the right direction. I know there’s a github source code repository from SCP CB, but I have been told MapSystem.bb is poor, as well as all of the code in the game being a complete mess.
What I’m needing to know is how to make sure the hallway aligns with the angle and position of another room, including 3-way and 4-way hallways in the most efficient and effective way possible with little lag.
Thanks in advance!
(also I’m not asking for people to give me scripts, just asking on tips about this specific area)
6 Likes
If you want your randomized structures to be based on a seed, you can set math.randomseed(number) before any math.random() calls.
I never played SCP: Containment Breach, but I’m assuming it works like how a lot of dungeons work, randomized rooms that don’t intersect. There are a lot of ways to go about doing this, but here’s a method I thought up of just now:
First, create all the different kind of rooms/hallways that will exist in your game. They should be designed in a way to where you can attach them together and be able to make an entire hallway/building/etc with all the pieces.
When you start generating it from coding, first start with the basic spawnroom/entrance. From there, you randomly select a hallway/room from the list of hallway/rooms you made earlier and attach it correctly to the current room. Then, for every door way, you do the same thing.
You would have to figure out how stop collision between rooms, but this could be done using some kind of 2D array if your map is more of a box format. If not, you could do some 2D collision checks before placing a new room to make sure it’s not colliding with some other room.
Good luck!
6 Likes