From 2a99f77bdde1b3fd864bd657c58d3a42c6f9d16b Mon Sep 17 00:00:00 2001 From: warriorstar-orion Date: Fri, 29 Mar 2024 05:50:41 -0400 Subject: [PATCH] refactor: Remove cave generation from mineral ore generation odds (#24783) * Remove cave generation from mineral ore generation odds * use clearer vars --- .../subsystem/non_firing/SSmapping.dm | 1 + code/game/turfs/simulated/minerals.dm | 13 ++++++++--- code/modules/lavaland/lavaland_theme.dm | 22 +++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/code/controllers/subsystem/non_firing/SSmapping.dm b/code/controllers/subsystem/non_firing/SSmapping.dm index 27193044dee..58aa4771dc0 100644 --- a/code/controllers/subsystem/non_firing/SSmapping.dm +++ b/code/controllers/subsystem/non_firing/SSmapping.dm @@ -76,6 +76,7 @@ SUBSYSTEM_DEF(mapping) seedRuins(list(level_name_to_num(MINING)), GLOB.configuration.ruins.lavaland_ruin_budget, /area/lavaland/surface/outdoors/unexplored, GLOB.lava_ruins_templates) if(lavaland_theme) lavaland_theme.setup() + lavaland_theme.setup_caves() var/time_spent = stop_watch(lavaland_setup_timer) log_startup_progress("Successfully populated lavaland in [time_spent]s.") else diff --git a/code/game/turfs/simulated/minerals.dm b/code/game/turfs/simulated/minerals.dm index c221da9adcf..23238971280 100644 --- a/code/game/turfs/simulated/minerals.dm +++ b/code/game/turfs/simulated/minerals.dm @@ -306,9 +306,16 @@ mineralChance = 10 mineralSpawnChanceList = list( - /turf/simulated/mineral/uranium/volcanic = 5, /turf/simulated/mineral/diamond/volcanic = 1, /turf/simulated/mineral/gold/volcanic = 10, /turf/simulated/mineral/titanium/volcanic = 11, - /turf/simulated/mineral/silver/volcanic = 12, /turf/simulated/mineral/plasma/volcanic = 20, /turf/simulated/mineral/iron/volcanic = 40, - /turf/simulated/mineral/gibtonite/volcanic = 4, /turf/simulated/floor/plating/asteroid/airless/cave/volcanic = 1, /turf/simulated/mineral/bscrystal/volcanic = 1) + /turf/simulated/mineral/uranium/volcanic = 5, + /turf/simulated/mineral/diamond/volcanic = 1, + /turf/simulated/mineral/gold/volcanic = 10, + /turf/simulated/mineral/titanium/volcanic = 11, + /turf/simulated/mineral/silver/volcanic = 12, + /turf/simulated/mineral/plasma/volcanic = 20, + /turf/simulated/mineral/iron/volcanic = 40, + /turf/simulated/mineral/gibtonite/volcanic = 4, + /turf/simulated/mineral/bscrystal/volcanic = 1 + ) /turf/simulated/mineral/random/labormineral mineralSpawnChanceList = list( diff --git a/code/modules/lavaland/lavaland_theme.dm b/code/modules/lavaland/lavaland_theme.dm index 7fa5a9088fa..20dfdecb38a 100644 --- a/code/modules/lavaland/lavaland_theme.dm +++ b/code/modules/lavaland/lavaland_theme.dm @@ -1,3 +1,8 @@ +/// Approximate lower bound of the walkable land area on Lavaland, north of the southern lava border. +#define LAVALAND_MIN_CAVE_Y 10 +/// Approximate upper bound of the walkable land area on Lavaland, south of the Legion entrance. +#define LAVALAND_MAX_CAVE_Y 222 + /datum/lavaland_theme /// Name of lavaland theme var/name = "Not Specified" @@ -12,6 +17,20 @@ else if(!ispath(primary_turf_type)) stack_trace("Wrong turf type `[primary_turf_type.type]` in `[type]` lavaland theme") +/datum/lavaland_theme/proc/setup_caves() + var/max_attempts = 100 + var/max_cave_spawns = 40 + var/z = level_name_to_num(MINING) + while(max_attempts > 0 && max_cave_spawns > 0) + var/x = rand(1, world.maxx) + var/y = rand(LAVALAND_MIN_CAVE_Y, LAVALAND_MAX_CAVE_Y) + var/turf/next_turf = locate(x, y, z) + var/area/next_area = get_area(next_turf) + if(istype(next_turf, /turf/simulated/mineral/random/volcanic) && istype(next_area, /area/lavaland/surface/outdoors/unexplored/danger)) + next_turf.ChangeTurf(/turf/simulated/floor/plating/asteroid/airless/cave/volcanic, FALSE, TRUE, TRUE) + max_cave_spawns-- + max_attempts-- + /** * This proc should do all theme specific thing. * Now it only generates rivers, but it can do all stuff you desire. @@ -46,3 +65,6 @@ /datum/lavaland_theme/chasm/setup() var/datum/river_spawner/spawner = new(level_name_to_num(MINING), spread_prob_ = 10, spread_prob_loss_ = 5) spawner.generate(nodes = 6, min_x = 50, min_y = 7, max_x = 250, max_y = 225) + +#undef LAVALAND_MIN_CAVE_Y +#undef LAVALAND_MAX_CAVE_Y