Skip to content

Commit

Permalink
Added the z-level manager system from TG (Aurorastation#19532)
Browse files Browse the repository at this point in the history
Added the z-level manager system from TG, mostly
  • Loading branch information
FluffyGhoster authored Jul 22, 2024
1 parent 0a91768 commit 1345bea
Show file tree
Hide file tree
Showing 90 changed files with 614 additions and 245 deletions.
47 changes: 28 additions & 19 deletions aurorastation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "code\__DEFINES\construction.dm"
#include "code\__DEFINES\cooldowns.dm"
#include "code\__DEFINES\damage_organs.dm"
#include "code\__DEFINES\directional.dm"
#include "code\__DEFINES\dna.dm"
#include "code\__DEFINES\documents.dm"
#include "code\__DEFINES\drinks.dm"
Expand Down Expand Up @@ -79,6 +80,8 @@
#include "code\__DEFINES\lighting.dm"
#include "code\__DEFINES\logging.dm"
#include "code\__DEFINES\machinery.dm"
#include "code\__DEFINES\mapping.dm"
#include "code\__DEFINES\maps.dm"
#include "code\__DEFINES\materials.dm"
#include "code\__DEFINES\math_physics.dm"
#include "code\__DEFINES\maths.dm"
Expand All @@ -91,6 +94,7 @@
#include "code\__DEFINES\modular_guns.dm"
#include "code\__DEFINES\move_force.dm"
#include "code\__DEFINES\movement.dm"
#include "code\__DEFINES\multiz.dm"
#include "code\__DEFINES\obj.dm"
#include "code\__DEFINES\organs.dm"
#include "code\__DEFINES\origin_traits.dm"
Expand Down Expand Up @@ -2395,25 +2399,30 @@
#include "code\modules\lock\lock.dm"
#include "code\modules\lock\lock_construct.dm"
#include "code\modules\makeshift\makeshift_reagents.dm"
#include "code\modules\maps\dmm_suite.dm"
#include "code\modules\maps\helper_landmarks.dm"
#include "code\modules\maps\map_template.dm"
#include "code\modules\maps\reader.dm"
#include "code\modules\maps\ruins.dm"
#include "code\modules\maps\swapmaps.dm"
#include "code\modules\maps\planet_types\asteroid.dm"
#include "code\modules\maps\planet_types\barren.dm"
#include "code\modules\maps\planet_types\crystal.dm"
#include "code\modules\maps\planet_types\desert.dm"
#include "code\modules\maps\planet_types\grass.dm"
#include "code\modules\maps\planet_types\jungle.dm"
#include "code\modules\maps\planet_types\lava.dm"
#include "code\modules\maps\planet_types\snow.dm"
#include "code\modules\maps\planet_types\lore\burzsia.dm"
#include "code\modules\maps\planet_types\lore\konyang.dm"
#include "code\modules\maps\planet_types\lore\srandmarr.dm"
#include "code\modules\maps\planet_types\lore\tauceti.dm"
#include "code\modules\maps\planet_types\lore\uueoaesa.dm"
#include "code\modules\mapping\dmm_suite.dm"
#include "code\modules\mapping\helper_landmarks.dm"
#include "code\modules\mapping\map_template.dm"
#include "code\modules\mapping\reader.dm"
#include "code\modules\mapping\ruins.dm"
#include "code\modules\mapping\swapmaps.dm"
#include "code\modules\mapping\planet_types\asteroid.dm"
#include "code\modules\mapping\planet_types\barren.dm"
#include "code\modules\mapping\planet_types\crystal.dm"
#include "code\modules\mapping\planet_types\desert.dm"
#include "code\modules\mapping\planet_types\grass.dm"
#include "code\modules\mapping\planet_types\jungle.dm"
#include "code\modules\mapping\planet_types\lava.dm"
#include "code\modules\mapping\planet_types\snow.dm"
#include "code\modules\mapping\planet_types\lore\burzsia.dm"
#include "code\modules\mapping\planet_types\lore\konyang.dm"
#include "code\modules\mapping\planet_types\lore\srandmarr.dm"
#include "code\modules\mapping\planet_types\lore\tauceti.dm"
#include "code\modules\mapping\planet_types\lore\uueoaesa.dm"
#include "code\modules\mapping\space_management\space_level.dm"
#include "code\modules\mapping\space_management\space_reservation.dm"
#include "code\modules\mapping\space_management\space_transition.dm"
#include "code\modules\mapping\space_management\traits.dm"
#include "code\modules\mapping\space_management\zlevel_manager.dm"
#include "code\modules\martial_arts\gunkata.dm"
#include "code\modules\martial_arts\martial.dm"
#include "code\modules\martial_arts\plasma_fist.dm"
Expand Down
13 changes: 13 additions & 0 deletions code/__DEFINES/_flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,16 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
#define PASSDOORHATCH (1<<15)
#define PASSTRACE (1<<16) //Used by turrets in the check_trajectory proc to target mobs hiding behind certain things (such as closets)
#define PASSRAILING (1<<17)

//TURF FLAGS
/// If a turf is an usused reservation turf awaiting assignment
#define UNUSED_RESERVATION_TURF BITFLAG(1)
/// If a turf is a reserved turf
#define RESERVATION_TURF BITFLAG(2)

// Turf-only flags.
///Blocks the jaunting spell from accessing the turf
#define TURF_FLAG_NOJAUNT BITFLAG(3)

///Used by shuttle movement to determine if it should be ignored by turf translation
#define TURF_FLAG_BACKGROUND BITFLAG(4)
14 changes: 14 additions & 0 deletions code/__DEFINES/directional.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Byond direction defines, because I want to put them somewhere.
// #define NORTH 1
// #define SOUTH 2
// #define EAST 4
// #define WEST 8

/// North direction as a string "[1]"
#define TEXT_NORTH "[NORTH]"
/// South direction as a string "[2]"
#define TEXT_SOUTH "[SOUTH]"
/// East direction as a string "[4]"
#define TEXT_EAST "[EAST]"
/// West direction as a string "[8]"
#define TEXT_WEST "[WEST]"
6 changes: 6 additions & 0 deletions code/__DEFINES/mapping.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Defines for SSmapping's multiz_levels
/// TRUE if we're ok with going up
#define Z_LEVEL_UP 1
/// TRUE if we're ok with going down
#define Z_LEVEL_DOWN 2
#define LARGEST_Z_LEVEL_INDEX Z_LEVEL_DOWN
44 changes: 44 additions & 0 deletions code/__DEFINES/maps.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// traits
// boolean - marks a level as having that property if present
#define ZTRAIT_CENTCOM "CentCom"
#define ZTRAIT_STATION "Station"
#define ZTRAIT_RESERVED "Transit/Reserved"
#define ZTRAIT_AWAY "Away Mission"
/* Aurora Snowflake */
#define ZTRAIT_OVERMAP "Overmap"
#define ZTRAIT_EXPLANET "Exoplanet"


// Whether this z level is linked up/down. Bool.
#define ZTRAIT_UP "Up"
#define ZTRAIT_DOWN "Down"

// enum - how space transitions should affect this level
#define ZTRAIT_LINKAGE "Linkage"
// UNAFFECTED if absent - no space transitions
#define UNAFFECTED null
// SELFLOOPING - space transitions always self-loop
#define SELFLOOPING "Self"
// CROSSLINKED - mixed in with the cross-linked space pool
#define CROSSLINKED "Cross"

// default trait definitions, used by SSmapping
///Z level traits for CentCom
#define ZTRAITS_CENTCOM list(ZTRAIT_CENTCOM = TRUE, ZTRAIT_NOPHASE = TRUE)
///Z level traits for Space Station 13
#define ZTRAITS_STATION list(ZTRAIT_LINKAGE = CROSSLINKED, ZTRAIT_STATION = TRUE)
///Z level traits for Away Missions
#define ZTRAITS_AWAY list(ZTRAIT_AWAY = TRUE)
///Z level traits for Overmap
#define ZTRAITS_OVERMAP list(ZTRAIT_OVERMAP = TRUE, ZTRAIT_LINKAGE = SELFLOOPING)
///Z level traits for Exoplanets
#define ZTRAITS_EXPLANET list(ZTRAIT_EXPLANET = TRUE, ZTRAIT_LINKAGE = SELFLOOPING)

#define DL_NAME "name"
#define DL_TRAITS "traits"
#define DECLARE_LEVEL(NAME, TRAITS) list(DL_NAME = NAME, DL_TRAITS = TRAITS)

// must correspond to _basemap.dm for things to work correctly
#define DEFAULT_MAP_TRAITS list(\
DECLARE_LEVEL("CentCom", ZTRAITS_CENTCOM),\
)
8 changes: 8 additions & 0 deletions code/__DEFINES/multiz.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// Attempt to get the turf below the provided one according to Z traits
#define GET_TURF_BELOW(turf) ( \
(turf.turf_flags & RESERVATION_TURF) ? SSmapping.get_reservation_from_turf(turf)?.get_turf_below(turf) : \
(!(turf) || !length(SSmapping.multiz_levels) || !SSmapping.multiz_levels[(turf).z][Z_LEVEL_DOWN]) ? null : get_step((turf), DOWN))
/// Attempt to get the turf above the provided one according to Z traits
#define GET_TURF_ABOVE(turf) ( \
(turf.turf_flags & RESERVATION_TURF) ? SSmapping.get_reservation_from_turf(turf)?.get_turf_above(turf) : \
(!(turf) || !length(SSmapping.multiz_levels) || !SSmapping.multiz_levels[(turf).z][Z_LEVEL_UP]) ? null : get_step((turf), UP))
26 changes: 0 additions & 26 deletions code/__DEFINES/turfs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -106,32 +106,6 @@
AURORA SHIT
################################*/

