[MIRROR] Fixes ore vents spawning without ores on icebox, sets up map specific ore configurations (#26375)

* Fixes ore vents spawning without ores on icebox, sets up map specific ore configurations (#81103)

## About The Pull Request

In short, we used a static list previously within the ore_generation
subsystem that held the amount of each ore that we expected a single map
to uniformly need. We held this number constant, since we were spawning
15 vents per map.

**Pros:** This worked flawlessly for Lavaland since 15 vents on a single
Z level makes it pretty densely packed map with a good amount of
map-based ore spawns, and it worked consistently.

**Cons:** 15 vents did not work well on Icebox however, even when split
so that the majority of the ores were spawning on the lower levels,
players did not feel like icebox spawned nearly enough ores and reported
the map spawning empty.

**Result:** As a result, we adjusted the ratio, so that we spawned
vastly more ores on the lower levels, now up to 4 vents on the upper
level, and 21 vents on the lower level. However, as we were still using
the ore distribution list based on lavaland, icebox vents were quickly
running out of ores to distribute between them, resulting in empty vents
-> which produced empty boulders -> which not only don't really let you
process them properly, but also just result in a metric ton of runtimes.

Icebox now has it's own list of ore distributions. These distributions
are now moved to a set of global lists as opposed to being saved on the
subsystem as a static list, which will make going and setting up new ore
distribution lists very very easy. Additionally, we've moved the setting
and getting of those ore_distributions over to the seedRuins proc, so
that we're actually setting the list of ores right before we actually
place them to make sure that the order that it's set is roughly as it's
needed, while still setting the list at the same time the
map-appropriate ruin placements are dropped in.

**Plus some misc cleanup fixes:**
`var/list/ore_vent_sizes` in SSore_generation wasn't being treated as a
similar budget list as `ore_vent_minerals`, since it `pick()`s off it's
own static size list. Which is honestly fine for this five seconds, I
can handle that later while we make sure the rest of the code code is
stable. In the meantime, I've just tweak it so that it's easy to see at
a glance how many of each random vent has spawned into the map.

Tweaked the description to not include anything about chemical
processing, as I'm planning on hitting on that in a part 2 PR that I'll
be picking back up after the freeze.

## Why It's Good For The Game

Cleans up the code a bit, but primarily fixes ores not spawning on
icebox as they should.
Should fix #81058.
Improves description to not mention mechanics that aren't in game.
Also, cleans up a piece of code that currently isn't serving much of a
purpose.

## Changelog

🆑
fix: Icebox should have it's ore distribution and it's ore vents fixed,
so that vents should now produce ore.
spellcheck: Boulder processing machines now don't mention things they
don't do.
/🆑

* Fixes ore vents spawning without ores on icebox, sets up map specific ore configurations

---------

Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com>
This commit is contained in:
SkyratBot
2024-02-07 13:26:08 -05:00
committed by GitHub
co-authored by ArcaneMusic
parent 0ac1027456
commit 602ac52e9d
11 changed files with 106 additions and 64 deletions
@@ -18,7 +18,7 @@
var/tapped = FALSE
/// Has this vent been scanned by a mining scanner? Cannot be scanned again. Adds ores to the vent's description.
var/discovered = FALSE
/// Is this type of vent exempt from the 15 vent limit? Think the free iron/glass vent or boss vents. This also causes it to not roll for random mineral breakdown.
/// Is this type of vent exempt from the map's vent budget/limit? Think the free iron/glass vent or boss vents. This also causes it to not roll for random mineral breakdown.
var/unique_vent = FALSE
/// What icon_state do we use when the ore vent has been tapped?
var/icon_state_tapped = "ore_vent_active"
@@ -74,7 +74,8 @@
if(mapload)
generate_description()
register_context()
SSore_generation.possible_vents += src
if(!unique_vent)
SSore_generation.possible_vents += src
boulder_icon_state = pick(list(
"boulder",
"rock",
@@ -168,33 +169,37 @@
/**
* This proc is called when the ore vent is initialized, in order to determine what minerals boulders it spawns can contain.
* The materials available are determined by SSore_generation.ore_vent_minerals, which is a list of all minerals that can be contained in ore vents for a given cave generation.
* As a result, minerals use a weighted list as seen by ore_vent_minerals_default, which is then copied to ore_vent_minerals.
* As a result, minerals use a weighted list as seen by ore_vent_minerals_lavaland, which is then copied to ore_vent_minerals.
* Once a material is picked from the weighted list, it's removed from ore_vent_minerals, so that it can't be picked again and provided it's own internal weight used when assigning minerals to boulders spawned by this vent.
* May also be called after the fact, as seen in SSore_generation's initialize, to add more minerals to an existing vent.
*
* The above applies only when spawning in at mapload, otherwise we pick randomly from ore_vent_minerals_default.
* The above applies only when spawning in at mapload, otherwise we pick randomly from ore_vent_minerals_lavaland.
*
* @params max_minerals How many minerals should be added to this vent? Defaults to MINERAL_TYPE_OPTIONS_RANDOM, which is 4.
* @params map_loading Is this vent being spawned in at mapload? If so, we use the ore_generation subsystem's ore_vent_minerals list to pick minerals. Otherwise, we pick randomly from ore_vent_minerals_default.
* @params new_minerals How many minerals should be added to this vent? Defaults to MINERAL_TYPE_OPTIONS_RANDOM, which is 4.
* @params map_loading Is this vent being spawned in at mapload? If so, we use the ore_generation subsystem's ore_vent_minerals list to pick minerals. Otherwise, we pick randomly from ore_vent_minerals_lavaland.
*/
/obj/structure/ore_vent/proc/generate_mineral_breakdown(max_minerals = MINERAL_TYPE_OPTIONS_RANDOM, map_loading = FALSE)
if(max_minerals < 1)
CRASH("generate_mineral_breakdown called with max_minerals < 1.")
for(var/iterator in 1 to max_minerals)
if(!SSore_generation.ore_vent_minerals.len && map_loading)
CRASH("No minerals left to pick from! We may have spawned too many ore vents in init, or added too many ores to the existing vents.")
var/datum/material/material
/obj/structure/ore_vent/proc/generate_mineral_breakdown(new_minerals = MINERAL_TYPE_OPTIONS_RANDOM, map_loading = FALSE)
if(new_minerals < 1)
CRASH("generate_mineral_breakdown called with new_minerals < 1.")
var/list/available_mats = difflist(first = SSore_generation.ore_vent_minerals, second = mineral_breakdown, skiprep = 1)
for(var/i in 1 to new_minerals)
if(!length(SSore_generation.ore_vent_minerals) && map_loading)
// We should prevent this from happening in SSore_generation, but if not then we crash here
CRASH("No minerals left to pick from! We may have spawned too many ore vents in init, or the map config in seedRuins may not have enough resources for the mineral budget.")
var/datum/material/new_material
if(map_loading)
material = pick_weight(SSore_generation.ore_vent_minerals)
if(is_type_in_list(mineral_breakdown, material))
continue
if(map_loading)
SSore_generation.ore_vent_minerals[material] -= 1 //We remove 1 from the ore vent's mineral breakdown weight, so that it can't be picked again.
if(SSore_generation.ore_vent_minerals[material] <= 0)
SSore_generation.ore_vent_minerals -= material
if(length(available_mats))
new_material = pick(GLOB.ore_vent_minerals_lavaland)
var/datum/material/surrogate_mat = pick(SSore_generation.ore_vent_minerals)
available_mats -= surrogate_mat
SSore_generation.ore_vent_minerals -= surrogate_mat
else
new_material = pick(available_mats)
available_mats -= new_material
SSore_generation.ore_vent_minerals -= new_material
else
material = pick_weight(SSore_generation.ore_vent_minerals_default)
mineral_breakdown[material] = rand(1, 4)
new_material = pick(GLOB.ore_vent_minerals_lavaland)
mineral_breakdown[new_material] = rand(1, 4)
/**
@@ -416,15 +421,15 @@
if(LARGE_VENT_TYPE)
boulder_size = BOULDER_SIZE_LARGE
if(mapload)
SSore_generation.ore_vent_sizes["large"] -= 1
SSore_generation.ore_vent_sizes["large"] += 1
if(MEDIUM_VENT_TYPE)
boulder_size = BOULDER_SIZE_MEDIUM
if(mapload)
SSore_generation.ore_vent_sizes["medium"] -= 1
SSore_generation.ore_vent_sizes["medium"] += 1
if(SMALL_VENT_TYPE)
boulder_size = BOULDER_SIZE_SMALL
if(mapload)
SSore_generation.ore_vent_sizes["small"] -= 1
SSore_generation.ore_vent_sizes["small"] += 1
else
boulder_size = BOULDER_SIZE_SMALL //Might as well set a default value
name = initial(name)