mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-24 04:27:35 +01:00
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:
co-authored by
AffectedArc07
Burzah
parent
f978108c74
commit
e37b83a0b9
@@ -12,8 +12,14 @@
|
||||
var/list/active_space_ruins = list()
|
||||
/// List of all active lavaland ruins
|
||||
var/list/active_lava_ruins = list()
|
||||
/// Budget for lavaland ruins
|
||||
var/lavaland_ruin_budget = 60
|
||||
/// Minimum budget for space ruins
|
||||
var/space_ruin_budget_min = 750
|
||||
/// Maximum budget for space ruins
|
||||
var/space_ruin_budget_max = 1000
|
||||
/// Minimum budget for lavaland ruins
|
||||
var/lavaland_ruin_budget_min = 175
|
||||
/// Maximum budget for lavaland ruins
|
||||
var/lavaland_ruin_budget_max = 325
|
||||
|
||||
/datum/configuration_section/ruin_configuration/load_data(list/data)
|
||||
// Use the load wrappers here. That way the default isnt made 'null' if you comment out the config line
|
||||
@@ -23,4 +29,7 @@
|
||||
CONFIG_LOAD_NUM(extra_levels_max, data["maximum_zlevels"])
|
||||
CONFIG_LOAD_LIST(active_space_ruins, data["active_space_ruins"])
|
||||
CONFIG_LOAD_LIST(active_lava_ruins, data["active_lava_ruins"])
|
||||
CONFIG_LOAD_NUM(lavaland_ruin_budget, data["lavaland_ruin_budget"])
|
||||
CONFIG_LOAD_NUM(space_ruin_budget_min, data["space_ruin_budget_min"])
|
||||
CONFIG_LOAD_NUM(space_ruin_budget_max, data["space_ruin_budget_max"])
|
||||
CONFIG_LOAD_NUM(lavaland_ruin_budget_min, data["lavaland_ruin_budget_min"])
|
||||
CONFIG_LOAD_NUM(lavaland_ruin_budget_max, data["lavaland_ruin_budget_max"])
|
||||
|
||||
@@ -26,6 +26,11 @@ SUBSYSTEM_DEF(mapping)
|
||||
/// A mapping of environment names to MILLA environment IDs.
|
||||
var/list/environments
|
||||
|
||||
/// Ruin placement manager for space levels.
|
||||
var/datum/ruin_placer/space/space_ruins_placer
|
||||
/// Ruin placement manager for lavaland levels.
|
||||
var/datum/ruin_placer/lavaland/lavaland_ruins_placer
|
||||
|
||||
// This has to be here because world/New() uses [station_name()], which looks this datum up
|
||||
/datum/controller/subsystem/mapping/PreInit()
|
||||
. = ..()
|
||||
@@ -108,7 +113,8 @@ SUBSYSTEM_DEF(mapping)
|
||||
// Spawn Lavaland ruins and rivers.
|
||||
log_startup_progress("Populating lavaland...")
|
||||
var/lavaland_setup_timer = start_watch()
|
||||
seedRuins(list(level_name_to_num(MINING)), GLOB.configuration.ruins.lavaland_ruin_budget, /area/lavaland/surface/outdoors/unexplored, GLOB.lava_ruins_templates)
|
||||
lavaland_ruins_placer = new()
|
||||
lavaland_ruins_placer.place_ruins(list(level_name_to_num(MINING)))
|
||||
if(lavaland_theme)
|
||||
lavaland_theme.setup()
|
||||
if(caves_theme)
|
||||
@@ -252,10 +258,10 @@ SUBSYSTEM_DEF(mapping)
|
||||
// Note that this budget is not split evenly accross all zlevels
|
||||
log_startup_progress("Seeding ruins...")
|
||||
var/seed_ruins_timer = start_watch()
|
||||
var/space_z_levels = levels_by_trait(SPAWN_RUINS)
|
||||
seedRuins(space_z_levels, rand(20, 30), /area/space, GLOB.space_ruins_templates)
|
||||
space_ruins_placer = new()
|
||||
space_ruins_placer.place_ruins(levels_by_trait(SPAWN_RUINS))
|
||||
log_startup_progress("Successfully seeded ruins in [stop_watch(seed_ruins_timer)]s.")
|
||||
seed_space_salvage(space_z_levels)
|
||||
seed_space_salvage(levels_by_trait(SPAWN_RUINS))
|
||||
|
||||
// Loads in the station
|
||||
/datum/controller/subsystem/mapping/proc/loadStation()
|
||||
@@ -301,90 +307,6 @@ SUBSYSTEM_DEF(mapping)
|
||||
GLOB.maploader.load_map(file("_maps/map_files/generic/Lavaland.dmm"), z_offset = lavaland_z_level)
|
||||
log_startup_progress("Loaded Lavaland in [stop_watch(watch)]s")
|
||||
|
||||
/datum/controller/subsystem/mapping/proc/seedRuins(list/z_levels = null, budget = 0, whitelist = /area/space, list/potentialRuins)
|
||||
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 = potentialRuins.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.cost > 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(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,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
|
||||
budget -= current_pick.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.cost > budget)
|
||||
ruins_availible -= R
|
||||
|
||||
log_world("Ruin loader finished with [budget] left to spend.")
|
||||
|
||||
/datum/controller/subsystem/mapping/proc/make_maint_all_access()
|
||||
for(var/area/station/maintenance/A in existing_station_areas)
|
||||
for(var/obj/machinery/door/airlock/D in A)
|
||||
|
||||
Reference in New Issue
Block a user