// Turf-only flags.
///Blocks the jaunting spell from accessing the turf
#define TURF_FLAG_NOJAUNT BITFLAG(1)

///Used by shuttle movement to determine if it should be ignored by turf translation
#define TURF_FLAG_BACKGROUND BITFLAG(2)


/**
* Get the turf above the current atom, if any
*
* Returns a `/turf` if there's a turf on the Z-level above, `null` otherwise
*
* * atom - The `/atom` you want to know the above turf of
*/
#define GET_ABOVE(atom) (HasAbove(atom.z) ? get_step(atom, UP) : null)

/**
* Get the turf below the current atom, if any
*
* Returns a `/turf` if there's a turf on the Z-level below, `null` otherwise
*
* * atom - The `/atom` you want to know the below turf of
*/
#define GET_BELOW(atom) (HasBelow(atom.z) ? get_step(atom, DOWN) : null)

#define NORTH_OF_TURF(T) locate(T.x, T.y + 1, T.z)
#define EAST_OF_TURF(T) locate(T.x + 1, T.y, T.z)
#define SOUTH_OF_TURF(T) locate(T.x, T.y - 1, T.z)
Expand Down
5 changes: 3 additions & 2 deletions code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
for(var/turf/T in view(usr.client.view + 3, usr)) // slightly extra to account for moving while looking for openness
if(T.density)
continue
var/turf/above_turf = GetAbove(T)
var/turf/above_turf = GET_TURF_ABOVE(T)
if(!isopenspace(above_turf))
continue
var/image/up_image = image(icon = 'icons/mob/screen/generic.dmi', icon_state = "arrow_up", loc = T)
Expand All @@ -356,7 +356,8 @@
usr << up_image
QDEL_IN(up_image, 12)
return
var/turf/T = GetAbove(usr)
var/turf/T1 = get_turf(usr)
var/turf/T = GET_TURF_ABOVE(T1)
if (!T)
to_chat(usr, SPAN_NOTICE("There is nothing above you!"))
else if (T.is_hole)
Expand Down
16 changes: 8 additions & 8 deletions code/controllers/subsystems/explosives.dm
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ SUBSYSTEM_DEF(explosives)

