Fixes Space-Ruin Issues (#6404)

* Fixes Space-Ruin Issues

Fixes Load-Time and Lighting issues on the Space Ruins by moving the loading of the ruins into Atlas

* Reworks the space ruin loader

It´s now based on a json file which allows to set the weight of the ruins, add various tags with a specified weight and restrict the maps the ruin can be used in

* Fixes compile warnings

* Change z-levels in aurora.dm

* Moves the SubSystem

* Changes the player_levels back again since the away mission is now loaded after the z expansion
This commit is contained in:
Werner
2019-05-09 01:12:28 +02:00
committed by GitHub
parent 92d0f712be
commit 87efc6aea3
8 changed files with 225 additions and 113 deletions

View File

@@ -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

View File

@@ -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("<span class='danger'>Map file [sr.file_name] for ruin [sr.name] does not exist.</span>")
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()

View File

@@ -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 = "<center><img src = ntlogo.png><BR><h2><BR><B>Icarus Reading Report</h2></B></FONT size><HR></center>"
ruintext += "<B><font face='Courier New'>The Icarus sensors located a away site with the possible characteristics:</font></B><br>"
switch(ruin_name)
if("crashed_freighter")
ruintext += "Lifeform signals.<br>"
if("derelict" || "nt_cloneship")
ruintext += "NanoTrasen infrastructure.<br>"
if("pra_blockade_runner")
ruintext += "Large biomass signals.<br>"
if("sol_frigate")
ruintext += "Warp signal.<br>"
else
ruintext += "Unrecognizable signals.<br>"
if(prob(20))
ruintext += "Mineral concentration.<br>"
if(prob(20))
ruintext += "Bluespace signals.<br>"
if(prob(20))
ruintext += "Artificial intelligence signals.<br>"
ruintext += "<HR>"
ruintext += "<B><font face='Courier New'>This reading has been detected within shuttle range of the [current_map.station_name] and deemed safe for survey by [current_map.company_name] personnel. \
The designated research director, or a captain level decision may determine the goal of any missions to this site. On-site command is deferred to any nearby command staff.</font></B><br>"
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 = ruintext
P.update_icon()