Fixes and improvements

-Templates now include a var for max dimensions, load/unload adjusts to match the template size instead of always using the max size limit
-4 shuttle landmarks per z-level, landmarks move based on the size of the submap to never be terribly far away
-Users can now choose which map to delete when maps are full
-Overmap POI objects will now move once if spawning on top of another POI object
-ChangeArea and shuttle landmark runtimes fixed
-2 map errors fixed
This commit is contained in:
Darlantan
2023-02-10 03:46:14 -05:00
parent 09e2711497
commit 12ced43427
4 changed files with 3967 additions and 204 deletions

View File

@@ -4,7 +4,9 @@
GLOBAL_VAR_INIT(dynamic_sector_master, null)
// Also adjust find_z_levels() if you adjust increase dynamic levels, that part is hard-coded so you don't gloss over world.increment_max_z().
#define MAX_DYNAMIC_LEVELS 3
#define MAX_DYNAMIC_POI_DIMENSIONS 94 // Keep this an even number if using even world.maxx/maxy
#define MAX_DYNAMIC_POI_DIMENSIONS 200 // Keep this an even number if using even world.maxx/maxy. This value MUST
// a large enough static border to fit OM ships. A 30x30 ship means max dimensions must be 60 less than the z-level max
// to keep a 30 turf border on each side of the load/unload area.
// The "master" object, which creates + stores + registers the actual z-levels used for dynamic POI's. Handles overmap
// sanity checks, + procs, should not be directly accessible by players. Do not use in maps. Only 1 should exist currently.
@@ -16,6 +18,7 @@ GLOBAL_VAR_INIT(dynamic_sector_master, null)
in_space = TRUE
scanner_desc = "You should not see this."
var/generated_z = FALSE
var/base_area = /area/space
// Initialized to match max dynamic levels.
map_z = list(null,null,null)
@@ -36,26 +39,31 @@ GLOBAL_VAR_INIT(dynamic_sector_master, null)
for(var/i = 1; i <= 3; i++) // Hard-coding limit because this is dangerous.
world.increment_max_z()
map_z[i] = world.maxz
// Find the center turf, spawn a shuttle landmark -10 tiles outside of the spawn/despawn boundaries.
// Shuttles are typically longer in x coordinates than y, so it's safer to set the landmark by x coordinates.
var/turf/T = locate(round(world.maxx/2 - MAX_DYNAMIC_POI_DIMENSIONS - 10), round(world.maxy/2), map_z[i])
// Spawn shuttle_landmarks near the lower x border, aligned with the POI spawning turf. These move during POI generation.
var/turf/T = locate(10, round(world.maxy/2), map_z[i])
if(istype(T))
var/obj/effect/shuttle_landmark/S = new(T)
S.name = "Subspace sector [i]"
S.landmark_tag = "dynamic_sector_[i]"
shuttle_landmarks[i] = S
var/list/spawn_directions = list() // Stores a landmark for each direction.
for(var/direction in list("FORE", "PORT", "AFT", "STARBOARD"))
var/obj/effect/shuttle_landmark/om_poi/S = new(T, "Subspace sector [i] - [direction]", "dynamic_sector_[i] - [direction]")
spawn_directions[direction] = S
shuttle_landmarks[i] = spawn_directions
generated_z = TRUE
/obj/effect/overmap/visitable/dynamic/Initialize()
if(!GLOB.dynamic_sector_master)
GLOB.dynamic_sector_master = src
. = ..()
if(ispath(base_area))
var/area/spehss = locate(base_area)
if(!istype(spehss))
CRASH("Dynamic POI generation couldn't locate area [base_area].")
base_area = spehss
create_children()
// Create POI objects for each overmap POI template, link to parent. Initialize() of children handles turf assignment
/obj/effect/overmap/visitable/dynamic/proc/create_children()
for(var/datum/map_template/dynamic_overmap/poi as anything in subtypesof(/datum/map_template/dynamic_overmap))
if(!initial(poi.mappath) || !initial(poi.name)) // Exclude templates without an actual map (or are not included in the mapping subsystem map_templates)
if(!initial(poi.mappath) || !initial(poi.name) || (initial(poi.block_size) > MAX_DYNAMIC_POI_DIMENSIONS)) // Exclude templates without an actual map or are too big (or are not included in the mapping subsystem map_templates)
continue
var/obj/effect/overmap/visitable/dynamic/poi/P = new()
P.my_template = SSmapping.map_templates[initial(poi.name)] // Link to the stored map datums.
@@ -69,6 +77,17 @@ GLOBAL_VAR_INIT(dynamic_sector_master, null)
var/random_index = rand(1,MAX_DYNAMIC_LEVELS)
var/obj/effect/overmap/visitable/dynamic/poi/P
// User selection. Remains random if user cancels.
if(user)
P = tgui_input_list(user, "Would you like to choose which link to sever?", "Sever link", active_pois)
if(P && istype(P) && src.is_empty(P.my_index))
random_index = P.my_index
P.destroy_poi(user)
active_pois[random_index] = null
return random_index
else
return 0
if(is_empty(random_index)) // If this z-level is empty, destroy the poi
P = active_pois[random_index]
P.destroy_poi(user)
@@ -132,6 +151,14 @@ GLOBAL_VAR_INIT(dynamic_sector_master, null)
forceMove(locate(start_x, start_y, global.using_map.overmap_z))
for(var/obj/effect/overmap/visitable/dynamic/poi/P in loc.contents) // If we've spawned on another poi, we'll try again once.
if(P == src)
continue
start_x = start_x || rand(OVERMAP_EDGE, global.using_map.overmap_size - OVERMAP_EDGE)
start_y = start_y || rand(OVERMAP_EDGE, global.using_map.overmap_size - OVERMAP_EDGE)
forceMove(locate(start_x, start_y, global.using_map.overmap_z))
break
if(!docking_codes)
docking_codes = "[ascii2text(rand(65,90))][ascii2text(rand(65,90))][ascii2text(rand(65,90))][ascii2text(rand(65,90))]"
@@ -193,7 +220,7 @@ GLOBAL_VAR_INIT(dynamic_sector_master, null)
my_index = i
parent.active_pois[i] = src
map_z[1] = parent.map_z[i]
map_sectors["[parent.map_z[i]]"] = src // Pass ownership of z-level to child, probably hacky and terribad
map_sectors["[parent.map_z[i]]"] = src // Pass ownership of z-level to child, probably hacky and terribad, also mandatory for using forceMove() on shuttle landmarks
break // Terminate loop
if(!my_index) // No z-levels available
var/confirm = alert(user, "\[REDACTED\] matrix at capacity; a bluespace link must be permanently severed to stabilize this anomaly. Continue?", "Are you sure?", "No", "Yes")
@@ -213,10 +240,25 @@ GLOBAL_VAR_INIT(dynamic_sector_master, null)
if(!istype(T))
log_debug("Dynamic overmap POI found [T] instead of a valid turf.")
return
// Move the shuttle landmarks.
var/list/landmark_directions = parent.shuttle_landmarks[my_index] // Each shuttle_landmarks entry is an associative list.
var/obj/effect/shuttle_landmark/om_poi/S = landmark_directions["FORE"]
S.forceMove(locate(T.x, min(world.maxy, T.y + round(src.my_template.block_size/2) + rand(10,20)), T.z)) // Above
add_landmark(S) // This lets overmap shuttles find our newly assigned z-level.
S = landmark_directions["AFT"]
S.forceMove(locate(T.x, max(1, T.y - round(src.my_template.block_size/2) - rand(10,20)), T.z))// Below
add_landmark(S)
S = landmark_directions["PORT"]
S.forceMove(locate(max(1, T.x - round(src.my_template.block_size/2) - rand(10,20)), T.y, T.z)) // Left
add_landmark(S)
S = landmark_directions["STARBOARD"]
S.forceMove(locate(min(world.maxx, T.x + round(src.my_template.block_size/2) + rand(10,20)), T.y, T.z)) // Right
add_landmark(S)
my_template.load(T, centered=TRUE)
loaded = TRUE
my_template.update_lighting(T)
add_landmark(parent.shuttle_landmarks[my_index]) // This lets overmap shuttles find our newly assigned z-level.
to_chat(user, "Stabilization tether successfully created.")
if(my_template.active_icon)
icon_state = my_template.active_icon
@@ -246,18 +288,24 @@ GLOBAL_VAR_INIT(dynamic_sector_master, null)
to_chat(user, "Destabilization initiated...")
log_debug("Dynamic overmap POI unloading initiated...")
// Some math to return a block of MAX_DYNAMIC_POI_DIMENSIONS turfs. Basically, start from center turf and subtract half of max dimensons for bottom left corner, add for top right corner.
var/list/turfs_to_reset = block(locate(round(world.maxx/2 - MAX_DYNAMIC_POI_DIMENSIONS/2), round(world.maxy/2 - MAX_DYNAMIC_POI_DIMENSIONS/2), map_z[1]), locate(round(world.maxx/2 + MAX_DYNAMIC_POI_DIMENSIONS/2), round(world.maxy/2 + MAX_DYNAMIC_POI_DIMENSIONS/2), map_z[1]))
// Some math to return a block of block_size turfs (+ 1 to each dimension to account for even-size maps lacking a true center to safely do math with). Basically, start from center turf and subtract half of block_size for bottom left corner, add for top right corner.
var/list/turfs_to_reset = block(locate(round(world.maxx/2 - my_template.block_size/2 - 1), round(world.maxy/2 - my_template.block_size/2 - 1), map_z[1]), locate(round(world.maxx/2 + my_template.block_size/2 + 1), round(world.maxy/2 + my_template.block_size/2 + 1), map_z[1]))
var/deleted_atoms = 0
if(turfs_to_reset.len)
var/area/A = parent.base_area
if(ispath(A))
A = locate(A)
if(!istype(A))
CRASH("Dynamic POI unloading couldn't locate area [A], unload aborted.")
for(var/turf/T in turfs_to_reset)
for(var/atom/movable/AM in T)
if(istype(AM, /mob/observer))
continue
++deleted_atoms
qdel(AM)
ChangeArea(T, A)
T = T.ChangeTurf(/turf/space)
ChangeArea(T, /area/space)
loaded = FALSE
map_z = null
icon_state = "ring_destroyed"
@@ -295,5 +343,15 @@ GLOBAL_VAR_INIT(dynamic_sector_master, null)
/obj/effect/overmap/visitable/dynamic/poi/cull_child()
return
/obj/effect/shuttle_landmark/om_poi // Landmarks used in dynamic poi generation
flags = SLANDMARK_FLAG_AUTOSET
base_area = /area/space
base_turf = /turf/space
/obj/effect/shuttle_landmark/om_poi/Initialize(mapload, var/new_name, var/new_tag)
name = new_name
landmark_tag = new_tag
. = ..()
#undef MAX_DYNAMIC_LEVELS
#undef MAX_DYNAMIC_POI_DIMENSIONS

View File

@@ -50,6 +50,7 @@
var/poi_icon = "ring"
var/active_icon = "ring_active" // Icon to use when the POI is loaded. Set to null to disable behavior.
var/poi_color = null
var/block_size = 60 // The size of the map's largest dimension. If the map is 66x49, this var should be 66. Essential for laoding/unloading system.
// Stolen from map_template/shelter
/datum/map_template/dynamic_overmap/proc/update_lighting(turf/deploy_location)
@@ -60,153 +61,189 @@
/datum/map_template/dynamic_overmap/abandonedtele_13x12
name = "abandoned tele"
mappath = "modular_chomp/maps/overmap/space_pois/abandonedtele_13x12.dmm"
block_size = 13
/datum/map_template/dynamic_overmap/abandonedzoo_20x20
name = "abandoned zoo"
mappath = "modular_chomp/maps/overmap/space_pois/abandonedzoo_20x20.dmm"
block_size = 20
/datum/map_template/dynamic_overmap/asteroid1_20x20
name = "asteroid"
mappath = "modular_chomp/maps/overmap/space_pois/asteroid1_20x20.dmm"
poi_icon = "asteroid1"
active_icon = "asteroid1_g"
block_size = 20
/datum/map_template/dynamic_overmap/asteroid2_20x20
name = "asteroider"
mappath = "modular_chomp/maps/overmap/space_pois/asteroid2_20x20.dmm"
poi_icon = "asteroid2"
active_icon = "asteroid2_g"
block_size = 20
/datum/map_template/dynamic_overmap/asteroid3_20x20
name = "asteroidest"
mappath = "modular_chomp/maps/overmap/space_pois/asteroid3_20x20.dmm"
poi_icon = "asteroid3"
active_icon = "asteroid3_g"
block_size = 20
/datum/map_template/dynamic_overmap/asteroid4_20x20
name = "asteroidester"
mappath = "modular_chomp/maps/overmap/space_pois/asteroid4_20x20.dmm"
poi_icon = "asteroid2"
active_icon = "asteroid2_g"
block_size = 20
/datum/map_template/dynamic_overmap/asteroid5_40x40
name = "asteroidestest"
mappath = "modular_chomp/maps/overmap/space_pois/asteroid5_40x40.dmm"
poi_icon = "asteroid0"
active_icon = "asteroid0_g"
block_size = 40
/datum/map_template/dynamic_overmap/blowntcommsat_53x56
name = "commsat"
mappath = "modular_chomp/maps/overmap/space_pois/blowntcommsat_53x56.dmm"
block_size = 56
/datum/map_template/dynamic_overmap/clownmime_28x20
name = "honk"
mappath = "modular_chomp/maps/overmap/space_pois/clownmime_28x20.dmm"
block_size = 28
/datum/map_template/dynamic_overmap/debris1_20x20
name = "debris"
mappath = "modular_chomp/maps/overmap/space_pois/debris1_20x20.dmm"
block_size = 20
/datum/map_template/dynamic_overmap/debris2_20x20
name = "debriss"
mappath = "modular_chomp/maps/overmap/space_pois/debris2_20x20.dmm"
block_size = 20
/datum/map_template/dynamic_overmap/debris3_30x20
name = "debrisss"
mappath = "modular_chomp/maps/overmap/space_pois/debris3_30x20.dmm"
block_size = 30
/datum/map_template/dynamic_overmap/deepstorage_85x67
name = "storage facility"
mappath = "modular_chomp/maps/overmap/space_pois/deepstorage_85x67.dmm"
block_size = 85
/datum/map_template/dynamic_overmap/derelict1_40x40
name = "ruins"
mappath = "modular_chomp/maps/overmap/space_pois/derelict1_40x40.dmm"
block_size = 40
/datum/map_template/dynamic_overmap/derelict2_20x20
name = "ruins again"
mappath = "modular_chomp/maps/overmap/space_pois/derelict2_20x20.dmm"
block_size = 20
/datum/map_template/dynamic_overmap/derelict3_40x40
name = "ruins three"
mappath = "modular_chomp/maps/overmap/space_pois/derelict3_40x40.dmm"
block_size = 40
/datum/map_template/dynamic_overmap/derelict4_40x40
name = "ruins maybe"
mappath = "modular_chomp/maps/overmap/space_pois/derelict4_40x40.dmm"
block_size = 40
/datum/map_template/dynamic_overmap/derelict5_40x40
name = "ruins?"
mappath = "modular_chomp/maps/overmap/space_pois/derelict5_40x40.dmm"
block_size = 40
/datum/map_template/dynamic_overmap/dj_31x28
name = "DJ Grooves"
mappath = "modular_chomp/maps/overmap/space_pois/dj_31x28.dmm"
block_size = 31
/datum/map_template/dynamic_overmap/druglab_16x14
name = "lab"
mappath = "modular_chomp/maps/overmap/space_pois/druglab_16x14.dmm"
block_size = 16
/datum/map_template/dynamic_overmap/emptyshell_17x15
name = "ruins..."
mappath = "modular_chomp/maps/overmap/space_pois/emptyshell_17x15.dmm"
block_size = 17
/datum/map_template/dynamic_overmap/gasthelizards_19x14
name = "unknown"
mappath = "modular_chomp/maps/overmap/space_pois/gasthelizards_19x14.dmm"
block_size = 19
/datum/map_template/dynamic_overmap/golemtarget_30x30
name = "unknown too"
mappath = "modular_chomp/maps/overmap/space_pois/golemtarget_30x30.dmm"
block_size = 30
/datum/map_template/dynamic_overmap/intactemptyship_13x11
name = "ship"
mappath = "modular_chomp/maps/overmap/space_pois/intactemptyship_13x11.dmm"
block_size = 13
/datum/map_template/dynamic_overmap/mechtransport_9x15
name = "transport"
mappath = "modular_chomp/maps/overmap/space_pois/mechtransport_9x15.dmm"
block_size = 15
/datum/map_template/dynamic_overmap/oldstation_80x45
name = "station"
mappath = "modular_chomp/maps/overmap/space_pois/oldstation_80x45.dmm"
block_size = 80
/datum/map_template/dynamic_overmap/onehalf_32x20
name = "lorem ipsum"
mappath = "modular_chomp/maps/overmap/space_pois/onehalf_32x20.dmm"
block_size = 32
/datum/map_template/dynamic_overmap/spacebar_40x40
name = "alcohol"
mappath = "modular_chomp/maps/overmap/space_pois/spacebar_40x40.dmm"
block_size = 40
/datum/map_template/dynamic_overmap/syndiecakesfactory_40x40
name = "land o' cakes"
mappath = "modular_chomp/maps/overmap/space_pois/syndiecakesfactory_40x40.dmm"
block_size = 40
/datum/map_template/dynamic_overmap/syndiedepot_57x49
name = "depot"
mappath = "modular_chomp/maps/overmap/space_pois/syndiedepot_57x49.dmm"
block_size = 57
/datum/map_template/dynamic_overmap/turretedoutpost_23x19
name = "gunpowder"
mappath = "modular_chomp/maps/overmap/space_pois/turretedoutpost_23x19.dmm"
block_size = 23
/datum/map_template/dynamic_overmap/ussp_84x90
name = "facility"
mappath = "modular_chomp/maps/overmap/space_pois/ussp_84x90.dmm"
block_size = 90
/datum/map_template/dynamic_overmap/ussptele_21x12
name = "facility but small"
mappath = "modular_chomp/maps/overmap/space_pois/ussptele_21x12.dmm"
block_size = 21
/datum/map_template/dynamic_overmap/wayhome_30x30
name = "something"
mappath = "modular_chomp/maps/overmap/space_pois/wayhome_30x30.dmm"
block_size = 30
/datum/map_template/dynamic_overmap/whiteship_55x30
name = "ship2"
mappath = "modular_chomp/maps/overmap/space_pois/whiteship_55x30.dmm"
block_size = 55
/datum/map_template/dynamic_overmap/wizardcrash_20x35
name = "also something"
mappath = "modular_chomp/maps/overmap/space_pois/wizardcrash_20x35.dmm"
block_size = 35

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,6 @@
"a" = (/turf/template_noop,/area/template_noop)
"b" = (/turf/simulated/mineral/vacuum,/area/submap/way_home)
"c" = (/obj/item/instrument/trombone/spectral,/obj/item/clothing/suit/skeleton,/turf/simulated/mineral/floor/vacuum,/area/submap/way_home)
"d" = (/obj/structure/signpost{name = "salvation"},/turf/simulated/mineral/floor/vacuum,/area/submap/way_home)
"e" = (/obj/structure/loot_pile/surface/bones,/turf/simulated/mineral/floor/vacuum,/area/submap/way_home)
"s" = (/turf/simulated/mineral/floor/vacuum,/area/submap/way_home)
"E" = (/obj/item/clothing/mask/smokable/pipe/bonepipe,/turf/simulated/mineral/floor/vacuum,/area/submap/way_home)
@@ -24,7 +23,7 @@ aaaaaabbbbbbsssaaaaaaaaaaaaaaa
aaaaaaabbbsssssaaaaaaaaaaaaaaa
aaaaaaabbaasssssaaaaaaaaaaaaaa
aaaaaaaaaaaaassssaaaaaaaaaaaaa
aaaaaaaaaaaaassdssaaaaaaaaaaaa
aaaaaaaaaaaaasssssaaaaaaaaaaaa
aaaaaaaaaaaaasEesssaaaaaaaaaaa
aaaaaaaaaaaaaassssssaaaaaaaaaa
aaaaaaaaaaaaaasssbssaaaaaaaaaa