// Handles recursive propagation of explosions.
if(devastation_range > 2 || heavy_impact_range > 2)
if(HasAbove(epicenter.z) && z_transfer & UP)
global.explosion(GetAbove(epicenter), max(0, devastation_range - 2), max(0, heavy_impact_range - 2), max(0, light_impact_range - 2), max(0, flash_range - 2), 0, UP, spreading = FALSE)
if(HasBelow(epicenter.z) && z_transfer & DOWN)
global.explosion(GetBelow(epicenter), max(0, devastation_range - 2), max(0, heavy_impact_range - 2), max(0, light_impact_range - 2), max(0, flash_range - 2), 0, DOWN, spreading = FALSE)
if(GET_TURF_ABOVE(epicenter) && z_transfer & UP)
global.explosion(GET_TURF_ABOVE(epicenter), max(0, devastation_range - 2), max(0, heavy_impact_range - 2), max(0, light_impact_range - 2), max(0, flash_range - 2), 0, UP, spreading = FALSE)
if(GET_TURF_BELOW(epicenter) && z_transfer & DOWN)
global.explosion(GET_TURF_BELOW(epicenter), max(0, devastation_range - 2), max(0, heavy_impact_range - 2), max(0, light_impact_range - 2), max(0, flash_range - 2), 0, DOWN, spreading = FALSE)

var/max_range = max(devastation_range, heavy_impact_range, light_impact_range, flash_range)

Expand Down Expand Up @@ -258,17 +258,17 @@ SUBSYSTEM_DEF(explosives)
power -= O.explosion_resistance

