Dungeon Generator
Spawning isn't done in procs to save on overhead on the 60k turfs we're going through.
Vars | |
area_ref | The original area that kicked off the whole generator. Used as a basis for all area based decisions |
---|---|
areas_included | The area that this generator is working in |
closed_turf_types | Expanded list of the types that spawns if the turf is closed |
desired_room_count | The number of rooms the random room placement algorithm will attempt to generate when the function is called, unless the function is called with specific arguments otherwise |
gen_gurf_only | If this is set to TRUE then it will only change turfs that are /turf/open/genturf, for more flexability in design |
generated_rooms | A list of the room datums generated by the Rust-g algorithm, and stored here |
hash | The rng Seed of the generator, randomly chosen between 1 and 1000 when the terrain is generated |
height | Height of the area being generated. Dynamically determined at init by getting the min and max y values |
map_subsection_min_room_height | Minimum height of a room generated in a map subsection, walls included. A minimum height of 5 is a 3 tall room with walls on each side. THIS VALUE SHOULD NOT BE LARGER THAN THE map_subsection_min_size!!!!!!!!!!! |
map_subsection_min_room_width | Minimum width of a room generated in a map subsection, walls included. A minimum width of 5 is a 3 wide room with walls on each side. THIS VALUE SHOULD NOT BE LARGER THAN THE map_subsection_min_size!!!!!!!!!!! |
map_subsection_min_size | Binary space partition works by cutting the map area in half, then that chunk in half, then that chunk in half, over and over until the next cut would create subsections smaller than the min specified size. so the size can be between the min size, and the min_size*2-1. The number of rooms you get back will be random based on how the algorithm decides to slice |
min_x | Minimum and Maximum X and Y coordinates, and the Z-level of the area being generated in. Generate_Terrain() will get these values for you automatically |
open_turf_types | Expanded list of the types that spawns if the turf is open |
owned_mobs | All mobs created by the generator. Either from the base generator or itself or the subsequent rooms created should add their mobs here |
probability_room_types | A list of the probability that a type of room theme can be selected. look at mapping.dm in yog defines |
room_datum_path | The path to the corresponding room datum for the generator. If you make a new generator subtype, make a new room subtype to go with it For example if you made: |
weighted_closed_turf_types | Weighted list of the types that spawns if the turf is closed |
weighted_open_turf_types | Weighted list of the types that spawns if the turf is open |
width | Width of the area being generated. Dynamically determined at init by getting the min and max x values |
working_turfs | Turfs that the generator can use to generate stuff. As rooms are created, they are deducted from this list so that in the end there is one "main" area left over |
Procs | |
build_dungeon | With the area we're going to be working in paved with the proper tiles, we now begin constructing the actual dungeon |
generate_rooms_with_bsp | Returns a list of rooms using the Binary Space Partition(bsp) algorithm. Binary space gives a pretty even spread of rooms with minimal overlapping by subsecting the area in half, and then that section in half, and that in half, until the next subsequent cut would be smaller than the minimum size. Each of these cuts have minor deviations for randomness, and alternate between vertical and horizontal cuts. Rooms are then generated in those sections of random height and width UP TO the size of the containing section. Rooms may border each other but will never overlap. Since the map area becomes a checkerboard of cuts, area coverage is extremely good |
generate_rooms_with_rrp | Returns a list of rooms using the Random Room Placement(rrp) algorithm. Random room placement simply generates rooms of random height and width, then selects a random X and Y value to be the bottom left corner of it. The only validation check this algorith performs is if a newly generated room overlaps with an existing room that the algorithm generated previously. If it does, the algorithm will generate a new room and coordinates for it and try again. |
parse_rooms_json | Converts the json list of room objects into a list of |
toggle_owned_mob_ai | Toggle the AI setting of all mobs in the generator. If the assistant starts crying like a child lost in a haunted house, you can turn off the mobs and escort them to their parent. |
valid_room_check | Designate behavior for whether or not you want the rooms kept or discarded here. At base this will just ensure the center of the room falls within the workable area the generator has access to |
Var Details
area_ref
The original area that kicked off the whole generator. Used as a basis for all area based decisions
areas_included
The area that this generator is working in
closed_turf_types
Expanded list of the types that spawns if the turf is closed
desired_room_count
The number of rooms the random room placement algorithm will attempt to generate when the function is called, unless the function is called with specific arguments otherwise
gen_gurf_only
If this is set to TRUE then it will only change turfs that are /turf/open/genturf, for more flexability in design
generated_rooms
A list of the room datums generated by the Rust-g algorithm, and stored here
hash
The rng Seed of the generator, randomly chosen between 1 and 1000 when the terrain is generated
height
Height of the area being generated. Dynamically determined at init by getting the min and max y values
map_subsection_min_room_height
Minimum height of a room generated in a map subsection, walls included. A minimum height of 5 is a 3 tall room with walls on each side. THIS VALUE SHOULD NOT BE LARGER THAN THE map_subsection_min_size!!!!!!!!!!!
map_subsection_min_room_width
Minimum width of a room generated in a map subsection, walls included. A minimum width of 5 is a 3 wide room with walls on each side. THIS VALUE SHOULD NOT BE LARGER THAN THE map_subsection_min_size!!!!!!!!!!!
map_subsection_min_size
Binary space partition works by cutting the map area in half, then that chunk in half, then that chunk in half, over and over until the next cut would create subsections smaller than the min specified size. so the size can be between the min size, and the min_size*2-1. The number of rooms you get back will be random based on how the algorithm decides to slice
min_x
Minimum and Maximum X and Y coordinates, and the Z-level of the area being generated in. Generate_Terrain() will get these values for you automatically
open_turf_types
Expanded list of the types that spawns if the turf is open
owned_mobs
All mobs created by the generator. Either from the base generator or itself or the subsequent rooms created should add their mobs here
probability_room_types
A list of the probability that a type of room theme can be selected. look at mapping.dm in yog defines
room_datum_path
The path to the corresponding room datum for the generator. If you make a new generator subtype, make a new room subtype to go with it For example if you made:
- /datum/map_generator/dungeon_generator/ice_dungeon
You should make:
- /datum/dungeon_room/ice_room
And set the room_datum_path to that path
weighted_closed_turf_types
Weighted list of the types that spawns if the turf is closed
weighted_open_turf_types
Weighted list of the types that spawns if the turf is open
width
Width of the area being generated. Dynamically determined at init by getting the min and max x values
working_turfs
Turfs that the generator can use to generate stuff. As rooms are created, they are deducted from this list so that in the end there is one "main" area left over
Proc Details
build_dungeon
With the area we're going to be working in paved with the proper tiles, we now begin constructing the actual dungeon
generate_rooms_with_bsp
Returns a list of rooms using the Binary Space Partition(bsp) algorithm. Binary space gives a pretty even spread of rooms with minimal overlapping by subsecting the area in half, and then that section in half, and that in half, until the next subsequent cut would be smaller than the minimum size. Each of these cuts have minor deviations for randomness, and alternate between vertical and horizontal cuts. Rooms are then generated in those sections of random height and width UP TO the size of the containing section. Rooms may border each other but will never overlap. Since the map area becomes a checkerboard of cuts, area coverage is extremely good
generate_rooms_with_rrp
Returns a list of rooms using the Random Room Placement(rrp) algorithm. Random room placement simply generates rooms of random height and width, then selects a random X and Y value to be the bottom left corner of it. The only validation check this algorith performs is if a newly generated room overlaps with an existing room that the algorithm generated previously. If it does, the algorithm will generate a new room and coordinates for it and try again.
parse_rooms_json
Converts the json list of room objects into a list of
toggle_owned_mob_ai
Toggle the AI setting of all mobs in the generator. If the assistant starts crying like a child lost in a haunted house, you can turn off the mobs and escort them to their parent.
For quick refence the commands are:
- 1: Turn mob AI on
- 2: Set mob AI to idle
- 3: Turn mob AI off completely
- 4: Turn mob AI off until a player enters the z-level which will cause them to flip back to on
valid_room_check
Designate behavior for whether or not you want the rooms kept or discarded here. At base this will just ensure the center of the room falls within the workable area the generator has access to