Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ zeroize = { version = "1.8", optional = true }
default = [
"acreplace",
"batchnoise",
"cave_system_generator",
"cellularnoise",
"dmi",
"file",
Expand All @@ -116,6 +117,7 @@ default = [
all = [
"acreplace",
"batchnoise",
"cave_system_generator",
"cellularnoise",
"dmi",
"dice",
Expand Down Expand Up @@ -147,6 +149,7 @@ all = [
# default features
acreplace = ["aho-corasick"]
batchnoise = ["dbpnoise"]
cave_system_generator = ["rand", "rayon", "serde", "serde_json"]
cellularnoise = ["rand", "rayon"]
dmi = ["png", "image", "qrcode", "serde_repr"]
file = []
Expand Down
25 changes: 25 additions & 0 deletions dmsrc/cave-system-generator.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Generates a procedural dungeon map using BSP tree partitioning, prefab placement,
* MST corridor generation, and Cellular Automata smoothing.
*
* Returns a plain binary grid string (matching cellularnoise format):
* A width*height string of '0' (wall) and '1' (floor) characters in row-major order.
*
* Arguments:
* * width - Grid width
* * height - Grid height
* * prefabs_json - JSON array of prefab configs: [{"x":55,"y":65,"w":10,"h":10,"isEnclosed":true},...] (if none use "[]") x = bottom-left turf x, y = bottom-left turf y, w = prefab width, h = prefab height, isEnclosed = whether prefab should be treated like its wall or floor by the generation
* * min_bsp_size - Minimum BSP leaf dimension
* * max_ratio - Maximum aspect ratio for BSP splits
* * padding - Room edge padding within BSP leaf
* * room_fill_percent - How much of each BSP leaf a room fills, 1-100
* * corridor_width - Width of corridors between rooms
* * loop_percent - Chance to add extra MST edges for loops
* * noise_percent - Initial random floor density
* * ca_steps - Cellular Automata smoothing iterations
* * birth_limit - Neighbors to create floor (>=)
* * survival_limit - Neighbors to survive as floor (>=)
* * edge_is_alive - Whether out-of-bounds cells count as ALIVE (floor) for CA neighbor counts
*/
#define rustg_cave_system_generator_generate(width, height, prefabs_json, min_bsp_size, max_ratio, padding, room_fill_percent, corridor_width, loop_percent, noise_percent, ca_steps, birth_limit, survival_limit, edge_is_alive) \
RUSTG_CALL(RUST_G, "cave_system_generator_generate")(width, height, prefabs_json, min_bsp_size, max_ratio, padding, room_fill_percent, corridor_width, loop_percent, noise_percent, ca_steps, birth_limit, survival_limit, edge_is_alive)
Loading
Loading