if (power >= GLOB.config.iterative_explosives_z_threshold)
if ((z_transfer & UP) && HasAbove(epicenter.z))
if ((z_transfer & UP) && GET_TURF_ABOVE(epicenter))
var/datum/explosiondata/data = new
data.epicenter = GetAbove(epicenter)
data.epicenter = GET_TURF_ABOVE(epicenter)
data.rec_pow = (power * GLOB.config.iterative_explosives_z_multiplier) - GLOB.config.iterative_explosives_z_subtraction
data.z_transfer = UP
data.spreading = TRUE
queue(data)

if ((z_transfer & DOWN) && HasBelow(epicenter.z))
if ((z_transfer & DOWN) && GET_TURF_BELOW(epicenter))
var/datum/explosiondata/data = new
data.epicenter = GetBelow(epicenter)
data.epicenter = GET_TURF_BELOW(epicenter)
data.rec_pow = (power * GLOB.config.iterative_explosives_z_multiplier) - GLOB.config.iterative_explosives_z_subtraction
data.z_transfer = DOWN
data.spreading = TRUE
Expand Down
3 changes: 2 additions & 1 deletion code/controllers/subsystems/falling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ SUBSYSTEM_DEF(falling)
REMOVE_AND_CONTINUE

// Get the below turf.
var/turf/below = GetBelow(victim)
var/turf/T = get_turf(victim)
var/turf/below = GET_TURF_BELOW(T)
if (!below)
REMOVE_AND_CONTINUE

Expand Down
43 changes: 35 additions & 8 deletions code/controllers/subsystems/initialization/atlas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ SUBSYSTEM_DEF(atlas)
)

/datum/controller/subsystem/atlas/stat_entry(msg)
msg = "W:{X:[world.maxx] Y:[world.maxy] Z:[world.maxz]} ZL:[GLOB.z_levels]"
msg = "W:{X:[world.maxx] Y:[world.maxy] Z:[world.maxz]} ZL:[length(SSmapping.z_list)]"
return ..()

/datum/controller/subsystem/atlas/Initialize(timeofday)
Expand Down Expand Up @@ -223,30 +223,57 @@ SUBSYSTEM_DEF(atlas)
var/static/regex/mapregex = new(".+\\.dmm$")
var/list/files = flist(directory)
sortTim(files, GLOBAL_PROC_REF(cmp_text_asc))
var/list/filemaps_to_load
for(var/file in files)
if(mapregex.Find(file))
filemaps_to_load += list(file)

var/mfile
var/first_dmm = TRUE
var/time
for (var/i in 1 to files.len)
mfile = files[i]
if (!mapregex.Find(mfile))
continue

var/is_first = TRUE
for(var/i in 1 to length(filemaps_to_load))
mfile = filemaps_to_load[i]

log_subsystem_atlas("Loading '[mfile]'.")
time = world.time

mfile = "[directory][mfile]"

var/target_z = 0
if (overwrite_default_z && first_dmm)
target_z = 1
first_dmm = FALSE
log_subsystem_atlas("Overwriting first Z.")

if (!maploader.load_map(file(mfile), 0, 0, target_z, no_changeturf = TRUE))
var/list/trait = ZTRAITS_STATION

//We're NOT loading the first level
if(!is_first)
//Last level is centcomm, noone goes in or out
if(i == length(filemaps_to_load))
trait += list(ZTRAIT_UP = FALSE, ZTRAIT_DOWN = FALSE)
//Last level in the actual stack, can only go down
else if(i == (length(filemaps_to_load) - 1))
trait += list(ZTRAIT_UP = FALSE, ZTRAIT_DOWN = TRUE)
//Bidirectional movement
else
trait += list(ZTRAIT_UP = TRUE, ZTRAIT_DOWN = TRUE)

//We're loading the first level, usually it has something above it
else if(length(filemaps_to_load) >= 2)
trait += list(ZTRAIT_UP = TRUE, ZTRAIT_DOWN = FALSE)
else //Special case for single-level maps
trait += list(ZTRAIT_UP = FALSE, ZTRAIT_DOWN = FALSE)

var/datum/space_level/level = SSmapping.add_new_zlevel(name, trait, contain_turfs = FALSE)

if (!maploader.load_map(file(mfile), 0, 0, level.z_value, no_changeturf = TRUE))
log_subsystem_atlas("Failed to load '[mfile]'!")
else
log_subsystem_atlas("Loaded level in [(world.time - time)/10] seconds.")

is_first = FALSE

.++
CHECK_TICK

Expand Down
Loading

0 comments on commit 1345bea

Please sign in to comment.