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

@@ -189,7 +189,6 @@
#include "code\controllers\subsystems\power.dm" #include "code\controllers\subsystems\power.dm"
#include "code\controllers\subsystems\radio.dm" #include "code\controllers\subsystems\radio.dm"
#include "code\controllers\subsystems\responseteam.dm" #include "code\controllers\subsystems\responseteam.dm"
#include "code\controllers\subsystems\space_ruin.dm"
#include "code\controllers\subsystems\statistics.dm" #include "code\controllers\subsystems\statistics.dm"
#include "code\controllers\subsystems\sun.dm" #include "code\controllers\subsystems\sun.dm"
#include "code\controllers\subsystems\sunlight.dm" #include "code\controllers\subsystems\sunlight.dm"
@@ -297,6 +296,7 @@
#include "code\datums\helper_datums\construction_datum.dm" #include "code\datums\helper_datums\construction_datum.dm"
#include "code\datums\helper_datums\events.dm" #include "code\datums\helper_datums\events.dm"
#include "code\datums\helper_datums\getrev.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\teleport.dm"
#include "code\datums\helper_datums\topic_input.dm" #include "code\datums\helper_datums\topic_input.dm"
#include "code\datums\looping_sounds\_looping_sound.dm" #include "code\datums\looping_sounds\_looping_sound.dm"

View File

@@ -1,29 +1,28 @@
#define SS_INIT_PERSISTENT_CONFIG 25 #define SS_INIT_PERSISTENT_CONFIG 24
#define SS_INIT_MISC_FIRST 24 #define SS_INIT_MISC_FIRST 23
#define SS_INIT_SEEDS 23 // Plant controller setup. #define SS_INIT_SEEDS 22 // 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_MAPLOAD 21 // DMM parsing and load. Unless you know what you're doing, make sure this remains first.
#define SS_INIT_JOBS 21 #define SS_INIT_JOBS 20
#define SS_INIT_MAPFINALIZE 20 // Asteroid generation. #define SS_INIT_MAPFINALIZE 19 // Asteroid generation.
#define SS_INIT_SHUTTLE 19 // Shuttle setup. #define SS_INIT_SHUTTLE 18 // Shuttle setup.
#define SS_INIT_PARALLAX 18 // Parallax image cache generation. Must run before ghosts are able to join. #define SS_INIT_PARALLAX 17 // Parallax image cache generation. Must run before ghosts are able to join.
#define SS_INIT_HOLOMAP 17 #define SS_INIT_HOLOMAP 16
#define SS_INIT_ATOMS 16 // World initialization. Will trigger lighting updates. Observers can join after this loads. #define SS_INIT_ATOMS 15 // World initialization. Will trigger lighting updates. Observers can join after this loads.
#define SS_INIT_POWER 15 // Initial powernet build. #define SS_INIT_POWER 14 // Initial powernet build.
#define SS_INIT_ECONOMY 14 // Cargo needs economy set up #define SS_INIT_ECONOMY 13 // 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_CARGO 12 // 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_PIPENET 11 // Initial pipenet build.
#define SS_INIT_MACHINERY 11 // Machinery prune and powernet build. #define SS_INIT_MACHINERY 10 // Machinery prune and powernet build.
#define SS_INIT_AIR 10 // Air setup and pre-bake. #define SS_INIT_AIR 9 // Air setup and pre-bake.
#define SS_INIT_NIGHT 9 // Nightmode controller. Will trigger lighting updates. #define SS_INIT_NIGHT 8 // Nightmode controller. Will trigger lighting updates.
#define SS_INIT_SMOOTHING 8 // Object icon smoothing. Creates overlays. #define SS_INIT_SMOOTHING 7 // Object icon smoothing. Creates overlays.
#define SS_INIT_ICON_UPDATE 7 // Icon update queue flush. Should run before overlays. #define SS_INIT_ICON_UPDATE 6 // Icon update queue flush. Should run before overlays.
#define SS_INIT_AO 6 // Wall AO neighbour build. #define SS_INIT_AO 5 // Wall AO neighbour build.
#define SS_INIT_OVERLAY 5 // Overlay flush. #define SS_INIT_OVERLAY 4 // Overlay flush.
#define SS_INIT_MISC 4 // Subsystems without an explicitly set initialization order start here. #define SS_INIT_MISC 3 // 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_SUNLIGHT 2 // 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_LIGHTING 1 // 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_ZCOPY 0 // 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_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. #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. // Something to remember when setting priorities: SS_TICKER runs before Normal, which runs before SS_BACKGROUND.

View File

