forked from Whitesands13/Whitesands
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the procedural generation of lavaland and turf/closed/minera…
…l (#54915) This replaces lavaland's old diagonal tunnel gen which was really horrendously jammed into asteroid floor code (?????) with Cellular Automata which runs in rust (PR for that here: tgstation/rust-g#57 ). The new code is a bit cleaner, but also looks better. VID: https://streamable.com/a45ke2 Things to do: - Make an icemoon version - Fix the roundstart atmos adjacency issues I asked AnturK if this was an acceptable PR for this month; he said it was okay as long as I didn't add new areas, which I don't plan to do. But if anyone thinks this PR breaks the spirit of the month I'll open it again in december.
- Loading branch information
1 parent
2814d65
commit 5df5585
Showing
18 changed files
with
266 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/datum/map_generator/cave_generator | ||
var/name = "Cave Generator" | ||
///Weighted list of the types that spawns if the turf is open | ||
var/open_turf_types = list(/turf/open/floor/plating/asteroid = 1) | ||
///Weighted list of the types that spawns if the turf is closed | ||
var/closed_turf_types = list(/turf/closed/mineral/random/volcanic = 1) | ||
|
||
|
||
///Weighted list of extra features that can spawn in the area, such as geysers. | ||
var/list/feature_spawn_list = list(/obj/structure/geyser/random = 1) | ||
///Weighted list of mobs that can spawn in the area. | ||
var/list/mob_spawn_list = list(/mob/living/simple_animal/hostile/asteroid/goliath/beast/random = 50, /obj/structure/spawner/lavaland/goliath = 3, \ | ||
/mob/living/simple_animal/hostile/asteroid/basilisk/watcher/random = 40, /obj/structure/spawner/lavaland = 2, \ | ||
/mob/living/simple_animal/hostile/asteroid/hivelord/legion/random = 30, /obj/structure/spawner/lavaland/legion = 3, \ | ||
SPAWN_MEGAFAUNA = 4, /mob/living/simple_animal/hostile/asteroid/goldgrub = 10) | ||
///Weighted list of flora that can spawn in the area. | ||
var/list/flora_spawn_list = list(/obj/structure/flora/ash/leaf_shroom = 2 , /obj/structure/flora/ash/cap_shroom = 2 , /obj/structure/flora/ash/stem_shroom = 2 , /obj/structure/flora/ash/cacti = 1, /obj/structure/flora/ash/tall_shroom = 2) | ||
// Weighted list of Megafauna that can spawn in the caves | ||
var/list/megafauna_spawn_list | ||
|
||
|
||
///Base chance of spawning a mob | ||
var/mob_spawn_chance = 6 | ||
///Base chance of spawning flora | ||
var/flora_spawn_chance = 2 | ||
///Base chance of spawning features | ||
var/feature_spawn_chance = 0.1 | ||
///Unique ID for this spawner | ||
var/string_gen | ||
|
||
///Chance of cells starting closed | ||
var/initial_closed_chance = 45 | ||
///Amount of smoothing iterations | ||
var/smoothing_iterations = 20 | ||
///How much neighbours does a dead cell need to become alive | ||
var/birth_limit = 4 | ||
///How little neighbours does a alive cell need to die | ||
var/death_limit = 3 | ||
|
||
/datum/map_generator/cave_generator/New() | ||
. = ..() | ||
if(!megafauna_spawn_list) | ||
megafauna_spawn_list = GLOB.megafauna_spawn_list | ||
|
||
/datum/map_generator/cave_generator/generate_terrain(list/turfs) | ||
. = ..() | ||
var/start_time = REALTIMEOFDAY | ||
string_gen = rustg_cnoise_generate("[initial_closed_chance]", "[smoothing_iterations]", "[birth_limit]", "[death_limit]", "[world.maxx]", "[world.maxy]") //Generate the raw CA data | ||
|
||
for(var/i in turfs) //Go through all the turfs and generate them | ||
var/turf/gen_turf = i | ||
|
||
var/area/A = gen_turf.loc | ||
if(!(A.area_flags & CAVES_ALLOWED)) | ||
continue | ||
|
||
var/closed = text2num(string_gen[world.maxx * (gen_turf.y - 1) + gen_turf.x]) | ||
|
||
var/stored_flags | ||
if(gen_turf.flags_1 & NO_RUINS_1) | ||
stored_flags |= NO_RUINS_1 | ||
|
||
var/turf/new_turf = gen_turf.ChangeTurf(pickweight(closed ? closed_turf_types : open_turf_types), null, CHANGETURF_DEFER_CHANGE) | ||
new_turf.flags_1 |= stored_flags | ||
|
||
if(!closed)//Open turfs have some special behavior related to spawning flora and mobs. | ||
|
||
var/turf/open/new_open_turf = new_turf | ||
|
||
///Spawning isn't done in procs to save on overhead on the 60k turfs we're going through. | ||
|
||
//FLORA SPAWNING HERE | ||
var/atom/spawned_flora | ||
if(flora_spawn_list && prob(flora_spawn_chance)) | ||
var/can_spawn = TRUE | ||
|
||
if(!(A.area_flags & FLORA_ALLOWED)) | ||
can_spawn = FALSE | ||
if(can_spawn) | ||
spawned_flora = pickweight(flora_spawn_list) | ||
spawned_flora = new spawned_flora(new_open_turf) | ||
|
||
//FEATURE SPAWNING HERE | ||
var/atom/spawned_feature | ||
if(feature_spawn_list && prob(feature_spawn_chance)) | ||
var/can_spawn = TRUE | ||
|
||
if(!(A.area_flags & FLORA_ALLOWED)) //checks the same flag because lol dunno | ||
can_spawn = FALSE | ||
|
||
var/atom/picked_feature = pickweight(feature_spawn_list) | ||
|
||
for(var/obj/structure/F in range(7, new_open_turf)) | ||
if(istype(F, picked_feature)) | ||
can_spawn = FALSE | ||
|
||
if(can_spawn) | ||
spawned_feature = new picked_feature(new_open_turf) | ||
|
||
//MOB SPAWNING HERE | ||
|
||
if(mob_spawn_list && !spawned_flora && !spawned_feature && prob(mob_spawn_chance)) | ||
var/can_spawn = TRUE | ||
|
||
if(!(A.area_flags & MOB_SPAWN_ALLOWED)) | ||
can_spawn = FALSE | ||
|
||
var/atom/picked_mob = pickweight(mob_spawn_list) | ||
|
||
if(picked_mob == SPAWN_MEGAFAUNA) // | ||
if((A.area_flags & MEGAFAUNA_SPAWN_ALLOWED) && megafauna_spawn_list?.len) //this is danger. it's boss time. | ||
picked_mob = pickweight(megafauna_spawn_list) | ||
else //this is not danger, don't spawn a boss, spawn something else | ||
picked_mob = pickweight(mob_spawn_list - SPAWN_MEGAFAUNA) //What if we used 100% of the brain...and did something (slightly) less shit than a while loop? | ||
|
||
for(var/thing in urange(12, new_open_turf)) //prevents mob clumps | ||
if(!ishostile(thing) && !istype(thing, /obj/structure/spawner)) | ||
continue | ||
if((ispath(picked_mob, /mob/living/simple_animal/hostile/megafauna) || ismegafauna(thing)) && get_dist(new_open_turf, thing) <= 7) | ||
can_spawn = FALSE //if there's a megafauna within standard view don't spawn anything at all | ||
break | ||
if(ispath(picked_mob, /mob/living/simple_animal/hostile/asteroid) || istype(thing, /mob/living/simple_animal/hostile/asteroid)) | ||
can_spawn = FALSE //if the random is a standard mob, avoid spawning if there's another one within 12 tiles | ||
break | ||
if((ispath(picked_mob, /obj/structure/spawner/lavaland) || istype(thing, /obj/structure/spawner/lavaland)) && get_dist(new_open_turf, thing) <= 2) | ||
can_spawn = FALSE //prevents tendrils spawning in each other's collapse range | ||
break | ||
|
||
if(can_spawn) | ||
if(ispath(picked_mob, /mob/living/simple_animal/hostile/megafauna/bubblegum)) //there can be only one bubblegum, so don't waste spawns on it | ||
megafauna_spawn_list.Remove(picked_mob) | ||
|
||
new picked_mob(new_open_turf) | ||
CHECK_TICK | ||
|
||
var/message = "[name] finished in [(REALTIMEOFDAY - start_time)/10]s!" | ||
to_chat(world, "<span class='boldannounce'>[message]</span>") | ||
log_world(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/datum/map_generator/cave_generator/icemoon | ||
open_turf_types = list(/turf/open/floor/plating/asteroid/snow/icemoon = 19, /turf/open/floor/plating/ice/icemoon = 1) | ||
closed_turf_types = list(/turf/closed/mineral/random/snow = 1) | ||
|
||
|
||
feature_spawn_list = list(/obj/structure/geyser/random = 1) | ||
mob_spawn_list = list(/mob/living/simple_animal/hostile/asteroid/wolf = 50, /obj/structure/spawner/ice_moon = 3, \ | ||
/mob/living/simple_animal/hostile/asteroid/polarbear = 30, /obj/structure/spawner/ice_moon/polarbear = 3, \ | ||
/mob/living/simple_animal/hostile/asteroid/hivelord/legion/snow = 50, /mob/living/simple_animal/hostile/asteroid/goldgrub = 10, \ | ||
/mob/living/simple_animal/hostile/asteroid/lobstrosity = 15) | ||
flora_spawn_list = list(/obj/structure/flora/tree/pine = 2, /obj/structure/flora/rock/icy = 2, /obj/structure/flora/rock/pile/icy = 2, /obj/structure/flora/grass/both = 6, /obj/structure/flora/ash/chilly = 2) | ||
|
||
/datum/map_generator/cave_generator/icemoon/surface | ||
flora_spawn_chance = 4 | ||
mob_spawn_list = null | ||
initial_closed_chance = 40 | ||
birth_limit = 5 | ||
death_limit = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/datum/map_generator/cave_generator/lavaland | ||
open_turf_types = list(/turf/open/floor/plating/asteroid/basalt/lava_land_surface = 1) | ||
closed_turf_types = list(/turf/closed/mineral/random/volcanic = 1) | ||
|
||
|
||
feature_spawn_list = list(/obj/structure/geyser/random = 1) | ||
mob_spawn_list = list(/mob/living/simple_animal/hostile/asteroid/goliath/beast/random = 50, /obj/structure/spawner/lavaland/goliath = 3, \ | ||
/mob/living/simple_animal/hostile/asteroid/basilisk/watcher/random = 40, /obj/structure/spawner/lavaland = 2, \ | ||
/mob/living/simple_animal/hostile/asteroid/hivelord/legion/random = 30, /obj/structure/spawner/lavaland/legion = 3, \ | ||
SPAWN_MEGAFAUNA = 4, /mob/living/simple_animal/hostile/asteroid/goldgrub = 10) | ||
flora_spawn_list = list(/obj/structure/flora/ash/leaf_shroom = 2 , /obj/structure/flora/ash/cap_shroom = 2 , /obj/structure/flora/ash/stem_shroom = 2 , /obj/structure/flora/ash/cacti = 1, /obj/structure/flora/ash/tall_shroom = 2) | ||
|
||
initial_closed_chance = 45 | ||
smoothing_iterations = 50 | ||
birth_limit = 4 | ||
death_limit = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.