Enforce ruin cost as factor of ruin size. (#27198)

* refactor: Enforce ruin cost as factor of ruin size.

* remove cost-related comment

* bump up space ruin numbers based on testing

* remove old lavaland_ruin_budget setting

* one more tiny tweak down

* Update config/example/config.toml

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>

* Update config/example/config.toml

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com>

---------

Signed-off-by: warriorstar-orion <orion@snowfrost.garden>
Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com>
Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
This commit is contained in:
warriorstar-orion
2024-11-24 14:10:15 +00:00
committed by GitHub
co-authored by AffectedArc07 Burzah
parent f978108c74
commit e37b83a0b9
8 changed files with 158 additions and 147 deletions
+9 -1
View File
@@ -10,7 +10,6 @@
var/unpickable = FALSE //If TRUE these won't be placed automatically (can still be forced or loaded with another ruin)
var/always_place = FALSE //Will skip the whole weighting process and just plop this down, ideally you want the ruins of this kind to have no cost.
var/placement_weight = 1 //How often should this ruin appear
var/cost = 0 //Cost in ruin budget placement system
var/allow_duplicates = TRUE
var/list/never_spawn_with = null //If this ruin is spawned these will not eg list(/datum/map_template/ruin/base_alternate)
@@ -23,3 +22,12 @@
mappath = prefix + suffix
..(path = mappath)
/// The cost of a ruin is the square root of the product of its dimensions.
/// This encodes the size of the ruin relative to each other without the
/// numbers getting ridiculous.
/datum/map_template/ruin/proc/get_cost()
if(!width || !height)
CRASH("cost of [name]/[suffix] requested before loaded size")
return floor(sqrt(width * height))
+1 -20
View File
@@ -3,7 +3,6 @@
ci_exclude = /datum/map_template/ruin/lavaland
/datum/map_template/ruin/lavaland/biodome
cost = 5
allow_duplicates = FALSE
ci_exclude = /datum/map_template/ruin/lavaland/biodome // This is a parent holder, not a ruin itself
@@ -36,7 +35,6 @@
Probably best to stay clear."
suffix = "lavaland_surface_ash_walker1.dmm"
allow_duplicates = FALSE
cost = 20 // Not auto due to the nature of walkers
/datum/map_template/ruin/lavaland/free_golem
name = "Free Golem Ship"
@@ -52,7 +50,6 @@
id = "althland-facility"
description = "A grim testament to the Althland Mining Company's ambitions, this facility lies in ruin, swallowed by the very planet it sought to exploit. \
Once a beacon of mining promise, it now stands as a stark reminder of the company's catastrophic demise."
cost = 5
suffix = "lavaland_surface_althland_facility.dmm"
allow_duplicates = FALSE
@@ -61,12 +58,10 @@
id = "althland-excavation"
description = "An abandoned mining pit, once operated by the late Althland Mining Corporation, stands as a testament to the extensive efforts of numerous labor groups who endeavored to exploit the ore-rich depths of the planet. \
Now, it lies abandoned, wholly reclaimed by the hostile environment, transforming into yet another relic of a lost company."
cost = 5
suffix = "lavaland_surface_althland_excavation.dmm"
allow_duplicates = FALSE
/datum/map_template/ruin/lavaland/sin
cost = 10
allow_duplicates = FALSE
ci_exclude = /datum/map_template/ruin/lavaland/sin // This is a parent holder, not a ruin itself
@@ -99,14 +94,12 @@
id = "sloth"
description = "..."
suffix = "lavaland_surface_sloth.dmm"
cost = 0
/datum/map_template/ruin/lavaland/ratvar
name = "Dead God"
id = "ratvar"
description = "Ratvars final resting place."
suffix = "lavaland_surface_dead_ratvar.dmm"
cost = 0
allow_duplicates = FALSE
/datum/map_template/ruin/lavaland/hierophant
@@ -122,7 +115,6 @@
id = "blooddrunk"
description = "A strange arrangement of stone tiles and an insane, beastly miner contemplating them."
suffix = "lavaland_surface_blooddrunk1.dmm"
cost = 0
allow_duplicates = FALSE //will only spawn one variant of the ruin
/datum/map_template/ruin/lavaland/blood_drunk_miner/guardian
@@ -138,7 +130,6 @@
id = "ufo-crash"
description = "Turns out that keeping your abductees unconscious is really important. Who knew?"
suffix = "lavaland_surface_ufo_crash.dmm"
cost = 5
/datum/map_template/ruin/lavaland/xeno_nest
name = "Xenomorph Nest"
@@ -146,21 +137,19 @@
description = "These xenomorphs got bored of horrifically slaughtering people on space stations, and have settled down on a nice lava filled hellscape to focus on what's really important in life. \
Quality memes."
suffix = "lavaland_surface_xeno_nest.dmm"
cost = 20
/datum/map_template/ruin/lavaland/fountain
name = "Fountain Hall"
id = "fountain"
description = "The fountain has a warning on the side. DANGER: May have undeclared side effects that only become obvious when implemented."
suffix = "lavaland_surface_fountain_hall.dmm"
cost = 5
/datum/map_template/ruin/lavaland/survivalcapsule
name = "Survival Capsule Ruins"
id = "survivalcapsule"
description = "What was once sanctuary to the common miner, is now their tomb."
suffix = "lavaland_surface_survivalpod.dmm"
cost = 5
/datum/map_template/ruin/lavaland/pizza
name = "Ruined Pizza Party"
@@ -168,7 +157,6 @@
description = "Little Timmy's birthday pizza-bash took a turn for the worse when a bluespace anomaly passed by."
suffix = "lavaland_surface_pizzaparty.dmm"
allow_duplicates = FALSE
cost = 5
/datum/map_template/ruin/lavaland/cultaltar
name = "Summoning Ritual"
@@ -176,7 +164,6 @@
description = "A place of vile worship, the scrawling of blood in the middle glowing eerily. A demonic laugh echoes throughout the caverns"
suffix = "lavaland_surface_cultaltar.dmm"
allow_duplicates = FALSE
cost = 10
/datum/map_template/ruin/lavaland/hermit
name = "Makeshift Shelter"
@@ -192,21 +179,18 @@
description = "A heavily-damaged mining ripley, property of a very unfortunate miner. You might have to do a bit of work to fix this thing up."
suffix = "lavaland_surface_random_ripley.dmm"
allow_duplicates = FALSE
cost = 5
/datum/map_template/ruin/lavaland/puzzle
name = "Ancient Puzzle"
id = "puzzle"
description = "Mystery to be solved."
suffix = "lavaland_surface_puzzle.dmm"
cost = 5
/datum/map_template/ruin/lavaland/tumor
name = "Elite Tumor"
id = "tumor"
description = "The victor freed, the loser the next fighter. The ghosts, the endless spectators. And thus the cycle loops..."
suffix = "lavaland_surface_elite_tumor.dmm"
cost = 5
always_place = TRUE
/datum/map_template/ruin/lavaland/monster_nest
@@ -215,14 +199,12 @@
description = "A cave of several tunnels, housing the local fauna deep underground."
suffix = "lavaland_surface_monster_nest.dmm"
allow_duplicates = FALSE
cost = 5
/datum/map_template/ruin/lavaland/watcher_grave
name = "Watchers' Grave"
id = "watcher-grave"
description = "A lonely cave where an orphaned child awaits a new parent."
suffix = "lavaland_surface_watcher_grave.dmm"
cost = 5
allow_duplicates = FALSE
/datum/map_template/ruin/lavaland/shuttlecrash
@@ -230,5 +212,4 @@
id = "shuttlecrash"
description = "A passenger shuttle crashsite of indeterminate origin."
suffix = "lavaland_surface_shuttlecrash.dmm"
cost = 5
allow_duplicates = FALSE
+108
View File
@@ -0,0 +1,108 @@
/datum/ruin_placer
var/ruin_budget
var/area_whitelist
var/list/templates
/datum/ruin_placer/proc/place_ruins(z_levels)
if(!z_levels || !length(z_levels))
WARNING("No Z levels provided - Not generating ruins")
return
for(var/zl in z_levels)
var/turf/T = locate(1, 1, zl)
if(!T)
WARNING("Z level [zl] does not exist - Not generating ruins")
return
var/list/ruins = templates.Copy()
var/list/forced_ruins = list() //These go first on the z level associated (same random one by default)
var/list/ruins_availible = list() //we can try these in the current pass
var/forced_z //If set we won't pick z level and use this one instead.
//Set up the starting ruin list
for(var/key in ruins)
var/datum/map_template/ruin/R = ruins[key]
if(R.get_cost() > ruin_budget) //Why would you do that
continue
if(R.always_place)
forced_ruins[R] = -1
if(R.unpickable)
continue
ruins_availible[R] = R.placement_weight
while(ruin_budget > 0 && (length(ruins_availible) || length(forced_ruins)))
var/datum/map_template/ruin/current_pick
var/forced = FALSE
if(length(forced_ruins)) //We have something we need to load right now, so just pick it
for(var/ruin in forced_ruins)
current_pick = ruin
if(forced_ruins[ruin] > 0) //Load into designated z
forced_z = forced_ruins[ruin]
forced = TRUE
break
else //Otherwise just pick random one
current_pick = pickweight(ruins_availible)
var/placement_tries = PLACEMENT_TRIES
var/failed_to_place = TRUE
var/z_placed = 0
while(placement_tries > 0)
placement_tries--
z_placed = pick(z_levels)
if(!current_pick.try_to_place(forced_z ? forced_z : z_placed, area_whitelist))
continue
else
failed_to_place = FALSE
break
//That's done remove from priority even if it failed
if(forced)
//TODO : handle forced ruins with multiple variants
forced_ruins -= current_pick
forced = FALSE
if(failed_to_place)
for(var/datum/map_template/ruin/R in ruins_availible)
if(R.id == current_pick.id)
ruins_availible -= R
log_world("Failed to place [current_pick.name] ruin.")
else
ruin_budget -= current_pick.get_cost()
if(!current_pick.allow_duplicates)
for(var/datum/map_template/ruin/R in ruins_availible)
if(R.id == current_pick.id)
ruins_availible -= R
if(current_pick.never_spawn_with)
for(var/blacklisted_type in current_pick.never_spawn_with)
for(var/possible_exclusion in ruins_availible)
if(istype(possible_exclusion,blacklisted_type))
ruins_availible -= possible_exclusion
forced_z = 0
//Update the availible list
for(var/datum/map_template/ruin/R in ruins_availible)
if(R.get_cost() > ruin_budget)
ruins_availible -= R
log_world("Ruin loader finished with [ruin_budget] left to spend.")
/datum/ruin_placer/space
area_whitelist = /area/space
/datum/ruin_placer/space/New()
ruin_budget = rand(
GLOB.configuration.ruins.space_ruin_budget_min,
GLOB.configuration.ruins.space_ruin_budget_max
)
templates = GLOB.space_ruins_templates
/datum/ruin_placer/lavaland
area_whitelist = /area/lavaland/surface/outdoors/unexplored
/datum/ruin_placer/lavaland/New()
ruin_budget = rand(
GLOB.configuration.ruins.lavaland_ruin_budget_min,
GLOB.configuration.ruins.lavaland_ruin_budget_max
)
templates = GLOB.lava_ruins_templates
+1 -25
View File
@@ -1,7 +1,5 @@
//The bigger ones lag like hell if there is more than one on a z-level, so cost 2 for them
/datum/map_template/ruin/space
prefix = "_maps/map_files/RandomRuins/SpaceRuins/"
cost = 1
ci_exclude = /datum/map_template/ruin/space
/datum/map_template/ruin/space/zoo
@@ -12,7 +10,6 @@
zoos to working order with the breeding stock kept in these 100% \
secure and unbreachable storage facilities. At no point has anything \
escaped. That's our story, and we're sticking to it."
cost = 2
/datum/map_template/ruin/space/asteroid1
id = "asteroid1"
@@ -58,7 +55,6 @@
a giant unused asteroid. Then make it self sufficient, mask any \
evidence of construction, hook it covertly into the \
telecommunications network and hope for the best."
cost = 2
allow_duplicates = FALSE // this shouldn't be spawning more than once anymore
/datum/map_template/ruin/space/derelict1
@@ -138,7 +134,6 @@
gutted asteroids, we suspect that a mining ship using a restricted \
engine is somewhere in the area. We'd like to request a patrol vessel \
to investigate."
cost = 2
/datum/map_template/ruin/space/spacebar
id = "spacebar"
@@ -149,7 +144,6 @@
Rampant Golem and Yellow Hound. Can I take your order?"
allow_duplicates = FALSE //it spawn ship docking, no more than one to avoid duplication in console.
always_place = TRUE
cost = 0
/datum/map_template/ruin/space/turreted_outpost
id = "turreted-outpost"
@@ -170,7 +164,6 @@
name = "Ancient Space Station"
description = "The crew of a space station awaken one hundred years after a crisis. Awaking to a derelict space station on the verge of collapse, and a hostile force of invading \
hivebots. Can the surviving crew overcome the odds and survive and rebuild, or will the cold embrace of the stars become their new home?"
cost = 0
always_place = TRUE
allow_duplicates = FALSE
@@ -179,7 +172,6 @@
suffix = "wizardcrash.dmm"
name = "Crashed Wizard Shuttle"
description = "A shuttle of the Wizard Federation, sent out to crush some wandless scum. Unfortunately, the pilot suffered a magic-related accident and the shuttle crashed into a nearby asteroid."
cost = 2
/datum/map_template/ruin/space/abandonedtele
id = "abandonedtele"
@@ -192,7 +184,6 @@
suffix = "blowntcommsat.dmm"
name = "Blown-out Telecommunications Satellite"
description = "The remains of an old telecommunications satellite once utilised by Nanotrasen. It lays derelict, with quite a few pieces missing."
cost = 5 // This is a chonky boy
allow_duplicates = FALSE // Absolutely huge, also has its own APC and the area isnt set to allow many
/datum/map_template/ruin/space/malftcommsat
@@ -200,7 +191,6 @@
suffix = "telecomns_returns.dmm"
name = "D.V.O.R.A.K'S Telecommunications Satellite"
description = "Seems the telecomunication satellite that went dark 4 years ago finally re-appeared on scanners? Strange signals are coming from it."
cost = 5 // Huge. Large. In charge
allow_duplicates = FALSE // One sadistic malfunctioning AI is enough. Also unique apcs.
/datum/map_template/ruin/space/clownmime
@@ -214,7 +204,6 @@
suffix = "dj.dmm"
name = "Soviet DJ Station"
description = "A USSP listening post masquerading as a popular Soviet entertainment broadcaster, keeping tabs on Nanotrasen activity in the system and relaying it back to the Union."
cost = 2
allow_duplicates = FALSE
/datum/map_template/ruin/space/druglab
@@ -229,7 +218,6 @@
name = "Suspicious Station"
description = "A syndicate drug laboratory hidden on an asteroid. It is strangely well-protected."
allow_duplicates = FALSE
cost = 3
/datum/map_template/ruin/space/syndiedepot
id = "syndiedepot"
@@ -238,7 +226,6 @@
description = "A syndicate supply depot, heavily stocked, but heavily guarded with an assortment of shields, sentry bots, armed operatives and more."
allow_duplicates = FALSE // One of these is enough
always_place = TRUE // This is on the always spawn list because of the shielding chance
cost = 0 // Force spawned so shouldnt have a cost
/datum/map_template/ruin/space/ussp_tele
id = "ussp_tele"
@@ -253,7 +240,6 @@
name = "USSP"
description = "A decript station of seemingly Soviet origin. The last contact had with this station was a distress signal, and the rest was dark."
allow_duplicates = FALSE // One of these has enough loot
cost = 5 // This ruin is 100x100 tiles, so we dont want it to be treated like a 10x10 meteor
/datum/map_template/ruin/space/whiteship
id = "whiteship"
@@ -262,7 +248,6 @@
description = "A small expeditionary ship for use in local space exploration and salvaging."
allow_duplicates = FALSE // I dont even want to think about what happens if you have 2 shuttles with the same ID. Likely scary stuff.
always_place = TRUE // Its designed to make exploring other space ruins more accessible
cost = 0 // Force spawned so shouldnt have a cost
/datum/map_template/ruin/space/golem_destination
id = "golemtarget"
@@ -271,14 +256,12 @@
description = "Just a handful of rocks floating in space. Guaranteed space destination for the Golem shuttle in case other destinations don't spawn."
allow_duplicates = FALSE
always_place = TRUE
cost = 0
/datum/map_template/ruin/space/syndicate_space_base
name = "Syndicate Space Base"
id = "syndie-space-base"
description = "A secret base researching illegal bioweapons, it is closely guarded by an elite team of syndicate agents."
suffix = "syndie_space_base.dmm"
cost = 0
always_place = TRUE
allow_duplicates = FALSE
@@ -288,7 +271,6 @@
name = "Syndicakes Factory"
description = "Syndicate used to get funds selling corgi cakes produced here. Was it hit by meteors or by a Nanotrasen comando?"
allow_duplicates = FALSE
cost = 2 //telecomms + multiple mobs
/datum/map_template/ruin/space/debris1
id = "debris1"
@@ -314,7 +296,6 @@
name = "Meat Packers"
description = "An old transport ship, possibly with a dubious past. It smells faintly of meat."
allow_duplicates = FALSE
cost = 2 // Pretty big
/datum/map_template/ruin/space/mo19
id = "mo19"
@@ -322,7 +303,6 @@
name = "Moon Outpost 19"
description = "A now-defunct outpost, with the last received signal being that of distress."
allow_duplicates = FALSE
cost = 2 // Also pretty big
/datum/map_template/ruin/space/voyager
id = "voyager"
@@ -330,7 +310,6 @@
name = "Voyager"
description = "A relic of old times, you don't know what it hide inside."
allow_duplicates = FALSE
cost = 1 // Gives research levels and it should be hard-to-find
/datum/map_template/ruin/space/wreckedcargoship
id = "wreckedcargoship"
@@ -338,7 +317,6 @@
name = "Wrecked Cargoship"
description = "A cargo shuttle in a wrecked condition. There are many unknown horrors in space and looks like its last crew has faced one of them."
allow_duplicates = FALSE
cost = 1 // With the loot it contains it shouldn't be found frequently
/datum/map_template/ruin/space/abandoned_engi_sat
id = "abandoned_engi_sat"
@@ -346,7 +324,6 @@
name = "Abandoned NT Engineering Satellite"
description = "A derelict operating base for NT engineering crew."
allow_duplicates = FALSE
cost = 1
/datum/map_template/ruin/space/rocky_motel
id = "rocky_motel"
@@ -354,7 +331,6 @@
name = "Rocky Motel"
description = "A cozy little home nestled in an asteroid, perfect for one or two people!"
allow_duplicates = FALSE
cost = 1
/datum/map_template/ruin/space/casino
id = "casino"
@@ -375,7 +351,7 @@
suffix = "freighter.dmm"
name = "Voidhopper of Nexus"
description = "A cargo ship headed to a nearby system."
/datum/map_template/ruin/space/drakehound_breacher
id = "drakehound_breacher"
suffix = "unathi_skiff.dmm"