Download

Creating procedural dungeons with Luos' Cave System and Sockets

I noticed while editing some of Luos’ caves that each section had 2 sockets, 0 and 1. I also know that it is possible to procedurally generate levels using instanced static meshes. It is also possible to attach a static mesh’s socket to another mesh’s socket.

Therefore, logic would dictate that it would be possible to generate a complex maze using the cave system. Would anyone like to enlighten us on where to research such a beast? :slight_smile:

-------------- Update 1 -----------------

Pretty simplistic logic:

Random dungeon logic
Give each mesh an index using an array (TileName)
Differentiate between rooms and hallways (TileTypeRoom, TileTypeHallway, TileTypeSeam, TileTypeCap)
Get each actor bounds and set it to an index (TileSizeX, TileSizeY, TileSizeZ)
Get a random Room tile and place at world origin
Give each socket in that mesh an index using an array (TileStartSockets)
At a random socket, place an End Cap transition
Remove that socket from the array
At a random location in this room, add a player start
For each socket in the room:

  • Get a random hallway, give each socket an index (TileTempSockets)
  • Place the first socket on the room socket
  • Add a seam
  • Remove the socket indexes of the hallway and room from their arrays
  • Loop through each socket, adding either a hallway or a room
  • Check each mesh, if that mesh’s bounds intersect another meshes bounds, then try another
  • The dungeon size will be how many rooms are added – 1 (the entrance) (DungeonSize)
  • When the room size has been met, then go through each hallway and room socket and cap it + seam it

-------------- Update 2 -----------------

Created 5 arrays: Rooms, Hallways, Seams, Caps, Sockets
Created 3 functions: Generate random room, Find Socket Info, Generate Random Hallway

-------------- Update 3 -----------------

Ran into issues with removing items from the array… and it’s almost 04:00 in the morning… so here’s what I have gotten thus far:

Added all of the I, L, T, X, Caps, and Seams to their own arrays

-------------- Update 4 -----------------

Decided to take everything out of the functions for troubleshooting. Ended up being a Set that wasn’t included. Yay. Sort of fixed, except for Initial seed value of 512 will only spawn 1 room, nothing else

-------------- Update 5 -----------------

So I re-did most/all of the functions for readability and code optimization. If you use a set of blueprints consistently, they should be set to a Blueprint function. So I did that. And what do you know… the system is broken, again. Triple checked everything in the functions versus what was working outside of functions, and everything is the same. Length tests through the array shows the length of the array being changed, however, the remove doesn’t remove the socket name that was used (or the socket name I’m feeding into the Remove Name). /sigh.

Of course, troubleshooting / debugging this is a nightmare since ALL VARIABLES ARE NOT IN SCOPE… I really hope Epic fixes this, which I’m wondering if that is why this bloody thing isn’t working.

-------------- Update 6 -----------------

I went ahead and completed the entire logic for the blueprint, even if the Name arrays aren’t being changed as they should be. I am doing a “sanity” check to test for collisions, if the instanced mesh collides with another mesh, then remove it, and put in a cap instead. To handle this, I thought of using bounds and vectors, however, it seems that this was a mistake, as all of the entries in the array are 0,0,0 instead of world coordinate space, so… yea. I might need to do something with GetWorldPosition instead.

Why can’t there be a sane collision test “Does this overlap something else” :\

-------------- Update 7: Major Change -----------------

Small update… I decided to delete everything and start over. Its pretty remarkable at how optimized the code is now (for what it can be) now that I sort of know what I’m doing :slight_smile:

I am trying to investigate a way to use 3 separate blueprints (1 for each mesh “type”), a blueprint function library, and a “System Builder” blueprint to put everything together. No idea how to do that, but I’m sure I’ll find a way.

There are a few ways to do this. Since all of the pivot points are at the socket named “Socket”, and I’m trying an iterative approach to level building. Choices choices.

-------------- Update 8: Blueprint tweaking -----------------

Instead of adding transition caps to every socket on the hallway (I got it to work!), I simplified the blueprint to only add a transition cap to the pivot point socket, “Socket”. I’m also looking at using Hierarchical Instanced Static Meshes instead of Static Mesh or Instanced Static Meshes. I should see a huge performance increase using this rather than the other two, or at least I hope!

Post some screenshots when you have it working. Wanted to try this a long time ago myself :slight_smile:

Pretty simplistic logic:

Random dungeon logic
Give each mesh an index using an array (TileName)
Differentiate between rooms and hallways (TileTypeRoom, TileTypeHallway, TileTypeSeam, TileTypeCap)
Get each actor bounds and set it to an index (TileSizeX, TileSizeY, TileSizeZ)
Get a random Room tile and place at world origin
Give each socket in that mesh an index using an array (TileStartSockets)
At a random socket, place an End Cap transition
Remove that socket from the array
At a random location in this room, add a player start
For each socket in the room:

  • Get a random hallway, give each socket an index (TileTempSockets)
  • Place the first socket on the room socket
  • Add a seam
  • Remove the socket indexes of the hallway and room from their arrays
  • Loop through each socket, adding either a hallway or a room
  • Check each mesh, if that mesh’s bounds intersect another meshes bounds, then try another
  • The dungeon size will be how many rooms are added – 1 (the entrance) (DungeonSize)
  • When the room size has been met, then go through each hallway and room socket and cap it + seam it

