izeeter's domain

procedural dungeon shit

so im currently working on a minecraft server which is like, idk i just always make minecraft servers its what i know how to do

but ive made some cool systems while working on it. i thought it'd be a short easy project, no. no its not.

it's definetly way easier then my last project, but still hard. cool, but still hard

i honestly cant wait for people to play it like i fucking love this shit idc if it's like 3 people or 10 i just want people to play it when its done

i LOVE making stuff for people to play. it fulfills my god game need, its like my own little society i make rules for. its cool.


Anyways.

so the first thing i had to make for my server, since its like dungeon based, i had to make a procedural dungeon generation system

it was really esay honestly

no one really talks about how all these systems are just Data, or at least i dont hear anyone talking about it.

example: dungeons are generated by generating each room

dungeon room

so instead of actually BUILDING the dungeon i just have the same room replace itself over and over to simulate you "entering a new room"

i dont want to actually write procedural generation code, just keeping it simple! (lol)

but YEAH thats a dungeon room, and then a dungeon is just a list of these rooms with a unique pin i generate (i just made a 4 digit pin)
honestly, i just did that because i thought it was cool, it doesnt have to be a pin or anything like that. i just think it makes it easier to track
for me lol.

dungeons also have some data

cool right? no, its not. really simple,
im not the greatest programmer i just think this stuff is cool.

anyways thats how i actually generate a dungeon. theres a lot of other stuff like actually building the rooms which actually im gonna
talk about how i place stuff in the rooms. i dont want to talk about door code, thats stupid. doors are placed in the dungeon just by using the centerpoint cords.
(which actually kind of breaks things cuz i cant change the size of rooms... at least i dont think, idk i havent tried. but i dont really plan on the rooms being
a different size then 20 blocks in all directions but idk. maybe later when balanching, but ill get to that when i need to get to it.


anyways STRUCTURE PLACINGGGGG!!!

so to place strucutres in the room i get all the blocks and make it into a 2D grid. and then thats the "floor" i can then place structures at "cordinates"
on the floor. so i use math to convert a list index to a coordinate by getting the rooms length and width as well. kind of cool, but again still basic stuff. anyways
thats how i map out the floor. im not even placing structures yet, just getting everything ready.

so to make schematics to place i use a skript addon called skematic, which makes builds into json files. Sick!
so i had to make it so i could get the blocks the skematic would affect before actually placing it.
thankful skematic has a skematic dimensions thing built that returns the length, width, and height as a x y z coordinate

fucking EASY. so i loop the blocks between those points by calculating the points using the length width and HEIGHT
and then i add those to a list and boom we have the affected blocks. fucking easy peasy lemon cheesey dude.

so when placing the schematic, i make sure that theres no other schematic in the area by looping through the affected blocks, and making sure those blocks arent in any strucutre.
after that i place the schematic, and then in that floor list we made earlier we set the spaces in that list that are in the schematic, to that schemtic, and boom just do that over and over again at random positions and you have a room!

a grid

so that's what a floor grid might look like, the red are spaces taken up by strucutres


so that's how generating a dungeon actually works, theres a lot of other stuff like placing the doors and spawning the mobs but it's pretty redudndant stuff. i really just wanna talk about
stuff i think is interesting or fun to make.