Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 0932358

Browse files
[MDB IGNORE] Procedurally Generated Maints (Sorry no Gax in this PR just the tools) (#20555)
* i think it's ready * this rustg define should match what it will be after the rust code is merged * adding some documentation * ready again * my rust dll was out of date lmao * fix things that makes biome cry * i think it's ready * this rustg define should match what it will be after the rust code is merged * will this fix the linter? * was that the issue? * rust update * ready again * rip multi-z gax, you will return later * my rust dll was out of date lmao * fix things that makes biome cry * why do these changes keep lingering * that's already done * is this alphabetical now * why was there duplicates that required me to use the web editor to fix * how did you get deleted * that would have been bad lmao * probably not super necessary but whatever * that was bothering me * that's already defined * ok i think that's all the cleanup * lastly stairs
1 parent 7a893fb commit 0932358

File tree

35 files changed

+24693
-14
lines changed

35 files changed

+24693
-14
lines changed

_maps/map_files/debug/MaintStation.dmm

Lines changed: 22832 additions & 0 deletions
Large diffs are not rendered by default.

code/__DEFINES/maps.dm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Always compile, always use that verb, and always make sure that it works for wha
7777
#define ZTRAIT_STATION "Station"
7878
#define ZTRAIT_MINING "Mining"
7979
#define ZTRAIT_REEBE "Reebe"
80+
#define ZTRAIT_PROCEDURAL_MAINTS "Random Maints"
8081
#define ZTRAIT_RESERVED "Transit/Reserved"
8182
#define ZTRAIT_AWAY "Away Mission"
8283
#define ZTRAIT_SPACE_RUINS "Space Ruins"
@@ -143,6 +144,14 @@ Always compile, always use that verb, and always make sure that it works for wha
143144

144145
#define ZTRAITS_REEBE list(ZTRAIT_REEBE = TRUE, ZTRAIT_BOMBCAP_MULTIPLIER = 0.60)
145146

147+
#define ZTRAITS_BACKROOM_MAINTS list(\
148+
ZTRAIT_PROCEDURAL_MAINTS = TRUE, \
149+
ZTRAIT_LINKAGE = SELFLOOPING, \
150+
ZTRAIT_GRAVITY = TRUE, \
151+
ZTRAIT_NOPHASE = TRUE, \
152+
ZTRAIT_NOXRAY = TRUE, \
153+
ZTRAIT_BASETURF = /turf/open/floor/plating)
154+
146155
///Z level traits for Away Missions
147156
#define ZTRAITS_AWAY list(ZTRAIT_AWAY = TRUE)
148157
///Z level traits for Secret Away Missions

code/__DEFINES/rust_g.dm

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,31 @@
9191
*/
9292
#define rustg_acreplace_with_replacements(key, text, replacements) RUSTG_CALL(RUST_G, "acreplace_with_replacements")(key, text, json_encode(replacements))
9393

94+
/**
95+
* This proc generates rooms in a specified area of random size and placement. Essential for procedurally generated areas, BSP works by cutting a given area in half,
96+
* then cutting one of those subsections in half, and repeating this process until a minimum size is reached, then backtracking to other subsections that are not of
97+
* the minimum size yet. These cuts are offset by small random amounts so that the sections are all varied in size and shape.
98+
*
99+
* BSP excels at creating rooms or areas with a relatively even distribution over an area, so there won't be too much blank open area. However if you discard rooms that
100+
* overlap pre-existing map structures or areas, you may still get blank areas where nothing interesting appears.
101+
*
102+
* Return:
103+
* * a json list of room data to be processed by json_decode in byond and further processed there.
104+
*
105+
* Arguments:
106+
* * width: the width of the area to generate in
107+
* * height: the height of the area to generate in
108+
* * hash: the rng seed the generator will use for this instance
109+
* * map_subsection_min_size: The minimum size of a map subsection. When using this for rooms with walls, the minimum possible square will be a 5x5 room. Barring walls,
110+
* this will be a 3x3 room. The maximum size will be 9x9, because a further cut could reduce this size beneath the minimum size.
111+
* * map_subsection_min_room_width: The minimum room width once the subsections are finalized. Room width and height are random between this amount, and the subsection
112+
* max size
113+
* * map_subsection_min_room_height: The minimum room height once the subsections are finalized. Room width and height are random between this amount, and the subsection
114+
* max size
115+
*/
116+
#define rustg_bsp_generate(width, height, hash, map_subsection_min_size, map_subsection_min_room_width, map_subsection_min_room_height) \
117+
RUSTG_CALL(RUST_G, "bsp_generate")(width, height, hash, map_subsection_min_size, map_subsection_min_room_width, map_subsection_min_room_height)
118+
94119
/**
95120
* This proc generates a cellular automata noise grid which can be used in procedural generation methods.
96121
*
@@ -216,6 +241,31 @@
216241
*/
217242
#define rustg_generate_path_astar(start_node_id, goal_node_id) RUSTG_CALL(RUST_G, "generate_path_astar")(start_node_id, goal_node_id)
218243

