From 1f5cb0665c9e58f32f6cb1e5a1d4fe0253bd2cfb Mon Sep 17 00:00:00 2001 From: Azrun Date: Thu, 6 Jun 2024 13:11:51 -0700 Subject: [PATCH] Improve mining magnet's clearing with terrainify Resolve issue with mining magnet generating impassible turfs with terrainify Add flag for map generators to force a floor/interactible turf --- +secret | 2 +- _std/map.dm | 1 + code/modules/admin/terrainify.dm | 23 ++++++++++++------- code/modules/atmospherics/FEA_gas_mixture.dm | 3 +++ code/modules/events/minor/trader.dm | 2 +- .../transport/shuttle/shuttle_controller.dm | 2 +- .../worldgen/mapgen/IceMoonGenerator.dm | 4 +++- .../worldgen/mapgen/LavaMoonGenerator.dm | 2 ++ code/modules/worldgen/mapgen/MarsGenerator.dm | 7 +++++- code/modules/worldgen/mapgen/RoomMaze.dm | 4 ++++ .../worldgen/mapgen/StorehouseGenerator.dm | 6 ++++- code/obj/machinery/computer/shuttle.dm | 2 +- code/obj/mining.dm | 8 +++++-- code/turf/turf.dm | 3 +++ 14 files changed, 52 insertions(+), 17 deletions(-) diff --git a/+secret b/+secret index 4a7285d3c2086..4f63ff23f35f9 160000 --- a/+secret +++ b/+secret @@ -1 +1 @@ -Subproject commit 4a7285d3c208645fb3074faf94d8a46138e60985 +Subproject commit 4f63ff23f35f96d1d48cbda326beeafadb7fcc49 diff --git a/_std/map.dm b/_std/map.dm index e960cded57f1c..e1e50f0921820 100644 --- a/_std/map.dm +++ b/_std/map.dm @@ -25,6 +25,7 @@ #define MAPGEN_IGNORE_FAUNA (1 << 1) #define MAPGEN_IGNORE_BUILDABLE (1 << 2) #define MAPGEN_ALLOW_VEHICLES (1 << 3) +#define MAPGEN_FLOOR_ONLY (1 << 4) #define MAPGEN_TURF_ONLY ( MAPGEN_IGNORE_FLORA | MAPGEN_IGNORE_FAUNA ) diff --git a/code/modules/admin/terrainify.dm b/code/modules/admin/terrainify.dm index cd74a467d40b1..bcd336c834d32 100644 --- a/code/modules/admin/terrainify.dm +++ b/code/modules/admin/terrainify.dm @@ -32,10 +32,11 @@ var/datum/station_zlevel_repair/station_repair = new default_air.nitrogen = MOLES_N2STANDARD default_air.temperature = T20C - proc/repair_turfs(turf/turfs, clear=FALSE) + proc/repair_turfs(turf/turfs, clear=FALSE, force_floor=FALSE) if(src.station_generator) - var/gen_flags = MAPGEN_IGNORE_FLORA|MAPGEN_IGNORE_FAUNA + var/gen_flags = MAPGEN_IGNORE_FLORA | MAPGEN_IGNORE_FAUNA gen_flags |= MAPGEN_ALLOW_VEHICLES * src.allows_vehicles + gen_flags |= MAPGEN_FLOOR_ONLY * force_floor src.station_generator.generate_terrain(turfs, reuse_seed=TRUE, flags=gen_flags) if(clear) @@ -287,7 +288,7 @@ ABSTRACT_TYPE(/datum/terrainify) for(var/turf/T in space_turfs) if(!istype(T, /turf/space)) space_turfs -= T - station_repair.repair_turfs(space_turfs) + station_repair.repair_turfs(space_turfs, force_floor=TRUE) logTheThing(LOG_DEBUG, null, "Prefab Z1 placement #[n] [P.type][P.required?" (REQUIRED)":""] succeeded. [target] @ [log_loc(target)]") n++ @@ -680,12 +681,18 @@ ABSTRACT_TYPE(/datum/terrainify) if(station_repair.allows_vehicles) T.allows_vehicles = station_repair.allows_vehicles T.UpdateOverlays(station_repair.weather_img, "weather") - ambient_value = lerp(20,80,T.x/300) - station_repair.ambient_light.color = rgb(ambient_value+((rand()*3)),ambient_value,ambient_value) //randomly shift red to reduce vertical banding - T.AddOverlays(station_repair.ambient_light, "ambient") - ambient_value = lerp(20,80,0.5) - station_repair.ambient_light.color = rgb(ambient_value+((rand()*3)),ambient_value,ambient_value) + if(params["Ambient Light Obj"]) + T.vis_contents |= station_repair.ambient_obj + else + ambient_value = lerp(20,80,T.x/300) + station_repair.ambient_light.color = rgb(ambient_value+((rand()*3)),ambient_value,ambient_value) //randomly shift red to reduce vertical banding + T.AddOverlays(station_repair.ambient_light, "ambient") + + if(station_repair.ambient_light) + ambient_value = lerp(20,80,0.5) + station_repair.ambient_light.color = rgb(ambient_value+((rand()*3)),ambient_value,ambient_value) + handle_mining(params, space) log_terrainify(user, "turned space into Mars.") diff --git a/code/modules/atmospherics/FEA_gas_mixture.dm b/code/modules/atmospherics/FEA_gas_mixture.dm index ca2f24ffe4d59..e45970e6075aa 100644 --- a/code/modules/atmospherics/FEA_gas_mixture.dm +++ b/code/modules/atmospherics/FEA_gas_mixture.dm @@ -408,6 +408,9 @@ What are the archived variables for? /// * Similar to [/datum/gas_mixture/proc/share], except the model is not modified. /// * Return: Moles of gas exchanged. /datum/gas_mixture/proc/mimic(turf/model, border_multiplier = 1) + if (!model) + return FALSE + #define _DELTA_GAS(GAS, ...) var/delta_##GAS = QUANTIZE(((src.ARCHIVED(GAS) - model.GAS)/5)*border_multiplier/src.group_multiplier); APPLY_TO_GASES(_DELTA_GAS) #undef _DELTA_GAS diff --git a/code/modules/events/minor/trader.dm b/code/modules/events/minor/trader.dm index e937403d5b145..39f312c3f1e69 100644 --- a/code/modules/events/minor/trader.dm +++ b/code/modules/events/minor/trader.dm @@ -122,7 +122,7 @@ start_location.color = OCEAN_COLOR #endif - station_repair.repair_turfs(dest_turfs) + station_repair.repair_turfs(dest_turfs, force_floor=TRUE) /proc/get_hiding_jerk(var/atom/movable/container) for(var/atom/movable/AM in container) diff --git a/code/modules/transport/shuttle/shuttle_controller.dm b/code/modules/transport/shuttle/shuttle_controller.dm index 3570efd5ec47b..8951060296813 100644 --- a/code/modules/transport/shuttle/shuttle_controller.dm +++ b/code/modules/transport/shuttle/shuttle_controller.dm @@ -286,7 +286,7 @@ var/global/datum/shuttle_controller/emergency_shuttle/emergency_shuttle if(station_repair.station_generator) var/list/turf/turfs_to_fix = get_area_turfs(start_location) if(length(turfs_to_fix)) - station_repair.repair_turfs(turfs_to_fix) + station_repair.repair_turfs(turfs_to_fix, force_floor=TRUE) DEBUG_MESSAGE("Done moving shuttle!") settimeleft(SHUTTLETRANSITTIME) diff --git a/code/modules/worldgen/mapgen/IceMoonGenerator.dm b/code/modules/worldgen/mapgen/IceMoonGenerator.dm index 6e29e6881e4ee..e1ad5be28ab18 100644 --- a/code/modules/worldgen/mapgen/IceMoonGenerator.dm +++ b/code/modules/worldgen/mapgen/IceMoonGenerator.dm @@ -73,7 +73,9 @@ var/height = text2num(rustg_noise_get_at_coordinates("[height_seed]", "[drift_x]", "[drift_y]")) var/datum/biome/selected_biome - if(height <= 0.85) //If height is less than 0.85, we generate biomes based on the heat and humidity of the area. + if(flags & MAPGEN_FLOOR_ONLY) + selected_biome = /datum/biome/icemoon/snow + else if(height <= 0.85) //If height is less than 0.85, we generate biomes based on the heat and humidity of the area. var/humidity = text2num(rustg_noise_get_at_coordinates("[humidity_seed]", "[drift_x]", "[drift_y]")) var/heat = text2num(rustg_noise_get_at_coordinates("[heat_seed]", "[drift_x]", "[drift_y]")) var/heat_level //Type of heat zone we're in LOW-MEDIUM-HIGH diff --git a/code/modules/worldgen/mapgen/LavaMoonGenerator.dm b/code/modules/worldgen/mapgen/LavaMoonGenerator.dm index f8f0a75b43ab8..31051384c65bb 100644 --- a/code/modules/worldgen/mapgen/LavaMoonGenerator.dm +++ b/code/modules/worldgen/mapgen/LavaMoonGenerator.dm @@ -168,6 +168,8 @@ var/datum/biome/selected_biome if(length(near_station?.get_nearby(gen_turf, range=6))) selected_biome = /datum/biome/lavamoon + else if(flags & MAPGEN_FLOOR_ONLY) + selected_biome = /datum/biome/lavamoon else if(lava_value) selected_biome = /datum/biome/lavamoon/lava else if(height <= 0.85) //If height is less than 0.85, we generate biomes based on the heat and humidity of the area. diff --git a/code/modules/worldgen/mapgen/MarsGenerator.dm b/code/modules/worldgen/mapgen/MarsGenerator.dm index 30fdbef97df45..a49a836b61b5b 100644 --- a/code/modules/worldgen/mapgen/MarsGenerator.dm +++ b/code/modules/worldgen/mapgen/MarsGenerator.dm @@ -56,6 +56,7 @@ ) ///Used to select "zoom" level into the perlin noise, higher numbers result in slower transitions var/perlin_zoom = 65 + var/floor_only_biome = /datum/biome/mars wall_turf_type = /turf/simulated/wall/auto/asteroid/mars floor_turf_type = /turf/unsimulated/floor/plating/asteroid/mars @@ -87,6 +88,8 @@ BIOME_HIGH_HUMIDITY = /datum/biome/mars/martian_area/duststorm ) ) + floor_only_biome = /datum/biome/mars/duststorm + floor_turf_type = /turf/unsimulated/floor/setpieces/martian/station_duststorm ///Seeds the rust-g perlin noise with a random number. /datum/map_generator/mars_generator/generate_terrain(list/turfs, reuse_seed, flags) @@ -103,7 +106,9 @@ var/height = text2num(rustg_noise_get_at_coordinates("[height_seed]", "[drift_x]", "[drift_y]")) var/datum/biome/selected_biome - if(height <= 0.85) //If height is less than 0.85, we generate biomes based on the heat and humidity of the area. + if(flags & MAPGEN_FLOOR_ONLY) + selected_biome = floor_only_biome + else if(height <= 0.85) //If height is less than 0.85, we generate biomes based on the heat and humidity of the area. var/humidity = text2num(rustg_noise_get_at_coordinates("[humidity_seed]", "[drift_x]", "[drift_y]")) var/heat = text2num(rustg_noise_get_at_coordinates("[heat_seed]", "[drift_x]", "[drift_y]")) var/heat_level //Type of heat zone we're in LOW-MEDIUM-HIGH diff --git a/code/modules/worldgen/mapgen/RoomMaze.dm b/code/modules/worldgen/mapgen/RoomMaze.dm index 18c6af61a246c..bde01fe363c09 100644 --- a/code/modules/worldgen/mapgen/RoomMaze.dm +++ b/code/modules/worldgen/mapgen/RoomMaze.dm @@ -208,9 +208,13 @@ /datum/map_generator/room_maze_generator/proc/assign_turf(turf/T, flags) var/cell_value = src.cell_grid[T.x][T.y] + if(flags & MAPGEN_FLOOR_ONLY) + cell_value = FLOOR + switch(cell_value) if(WALL, null) T.ReplaceWith(wall_turf_type, handle_air=FALSE) + if(FLOOR) T.ReplaceWith(floor_turf_type, handle_air=FALSE) diff --git a/code/modules/worldgen/mapgen/StorehouseGenerator.dm b/code/modules/worldgen/mapgen/StorehouseGenerator.dm index ec2303be6d94a..c969be37cb84c 100644 --- a/code/modules/worldgen/mapgen/StorehouseGenerator.dm +++ b/code/modules/worldgen/mapgen/StorehouseGenerator.dm @@ -265,6 +265,9 @@ var/generate_stuff = !(flags & (MAPGEN_IGNORE_FLORA|MAPGEN_IGNORE_FAUNA)) + if(flags & MAPGEN_FLOOR_ONLY) + cell_value = FLOOR_ONLY + switch(cell_value) if(FLOOR) T.ReplaceWith(floor_path) @@ -324,9 +327,10 @@ meaty = text2num(meatier[T.x * world.maxx + T.y]) if(index <= length(stomach)) stomach_goop = text2num(stomach[T.x * world.maxx + T.y]) + if(flags & MAPGEN_FLOOR_ONLY) + cell_value = FLOOR_ONLY var/datum/biome/selected_biome - switch(cell_value) if(FLOOR) if(meaty && stomach_goop) diff --git a/code/obj/machinery/computer/shuttle.dm b/code/obj/machinery/computer/shuttle.dm index 5146920dd0bfd..421249f522d30 100644 --- a/code/obj/machinery/computer/shuttle.dm +++ b/code/obj/machinery/computer/shuttle.dm @@ -196,7 +196,7 @@ ABSTRACT_TYPE(/obj/machinery/computer/transit_shuttle) if (currentlocation.z == Z_LEVEL_STATION && station_repair.station_generator) var/list/turf/turfs_to_fix = get_area_turfs(currentlocation) if(length(turfs_to_fix)) - station_repair.repair_turfs(turfs_to_fix) + station_repair.repair_turfs(turfs_to_fix, force_floor=TRUE) for(var/obj/machinery/computer/transit_shuttle/Console in machine_registry[MACHINES_SHUTTLECOMPS]) if (Console.shuttlename != src.shuttlename) continue diff --git a/code/obj/mining.dm b/code/obj/mining.dm index cdb9b079bf848..2f59804d0a554 100644 --- a/code/obj/mining.dm +++ b/code/obj/mining.dm @@ -628,12 +628,16 @@ var/sleep_time = attract_time if (sleep_time < 1) sleep_time = 20 - sleep_time /= 2 + sleep_time /= 3 if (malfunctioning && prob(20)) do_malfunction() sleep(sleep_time) + // Ensure area is erased, helps if atmos is being a jerk + target.erase_area() + sleep(sleep_time) + var/datum/mining_encounter/MC if(selectable_encounter_id != null) @@ -662,7 +666,7 @@ var/turf/origin = get_turf(target) for (var/turf/space/T in block(origin, locate(origin.x + target.width - 1, origin.y + target.height - 1, origin.z))) repair_turfs += T - station_repair.repair_turfs(repair_turfs) + station_repair.repair_turfs(repair_turfs, force_floor=TRUE) sleep(sleep_time) if (malfunctioning && prob(20)) diff --git a/code/turf/turf.dm b/code/turf/turf.dm index afacad502f07a..36c9e76ea1849 100644 --- a/code/turf/turf.dm +++ b/code/turf/turf.dm @@ -449,6 +449,9 @@ proc/generate_space_color() return /turf/proc/delay_space_conversion() + return + +/turf/simulated/delay_space_conversion() if(air_master?.is_busy) air_master.tiles_to_space |= src return TRUE