From b96bec5157a49532ccd61553b69dbb0ee642353e Mon Sep 17 00:00:00 2001 From: KorPhaeron Date: Fri, 18 Dec 2015 15:49:18 -0600 Subject: [PATCH] River Generation Module This is going to be used for lava rivers in lavaland. --- code/game/turfs/simulated/river.dm | 25 ++++++++++++------- code/modules/mining/mine_turfs.dm | 2 +- .../procedural mapping/mapGenerator.dm | 1 - .../mapGenerators/lava_river.dm | 18 +++++++++++++ tgstation.dme | 2 ++ 5 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 code/modules/procedural mapping/mapGenerators/lava_river.dm diff --git a/code/game/turfs/simulated/river.dm b/code/game/turfs/simulated/river.dm index 27ce2361dbe..b602319fba6 100644 --- a/code/game/turfs/simulated/river.dm +++ b/code/game/turfs/simulated/river.dm @@ -14,13 +14,16 @@ num_spawned++ //make some randomly pathing rivers - for(var/obj/effect/landmark/river_waypoint/W in river_nodes) + for(var/A in river_nodes) + var/obj/effect/landmark/river_waypoint/W = A if (W.z != target_z || W.connected) continue W.connected = 1 - var/turf/cur_turf = new turf_type(get_turf(W)) - var/turf/target_turf = get_turf(pick(river_nodes)) - + var/turf/cur_turf = get_turf(W) + cur_turf.ChangeTurf(turf_type) + var/turf/target_turf = get_turf(pick(river_nodes - W)) + if(!target_turf) + break var/detouring = 0 var/cur_dir = get_dir(cur_turf, target_turf) while(cur_turf != target_turf) @@ -40,8 +43,9 @@ cur_turf = get_step(cur_turf, cur_dir) - if(!istype(cur_turf, /turf/simulated/wall) //Rivers will flow around walls - var/turf/simulated/river_turf = new turf_type(cur_turf) + if(!istype(cur_turf, /turf/simulated/wall)) //Rivers will flow around walls + var/turf/simulated/river_turf = cur_turf + river_turf.ChangeTurf(turf_type) river_turf.Spread(30, 25) else detouring = 0 @@ -50,7 +54,8 @@ continue - + for(var/WP in river_nodes) + qdel(WP) /obj/effect/landmark/river_waypoint @@ -65,7 +70,9 @@ for(var/turf/simulated/F in orange(1, src)) - var/turf/L = new src.type(F) + var/turf/L = F + + L.ChangeTurf(src.type) if(L && prob(probability)) L.Spread(probability - prob_loss) @@ -75,4 +82,4 @@ #undef RANDOM_UPPER_Y #undef RANDOM_LOWER_X -#undef RANDOM_LOWER_Y \ No newline at end of file +#undef RANDOM_LOWER_Y diff --git a/code/modules/mining/mine_turfs.dm b/code/modules/mining/mine_turfs.dm index 284e1b66050..204a898c458 100644 --- a/code/modules/mining/mine_turfs.dm +++ b/code/modules/mining/mine_turfs.dm @@ -89,7 +89,7 @@ var/global/list/rockTurfEdgeCache icon_state = "rock" return -/turf/simulated/mineral/proc/Spread(turf/T) +/turf/simulated/mineral/Spread(turf/T) new src.type(T) /turf/simulated/mineral/random diff --git a/code/modules/procedural mapping/mapGenerator.dm b/code/modules/procedural mapping/mapGenerator.dm index f421b1db0ee..ce6b5a18c89 100644 --- a/code/modules/procedural mapping/mapGenerator.dm +++ b/code/modules/procedural mapping/mapGenerator.dm @@ -38,7 +38,6 @@ if(replace) undefineRegion() - map |= block(Start,End) return map diff --git a/code/modules/procedural mapping/mapGenerators/lava_river.dm b/code/modules/procedural mapping/mapGenerators/lava_river.dm new file mode 100644 index 00000000000..124868557d9 --- /dev/null +++ b/code/modules/procedural mapping/mapGenerators/lava_river.dm @@ -0,0 +1,18 @@ +/datum/mapGenerator/lavaland + var/start_z = 5 + modules = list(/datum/mapGeneratorModule/river) + +/datum/mapGenerator/lavaland/defineRegion(turf/Start, turf/End, replace = 0) + start_z = Start.z + ..() + +/datum/mapGeneratorModule/river + var/river_type = /turf/simulated/floor/plating/lava/smooth + var/river_nodes = 4 + var/start_z = 5 + +/datum/mapGeneratorModule/river/generate() + if(istype(mother, /datum/mapGenerator/lavaland)) + var/datum/mapGenerator/lavaland/L = mother + start_z = L.start_z + spawn_rivers(start_z, river_nodes, river_type) diff --git a/tgstation.dme b/tgstation.dme index 149e4ef6e91..f3b6d88a4b7 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -813,6 +813,7 @@ #include "code\game\turfs\turf.dm" #include "code\game\turfs\simulated\dirtystation.dm" #include "code\game\turfs\simulated\floor.dm" +#include "code\game\turfs\simulated\river.dm" #include "code\game\turfs\simulated\walls.dm" #include "code\game\turfs\simulated\walls_mineral.dm" #include "code\game\turfs\simulated\walls_misc.dm" @@ -1448,6 +1449,7 @@ #include "code\modules\procedural mapping\mapGeneratorModules\nature.dm" #include "code\modules\procedural mapping\mapGenerators\asteroid.dm" #include "code\modules\procedural mapping\mapGenerators\cellular.dm" +#include "code\modules\procedural mapping\mapGenerators\lava_river.dm" #include "code\modules\procedural mapping\mapGenerators\nature.dm" #include "code\modules\procedural mapping\mapGenerators\shuttle.dm" #include "code\modules\procedural mapping\mapGenerators\syndicate.dm"