diff --git a/aurorastation.dme b/aurorastation.dme index cc7981e67a6..2e74cba9b01 100644 --- a/aurorastation.dme +++ b/aurorastation.dme @@ -189,7 +189,6 @@ #include "code\controllers\subsystems\power.dm" #include "code\controllers\subsystems\radio.dm" #include "code\controllers\subsystems\responseteam.dm" -#include "code\controllers\subsystems\space_ruin.dm" #include "code\controllers\subsystems\statistics.dm" #include "code\controllers\subsystems\sun.dm" #include "code\controllers\subsystems\sunlight.dm" @@ -297,6 +296,7 @@ #include "code\datums\helper_datums\construction_datum.dm" #include "code\datums\helper_datums\events.dm" #include "code\datums\helper_datums\getrev.dm" +#include "code\datums\helper_datums\space_ruin.dm" #include "code\datums\helper_datums\teleport.dm" #include "code\datums\helper_datums\topic_input.dm" #include "code\datums\looping_sounds\_looping_sound.dm" diff --git a/code/__defines/subsystem-priority.dm b/code/__defines/subsystem-priority.dm index 5ab0b13a471..7f3d2bb1b34 100644 --- a/code/__defines/subsystem-priority.dm +++ b/code/__defines/subsystem-priority.dm @@ -1,29 +1,28 @@ -#define SS_INIT_PERSISTENT_CONFIG 25 -#define SS_INIT_MISC_FIRST 24 -#define SS_INIT_SEEDS 23 // Plant controller setup. -#define SS_INIT_MAPLOAD 22 // DMM parsing and load. Unless you know what you're doing, make sure this remains first. -#define SS_INIT_JOBS 21 -#define SS_INIT_MAPFINALIZE 20 // Asteroid generation. -#define SS_INIT_SHUTTLE 19 // Shuttle setup. -#define SS_INIT_PARALLAX 18 // Parallax image cache generation. Must run before ghosts are able to join. -#define SS_INIT_HOLOMAP 17 -#define SS_INIT_ATOMS 16 // World initialization. Will trigger lighting updates. Observers can join after this loads. -#define SS_INIT_POWER 15 // Initial powernet build. -#define SS_INIT_ECONOMY 14 // Cargo needs economy set up -#define SS_INIT_CARGO 13 // Random warehouse generation. Runs after SSatoms because it assumes objects are initialized when it runs. -#define SS_INIT_PIPENET 12 // Initial pipenet build. -#define SS_INIT_MACHINERY 11 // Machinery prune and powernet build. -#define SS_INIT_AIR 10 // Air setup and pre-bake. -#define SS_INIT_NIGHT 9 // Nightmode controller. Will trigger lighting updates. -#define SS_INIT_SMOOTHING 8 // Object icon smoothing. Creates overlays. -#define SS_INIT_ICON_UPDATE 7 // Icon update queue flush. Should run before overlays. -#define SS_INIT_AO 6 // Wall AO neighbour build. -#define SS_INIT_OVERLAY 5 // Overlay flush. -#define SS_INIT_MISC 4 // Subsystems without an explicitly set initialization order start here. -#define SS_INIT_SUNLIGHT 3 // Sunlight setup. Creates lots of lighting & SSzcopy updates. -#define SS_INIT_LIGHTING 2 // Generation of lighting overlays and pre-bake. May cause openturf updates, should initialize before SSzcopy. -#define SS_INIT_ZCOPY 1 // Z-mimic flush. Should run after SSoverlay & SSicon_smooth so it copies the smoothed sprites. -#define SS_INIT_SPACE_RUINS 0 // Used in the creation of random space ruins. +#define SS_INIT_PERSISTENT_CONFIG 24 +#define SS_INIT_MISC_FIRST 23 +#define SS_INIT_SEEDS 22 // Plant controller setup. +#define SS_INIT_MAPLOAD 21 // DMM parsing and load. Unless you know what you're doing, make sure this remains first. +#define SS_INIT_JOBS 20 +#define SS_INIT_MAPFINALIZE 19 // Asteroid generation. +#define SS_INIT_SHUTTLE 18 // Shuttle setup. +#define SS_INIT_PARALLAX 17 // Parallax image cache generation. Must run before ghosts are able to join. +#define SS_INIT_HOLOMAP 16 +#define SS_INIT_ATOMS 15 // World initialization. Will trigger lighting updates. Observers can join after this loads. +#define SS_INIT_POWER 14 // Initial powernet build. +#define SS_INIT_ECONOMY 13 // Cargo needs economy set up +#define SS_INIT_CARGO 12 // Random warehouse generation. Runs after SSatoms because it assumes objects are initialized when it runs. +#define SS_INIT_PIPENET 11 // Initial pipenet build. +#define SS_INIT_MACHINERY 10 // Machinery prune and powernet build. +#define SS_INIT_AIR 9 // Air setup and pre-bake. +#define SS_INIT_NIGHT 8 // Nightmode controller. Will trigger lighting updates. +#define SS_INIT_SMOOTHING 7 // Object icon smoothing. Creates overlays. +#define SS_INIT_ICON_UPDATE 6 // Icon update queue flush. Should run before overlays. +#define SS_INIT_AO 5 // Wall AO neighbour build. +#define SS_INIT_OVERLAY 4 // Overlay flush. +#define SS_INIT_MISC 3 // Subsystems without an explicitly set initialization order start here. +#define SS_INIT_SUNLIGHT 2 // Sunlight setup. Creates lots of lighting & SSzcopy updates. +#define SS_INIT_LIGHTING 1 // Generation of lighting overlays and pre-bake. May cause openturf updates, should initialize before SSzcopy. +#define SS_INIT_ZCOPY 0 // Z-mimic flush. Should run after SSoverlay & SSicon_smooth so it copies the smoothed sprites. #define SS_INIT_LOBBY -1 // Lobby timer starts here. The lobby timer won't actually start going down until the MC starts ticking, so you probably want this last. // Something to remember when setting priorities: SS_TICKER runs before Normal, which runs before SS_BACKGROUND. diff --git a/code/controllers/subsystems/initialization/atlas.dm b/code/controllers/subsystems/initialization/atlas.dm index 4f2663b0e3c..c4876d0146b 100644 --- a/code/controllers/subsystems/initialization/atlas.dm +++ b/code/controllers/subsystems/initialization/atlas.dm @@ -192,4 +192,4 @@ var/datum/controller/subsystem/atlas/SSatlas /proc/commstation_name() ASSERT(current_map) - return current_map.dock_name + return current_map.dock_name \ No newline at end of file diff --git a/code/controllers/subsystems/initialization/map_finalization.dm b/code/controllers/subsystems/initialization/map_finalization.dm index 07a2093ef58..6efb4161bab 100644 --- a/code/controllers/subsystems/initialization/map_finalization.dm +++ b/code/controllers/subsystems/initialization/map_finalization.dm @@ -5,6 +5,9 @@ flags = SS_NO_FIRE | SS_NO_DISPLAY init_order = SS_INIT_MAPFINALIZE + var/dmm_suite/maploader + var/datum/space_ruin/selected_ruin + /datum/controller/subsystem/finalize/Initialize(timeofday) // Setup the global antag uplink. This needs to be done after SSatlas as it requires current_map. global.uplink = new @@ -13,6 +16,11 @@ current_map.finalize_load() log_ss("map_finalization", "Finalized map in [(world.time - time)/10] seconds.") + //Select ruin and spawn it + if(current_map.has_space_ruins) + select_ruin() + load_space_ruin() + if(config.dungeon_chance > 0) place_dungeon_spawns() @@ -27,6 +35,9 @@ // This is dependant on markers. populate_antag_spawns() + // Generate contact report. + generate_contact_report() + ..() /proc/resort_all_areas() @@ -36,7 +47,65 @@ sortTim(all_areas, /proc/cmp_name_asc) -/proc/place_dungeon_spawns() +/datum/controller/subsystem/finalize/proc/select_ruin() + var/list/ruinconfig = list() + var/list/ruinlist = list() + var/list/weightedlist = list() + try + ruinconfig = json_decode(return_file_text("config/space_ruins.json")) + catch(var/exception/ej) + log_debug("SSatlas: Warning: Could not load space ruin config, as space_ruins.json is missing - [ej]") + return + + for(var/ruinname in ruinconfig) + //Create the datums + var/datum/space_ruin/sr = new(ruinname,ruinconfig[ruinname]["file_name"]) + if("weight" in ruinconfig[ruinname]) + sr.weight = ruinconfig[ruinname]["weight"] + if("valid_maps" in ruinconfig[ruinname]) + sr.valid_maps = ruinconfig[ruinname]["valid_maps"] + if("characteristics" in ruinconfig[ruinname]) + sr.characteristics = ruinconfig[ruinname]["characteristics"] + + //Check if the file exists + var/map_directory = "maps/space_ruins/" + if(!fexists("[map_directory][sr.file_name]")) + admin_notice("Map file [sr.file_name] for ruin [sr.name] does not exist.") + log_ss("atlas","Map file [sr.file_name] for ruin [sr.name] does not exist.") + continue + + //Build the lists + if(length(sr.valid_maps)) + if(!(current_map.name in sr.valid_maps)) + continue + ruinlist[sr.name] = sr + weightedlist[sr.name] = sr.weight + + if(!length(ruinlist)) + log_ss("atlas","Found no valid ruins for current map.") + return + + log_ss("atlas", "Loaded ruin config.") + var/ruinname = pickweight(weightedlist) + selected_ruin = ruinlist[ruinname] + return + +/datum/controller/subsystem/finalize/proc/load_space_ruin() + maploader = new + + if(!selected_ruin) + return + var/map_directory = "maps/space_ruins/" + var/mfile = "[map_directory][selected_ruin.file_name]" + var/time = world.time + + if (!maploader.load_map(file(mfile), 0, 0, no_changeturf = TRUE)) + log_ss("finalize", "Failed to load '[mfile]'!") + else + log_ss("atlas", "Loaded space ruin in [(world.time - time)/10] seconds.") + QDEL_NULL(maploader) + +/datum/controller/subsystem/finalize/proc/place_dungeon_spawns() var/map_directory = "maps/dungeon_spawns/" var/list/files = flist(map_directory) var/start_time = world.time @@ -78,3 +147,13 @@ qdel(maploader) +/datum/controller/subsystem/finalize/proc/generate_contact_report() + if(!selected_ruin) + return + var/report_text = selected_ruin.get_contact_report() + for(var/obj/effect/landmark/C in landmarks_list) + if(C.name == "Space Ruin Paper") + var/obj/item/weapon/paper/P = new /obj/item/weapon/paper(get_turf(C)) + P.name = "Icarus reading report" + P.info = report_text + P.update_icon() \ No newline at end of file diff --git a/code/controllers/subsystems/space_ruin.dm b/code/controllers/subsystems/space_ruin.dm deleted file mode 100644 index ed156c224e1..00000000000 --- a/code/controllers/subsystems/space_ruin.dm +++ /dev/null @@ -1,83 +0,0 @@ -/var/global/datum/controller/subsystem/trade/SSspace_ruins - -/datum/controller/subsystem/space_ruins - name = "Space Ruins" - flags = SS_NO_FIRE - init_order = SS_INIT_SPACE_RUINS - -/datum/controller/subsystem/space_ruins/New() - NEW_SS_GLOBAL(SSspace_ruins) - -/datum/controller/subsystem/space_ruins/Initialize() - if(current_map.has_space_ruins) - create_space_ruin() - ..() - -/datum/controller/subsystem/space_ruins/proc/create_space_ruin() - var/map_directory = "maps/space_ruins/" - var/list/files = flist(map_directory) - var/start_time = world.time - - if(length(files) <= 0) - log_ss("map_finalization","There are no space ruin map.") - return - - var/chosen_ruin = pick(files) - - if(!dd_hassuffix(chosen_ruin,".dmm")) - files -= chosen_ruin - log_ss("map_finalization","ALERT: [chosen_ruin] is not a .dmm file! Skipping!") - - var/map_file = "[map_directory][chosen_ruin]" - - if(fexists(map_file)) - var/datum/map_template/T = new(map_file, "Space Ruin") - T.load_new_z() - - else - log_ss("map_finalization","ERROR: Something weird happened with the file: [chosen_ruin].") - - log_ss("map_finalization","Loaded [chosen_ruin] space ruin in [(world.time - start_time)/10] seconds.") - create_space_ruin_report("chosen_ruin") - - -/datum/controller/subsystem/space_ruins/proc/create_space_ruin_report(var/ruin_name) - var/ruintext = "