@@ -5,6 +5,9 @@
flags = SS_NO_FIRE | SS_NO_DISPLAY flags = SS_NO_FIRE | SS_NO_DISPLAY
init_order = SS_INIT_MAPFINALIZE init_order = SS_INIT_MAPFINALIZE
var/dmm_suite/maploader
var/datum/space_ruin/selected_ruin
/datum/controller/subsystem/finalize/Initialize(timeofday) /datum/controller/subsystem/finalize/Initialize(timeofday)
// Setup the global antag uplink. This needs to be done after SSatlas as it requires current_map. // Setup the global antag uplink. This needs to be done after SSatlas as it requires current_map.
global.uplink = new global.uplink = new
@@ -13,6 +16,11 @@
current_map.finalize_load() current_map.finalize_load()
log_ss("map_finalization", "Finalized map in [(world.time - time)/10] seconds.") 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) if(config.dungeon_chance > 0)
place_dungeon_spawns() place_dungeon_spawns()
@@ -27,6 +35,9 @@
// This is dependant on markers. // This is dependant on markers.
populate_antag_spawns() populate_antag_spawns()
// Generate contact report.
generate_contact_report()
..() ..()
/proc/resort_all_areas() /proc/resort_all_areas()
@@ -36,7 +47,65 @@
sortTim(all_areas, /proc/cmp_name_asc) 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/map_directory = "maps/dungeon_spawns/"
var/list/files = flist(map_directory) var/list/files = flist(map_directory)
var/start_time = world.time var/start_time = world.time
@@ -78,3 +147,13 @@
qdel(maploader) 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()

View File

@@ -0,0 +1,26 @@
/datum/space_ruin
var/name
var/file_name
var/weight = 1
var/list/valid_maps = null
var/list/characteristics = null
/datum/space_ruin/New(var/i_name, var/i_file_name)
name = i_name
file_name = i_file_name
/datum/space_ruin/proc/get_contact_report()
var/list/schar = sortList(characteristics) //Sort them alphabetically to avoid metaing based on the order
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><ul>"
for(var/characteristic in schar)
if(prob(schar[characteristic]))
ruintext += "<li>[characteristic]</li>"
ruintext += "</ul><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>"
return ruintext

View File

@@ -24,7 +24,7 @@
else else
to_chat(user, "It says '[icon_state]'") to_chat(user, "It says '[icon_state]'")
/obj/structure/sign/double/barsign/New() /obj/structure/sign/double/barsign/Initialize()
..() ..()
icon_state = pick(get_valid_states()) icon_state = pick(get_valid_states())

View File

@@ -0,0 +1,91 @@
{
"crashed freighter": {
"file_name": "crashed_freighter.dmm",
"valid maps": ["aurora"],
"weight": 1,
"characteristics": {
"Life Form Signals": 100,
"Bluespace Signals": 20,
"Artificial Intelligence Signals": 20,
"Unrecognizable Signals": 20
}
},
"derelict": {
"file_name": "derelict.dmm",
"valid maps": ["aurora"],
"characteristics": {
"Abandoned Infrastructure": 100,
"Artificial Intelligence Signals": 20,
"Bluespace Signals": 20,
"Unrecognizable Signals": 20
}
},
"listening post": {
"file_name": "listening_post.dmm",
"valid maps": ["aurora"],
"characteristics": {
"Bluespace Signals": 20,
"Artificial Intelligence Signals": 20,
"Unrecognizable Signals": 20
}
},
"nt cloneship": {
"file_name": "nt_cloneship.dmm",
"valid maps": ["aurora"],
"characteristics": {
"Abandoned Infrastructure": 100,
"Life Form Signals": 20,
"Bluespace Signals": 20,
"Artificial Intelligence Signals": 20,
"Unrecognizable Signals": 20
}
},
"pra blockade runner": {
"file_name": "pra_blockade_runner.dmm",
"valid maps": ["aurora"],
"characteristics": {
"Large biomass signals": 100,
"Life Form Signals": 20,
"Bluespace Signals": 20,
"Unrecognizable Signals": 20
}
},
"sol corvette": {
"file_name": "sol_corvette.dmm",
"valid maps": ["aurora"],
"characteristics": {
"Life Form Signals": 20,
"Bluespace Signals": 20,
"Unrecognizable Signals": 20
}
},
"sol frigate": {
"file_name": "sol_frigate.dmm",
"valid maps": ["aurora"],
"characteristics": {
"Wrap Signal": 100,
"Life Form Signals": 20,
"Bluespace Signals": 20,
"Unrecognizable Signals": 20
}
},
"syndicate base": {
"file_name": "syndicatebase.dmm",
"valid maps": ["aurora"],
"weight": 0.5,
"characteristics": {
"Unrecognizable Signals": 100,
"Life Form Signals": 20,
"Bluespace Signals": 20
}
},
"tcfl frigate": {
"file_name": "tcfl_frigate.dmm",
"valid maps": ["aurora"],
"characteristics": {
"Unrecognizable Signals": 100,
"Life Form Signals": 20,
"Bluespace Signals": 20
}
}
}