Here is the start of some randomization / making a massive cave system… the While condition gets plugged into the room count < dungeon size test from the 2nd screen shot. I’ll need to make a sanity check function so if a mesh’s bounds overlap another mesh’s, the it’s not placed. If it loops through the check w/o being able to put anything, it will put a cap on that socket location. After that, everything will loop through all of the sockets placing stuff randomly, until the room count is = dungeon size. Any left over sockets will have hallways (max of 3 placed in succession) (if applicable) or caps (if near another mesh)

CaveLayoutGenerator_LogicStart.PNG

Your naming convention for the meshes is much cleaner than mine, should ask you for naming advice next time :stuck_out_tongue:

As someone who just started to use blueprints, im digging this!
Ill be following the progress :slight_smile:

I just started using (really using, not just looking at stuff) blueprints yesterday :wink: Thank the almighty squirrel god for Google, lol.

Im trin to follow. Your trin to create a random doungen generator or cave generator,yes? If I am following you. There was a game back in the 90s that bragged about never a repeat in doungen ever being repeated. Slayer was the name and was for the 3do. It did repeat sorry to say. If that is what your trin to do your gonna need alot of stlyes and vairialbes in styles mainly meshes and textures cause if your tryb to decieve the eye I would start with them. Big library of textures and mesh. If that isnt what your talking about disregard this ,lol.

Sort of. Basically, I’m trying to figure out a methodology to create a (very) large cave system, based on how many rooms (minus the start room) that you want to generate (this is done in production, not during runtime, although it would be easy to do, on begin play -> Generate a random seed value for the random stream.

I suppose the correct name of this thread should be “Creating Random dungeons” rather than Procedural dungeons. My mistake!

With using random streams, I am able to create cave systems reliably (useful for what I’m doing, you try to create 100+ dungeons, with increasingly more room counts in 3 months, the 100th floor will have 1000 rooms (each level adds 10 rooms).

Speaking of, I have a small update!

I basically had to take all the nodes out of the functions to troubleshoot, but I am now able to randomly generate 1 room, that has 1 hallway with a seam, and 1 cap! And they all fit nicely together, hoorah! Here is the overview of the construction script:

e0fd060b64b17c2e943e906a0dc4186e656ef67f.png

And this is what it looks like :smiley:

ProofOfSuccessIsh.PNG

However, there is 1 hiccup, and I have no idea why. When I use 512 as the initial random seed value, all it generates is the room, nothing else. Double ya tee eff.

I understand what your sayin. Like if you was to open a minecraft game and just keeped goin north. the constant created forms are rediculas. All I can say is. when u figure that out keep quite until copy rights lol. But really. My best idea is to study notch and what kind of variables with in variables if that is it at all. When I played that game long ago that game even then sucked. Cause there was nothin original about it. It reminded me of playin drakkar open space of nuthin but was closed of space with same mesh. may ave changed colors but not good. Have you tried just throughin in numbers? Im a type of just $@#^*& guy. If you dont know now you know. I will keep this on back burnner cause this is on of my projects for future also. repeative displacement.

Ok look at what is your main applier of the room. add more see what happens. What I been readin about the bluprints is not that you add to many. These guys made it to be like C++ and swear that it is the same. http://www.unrealenginetutorials.com/unreal-engine-4-c-or-blueprints/

be careful who sees your bluprints so.

Once it’s finally completed I planned on sharing it with the community (hence the development thread). The cool thing about this is that it is not necessarily only for Luos’ pack, but it can be used with any “modular” style pack that includes the various types of sections.

As far as “this looks exactly the same” you get when you make games using stock assets, with just the ones I am using (I haven’t done the math), but the percentage of it being replicated is very, very low. At the basic level, I have 7 possible rooms, ranging from 2 exits to 4 exits, with 18(?) possible hallways, 4 possible caps, 4 possible seams. The base level has 10 rooms (+ starting room), with seed values going from 1 to (what is the maximum seed value?) so I’ll leave the math to you :smiley:

Brotha dont sell your wrk short. get paid alil for it and update it constant. thats why we got issues with assets now. No one updates. I know what your teyin to do and that will help but keep your name on it and update it and look into the business terms of UE4 they help fight against idea infringment

I cannot, in good conscience, sell this (I did think about it!). The reason is simple… I am using someone else’s work (Luos’ Modular Cave System). It is also based on the Procedural Tile Grid tutorial thing that Epic did, so it’s not entirely my own ideas… even though the only thing I basically kept from the session was the use of “Tiles” in my naming structure, lol.

edit: Don’t get me wrong, I will (hopefully) be profiting from this as a complete game.

Luos’ Modular Cave System . now this is the same guy from Veitnam. ok i just read about him. I understand and good for you. try to get with him and show him where he went wrong"when u find it". and share. LOL im old so

The assets on the marketplace are assets, no code included (as stated in the previous posts). I’m designing the blueprints from the ground up, putting the assets from his pack into arrays, and then randomly spawning them (in essence). Either way, it could be sold as a “separate sub-system” that requires his pack, however, there would be a bit too much user setup involved, and I don’t feel comfortable with that and the fact that it would not entirely be my own. Anyways… since I can spawn the meshes reliably now, tomorrow I’ll start on the While/Loop and For/Loops to start generating the entire cave system.

Updated OP.

look at this one

Yes, I’ve seen that. Close to what I’m trying to do, but I’m attempting something with less configuration being needed; a drag and drop solution, with only 2 things the user needs to worry about… the random seed, and how many rooms they want to have.

llike the minecraft dungeon gemerator. does everything you discribed/

Hey Savior, any updates on this? :slight_smile: