From 9a51dfabbfbcc19f81bd31082805a2c4aae75a2a Mon Sep 17 00:00:00 2001 From: DreamySkrell <107256943+DreamySkrell@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:10:41 +0100 Subject: [PATCH] Guaranteed spawn flag respects current sector && sectors blacklist (#17733) * 0 * sectors_blacklist * Update code/datums/ruins.dm Co-authored-by: Fluffy <65877598+FluffyGhoster@users.noreply.github.com> * Update code/modules/maps/ruins.dm Co-authored-by: Fluffy <65877598+FluffyGhoster@users.noreply.github.com> * Update maps/_common/mapsystem/map.dm Co-authored-by: Fluffy <65877598+FluffyGhoster@users.noreply.github.com> * Update maps/_common/mapsystem/map.dm Co-authored-by: Fluffy <65877598+FluffyGhoster@users.noreply.github.com> --------- Co-authored-by: DreamySkrell <> Co-authored-by: Fluffy <65877598+FluffyGhoster@users.noreply.github.com> --- code/__defines/misc.dm | 13 ++++-- code/__defines/space_sectors.dm | 44 +++++++++---------- code/datums/ruins.dm | 24 +++++++++- code/modules/maps/ruins.dm | 4 +- ...Skrell-guaranteed-spawn-respect-sector.yml | 43 ++++++++++++++++++ maps/_common/mapsystem/map.dm | 4 +- .../konyang/point_verdant/point_verdant.dm | 1 + maps/away/ships/freebooter/freebooter_ship.dm | 2 +- maps/away/ships/orion/orion_express_ship.dm | 2 +- .../ships/tramp_freighter/tramp_freighter.dm | 2 +- .../exoplanets/konyang/landing_zone.dm | 2 +- 11 files changed, 105 insertions(+), 36 deletions(-) create mode 100644 html/changelogs/DreamySkrell-guaranteed-spawn-respect-sector.yml diff --git a/code/__defines/misc.dm b/code/__defines/misc.dm index 7681e04b484..ff4319a167b 100644 --- a/code/__defines/misc.dm +++ b/code/__defines/misc.dm @@ -499,10 +499,15 @@ example: #define HABITABILITY_BAD 3 //Map template flags -#define TEMPLATE_FLAG_ALLOW_DUPLICATES 1 // Lets multiple copies of the template to be spawned -#define TEMPLATE_FLAG_SPAWN_GUARANTEED 2 // Makes it ignore away site budget and just spawn (only for away sites) -#define TEMPLATE_FLAG_CLEAR_CONTENTS 4 // if it should destroy objects it spawns on top of -#define TEMPLATE_FLAG_NO_RUINS 8 // if it should forbid ruins from spawning on top of it +/// Lets multiple copies of the template to be spawned +#define TEMPLATE_FLAG_ALLOW_DUPLICATES 1 +/// Makes it ignore away site budget and just spawn (works only for away sites) +/// A site needs to be set to spawn in current sector to be considered still +#define TEMPLATE_FLAG_SPAWN_GUARANTEED 2 +/// if it should destroy objects it spawns on top of +#define TEMPLATE_FLAG_CLEAR_CONTENTS 4 +/// if it should forbid ruins from spawning on top of it +#define TEMPLATE_FLAG_NO_RUINS 8 //Ruin map template flags #define TEMPLATE_FLAG_RUIN_STARTS_DISALLOWED 32 // Ruin is not available during spawning unless another ruin permits it, or whitelisted by the exoplanet diff --git a/code/__defines/space_sectors.dm b/code/__defines/space_sectors.dm index 6297b5d354e..38850857336 100644 --- a/code/__defines/space_sectors.dm +++ b/code/__defines/space_sectors.dm @@ -1,44 +1,44 @@ //Comments contain criteria for whatever these sectors literally define, for future-proofing and consistency //Generic sectors are generic intermediate areas for when we can't attribute locale to anywhere in specific //Tau ceti sectors -#define SECTOR_ROMANOVICH "Romanovich Cloud"//The fat cloud of rocks surrounding Tau Ceti and its gravity well -#define SECTOR_TAU_CETI "Tau Ceti"//Tau Ceti and its gravity well, Biesel and its subfactions are found here -#define SECTOR_CORP_ZONE "Corporate Reconstruction Zone"//The entire corporate reconstruction zone borders +#define SECTOR_ROMANOVICH "Romanovich Cloud" //The fat cloud of rocks surrounding Tau Ceti and its gravity well +#define SECTOR_TAU_CETI "Tau Ceti" //Tau Ceti and its gravity well, Biesel and its subfactions are found here +#define SECTOR_CORP_ZONE "Corporate Reconstruction Zone" //The entire corporate reconstruction zone borders #define ALL_TAU_CETI_SECTORS list(SECTOR_ROMANOVICH, SECTOR_TAU_CETI, SECTOR_CORP_ZONE) //Badlands sectors, at least six factions are here so its noteworthy -#define SECTOR_VALLEY_HALE "Valley Hale"//Generic sector but is also used for the entire Elyran territory -#define SECTOR_BADLANDS "Badlands"//Generic sector +#define SECTOR_VALLEY_HALE "Valley Hale" //Generic sector but is also used for the entire Elyran territory +#define SECTOR_BADLANDS "Badlands" //Generic sector //Elyran sectors -#define SECTOR_NEW_ANKARA "New Ankara"//New Ankara and its gravity well, Persepolis and New Suez are found here -#define SECTOR_AEMAQ "Al-Wakwak"//al-Wakwak and its gravity well, Aemaqq is found here +#define SECTOR_NEW_ANKARA "New Ankara" //New Ankara and its gravity well, Persepolis and New Suez are found here +#define SECTOR_AEMAQ "Al-Wakwak" //al-Wakwak and its gravity well, Aemaqq is found here //Tajaran and Unathi sectors -#define SECTOR_SRANDMARR "S'rand'marr"//S'r'and'marr and its gravity well, Adhomai and Raskara are found here -#define SECTOR_NRRAHRAHUL "Nrrahrahul"//Nrrahrahul and its gravity well, Hro'zamal is found here -#define SECTOR_GAKAL "Gakal"//Gakal and its gravity well, Gakal'zaal is found here. -#define SECTOR_UUEOAESA "Uueoa-Esa"//Uueoa-Esa and its gravity well, Moghes and Ouerea are found here. +#define SECTOR_SRANDMARR "S'rand'marr" //S'r'and'marr and its gravity well, Adhomai and Raskara are found here +#define SECTOR_NRRAHRAHUL "Nrrahrahul" //Nrrahrahul and its gravity well, Hro'zamal is found here +#define SECTOR_GAKAL "Gakal" //Gakal and its gravity well, Gakal'zaal is found here. +#define SECTOR_UUEOAESA "Uueoa-Esa" //Uueoa-Esa and its gravity well, Moghes and Ouerea are found here. #define ALL_BADLAND_SECTORS list(SECTOR_VALLEY_HALE, SECTOR_BADLANDS, SECTOR_NEW_ANKARA, SECTOR_AEMAQ, SECTOR_SRANDMARR, SECTOR_NRRAHRAHUL, SECTOR_GAKAL, SECTOR_UUEOAESA) //Coalition-aligned sectors -#define SECTOR_COALITION "Coalition of Colonies"//For if we want to specify coalition assets, but not focused on a particular planet -#define SECTOR_WEEPING_STARS "Weeping Stars"//Generic sector -#define SECTOR_ARUSHA "Arusha"//Generic sector -#define SECTOR_LIBERTYS_CRADLE "Liberty's Cradle"//Generic sector -#define SECTOR_BURZSIA "Burzsia" //Burzsia I and II are here -#define SECTOR_HANEUNIM "Haneunim"//Haneunim and its gravity well, Konyang is found here -#define ALL_COALITION_SECTORS list(SECTOR_COALITION, SECTOR_WEEPING_STARS, SECTOR_LIBERTYS_CRADLE, SECTOR_ARUSHA, SECTOR_BURZSIA) +#define SECTOR_COALITION "Coalition of Colonies" //For if we want to specify coalition assets, but not focused on a particular planet +#define SECTOR_WEEPING_STARS "Weeping Stars" //Generic sector +#define SECTOR_ARUSHA "Arusha" //Generic sector +#define SECTOR_LIBERTYS_CRADLE "Liberty's Cradle" //Generic sector +#define SECTOR_BURZSIA "Burzsia" //Burzsia I and II are here +#define SECTOR_HANEUNIM "Haneunim" //Haneunim and its gravity well, Konyang is found here +#define ALL_COALITION_SECTORS list(SECTOR_COALITION, SECTOR_WEEPING_STARS, SECTOR_ARUSHA, SECTOR_LIBERTYS_CRADLE, SECTOR_BURZSIA, SECTOR_HANEUNIM) //Light's edge, which should have unique properties all around -#define SECTOR_LIGHTS_EDGE "Light's Edge"//For the area of Light's Edge that is somewhat inhabited -#define SECTOR_LEMURIAN_SEA "Lemurian Sea"//For the actual black void area +#define SECTOR_LIGHTS_EDGE "Light's Edge" //For the area of Light's Edge that is somewhat inhabited +#define SECTOR_LEMURIAN_SEA "Lemurian Sea" //For the actual black void area #define ALL_VOID_SECTORS list(SECTOR_LIGHTS_EDGE, SECTOR_LEMURIAN_SEA) //Generic sectors, particularly ones that can be seen regardless of region the ship is in -#define SECTOR_STAR_NURSERY "Star Nursery"//Used by the idris cruise map +#define SECTOR_STAR_NURSERY "Star Nursery" //Used by the idris cruise map #define SECTOR_GENERIC "Generic Sector" #define ALL_GENERIC_SECTORS list(SECTOR_STAR_NURSERY, SECTOR_GENERIC) //For sectors where corporate entities can or should appear. Corporate ships having this tag can be seen more reliably #define ALL_CORPORATE_SECTORS list(ALL_TAU_CETI_SECTORS, SECTOR_SRANDMARR, SECTOR_UUEOAESA, ALL_COALITION_SECTORS, ALL_GENERIC_SECTORS, SECTOR_GAKAL, SECTOR_NRRAHRAHUL, SECTOR_BADLANDS)//Currently excludes Elyran sectors and Light's Edge -#define ALL_POSSIBLE_SECTORS list(SECTOR_ROMANOVICH, SECTOR_TAU_CETI, SECTOR_CORP_ZONE, SECTOR_VALLEY_HALE, SECTOR_BADLANDS, SECTOR_NEW_ANKARA, SECTOR_AEMAQ, SECTOR_SRANDMARR, SECTOR_NRRAHRAHUL, SECTOR_GAKAL, SECTOR_UUEOAESA, SECTOR_COALITION, SECTOR_WEEPING_STARS, SECTOR_ARUSHA, SECTOR_BURZSIA, SECTOR_HANEUNIM, SECTOR_LIBERTYS_CRADLE, SECTOR_LIGHTS_EDGE, SECTOR_LEMURIAN_SEA, SECTOR_STAR_NURSERY, SECTOR_GENERIC) +#define ALL_POSSIBLE_SECTORS list(ALL_TAU_CETI_SECTORS, ALL_BADLAND_SECTORS, ALL_COALITION_SECTORS, ALL_VOID_SECTORS, ALL_GENERIC_SECTORS, ALL_CORPORATE_SECTORS) diff --git a/code/datums/ruins.dm b/code/datums/ruins.dm index c069ec73adc..891ab0e7858 100644 --- a/code/datums/ruins.dm +++ b/code/datums/ruins.dm @@ -9,11 +9,25 @@ var/spawn_cost = 0 var/player_cost = 0 var/ship_cost = 0 - var/list/sectors = list() //This ruin can only spawn in the sectors in this list. + /// This ruin can only spawn in the sectors in this list. + /// Should contain names of sectors as defined in `space_sectors.dm`. + /// This list is flattened so it can contain nested lists like, for example, `ALL_POSSIBLE_SECTORS`. + var/list/sectors = list() + /// Sectors in this list are removed from the `sectors` list. + /// Usage is same as of `sectors`. + /// Intention is to allow to, for example, set `sectors` to `ALL_POSSIBLE_SECTORS`, + /// but then disallow just one sector from that list. + var/list/sectors_blacklist = list() + + /// Prefix part of the path to the dmm maps. var/prefix = null + /// A list of suffix parts of paths of the dmm maps. + /// Combined with prefix to get the actual path. var/list/suffixes = null - template_flags = TEMPLATE_FLAG_NO_RUINS // Don't let ruins spawn on top of ruins + + /// Template flags for this ruin + template_flags = TEMPLATE_FLAG_NO_RUINS // !! Currently only implemented for away sites var/list/force_ruins // Listed ruins are always spawned unless disallowed by flags. @@ -26,4 +40,10 @@ for (var/suffix in suffixes) mappaths += (prefix + suffix) sectors = flatten_list(sectors) + sectors_blacklist = flatten_list(sectors_blacklist) + sectors -= sectors_blacklist ..() + +/// Returns `TRUE` if this ruin can spawn in current sector, otherwise `FALSE`. +/datum/map_template/ruin/proc/spawns_in_current_sector() + return (SSatlas.current_sector.name in sectors) diff --git a/code/modules/maps/ruins.dm b/code/modules/maps/ruins.dm index d85f4fd36dc..9191ac143ac 100644 --- a/code/modules/maps/ruins.dm +++ b/code/modules/maps/ruins.dm @@ -17,12 +17,12 @@ var/list/banned_ruin_ids = list() var/remaining = budget for(var/datum/map_template/ruin/ruin in potentialRuins) - if(ruin.template_flags & TEMPLATE_FLAG_SPAWN_GUARANTEED) + if(HAS_FLAG(ruin.template_flags, TEMPLATE_FLAG_SPAWN_GUARANTEED) && (ruin.spawns_in_current_sector())) force_spawn |= ruin continue if(ruin.id in banned_ruin_ids) continue - if(!(SSatlas.current_sector.name in ruin.sectors) && !ignore_sector) + if(!(ruin.spawns_in_current_sector()) && !ignore_sector) continue available[ruin] = ruin.spawn_weight diff --git a/html/changelogs/DreamySkrell-guaranteed-spawn-respect-sector.yml b/html/changelogs/DreamySkrell-guaranteed-spawn-respect-sector.yml new file mode 100644 index 00000000000..d34538784ec --- /dev/null +++ b/html/changelogs/DreamySkrell-guaranteed-spawn-respect-sector.yml @@ -0,0 +1,43 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: DreamySkrell + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Away site/ruin guaranteed spawn flag respects current sector." + - rscadd: "Guaranteed spawn flag added to Point Verdant." + - rscadd: "Sectors blacklist mechanism." diff --git a/maps/_common/mapsystem/map.dm b/maps/_common/mapsystem/map.dm index 5326585400d..fd0caf53231 100644 --- a/maps/_common/mapsystem/map.dm +++ b/maps/_common/mapsystem/map.dm @@ -237,11 +237,11 @@ for (var/site_id in SSmapping.away_sites_templates) var/datum/map_template/ruin/away_site/site = SSmapping.away_sites_templates[site_id] - if (site.template_flags & TEMPLATE_FLAG_SPAWN_GUARANTEED) + if (HAS_FLAG(site.template_flags, TEMPLATE_FLAG_SPAWN_GUARANTEED) && (site.spawns_in_current_sector())) guaranteed += site if ((site.template_flags & TEMPLATE_FLAG_ALLOW_DUPLICATES) && !(site.template_flags & TEMPLATE_FLAG_RUIN_STARTS_DISALLOWED)) available[site] = site.spawn_weight - else if (!(site.template_flags & TEMPLATE_FLAG_RUIN_STARTS_DISALLOWED) && (SSatlas.current_sector.name in site.sectors)) + else if (NOT_FLAG(site.template_flags, TEMPLATE_FLAG_RUIN_STARTS_DISALLOWED) && (site.spawns_in_current_sector())) available[site] = site.spawn_weight by_type[site.type] = site diff --git a/maps/away/away_site/konyang/point_verdant/point_verdant.dm b/maps/away/away_site/konyang/point_verdant/point_verdant.dm index 173131184d4..dd0668c2469 100644 --- a/maps/away/away_site/konyang/point_verdant/point_verdant.dm +++ b/maps/away/away_site/konyang/point_verdant/point_verdant.dm @@ -6,6 +6,7 @@ suffixes = list("away_site/konyang/point_verdant/point_verdant-1.dmm","away_site/konyang/point_verdant/point_verdant-2.dmm","away_site/konyang/point_verdant/point_verdant-3.dmm") spawn_weight = 1 spawn_cost = 1 + template_flags = TEMPLATE_FLAG_SPAWN_GUARANTEED /singleton/submap_archetype/point_verdant map = "point_verdant" diff --git a/maps/away/ships/freebooter/freebooter_ship.dm b/maps/away/ships/freebooter/freebooter_ship.dm index bcdc0b3d9e7..86ab88c3a00 100644 --- a/maps/away/ships/freebooter/freebooter_ship.dm +++ b/maps/away/ships/freebooter/freebooter_ship.dm @@ -2,7 +2,7 @@ name = "Freebooter Ship" description = "One of the most common sights in the Orion Spur, even outside of human space, is the Hephaestus-produced Ox-class freighter. Designed to haul significant amounts of cargo on well-charted routes between civilized systems, the Ox-class is the backbone of many interstellar markets outside of the United Syndicates of Himeo. Repurposed Ox-class freighters are often used by pirates throughout the Spur thanks to their large size and ease of maintenance – and modification." suffixes = list("ships/freebooter/freebooter_ship.dmm") - sectors = list(SECTOR_TAU_CETI, SECTOR_ROMANOVICH, SECTOR_CORP_ZONE, SECTOR_VALLEY_HALE, SECTOR_NEW_ANKARA, SECTOR_BADLANDS, SECTOR_AEMAQ, SECTOR_SRANDMARR, ALL_COALITION_SECTORS, SECTOR_HANEUNIM) + sectors = list(SECTOR_TAU_CETI, SECTOR_ROMANOVICH, SECTOR_CORP_ZONE, SECTOR_VALLEY_HALE, SECTOR_NEW_ANKARA, SECTOR_BADLANDS, SECTOR_AEMAQ, SECTOR_SRANDMARR, ALL_COALITION_SECTORS) spawn_weight = 1 ship_cost = 1 id = "freebooter_ship" diff --git a/maps/away/ships/orion/orion_express_ship.dm b/maps/away/ships/orion/orion_express_ship.dm index 4ad8e89235d..a1ef99a13e9 100644 --- a/maps/away/ships/orion/orion_express_ship.dm +++ b/maps/away/ships/orion/orion_express_ship.dm @@ -2,7 +2,7 @@ name = "Orion Express Mobile Station" description = "The Traveler-class mobile station is a relatively old design, but nonetheless venerable and one of the building blocks of interstellar commerce. While relatively small, is a treasured asset in the Orion Express corporation's fleet, and has been referred to as “the gas station of the stars”, offering food, supplies, and fuel to anyone who may need it." suffixes = list("ships/orion/orion_express_ship.dmm") - sectors = list(ALL_CORPORATE_SECTORS, SECTOR_HANEUNIM) + sectors = list(ALL_CORPORATE_SECTORS) spawn_weight = 1 ship_cost = 1 id = "orion_express_ship" diff --git a/maps/away/ships/tramp_freighter/tramp_freighter.dm b/maps/away/ships/tramp_freighter/tramp_freighter.dm index 260c5b5ecc9..23a4b172ca9 100644 --- a/maps/away/ships/tramp_freighter/tramp_freighter.dm +++ b/maps/away/ships/tramp_freighter/tramp_freighter.dm @@ -2,7 +2,7 @@ name = "Tramp Freighter" description = "A freighter of mixed repute, the Catspaw-class is a rare independent design, and a favorite of small-scale freight businesses. It has a shielded cargo bay and an internal hangar, capable of accommodating a small shuttle. Its other features, however, are lacking - with cramped crew amenities and no defenses to speak of, the Catspaw is risky to operate in unpoliced space." suffixes = list("ships/tramp_freighter/tramp_freighter.dmm") - sectors = list(SECTOR_TAU_CETI, SECTOR_ROMANOVICH, SECTOR_CORP_ZONE, SECTOR_VALLEY_HALE, SECTOR_NEW_ANKARA, SECTOR_BADLANDS, SECTOR_AEMAQ, SECTOR_SRANDMARR, ALL_COALITION_SECTORS, SECTOR_HANEUNIM) + sectors = list(SECTOR_TAU_CETI, SECTOR_ROMANOVICH, SECTOR_CORP_ZONE, SECTOR_VALLEY_HALE, SECTOR_NEW_ANKARA, SECTOR_BADLANDS, SECTOR_AEMAQ, SECTOR_SRANDMARR, ALL_COALITION_SECTORS) spawn_weight = 1 ship_cost = 1 id = "tramp_freighter" diff --git a/maps/random_ruins/exoplanets/konyang/landing_zone.dm b/maps/random_ruins/exoplanets/konyang/landing_zone.dm index bfafbe6db92..6671ed9d8f1 100644 --- a/maps/random_ruins/exoplanets/konyang/landing_zone.dm +++ b/maps/random_ruins/exoplanets/konyang/landing_zone.dm @@ -3,7 +3,7 @@ id = "konyang_landing_zone" description = "An artificial orbitally-dropped prefab of flattened ground established for shuttle landing." - template_flags = TEMPLATE_FLAG_NO_RUINS|TEMPLATE_FLAG_RUIN_STARTS_DISALLOWED + template_flags = TEMPLATE_FLAG_NO_RUINS|TEMPLATE_FLAG_RUIN_STARTS_DISALLOWED|TEMPLATE_FLAG_SPAWN_GUARANTEED sectors = list(SECTOR_HANEUNIM) suffixes = list("konyang/landing_zone.dmm")