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/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm
index 207c2fd8eb..3c6660b3ab 100644
--- a/code/controllers/configuration/entries/game_options.dm
+++ b/code/controllers/configuration/entries/game_options.dm
@@ -298,6 +298,8 @@
/datum/config_entry/flag/roundstart_away //Will random away mission be loaded.
+/datum/config_entry/flag/roundstart_vr //Will virtual reality missions be loaded?
+
/datum/config_entry/number/gateway_delay //How long the gateway takes before it activates. Default is half an hour. Only matters if roundstart_away is enabled.
config_entry_value = 18000
min_val = 0
diff --git a/code/controllers/subsystem/mapping.dm b/code/controllers/subsystem/mapping.dm
index f13d5a2779..89155cefb3 100644
--- a/code/controllers/subsystem/mapping.dm
+++ b/code/controllers/subsystem/mapping.dm
@@ -1,3 +1,5 @@
+#define INIT_ANNOUNCE(X) to_chat(world, "[X]"); log_world(X)
+
SUBSYSTEM_DEF(mapping)
name = "Mapping"
init_order = INIT_ORDER_MAPPING
@@ -81,7 +83,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
@@ -181,7 +185,6 @@ SUBSYSTEM_DEF(mapping)
z_list = SSmapping.z_list
-#define INIT_ANNOUNCE(X) to_chat(world, "[X]"); log_world(X)
/datum/controller/subsystem/mapping/proc/LoadGroup(list/errorList, name, path, files, list/traits, list/default_traits, silent = FALSE)
. = list()
var/start_time = REALTIMEOFDAY
@@ -265,7 +268,6 @@ SUBSYSTEM_DEF(mapping)
msg += ", [FailedZs[I]]"
msg += ". Yell at your server host!"
INIT_ANNOUNCE(msg)
-#undef INIT_ANNOUNCE
GLOBAL_LIST_EMPTY(the_station_areas)
@@ -410,52 +412,63 @@ 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(ztraits)
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)
+ level = template.load_new_z(ztraits)
- 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..6c8d8287d8 100644
--- a/code/modules/awaymissions/zlevel.dm
+++ b/code/modules/awaymissions/zlevel.dm
@@ -1,15 +1,19 @@
-// 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 = GLOB.potential_away_levels)
+ if(GLOB.random_zlevels_generated[name])
+ stack_trace("[name] level already generated.")
+ return
+ if(!length(potential_levels))
+ stack_trace("No potential [name] level to load has been found.")
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.")
+ var/start_time = REALTIMEOFDAY
+ var/map = pick(potential_levels)
+ if(!load_new_z_level(map, name, traits))
+ INIT_ANNOUNCE("Failed to load [name]! map filepath: [map]!")
+ return
+ INIT_ANNOUNCE("Loaded [name] in [(REALTIMEOFDAY - start_time)/10]s!")
+ GLOB.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..873c10fc02 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()
+ return template.load_new_z(traits)
diff --git a/config/awaymissionconfig.txt b/config/awaymissionconfig.txt
index 545394f3e9..c6a5d9ef8f 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/game_options.txt b/config/game_options.txt
index e1294f688a..781be6d5b1 100644
--- a/config/game_options.txt
+++ b/config/game_options.txt
@@ -288,6 +288,9 @@ MINIMUM_SECBORG_ALERT 3
## Uncomment to load one of the missions from awaymissionconfig.txt at roundstart.
#ROUNDSTART_AWAY
+## Uncomment to load one of the virtual reality levels from vr_config at roundstart.
+#ROUNDSTART_VR
+
## How long the delay is before the Away Mission gate opens. Default is half an hour.
## 600 is one minute.
GATEWAY_DELAY 18000
diff --git a/config/vr_config.txt b/config/vr_config.txt
new file mode 100644
index 0000000000..0c6354f8fe
--- /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.dmm
+#_maps/RandomZLevels/VR/syndicate_trainer.dmm
\ No newline at end of file