From 58fc679cce74cf75a118a2b235f5f679fbf5f488 Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Fri, 24 Apr 2020 20:49:15 +0200 Subject: [PATCH] WIP --- .../{ => away_mission}/Academy.dmm | 0 .../{ => away_mission}/Cabin.dmm | 0 .../{ => away_mission}/TheBeach.dmm | 0 .../{ => away_mission}/caves.dmm | 0 .../{ => away_mission}/challenge.dmm | 0 .../{ => away_mission}/moonoutpost19.dmm | 0 .../{ => away_mission}/research.dmm | 0 .../{ => away_mission}/snowdin.dmm | 0 .../{ => away_mission}/spacebattle.dmm | 0 .../undergroundoutpost45.dmm | 0 .../{ => away_mission}/wildwest.dmm | 0 code/__DEFINES/maps.dm | 7 +- code/__HELPERS/level_traits.dm | 2 + code/_globalvars/lists/mapping.dm | 5 ++ code/controllers/subsystem/mapping.dm | 65 ++++++++++++------- code/modules/awaymissions/zlevel.dm | 16 ++--- code/modules/mapping/map_template.dm | 8 +-- config/awaymissionconfig.txt | 26 ++++---- config/vr_config.txt | 13 ++++ 19 files changed, 90 insertions(+), 52 deletions(-) rename _maps/RandomZLevels/{ => away_mission}/Academy.dmm (100%) rename _maps/RandomZLevels/{ => away_mission}/Cabin.dmm (100%) rename _maps/RandomZLevels/{ => away_mission}/TheBeach.dmm (100%) rename _maps/RandomZLevels/{ => away_mission}/caves.dmm (100%) rename _maps/RandomZLevels/{ => away_mission}/challenge.dmm (100%) rename _maps/RandomZLevels/{ => away_mission}/moonoutpost19.dmm (100%) rename _maps/RandomZLevels/{ => away_mission}/research.dmm (100%) rename _maps/RandomZLevels/{ => away_mission}/snowdin.dmm (100%) rename _maps/RandomZLevels/{ => away_mission}/spacebattle.dmm (100%) rename _maps/RandomZLevels/{ => away_mission}/undergroundoutpost45.dmm (100%) rename _maps/RandomZLevels/{ => away_mission}/wildwest.dmm (100%) create mode 100644 config/vr_config.txt diff --git a/_maps/RandomZLevels/Academy.dmm b/_maps/RandomZLevels/away_mission/Academy.dmm similarity index 100% rename from _maps/RandomZLevels/Academy.dmm rename to _maps/RandomZLevels/away_mission/Academy.dmm diff --git a/_maps/RandomZLevels/Cabin.dmm b/_maps/RandomZLevels/away_mission/Cabin.dmm similarity index 100% rename from _maps/RandomZLevels/Cabin.dmm rename to _maps/RandomZLevels/away_mission/Cabin.dmm diff --git a/_maps/RandomZLevels/TheBeach.dmm b/_maps/RandomZLevels/away_mission/TheBeach.dmm similarity index 100% rename from _maps/RandomZLevels/TheBeach.dmm rename to _maps/RandomZLevels/away_mission/TheBeach.dmm diff --git a/_maps/RandomZLevels/caves.dmm b/_maps/RandomZLevels/away_mission/caves.dmm similarity index 100% rename from _maps/RandomZLevels/caves.dmm rename to _maps/RandomZLevels/away_mission/caves.dmm diff --git a/_maps/RandomZLevels/challenge.dmm b/_maps/RandomZLevels/away_mission/challenge.dmm similarity index 100% rename from _maps/RandomZLevels/challenge.dmm rename to _maps/RandomZLevels/away_mission/challenge.dmm diff --git a/_maps/RandomZLevels/moonoutpost19.dmm b/_maps/RandomZLevels/away_mission/moonoutpost19.dmm similarity index 100% rename from _maps/RandomZLevels/moonoutpost19.dmm rename to _maps/RandomZLevels/away_mission/moonoutpost19.dmm diff --git a/_maps/RandomZLevels/research.dmm b/_maps/RandomZLevels/away_mission/research.dmm similarity index 100% rename from _maps/RandomZLevels/research.dmm rename to _maps/RandomZLevels/away_mission/research.dmm diff --git a/_maps/RandomZLevels/snowdin.dmm b/_maps/RandomZLevels/away_mission/snowdin.dmm similarity index 100% rename from _maps/RandomZLevels/snowdin.dmm rename to _maps/RandomZLevels/away_mission/snowdin.dmm diff --git a/_maps/RandomZLevels/spacebattle.dmm b/_maps/RandomZLevels/away_mission/spacebattle.dmm similarity index 100% rename from _maps/RandomZLevels/spacebattle.dmm rename to _maps/RandomZLevels/away_mission/spacebattle.dmm diff --git a/_maps/RandomZLevels/undergroundoutpost45.dmm b/_maps/RandomZLevels/away_mission/undergroundoutpost45.dmm similarity index 100% rename from _maps/RandomZLevels/undergroundoutpost45.dmm rename to _maps/RandomZLevels/away_mission/undergroundoutpost45.dmm diff --git a/_maps/RandomZLevels/wildwest.dmm b/_maps/RandomZLevels/away_mission/wildwest.dmm similarity index 100% rename from _maps/RandomZLevels/wildwest.dmm rename to _maps/RandomZLevels/away_mission/wildwest.dmm diff --git a/code/__DEFINES/maps.dm b/code/__DEFINES/maps.dm index 73e900226e..844fe2cb90 100644 --- a/code/__DEFINES/maps.dm +++ b/code/__DEFINES/maps.dm @@ -35,6 +35,7 @@ require only minor tweaks. #define ZTRAIT_REEBE "Reebe" #define ZTRAIT_RESERVED "Transit/Reserved" #define ZTRAIT_AWAY "Away Mission" +#define ZTRAIT_VR "Virtual Reality" #define ZTRAIT_SPACE_RUINS "Space Ruins" #define ZTRAIT_LAVA_RUINS "Lava Ruins" #define ZTRAIT_ISOLATED_RUINS "Isolated Ruins" //Placing ruins on z levels with this trait will use turf reservation instead of usual placement. @@ -101,4 +102,8 @@ require only minor tweaks. #define PLACE_BELOW "below" //On z levl below - centered on same tile #define PLACE_ISOLATED "isolated" //On isolated ruin z level //Map type stuff. -#define MAP_TYPE_STATION "station" \ No newline at end of file +#define MAP_TYPE_STATION "station" + +//Random z-levels name defines. +#define AWAY_MISSION_NAME "Away Mission" +#define VIRT_REALITY_NAME "Virtual Reality" diff --git a/code/__HELPERS/level_traits.dm b/code/__HELPERS/level_traits.dm index 3e6e88c8fa..030a324614 100644 --- a/code/__HELPERS/level_traits.dm +++ b/code/__HELPERS/level_traits.dm @@ -12,3 +12,5 @@ #define is_reserved_level(z) SSmapping.level_trait(z, ZTRAIT_RESERVED) #define is_away_level(z) SSmapping.level_trait(z, ZTRAIT_AWAY) + +#define is_vr_level(z) SSmapping.level_trait(z, ZTRAIT_VR) diff --git a/code/_globalvars/lists/mapping.dm b/code/_globalvars/lists/mapping.dm index fb8863ebe7..d214ec94ef 100644 --- a/code/_globalvars/lists/mapping.dm +++ b/code/_globalvars/lists/mapping.dm @@ -50,3 +50,8 @@ GLOBAL_LIST_EMPTY_TYPED(areas_by_type, /area) GLOBAL_LIST_EMPTY(all_abstract_markers) GLOBAL_LIST_EMPTY(stationroom_landmarks) //List of all spawns for stationrooms + +///Away missions, VR, random z levels stuff. +GLOBAL_LIST_EMPTY(random_zlevels_generated) +GLOBAL_LIST_INIT(potential_away_levels, generateMapList(filename = "[global.config.directory]/awaymissionconfig.txt")) +GLOBAL_LIST_INIT(potential_vr_levels, generateMapList(filename = "[global.config.directory]/vr_config.txt")) diff --git a/code/controllers/subsystem/mapping.dm b/code/controllers/subsystem/mapping.dm index f13d5a2779..34e7439c38 100644 --- a/code/controllers/subsystem/mapping.dm +++ b/code/controllers/subsystem/mapping.dm @@ -81,7 +81,9 @@ SUBSYSTEM_DEF(mapping) // Pick a random away mission. if(CONFIG_GET(flag/roundstart_away)) createRandomZlevel() - + // Pick a random VR level. + if(CONFIG_GET(flag/roundstart_vr)) + createRandomZlevel(VIRT_REALITY_NAME, list(ZTRAIT_AWAY = TRUE, ZTRAIT_VR = TRUE), GLOB.potential_vr_levels) // Generate mining ruins loading_ruins = TRUE @@ -410,52 +412,65 @@ GLOBAL_LIST_EMPTY(the_station_areas) //Manual loading of away missions. /client/proc/admin_away() - set name = "Load Away Mission" + set name = "Load Away Mission / Virtual Reality" set category = "Fun" if(!holder ||!check_rights(R_FUN)) return + var/choice = alert(src, "What kind of level would you like to load?", "Load Away/VR", AWAY_MISSION_NAME, VIRT_REALITY_NAME, "Cancel") - if(!GLOB.the_gateway) - if(alert("There's no home gateway on the station. You sure you want to continue ?", "Uh oh", "Yes", "No") != "Yes") + var/list/possible_options + var/list/ztraits + switch(choice) + if(VIRT_REALITY_NAME) + possible_options = GLOB.potential_vr_levels + ztraits = list(ZTRAIT_AWAY = TRUE, ZTRAIT_VR = TRUE) + if(AWAY_MISSION_NAME) + if(!GLOB.the_gateway) + if(alert("There's no home gateway on the station. You sure you want to continue ?", "Uh oh", "Yes", "No") != "Yes") + return + possible_options = GLOB.potential_away_levels + ztraits = list(ZTRAIT_AWAY = TRUE) + else return - var/list/possible_options = GLOB.potentialRandomZlevels + "Custom" - var/away_name - var/datum/space_level/away_level + possible_options += "Custom" + var/lvl_name + var/datum/space_level/level - var/answer = input("What kind ? ","Away") as null|anything in possible_options + var/answer = input("What kind ? ","Away/VR") as null|anything in possible_options switch(answer) + if(null) + return if("Custom") var/mapfile = input("Pick file:", "File") as null|file if(!mapfile) return - away_name = "[mapfile] custom" - to_chat(usr,"Loading [away_name]...") - var/datum/map_template/template = new(mapfile, "Away Mission") - away_level = template.load_new_z() + lvl_name = "[mapfile] custom" + to_chat(usr,"Loading [lvl_name]...") + var/datum/map_template/template = new(mapfile, choice, ztraits) + level = template.load_new_z() else - if(answer in GLOB.potentialRandomZlevels) - away_name = answer - to_chat(usr,"Loading [away_name]...") - var/datum/map_template/template = new(away_name, "Away Mission") - away_level = template.load_new_z() - else - return + lvl_name = answer + to_chat(usr,"Loading [lvl_name]...") + var/datum/map_template/template = new(lvl_name, choice, ztraits) + level = template.load_new_z() + else + return - message_admins("Admin [key_name_admin(usr)] has loaded [away_name] away mission.") - log_admin("Admin [key_name(usr)] has loaded [away_name] away mission.") - if(!away_level) - message_admins("Loading [away_name] failed!") + message_admins("Admin [key_name_admin(usr)] has loaded [lvl_name] [choice].") + log_admin("Admin [key_name(usr)] has loaded [lvl_name] [choice].") + if(!level) + message_admins("Loading [lvl_name] failed!") return - if(GLOB.the_gateway) + if(choice == AWAY_MISSION_NAME && GLOB.the_gateway) //Link any found away gate with station gate var/obj/machinery/gateway/centeraway/new_gate for(var/obj/machinery/gateway/centeraway/G in GLOB.machines) - if(G.z == away_level.z_value) //I'll have to refactor gateway shitcode before multi-away support. + if(G.z == level.z_value) //I'll have to refactor gateway shitcode before multi-away support. new_gate = G break //Link station gate with away gate and remove wait time. diff --git a/code/modules/awaymissions/zlevel.dm b/code/modules/awaymissions/zlevel.dm index d4c9fdbee7..55a1c9dcc4 100644 --- a/code/modules/awaymissions/zlevel.dm +++ b/code/modules/awaymissions/zlevel.dm @@ -1,15 +1,13 @@ -// How much "space" we give the edge of the map -GLOBAL_LIST_INIT(potentialRandomZlevels, generateMapList(filename = "[global.config.directory]/awaymissionconfig.txt")) -/proc/createRandomZlevel() - if(GLOB.awaydestinations.len) //crude, but it saves another var! +/proc/createRandomZlevel(name = AWAY_MISSION_NAME, list/traits = list(ZTRAIT_AWAY = TRUE), list/potential_levels = potential_away_levels) + if(GLOB.random_zlevels_generated[name] || !length(potential_levels)) return - if(GLOB.potentialRandomZlevels && GLOB.potentialRandomZlevels.len) - to_chat(world, "Loading away mission...") - var/map = pick(GLOB.potentialRandomZlevels) - load_new_z_level(map, "Away Mission") - to_chat(world, "Away mission loaded.") + to_chat(world, "Loading [name]...") + var/map = pick(potential_levels) + load_new_z_level(map, name, traits) + to_chat(world, "[name] loaded.") + random_zlevels_generated[name] = TRUE /proc/reset_gateway_spawns(reset = FALSE) for(var/obj/machinery/gateway/G in world) diff --git a/code/modules/mapping/map_template.dm b/code/modules/mapping/map_template.dm index 3e361179de..5d8acec7e8 100644 --- a/code/modules/mapping/map_template.dm +++ b/code/modules/mapping/map_template.dm @@ -55,11 +55,11 @@ SSmachines.setup_template_powernets(cables) SSair.setup_template_machinery(atmos_machines) -/datum/map_template/proc/load_new_z() +/datum/map_template/proc/load_new_z(list/traits = list(ZTRAIT_AWAY = TRUE)) var/x = round((world.maxx - width)/2) var/y = round((world.maxy - height)/2) - var/datum/space_level/level = SSmapping.add_new_zlevel(name, list(ZTRAIT_AWAY = TRUE)) + var/datum/space_level/level = SSmapping.add_new_zlevel(name, traits) var/datum/parsed_map/parsed = load_map(file(mappath), x, y, level.z_value, no_changeturf=(SSatoms.initialized == INITIALIZATION_INSSATOMS), placeOnTop=TRUE) var/list/bounds = parsed.bounds if(!bounds) @@ -121,6 +121,6 @@ //for your ever biggening badminnery kevinz000 //❤ - Cyberboss -/proc/load_new_z_level(var/file, var/name) +/proc/load_new_z_level(file, name, list/traits) var/datum/map_template/template = new(file, name) - template.load_new_z() + template.load_new_z(traits) diff --git a/config/awaymissionconfig.txt b/config/awaymissionconfig.txt index 545394f3e9..ae52b8be14 100644 --- a/config/awaymissionconfig.txt +++ b/config/awaymissionconfig.txt @@ -7,16 +7,16 @@ #Do NOT tick the maps during compile -- the game uses this list to decide which map to load. Ticking the maps will result in them ALL being loaded at once. #DO tick the associated code file for the away mission you are enabling. Otherwise, the map will be trying to reference objects which do not exist, which will cause runtime errors! -#_maps/RandomZLevels/blackmarketpackers.dmm -#_maps/RandomZLevels/spacebattle.dmm -#_maps/RandomZLevels/TheBeach.dmm -#_maps/RandomZLevels/Academy.dmm -#_maps/RandomZLevels/wildwest.dmm -#_maps/RandomZLevels/challenge.dmm -#_maps/RandomZLevels/centcomAway.dmm -#_maps/RandomZLevels/moonoutpost19.dmm -#_maps/RandomZLevels/undergroundoutpost45.dmm -#_maps/RandomZLevels/caves.dmm -#_maps/RandomZLevels/snowdin.dmm -#_maps/RandomZLevels/research.dmm -#_maps/RandomZLevels/Cabin.dmm +#_maps/RandomZLevels/away_mission/blackmarketpackers.dmm +#_maps/RandomZLevels/away_mission/spacebattle.dmm +_maps/RandomZLevels/away_mission/TheBeach.dmm +_maps/RandomZLevels/away_mission/Academy.dmm +_maps/RandomZLevels/away_mission/wildwest.dmm +#_maps/RandomZLevels/away_mission/challenge.dmm +#_maps/RandomZLevels/away_mission/centcomAway.dmm +#_maps/RandomZLevels/away_mission/moonoutpost19.dmm +#_maps/RandomZLevels/away_mission/undergroundoutpost45.dmm +#_maps/RandomZLevels/away_mission/caves.dmm +#_maps/RandomZLevels/away_mission/snowdin.dmm +#_maps/RandomZLevels/away_mission/research.dmm +#_maps/RandomZLevels/away_mission/Cabin.dmm diff --git a/config/vr_config.txt b/config/vr_config.txt new file mode 100644 index 0000000000..a68a75e654 --- /dev/null +++ b/config/vr_config.txt @@ -0,0 +1,13 @@ +#List the potential virtual reality Z-levels here. awaymissionconfig copypasta follows. + +#Maps must be the full path to them +#Maps should be 255x255 or smaller and be bounded. Falling off the edge of the map will result in undefined behavior. +#SPECIFYING AN INVALID MAP WILL RESULT IN RUNTIMES ON GAME START + +#!!IMPORTANT NOTES FOR HOSTING VR MAPS!!: +#Do NOT tick the maps during compile -- the game uses this list to decide which map to load. Ticking the maps will result in them ALL being loaded at once. +#DO tick the associated code file for the virtual reality levels you are enabling. Otherwise, the map will be trying to reference objects which do not exist, which will cause runtime errors! + +_maps/RandomZLevels/VR/murderdome.dmm +_maps/RandomZLevels/VR/snowdin_VR.dm +_maps/RandomZLevels/VR/syndicate_trainer.dm \ No newline at end of file