244+
/**
245+
* This proc generates rooms in a specified area of random size and placement. Used in procedural generation, but far less intensively than Binary Space Partitioning
246+
* due to Random Room Placement being far more simple and unreliable for area coverage. These rooms will not overlap one another, but that is the only logic
247+
* they do. The room dimensions returned by this call are hardcoded to be the dimensions of maint ruins so that I could sprinkle pre-generated areas over
248+
* the binary space rooms that are random.
249+
* These dimensions are:
250+
* * 3x3
251+
* * 3x5
252+
* * 5x3
253+
* * 5x4
254+
* * 10x5
255+
* * 10x10
256+
*
257+
* Return:
258+
* * a json list of room data to be processed by json_decode in byond and further processed there.
259+
*
260+
* Arguments:
261+
* * width: the width of the area to generate in
262+
* * height: the height of the area to generate in
263+
* * desired_room_count: the number of rooms you want generated and returned
264+
* * hash: the rng seed the generator will use for this instance
265+
*/
266+
#define rustg_random_room_generate(width, height, desired_room_count, hash) \
267+
RUSTG_CALL(RUST_G, "random_room_generate")(width, height, desired_room_count, hash)
268+
219269
#define RUSTG_REDIS_ERROR_CHANNEL "RUSTG_REDIS_ERROR_CHANNEL"
220270

221271
#define rustg_redis_connect(addr) RUSTG_CALL(RUST_G, "redis_connect")(addr)
@@ -285,5 +335,3 @@
285335
*/
286336
#define rustg_worley_generate(region_size, threshold, node_per_region_chance, size, node_min, node_max) \
287337
RUSTG_CALL(RUST_G, "worley_generate")(region_size, threshold, node_per_region_chance, size, node_min, node_max)
288-
289-

code/__DEFINES/subsystems.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
#define INIT_ORDER_QUIRKS 73
147147
#define INIT_ORDER_EVENTS 70
148148
#define INIT_ORDER_JOBS 65
149+
#define INIT_ORDER_PATH 61
149150
#define INIT_ORDER_TICKER 55
150151
#define INIT_ORDER_MAPPING 50
151152
#define INIT_ORDER_EARLY_ASSETS 48
@@ -172,7 +173,6 @@
172173
#define INIT_ORDER_SHUTTLE -21
173174
#define INIT_ORDER_MINOR_MAPPING -40
174175
#define INIT_ORDER_BLUESPACE_LOCKER -45
175-
#define INIT_ORDER_PATH -50
176176
#define INIT_ORDER_DISCORD -60
177177
#define INIT_ORDER_EXPLOSIONS -69
178178
#define INIT_ORDER_STATPANELS -97
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/** Defines for the Dungeon Generator.
2+
* These bitflags control which elements are present in each room theme so the parent room of the theme knows which furnishing procs it needs to call
3+
*/
4+
///If the room has specific floor tiles
5+
#define ROOM_HAS_FLOORS (1<<0)
6+
///If the room has specific wall tiles
7+
#define ROOM_HAS_WALLS (1<<1)
8+
///If the room has windows and specific window type
9+
#define ROOM_HAS_WINDOWS (1<<2)
10+
///If the room has windows and specific window type, but no walls to spawn, so this room should just be a glass box
11+
#define ROOM_HAS_ONLY_WINDOWS (1<<3)
12+
///If the room has specific door type
13+
#define ROOM_HAS_DOORS (1<<4)
14+
///If we want the room shape, but then the room to do something very specific. This is how I handle ruin spawning
15+
#define ROOM_HAS_SPECIAL_FEATURES (1<<5)
16+
///If the room has specific decorative features like blood splatters or loot spawners
17+
#define ROOM_HAS_FEATURES (1<<6)
18+
///If the room has mobs to spawn, whether they're hostile spiders or harmless rats
19+
#define ROOM_HAS_MOBS (1<<7)
20+
21+
//The danger the room presents ranging from always safe to you should die NOW
22+
#define ROOM_RATING_SAFE (1<<0)
23+
#define ROOM_RATING_HOSTILE (1<<1)
24+
#define ROOM_RATING_EXTREMELY_HOSTILE (1<<2)
25+
#define ROOM_RATING_DEATH (1<<3)
26+
27+
//For categorizing rooms
28+
#define ROOM_TYPE_RANDOM "random"
29+
#define ROOM_TYPE_SPACE "space"
30+
#define ROOM_TYPE_RUIN "ruin"
31+
#define ROOM_TYPE_SECRET "secret"
32+
33+
#define VERTICAL "vertical"
34+
#define HORIZONTAL "horizontal"
35+
36+
#define ALGORITHM_BSP "Binary Search Partition"
37+
#define ALGORITHM_RRP "Random Room Placement"

code/__HELPERS/AStar.dm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,7 @@ Actual Adjacent procs :
234234
if(!istype(D, /obj/structure/window) && D.density) //had to do it silly like this so rwindows didn't stop it outright
235235
return FALSE
236236
return TRUE
237+
238+
/turf/proc/wiringTurfTest(caller, turf/T, ID, simulated_only)
239+
if(T && !T.density && !istype(T.loc, /area/space))
240+
return TRUE

0 commit comments

Comments
 (0)