Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArcMining Pr Beta: Version 1.2 #78524

Merged
merged 209 commits into from Jan 21, 2024
Merged

Conversation

ArcaneMusic
Copy link
Contributor

@ArcaneMusic ArcaneMusic commented Sep 23, 2023

This one's not like the last one, so much so that I'm not even going to outsource the PR description to a robot this time!
Basically, You should read the PR body before assuming that everything is the same as last time. It's not.

Video Summary

Click the link below to see a video summary of the main features of this pull request.
https://youtu.be/Aho2omR0mjY?feature=shared

About The Pull Request

This pull request serves as a large rework of minerals produced by mining, and by extension mining itself. I'll try and list each change and it's associated nuance here.

Ore Vents

The biggest addition to the game with ArcMining is Ore Vents. Ore vents spawn as a ruin on the map, placing a randomized ore vent onto map generation. Ore vents spawn in 3 different sizes, Small, Medium, and Large. These vents will pick from a pool of materials they can generate, and will hang out across the map. A player can use a mining scanner to discover an ore vent, granting a small quantity of mining points to begin with. Once scanned, ore vents will show what minerals that ore vent will generate after they're fully tapped.

Scanning the vent again will trigger the extraction process. A small drone will fly down, called the NODE drone, and buckle onto the vent. Your job during wave defense is to protect the drone and to defeat waves of randomly spawning mobs (dependent on if you're on lavaland or on icebox). The quantity, duration, and time between waves is scaled to the size of the vent you're protecting. Starting by scanning and protecting lower tier vents earlier in the shift is a safer bet than doing a large vent in the first few minutes. The drone has 500 health, and can take a good few hits, but leaving it alone will cause it to meet an unfortunate end quite quickly.

Cooperation can be your best asset, as mining with allies can greatly help with wave defense, and mineral points are granted to anyone who helps with defending the ore vent equally (So 500 * size tier, regardless of how much help you receive). Once complete, the ore vent will have a mining machine constructed on top of it, and will start to dredge up Boulders from the earth automatically. More on boulders later.

Ore vents can be located based on your mining scanner, and will provide an appropriate audio cue based on if the ore vent has been discovered or not, and once processed will no longer alert you to it's presence.

Each station comes with a free vent that produces exclusively iron and glass, free of charge. This is to help with shifts where the station may not have shaft miners to produce minerals, and to provide the station with a baseline amount of minerals where none may exist otherwise.

Mineral Generation

Mineral generation has been completely reworked. Previously, Mineral Generation had a flat 13% spawn rate in-game. Once minerals spawned, they would also have a chance to propagate their minerals to nearby tiles, resulting in a rather massive pool of minerals that could spawn throughout lavaland on the whole.

This tweaks that, by making minerals in walls spawn based on their proximity to ore vents on maps that use cave generation. Both the probability, and quantity of ores spawning in walls is scaled based on distance, with ore vents looking like large caches of ores found in walls. This makes following ores found in walls and checking their quantity of minerals spawned a good indicator of how close you are to a nearby vent in-round.

This means you can collect some points form both discovering ore vents first, as well as collecting their surrounding ores, turn those in for mining points, and then trading them in for gear upgrades to more effectively take on ore vents. As a result of tweaking the balance of this, the total amount of ores spawned in walls overall has been decreased. However, by making more of the process time based, we still result in a mostly balanced finished product.

Boulder Processing

On station, there are now three new machines. These are the BRM, the Refinery, and the Smelter.

  • The BRM acts as a teleporter. Instead of needing to carry boulders back to the station, you can activate the BRM, and it will automatically pick boulders to teleport back to itself. You can use this to teleport boulders dredged up from lavaland onto the station for processing. The BRM will only lock on to boulders that are resting on an ore vent. Moving boulders back by hand will mean you'll have to haul it back by hand.
  • The refinery processes the non-metallic materials out of boulders. This process sends the materials straight to the ORM, and collects mining points from the ores smelted in the machine. Swiping with an ID card lets you withdraw those points for your own personal account, but remember that these points are for your whole team to share from. The Mining points obtained from this process is only 75% of the amount an equivalent amount of ores would provide.
  • The smelter works nearly identically, however the smelter produces metallic materials out of boulders instead.
  • Once a boulder has had all of it's materials extracted, it's broken down and deleted from the line. Otherwise, the boulder is spat out for the next machine to process it (either the refinery or smelter).
  • Once there's no minerals left in a boulder of any type, the refinery or smelter will break the boulder down.
  • Boulders do not stack onto tiles with each other, so they'll block each other when pulled or when moving on a conveyor belt.

Boulders can also be processed by hand. Using a mining tool on a boulder with right click will allow you to break down a boulder into it's composite ores, but limits you to a maximum of 10 ore per boulder, where the full amount can be extracted using the proper processing machines. Also, processing by hand does deal small amounts of stamina damage over time, do breaking a full large boulder can be particularly taxing.

Additional Boulder Processing Machines can be built, with the BRM board being obtained from the Protolathe, while the Smelter and Refinery boards being obtainable from the Autolathe instead. A boulder processing beacon can also be obtained from the mining points vendor as a reward to assist with boulder processing. Boulder processing beacons can be used to spawn in a new BRM, refinery, and smelter on the tile the user is standing on, however you'll still need to link them to the ORM!

All three machines can be upgraded with Stock Parts, allowing for more boulders to be processed at a time. It does not, however, increase the amount of minerals received from boulders, or points earned.

Mining Borg Tweaks

Mining borgs have been given some minor adjustments to compensate for the changes to mining. Their mineral scanner, which now has an active component to gameplay, is now a module as opposed to built into the mob. This module allows for the same ability to discover and start waves of monsters to fight.

Mining modules will find that their PKA now has a total of 90% mod capacity as compared to the 80% they had before, to allow for more robust defense of ore vents.

In addition, all borgs and AIs can interact with the BRM for boulder collection.

Mining Mech Tweaks

Mining Mechs have had their utility tweaked as a result of these changes as well. Mineral scanners to be used on mining mechs now have a larger radius by comparison to their handheld cousins. Similarly, it now has an active scanning button, which will actively discovery nearby ore vents. To begin wave defense, you will need to hop out and scan a second time however, so that you can properly accept the risks of drawing a horde of bloodthirsty wildlife towards you and your companions.

Mechs can also manually process boulders, similar to mining tools using their drill.

Golem Tweaks

Golems, being more gentle and less aggressive than humans, while being made out of LITERAL ROCKS, have a greater need to secure access to ores and minerals to eat. As such, they have adapted to be able to do two new things:

  • Golems may now right click ore vents to be able to manually haul a boulder out of the vent. This costs a hefty amount of stamina, but it allows for golems to avoid combat during regular gameplay.
  • Golems may now left click a boulder with an open hand in order to manually process a boulder like a pickaxe. While not faster, it is consistent and prevents golems from starving if they have access to a vent, but no ores, somehow.

Gulag Tweaks

The labor camp, being a camp for rehabilitation and excessive manual labor has been tweaked. Boulders now replace the random minerals located on their island, and to acquire their prizes inside, much be excavated and then broken out of the rock. Now YOU TOO can excavate minerals and become a true mineral hero by working your way to freedom.

Mining Point Changes

As a result of fewer mining points being available across the map due to the new ore spawning mechanics, and the shift in how and when ores will be coming in, almost every progress based mining point cost has been reduced by around 10-20%. Many numbers are still subject to change at present, but the idea is that core progress unlocks should be made a bit more available earlier in the round before players can start to solo or duo larger or more difficult ore vents, after which they'll be rolling in ores.

Rarities

Every once in awhile, an unusual boulder will get hauled up from the mineral rich depths of lavaland. These Artifact boulders can occasionally produce rare items, but for now they've mostly just been pulling up Strange objects for science. Nanotrasen Natural Sciences department will reward you extra points to be collected by boulder processing machines for successfully extracting one. In the future, this opens up a passive reward space that mining can reward to the station, like providing cytology DNA samples, ancient seeds, or other artifacts.

Misc notes

  • Boulders can be stored in all varieties of ore boxes (ground, mech) should you choose, however as mentioned it's best to leave them where they spawn and teleport them to the station for convenience.
  • Maps that are not subject to cave generation will find that they are largely untouched in terms of mineral balance.
  • Future or existing ruins can now be tweaked to have a mineral balance cost, as the ore vent ruin does. This will allow us to spawn in more interesting ruins for pre-made combat challenges.
  • There are unique ore vents that spawn across the map, that will summon a boss mob relevant to that map. If the boss mob is defeated, that vent will spawn large boulders pulling from every possible ore type that can spawn. Not for the faint of heart!
  • Similarly, the number of ore vents and mineral budget is now adjustable in the cave generation procs, so maps may spawn with more or less ore vents as desired for balance.
  • Artifact boulders opens up a LOT of room for possible future content like archaeology, xenoarch, artisci, and other design spaces!
  • Megafauna STILL SPAWN ON THE MAP. They just happen to spawn in addition to boss ore vents.
  • I'll add more to this as I get asked questions and remember things, this is a huge PR and I'm confident I've missed at least something

Why It's Good For The Game

I outlined a lot of this in #78040, so I'll try and keep this relatively snappy this time, while noting that I've made some concessions to make the whole system a lot more playable while not trying to break out design decisions that are at the end of the day, better for the game and the overall resource balance in round.

Minerals are a very poorly balanced system, and have been since their inception many years ago. We heavily rely on mineral balance in round, and yet we've really only balanced it by introducing so much supply that there's no equivalent exchange for materials that doesn't just heavily flood the exchanged material. For example, items printed from materials that are otherwise considered "rare" on master exist in such quantities and they'll never practically run out in our allotted 90 minute time slot design. This PR adjusts how ores spawn to a point where we can minimize the amount of ores that need to exist on the map for mining to be able to progress, while still providing enough resources for the station that it covers the needs of the station adequately.

Miners will need to be more strategic about what resources they've collected, and be able to make decisions about which vents are worth the risk of attempting to fight, how to prepare for a wave defense, and when to head back up for upgrades, while finally giving them at least some kind of incentive to work together and use different equipment. Resonators make cleaning up the caves around vent easy, sandbags set up easy defenses for your vent, mechs can serve as a wider range radar while mining, all while still providing a new gameplay loop to mining.

By limiting the amount of ores that can enter the round from the massive, massive amounts that were coming into the round beforehand (see #78346 ), we can make ore processing more meaningful by adding more gameplay to the processing of minerals. I have some plans for that, however this PR already got bloated really REALLY badly due to scope creep and the number of intersecting systems that rammed into each other to make this PR possible. So that'll be next. Plus, as I've mentioned, we open up places for ore processing to find fossils, relics, and other things that can implemented down the line.

Overall, I don't expect this PR to save or kill ore balance, but we gain a LOT more control over it through the use of our mining defines attached to this PR, and at the end of the day, that's a great place to start off of.

Changelog

🆑
add: Added ore vents. Scanning them with mining scanners shows what minerals they contain. Scan again to fight off a horde of beasts as your drone assistant excavates the vent, so the ore vent will produce mineral boulders!
bal: Ores that spawn in walls now spawn based on their proximity to ore vents, with their chance to spawn and their minerals contained scaling from low to high.
add: Added the BRM, Refinery, and Smelter. These pieces of equipment are used to process ore boulders into minerals for the station. Stock Part upgrades allow more boulders to be processed at one time. They collect mining points as well, to be redeemed with an ID card swipe.
add: Boulders are teleported to the station via the BRM if left untouched. Boulders can also be cracked open for a reduced amount of ore using pickaxes or golems hands.
add: All stations come equipt with a pre-excavated ore vent, which produces a basic supply of iron and glass only. Scan other vents for your critical resources!
add: Look there's a shit ton of changes on mining, for more detail check out the Pull Request: #78524.
sound: New sounds and noises for your high octane factorio-like gameplay!
image: All new boulder sprites for the new minerals and rocks added to the mining gameplay loop, as well as mining machines!
image: Overlays appear over vents when scanned to let you know their contents at a glance when actively scanned with any mining scanners.
/:cl:

ArcaneMusic and others added 30 commits June 20, 2023 22:27
…ulder processing machines, called "bouldertech".
…uccessfully unlatch themselves when they need to run.
@Iajret
Copy link
Contributor

Iajret commented Jan 29, 2024

Not only it passes boulders through, but sometimes it spills rocks with 0 or even -1 steps left in them

@Inari-Whitebear
Copy link
Contributor

So I did some more testing.

Seems maybe related to conveyors as a whole?
What I did was to build the machines, then put conveyors and wrench the conveyors to be the right direction. Seems that causes my issue.
If I first build the conveyors and then the machines it works.

To fix it after building it the wrong way around I had to unwrench the machines, drag them off the tile, then back onto the tile and re-wrench them it appears.

Ghommie pushed a commit that referenced this pull request Jan 29, 2024
…of mineral balance (#81151)

## About The Pull Request


![image](https://github.com/tgstation/tgstation/assets/41715314/9ea9b578-d394-4a0e-971c-7f1099acae4a)

![image](https://github.com/tgstation/tgstation/assets/41715314/ab06a6b8-ab7c-4db4-86a8-e91d4f0bb771)

![image](https://github.com/tgstation/tgstation/assets/41715314/5d08ee4b-4005-4175-9f21-a0295f1596c5)

With the merge of #78524, we have a significant amount more control over
how many materials are entering the round, as if it's overtuned, we can
adjust the mineral spawning percentages, and if it's undertuned we can
do vice-versa. Similarly with ore vents, we can adjust how much of every
resource will spawn, allowing for items that can be printed via the
lathe to have a significant more impact on how much they cost depending
on round balance.

Going forward, this data can be found using the mineral logging and
graphing tool found in `tools\silo_grapher\silo_graph_script.py` to make
future balance decisions. These tools combined allow for a full suite of
resource controls going in and out of the round for decisions to be made
on item printing.

## Why It's Good For The Game

We needed better control on resources going in and out of the round for
the massive, massive quantity of items in game limited by being
extremely cheap to print on the lathe.

We have those resource controls now, and the tools to adjust the balance
as necessary. Therefore, I'm fine with us axing this.

Fixes #67009, and fixes #66601.

I would wait out the last bit of the freeze but ahh fuck it I don't see
why not to do it now

## Changelog

:cl:
del: The lathe tax on printing items has been removed from the game for
both humans and silicons.
/:cl:
Jolly-66 pushed a commit to TaleStation/TaleStation that referenced this pull request Jan 30, 2024
Original PR: tgstation/tgstation#78524
-----
This one's not like the last one, so much so that I'm not even going to
outsource the PR description to a robot this time!
Basically, **You should read the PR body before assuming that everything
is the same as last time. It's not.**

## Video Summary
Click the link below to see a video summary of the main features of this
pull request.
https://youtu.be/Aho2omR0mjY?feature=shared

## About The Pull Request
This pull request serves as a large rework of minerals produced by
mining, and by extension mining itself. I'll try and list each change
and it's associated nuance here.

### Ore Vents
The biggest addition to the game with ArcMining is **Ore Vents**. Ore
vents spawn as a ruin on the map, placing a randomized ore vent onto map
generation. Ore vents spawn in 3 different sizes, **Small, Medium, and
Large**. These vents will pick from a pool of materials they can
generate, and will hang out across the map. A player can use a mining
scanner to discover an ore vent, granting a small quantity of **mining
points** to begin with. Once scanned, ore vents will show what minerals
that ore vent will generate after they're fully tapped.

Scanning the vent again will trigger the extraction process. A small
drone will fly down, called the NODE drone, and buckle onto the vent.
Your job during wave defense is to protect the drone and to defeat waves
of randomly spawning mobs (dependent on if you're on lavaland or on
icebox). The quantity, duration, and time between waves is scaled to the
size of the vent you're protecting. Starting by scanning and protecting
lower tier vents earlier in the shift is a safer bet than doing a large
vent in the first few minutes. The drone has 500 health, and can take a
good few hits, but leaving it alone will cause it to meet an unfortunate
end quite quickly.

Cooperation can be your best asset, as mining with allies can greatly
help with wave defense, and mineral points are granted to anyone who
helps with defending the ore vent equally (So 500 * size tier,
regardless of how much help you receive). Once complete, the ore vent
will have a mining machine constructed on top of it, and will start to
dredge up **Boulders** from the earth automatically. More on boulders
later.

Ore vents can be located based on your mining scanner, and will provide
an appropriate audio cue based on if the ore vent has been discovered or
not, and once processed will no longer alert you to it's presence.

**Each station comes with a free vent that produces exclusively iron and
glass, free of charge.** This is to help with shifts where the station
may not have shaft miners to produce minerals, and to provide the
station with a baseline amount of minerals where none may exist
otherwise.

### Mineral Generation
Mineral generation has been completely reworked. Previously, Mineral
Generation had a flat 13% spawn rate in-game. Once minerals spawned,
they would also have a chance to propagate their minerals to nearby
tiles, resulting in a rather massive pool of minerals that could spawn
throughout lavaland on the whole.

This tweaks that, by making minerals in walls spawn based on their
proximity to ore vents on maps that use cave generation. Both the
probability, and quantity of ores spawning in walls is scaled based on
distance, with ore vents looking like large caches of ores found in
walls. This makes following ores found in walls and checking their
quantity of minerals spawned a good indicator of how close you are to a
nearby vent in-round.

This means you can collect some points form both discovering ore vents
first, as well as collecting their surrounding ores, turn those in for
mining points, and then trading them in for gear upgrades to more
effectively take on ore vents. As a result of tweaking the balance of
this, the total amount of ores spawned in walls overall has been
decreased. However, by making more of the process time based, we still
result in a mostly balanced finished product.

### Boulder Processing
On station, there are now three new machines. These are the BRM, the
Refinery, and the Smelter.

- The BRM acts as a teleporter. Instead of needing to carry boulders
back to the station, you can activate the BRM, and it will automatically
pick boulders to teleport back to itself. You can use this to teleport
boulders dredged up from lavaland onto the station for processing. **The
BRM will only lock on to boulders that are resting on an ore vent.**
Moving boulders back by hand will mean you'll have to haul it back by
hand.
- The refinery processes the non-metallic materials out of boulders.
This process sends the materials straight to the ORM, and collects
mining points from the ores smelted in the machine. Swiping with an ID
card lets you withdraw those points for your own personal account, but
remember that these points are for your whole team to share from. The
**Mining points obtained from this process is only 75% of the amount an
equivalent amount of ores would provide.**
- The smelter works nearly identically, however the smelter produces
metallic materials out of boulders instead.
- Once a boulder has had all of it's materials extracted, it's broken
down and deleted from the line. Otherwise, the boulder is spat out for
the next machine to process it (either the refinery or smelter).
- Once there's no minerals left in a boulder of any type, the refinery
or smelter will break the boulder down.
- Boulders **do not stack onto tiles with each other**, so they'll block
each other when pulled or when moving on a conveyor belt.

Boulders can also be processed by hand. Using a mining tool on a boulder
with right click will allow you to break down a boulder into it's
composite ores, but limits you to a maximum of 10 ore per boulder, where
the full amount can be extracted using the proper processing machines.
Also, processing by hand does deal small amounts of stamina damage over
time, do breaking a full large boulder can be particularly taxing.

Additional Boulder Processing Machines can be built, with the BRM board
being obtained from the Protolathe, while the Smelter and Refinery
boards being obtainable from the Autolathe instead. A _boulder
processing beacon_ can also be obtained from the mining points vendor as
a reward to assist with boulder processing. Boulder processing beacons
can be used to spawn in a new BRM, refinery, and smelter on the tile the
user is standing on, however **you'll still need to link them to the
ORM**!

All three machines can be upgraded with Stock Parts, allowing for **more
boulders to be processed at a time**. It does not, however, increase the
amount of minerals received from boulders, or points earned.

### Mining Borg Tweaks
Mining borgs have been given some minor adjustments to compensate for
the changes to mining. Their mineral scanner, which now has an active
component to gameplay, is now a module as opposed to built into the mob.
This module allows for the same ability to discover and start waves of
monsters to fight.

Mining modules will find that their PKA now has a total of 90% mod
capacity as compared to the 80% they had before, to allow for more
robust defense of ore vents.

In addition, all borgs and AIs can interact with the BRM for boulder
collection.

### Mining Mech Tweaks
Mining Mechs have had their utility tweaked as a result of these changes
as well. Mineral scanners to be used on mining mechs now have a larger
radius by comparison to their handheld cousins. Similarly, it now has an
active scanning button, which will actively discovery nearby ore vents.
To begin wave defense, you will need to hop out and scan a second time
however, so that you can properly accept the risks of drawing a horde of
bloodthirsty wildlife towards you and your companions.

Mechs can also manually process boulders, similar to mining tools using
their drill.

### Golem Tweaks
Golems, being more gentle and less aggressive than humans, while being
made out of LITERAL ROCKS, have a greater need to secure access to ores
and minerals to eat. As such, they have adapted to be able to do two new
things:

- Golems may now right click ore vents to be able to manually haul a
boulder out of the vent. This costs a hefty amount of stamina, but it
allows for golems to avoid combat during regular gameplay.
- Golems may now left click a boulder with an open hand in order to
manually process a boulder like a pickaxe. While not faster, it is
consistent and prevents golems from starving if they have access to a
vent, but no ores, somehow.

### Gulag Tweaks
The labor camp, being a camp for rehabilitation and ~~excessive manual
labor~~ has been tweaked. Boulders now replace the random minerals
located on their island, and to acquire their prizes inside, much be
excavated and then broken out of the rock. Now YOU TOO can excavate
minerals and become a true mineral hero by working your way to freedom.

### Mining Point Changes
As a result of fewer mining points being available across the map due to
the new ore spawning mechanics, and the shift in how and when ores will
be coming in, almost every progress based mining point cost has been
reduced by around 10-20%. Many numbers are still subject to change at
present, but the idea is that core progress unlocks should be made a bit
more available earlier in the round before players can start to solo or
duo larger or more difficult ore vents, after which they'll be rolling
in ores.

### Rarities
Every once in awhile, an unusual boulder will get hauled up from the
mineral rich depths of lavaland. These **Artifact boulders** can
occasionally produce rare items, but for now they've mostly just been
pulling up **Strange objects** for science. Nanotrasen Natural Sciences
department will reward you extra points to be collected by boulder
processing machines for successfully extracting one. In the future, this
opens up a passive reward space that mining can reward to the station,
like providing cytology DNA samples, ancient seeds, or other artifacts.

### Misc notes

- Boulders can be stored in all varieties of ore boxes (ground, mech)
should you choose, however as mentioned it's best to leave them where
they spawn and teleport them to the station for convenience.
- Maps that are not subject to cave generation will find that they are
largely untouched in terms of mineral balance.
- Future or existing ruins can now be tweaked to have a mineral balance
cost, as the ore vent ruin does. This will allow us to spawn in more
interesting ruins for pre-made combat challenges.
- There are unique ore vents that spawn across the map, that will summon
a boss mob relevant to that map. If the boss mob is defeated, that vent
will spawn large boulders pulling from every possible ore type that can
spawn. Not for the faint of heart!
- Similarly, the number of ore vents and mineral budget is now
adjustable in the cave generation procs, so maps may spawn with more or
less ore vents as desired for balance.
- Artifact boulders opens up a LOT of room for possible future content
like archaeology, xenoarch, artisci, and other design spaces!
- Megafauna STILL SPAWN ON THE MAP. They just happen to spawn in
addition to boss ore vents.
- **I'll add more to this as I get asked questions and remember things,
this is a huge PR and I'm confident I've missed at least something**

## Why It's Good For The Game

I outlined a lot of this in #78040, so I'll try and keep this relatively
snappy this time, while noting that I've made some concessions to make
the whole system a lot more playable while not trying to break out
design decisions that are at the end of the day, better for the game and
the overall resource balance in round.

Minerals are a very poorly balanced system, and have been since their
inception many years ago. We heavily rely on mineral balance in round,
and yet we've really only balanced it by introducing so much supply that
there's no equivalent exchange for materials that doesn't just heavily
flood the exchanged material. For example, items printed from materials
that are otherwise considered "rare" on master exist in such quantities
and they'll never practically run out in our allotted 90 minute time
slot design. This PR adjusts how ores spawn to a point where we can
minimize the amount of ores that need to exist on the map for mining to
be able to progress, while still providing enough resources for the
station that it covers the needs of the station adequately.

Miners will need to be more strategic about what resources they've
collected, and be able to make decisions about which vents are worth the
risk of attempting to fight, how to prepare for a wave defense, and when
to head back up for upgrades, while finally giving them at least some
kind of incentive to work together and use different equipment.
Resonators make cleaning up the caves around vent easy, sandbags set up
easy defenses for your vent, mechs can serve as a wider range radar
while mining, all while still providing a new gameplay loop to mining.

By limiting the amount of ores that can enter the round from the
massive, massive amounts that were coming into the round beforehand (see
#78346 ), we can make ore processing more meaningful by adding more
gameplay to the processing of minerals. I have some plans for that,
however this PR already got bloated really REALLY badly due to scope
creep and the number of intersecting systems that rammed into each other
to make this PR possible. So that'll be next. Plus, as I've mentioned,
we open up places for ore processing to find fossils, relics, and other
things that can implemented down the line.

Overall, I don't expect this PR to save or kill ore balance, but we gain
a LOT more control over it through the use of our mining defines
attached to this PR, and at the end of the day, that's a great place to
start off of.

## Changelog

:cl:
add: Added ore vents. Scanning them with mining scanners shows what
minerals they contain. Scan again to fight off a horde of beasts as your
drone assistant excavates the vent, so the ore vent will produce mineral
boulders!
bal: Ores that spawn in walls now spawn based on their proximity to ore
vents, with their chance to spawn and their minerals contained scaling
from low to high.
add: Added the BRM, Refinery, and Smelter. These pieces of equipment are
used to process ore boulders into minerals for the station. Stock Part
upgrades allow more boulders to be processed at one time. They collect
mining points as well, to be redeemed with an ID card swipe.
add: Boulders are teleported to the station via the BRM if left
untouched. Boulders can also be cracked open for a reduced amount of ore
using pickaxes or golems hands.
add: All stations come equipt with a pre-excavated ore vent, which
produces a basic supply of iron and glass only. Scan other vents for
your critical resources!
add: Look there's a shit ton of changes on mining, for more detail check
out the Pull Request: tgstation/tgstation#78524.
sound: New sounds and noises for your high octane factorio-like
gameplay!
image: All new boulder sprites for the new minerals and rocks added to
the mining gameplay loop, as well as mining machines!
image: Overlays appear over vents when scanned to let you know their
contents at a glance when actively scanned with any mining scanners.
/:cl:

---------

Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com>
Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com>
Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: Jacquerel <hnevard@gmail.com>
Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
Co-authored-by: Zytolg <33048583+Zytolg@users.noreply.github.com>
Erol509 pushed a commit to Erol509/Bubberstation that referenced this pull request Jan 30, 2024
This one's not like the last one, so much so that I'm not even going to
outsource the PR description to a robot this time!
Basically, **You should read the PR body before assuming that everything
is the same as last time. It's not.**

Click the link below to see a video summary of the main features of this
pull request.
https://youtu.be/Aho2omR0mjY?feature=shared

This pull request serves as a large rework of minerals produced by
mining, and by extension mining itself. I'll try and list each change
and it's associated nuance here.

The biggest addition to the game with ArcMining is **Ore Vents**. Ore
vents spawn as a ruin on the map, placing a randomized ore vent onto map
generation. Ore vents spawn in 3 different sizes, **Small, Medium, and
Large**. These vents will pick from a pool of materials they can
generate, and will hang out across the map. A player can use a mining
scanner to discover an ore vent, granting a small quantity of **mining
points** to begin with. Once scanned, ore vents will show what minerals
that ore vent will generate after they're fully tapped.

Scanning the vent again will trigger the extraction process. A small
drone will fly down, called the NODE drone, and buckle onto the vent.
Your job during wave defense is to protect the drone and to defeat waves
of randomly spawning mobs (dependent on if you're on lavaland or on
icebox). The quantity, duration, and time between waves is scaled to the
size of the vent you're protecting. Starting by scanning and protecting
lower tier vents earlier in the shift is a safer bet than doing a large
vent in the first few minutes. The drone has 500 health, and can take a
good few hits, but leaving it alone will cause it to meet an unfortunate
end quite quickly.

Cooperation can be your best asset, as mining with allies can greatly
help with wave defense, and mineral points are granted to anyone who
helps with defending the ore vent equally (So 500 * size tier,
regardless of how much help you receive). Once complete, the ore vent
will have a mining machine constructed on top of it, and will start to
dredge up **Boulders** from the earth automatically. More on boulders
later.

Ore vents can be located based on your mining scanner, and will provide
an appropriate audio cue based on if the ore vent has been discovered or
not, and once processed will no longer alert you to it's presence.

**Each station comes with a free vent that produces exclusively iron and
glass, free of charge.** This is to help with shifts where the station
may not have shaft miners to produce minerals, and to provide the
station with a baseline amount of minerals where none may exist
otherwise.

Mineral generation has been completely reworked. Previously, Mineral
Generation had a flat 13% spawn rate in-game. Once minerals spawned,
they would also have a chance to propagate their minerals to nearby
tiles, resulting in a rather massive pool of minerals that could spawn
throughout lavaland on the whole.

This tweaks that, by making minerals in walls spawn based on their
proximity to ore vents on maps that use cave generation. Both the
probability, and quantity of ores spawning in walls is scaled based on
distance, with ore vents looking like large caches of ores found in
walls. This makes following ores found in walls and checking their
quantity of minerals spawned a good indicator of how close you are to a
nearby vent in-round.

This means you can collect some points form both discovering ore vents
first, as well as collecting their surrounding ores, turn those in for
mining points, and then trading them in for gear upgrades to more
effectively take on ore vents. As a result of tweaking the balance of
this, the total amount of ores spawned in walls overall has been
decreased. However, by making more of the process time based, we still
result in a mostly balanced finished product.

On station, there are now three new machines. These are the BRM, the
Refinery, and the Smelter.

- The BRM acts as a teleporter. Instead of needing to carry boulders
back to the station, you can activate the BRM, and it will automatically
pick boulders to teleport back to itself. You can use this to teleport
boulders dredged up from lavaland onto the station for processing. **The
BRM will only lock on to boulders that are resting on an ore vent.**
Moving boulders back by hand will mean you'll have to haul it back by
hand.
- The refinery processes the non-metallic materials out of boulders.
This process sends the materials straight to the ORM, and collects
mining points from the ores smelted in the machine. Swiping with an ID
card lets you withdraw those points for your own personal account, but
remember that these points are for your whole team to share from. The
**Mining points obtained from this process is only 75% of the amount an
equivalent amount of ores would provide.**
- The smelter works nearly identically, however the smelter produces
metallic materials out of boulders instead.
- Once a boulder has had all of it's materials extracted, it's broken
down and deleted from the line. Otherwise, the boulder is spat out for
the next machine to process it (either the refinery or smelter).
- Once there's no minerals left in a boulder of any type, the refinery
or smelter will break the boulder down.
- Boulders **do not stack onto tiles with each other**, so they'll block
each other when pulled or when moving on a conveyor belt.

Boulders can also be processed by hand. Using a mining tool on a boulder
with right click will allow you to break down a boulder into it's
composite ores, but limits you to a maximum of 10 ore per boulder, where
the full amount can be extracted using the proper processing machines.
Also, processing by hand does deal small amounts of stamina damage over
time, do breaking a full large boulder can be particularly taxing.

Additional Boulder Processing Machines can be built, with the BRM board
being obtained from the Protolathe, while the Smelter and Refinery
boards being obtainable from the Autolathe instead. A _boulder
processing beacon_ can also be obtained from the mining points vendor as
a reward to assist with boulder processing. Boulder processing beacons
can be used to spawn in a new BRM, refinery, and smelter on the tile the
user is standing on, however **you'll still need to link them to the
ORM**!

All three machines can be upgraded with Stock Parts, allowing for **more
boulders to be processed at a time**. It does not, however, increase the
amount of minerals received from boulders, or points earned.

Mining borgs have been given some minor adjustments to compensate for
the changes to mining. Their mineral scanner, which now has an active
component to gameplay, is now a module as opposed to built into the mob.
This module allows for the same ability to discover and start waves of
monsters to fight.

Mining modules will find that their PKA now has a total of 90% mod
capacity as compared to the 80% they had before, to allow for more
robust defense of ore vents.

In addition, all borgs and AIs can interact with the BRM for boulder
collection.

Mining Mechs have had their utility tweaked as a result of these changes
as well. Mineral scanners to be used on mining mechs now have a larger
radius by comparison to their handheld cousins. Similarly, it now has an
active scanning button, which will actively discovery nearby ore vents.
To begin wave defense, you will need to hop out and scan a second time
however, so that you can properly accept the risks of drawing a horde of
bloodthirsty wildlife towards you and your companions.

Mechs can also manually process boulders, similar to mining tools using
their drill.

Golems, being more gentle and less aggressive than humans, while being
made out of LITERAL ROCKS, have a greater need to secure access to ores
and minerals to eat. As such, they have adapted to be able to do two new
things:

- Golems may now right click ore vents to be able to manually haul a
boulder out of the vent. This costs a hefty amount of stamina, but it
allows for golems to avoid combat during regular gameplay.
- Golems may now left click a boulder with an open hand in order to
manually process a boulder like a pickaxe. While not faster, it is
consistent and prevents golems from starving if they have access to a
vent, but no ores, somehow.

The labor camp, being a camp for rehabilitation and ~~excessive manual
labor~~ has been tweaked. Boulders now replace the random minerals
located on their island, and to acquire their prizes inside, much be
excavated and then broken out of the rock. Now YOU TOO can excavate
minerals and become a true mineral hero by working your way to freedom.

As a result of fewer mining points being available across the map due to
the new ore spawning mechanics, and the shift in how and when ores will
be coming in, almost every progress based mining point cost has been
reduced by around 10-20%. Many numbers are still subject to change at
present, but the idea is that core progress unlocks should be made a bit
more available earlier in the round before players can start to solo or
duo larger or more difficult ore vents, after which they'll be rolling
in ores.

Every once in awhile, an unusual boulder will get hauled up from the
mineral rich depths of lavaland. These **Artifact boulders** can
occasionally produce rare items, but for now they've mostly just been
pulling up **Strange objects** for science. Nanotrasen Natural Sciences
department will reward you extra points to be collected by boulder
processing machines for successfully extracting one. In the future, this
opens up a passive reward space that mining can reward to the station,
like providing cytology DNA samples, ancient seeds, or other artifacts.

- Boulders can be stored in all varieties of ore boxes (ground, mech)
should you choose, however as mentioned it's best to leave them where
they spawn and teleport them to the station for convenience.
- Maps that are not subject to cave generation will find that they are
largely untouched in terms of mineral balance.
- Future or existing ruins can now be tweaked to have a mineral balance
cost, as the ore vent ruin does. This will allow us to spawn in more
interesting ruins for pre-made combat challenges.
- There are unique ore vents that spawn across the map, that will summon
a boss mob relevant to that map. If the boss mob is defeated, that vent
will spawn large boulders pulling from every possible ore type that can
spawn. Not for the faint of heart!
- Similarly, the number of ore vents and mineral budget is now
adjustable in the cave generation procs, so maps may spawn with more or
less ore vents as desired for balance.
- Artifact boulders opens up a LOT of room for possible future content
like archaeology, xenoarch, artisci, and other design spaces!
- Megafauna STILL SPAWN ON THE MAP. They just happen to spawn in
addition to boss ore vents.
- **I'll add more to this as I get asked questions and remember things,
this is a huge PR and I'm confident I've missed at least something**

I outlined a lot of this in #78040, so I'll try and keep this relatively
snappy this time, while noting that I've made some concessions to make
the whole system a lot more playable while not trying to break out
design decisions that are at the end of the day, better for the game and
the overall resource balance in round.

Minerals are a very poorly balanced system, and have been since their
inception many years ago. We heavily rely on mineral balance in round,
and yet we've really only balanced it by introducing so much supply that
there's no equivalent exchange for materials that doesn't just heavily
flood the exchanged material. For example, items printed from materials
that are otherwise considered "rare" on master exist in such quantities
and they'll never practically run out in our allotted 90 minute time
slot design. This PR adjusts how ores spawn to a point where we can
minimize the amount of ores that need to exist on the map for mining to
be able to progress, while still providing enough resources for the
station that it covers the needs of the station adequately.

Miners will need to be more strategic about what resources they've
collected, and be able to make decisions about which vents are worth the
risk of attempting to fight, how to prepare for a wave defense, and when
to head back up for upgrades, while finally giving them at least some
kind of incentive to work together and use different equipment.
Resonators make cleaning up the caves around vent easy, sandbags set up
easy defenses for your vent, mechs can serve as a wider range radar
while mining, all while still providing a new gameplay loop to mining.

By limiting the amount of ores that can enter the round from the
massive, massive amounts that were coming into the round beforehand (see
gameplay to the processing of minerals. I have some plans for that,
however this PR already got bloated really REALLY badly due to scope
creep and the number of intersecting systems that rammed into each other
to make this PR possible. So that'll be next. Plus, as I've mentioned,
we open up places for ore processing to find fossils, relics, and other
things that can implemented down the line.

Overall, I don't expect this PR to save or kill ore balance, but we gain
a LOT more control over it through the use of our mining defines
attached to this PR, and at the end of the day, that's a great place to
start off of.

:cl:
add: Added ore vents. Scanning them with mining scanners shows what
minerals they contain. Scan again to fight off a horde of beasts as your
drone assistant excavates the vent, so the ore vent will produce mineral
boulders!
bal: Ores that spawn in walls now spawn based on their proximity to ore
vents, with their chance to spawn and their minerals contained scaling
from low to high.
add: Added the BRM, Refinery, and Smelter. These pieces of equipment are
used to process ore boulders into minerals for the station. Stock Part
upgrades allow more boulders to be processed at one time. They collect
mining points as well, to be redeemed with an ID card swipe.
add: Boulders are teleported to the station via the BRM if left
untouched. Boulders can also be cracked open for a reduced amount of ore
using pickaxes or golems hands.
add: All stations come equipt with a pre-excavated ore vent, which
produces a basic supply of iron and glass only. Scan other vents for
your critical resources!
add: Look there's a shit ton of changes on mining, for more detail check
out the Pull Request: tgstation/tgstation#78524.
sound: New sounds and noises for your high octane factorio-like
gameplay!
image: All new boulder sprites for the new minerals and rocks added to
the mining gameplay loop, as well as mining machines!
image: Overlays appear over vents when scanned to let you know their
contents at a glance when actively scanned with any mining scanners.
/:cl:

---------

Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com>
Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: Jacquerel <hnevard@gmail.com>
Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
Ghommie added a commit that referenced this pull request Feb 18, 2024
## About The Pull Request
**1. Qol**
- Adds screen tips & examines for screwdriver & crowbar acts on BRM,
Refinery & Smelter
- Adds examines to display number of boulders stored inside a refinery &
maximum number of boulders it can hold. Right click screentip to remove
boulders
- Adds examines to display maximum number of boulders than can be
teleported by a BRM & screentips for interacting with wires
- More audio & visual feedback for refinery processing. If a boulder
requires multiple steps you will get a balloon alert saying "crushing"
for refineries & "smelting" for smelters along with a sound per process
tick(which is every 2 seconds so no need for cooldown) giving you a
better idea of what's happening in the pipeline
- BRM now will display all lights when the "Automatic boulder retrieval"
is on & turn off the lights when disabled along with examines giving you
a visual indicator of its state

**2. Code Improvements**
- Splits types of boulders into its own file `boulder_types.dm` for easy
maintainability
- Moves beacon for refinery machines into its own file
`boulder_processing/beacon.dm` for easy maintainability
- Moves the cooldown for processing a boulder `processing_cooldown` into
the refinery machine itself. Since 100's of boulders can be created per
round this var can take up memory quickly so by moving them into the
refinery machine it gives us some savings
- Compressed & merged procs such as `create_mineral_contents()` ,
`flavour_boulder()` etc with the vent code. These procs were only used
by the vent 1 time & by merging the code we removed if conditions to
check if a parent vent was passed or not(since now that's always the
case). Helped in removing boilder plate code

**3. Fixes**
- **Fixes vents always spawning "Small size boulders" & not medium, nor
large boulders.**
 Once a vent generates a boulder it calls  `flavour_boulder()`

https://github.com/tgstation/tgstation/blob/084f56938c0169aeeee0b5f41453f31d072f3f67/code/game/objects/structures/lavaland/ore_vent.dm#L385
however this proc also accepts 2 more params `size` which would always
default to `BOULDER_SIZE_SMALL` and `is_artifact` which is simply unused
in the proc

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L219
Therefore vents would always generate small boulders giving us no
varity. Now the boulder size is set depending on the vent size &
durability for each boulder is set to a random value between 2 & the
boulder max size giving us the flavour we actually wanted

- **Fixes "Expanded Gulag boulders" using "normal gulag material list"
when setting its custom materials.**
If you look at the `add_gulag_minerals()` proc it always picks from the
`gulag_minerals` list & accepts no params

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L235-L236
So when we try to pass params to this proc which in reality doesn't
accept any we were wasting our time doing this

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L274
And for our case `expanded_gulag_minerals` list was simply unused
because our proc doesn't care about it and it went back to just using
`gulag_minerals` list thus ignoring our list

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L282
As i said in the "Code Improvement` section when i moved boulder types
into it's own unique file this was fixed & now expanded gulag boulders
actually has a chance to spawn with bluespace crystals inside them

- **Fixes manual tapping of ore vents by hand not using a cooldown**
`produce_boulder()` accepts a cooldown var for when you need to manually
tap the vent by hand.

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L374
This var was always set to FALSE because we never passed `TRUE` into it.
Not once here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L124
Nor here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L131
Now we just pass `TRUE` so tapping these vents by hand have a cooldown

- **Fixes BRM off icon state never being used**
When the room ran out of power it would still look on. Now we use that
state correctly

- **Fixes Automatic Boulder Retrieval by the BRM not actually being
automatic**
You must have noticed that once you do "Right click" and wait for all
the boulders it can teleport (determined by `boulder_processing_max`) to
be teleported it stops permanently after that. Even if more boulders get
generated it won't do anything, You have to again "Right click" &
retoggle automatic boulder retrieval on again, thus forcing someone to
stand there & monitor the BRM

Now once you set Automatic Boulder Retrieval on you can leave & forget.
It will teleport boulders as & when available thus enabling automation
properly.

- **Fixes boulders ejected from refineries via right click from getting
teleported back into the machines loc**
Fixes
#78524 (comment).
The problem is refinery machines & the BRM keep track of all the
boulders that entered into it via the `boulders_contained` list.

Now we directly check `contents` for boulders so we don't have to
maintain 2 seperate lists to keep track of boulders. It also now uses
`processed_by` var of boulders to ensure refinerries don't retake in the
same boulder it just processed. Not sure where exactly the problem got
fixed but implementing these 2 measures fixed it regardless.

- **Fixes boulders with 0 durability[a.k.a steps] from getting ejected
out**
Fixes
#78524 (comment).
So inside `process()` we constantly decrease the durability of the
boulder till it becomes 0.

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L159

  When it reaches 0 it calls `breakdown_boulder()`

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L164-L165

This proc has a chance to reject the boulder if it could not process any
materials

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L219-L222
  
  **"Without resetting its durability"** over here

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L241

So it ends up rejecting a "0" or worse -1 durability boulder. Now we set
the durability in `remove_boulder()` so regardless of what circumstances
the boulder is ejected it always gets a positive durability

- **Fixes BRM & Refinery from rapidly spitting out boulders in their loc
which causes lag in the long terms**
Fixes #81404. Basically even if there is 1 boulder sitting at a BRM's
loc or an refineries loc. Operations are haulted i.e. the BRM will not
teleport any more boulders & the refinery will keep their already
processed boulders inside till their locs are cleared from boulders.
This prevents large number of boulders from pilling up in long rounds

- **[Priority : High] Fixes refineries incorrectly removing materials
from processed boulders**
Fixes #81109. This bug is quite serious because it can't literarily
affect any random item with custom materials in game. This one line of
code over here can break the entire material economy as we know it

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L217
  
**"DONT DO THIS"**. The `custom_materials` list is a **"read only"**
list & if you ever want to change it call the `set_custom_materials()`
proc with your new values but do not edit this list manually as it is
done here.
  
All lists related to materials are cached by the `SSmaterials`
subsystem. List values are cached & shared across multiple objects so
when you edit those values like here, you might end up effecting an
item/multiple items in some random corner of the map that shares this
list.

This also causes boulders with empty list of materials to get spawned at
random so yeah again plzz don't do this

**4. Refactors**
- Repathes `obj/machinery/boulder_processing/brm` -> just
`obj/machinery/brm`.
Even though semantically it looks nice that the brm is a subtype of
`obj/machinery/boulder_processing` from a code & operation perspective
they have 0 similarities.

1) The BRM does not accept boulders feed into it from a conveyer belt
unlike a refinery but instead picks boulders from `SSore` subsystem &
put it on the conveyer belt. This means procs for accepting boulders
such `CanAllowThrough()`, `breakdown_boulder()`, `accept_boulder()` etc
have no use in the BRM. Their just code clutter at this point
2) The BRM overrides `process()` & does not call its parent proc making
that code wasted
3) It has no use for silo materials & mining points making those vars go
to waste

With so much wasted code its better to just let go off all of it & just
make it a basic instance of `obj/machinery` making maintainence easy

- BRM now teleports boulders in a batch (batch size determined by
`boulders_processing_max` max value from upgraded parts is 7) with a
boulder appearing every 1.5 seconds rather than spawning all at once.
After a batch is processed it has a cooldown of 3 seconds before
repeating the process if automatic boulder retrieval is on. This stops
the conveyer belt from getting crowded with boulders and makes the
refining process more efficient.

With this BRM wires are removed because only it had only 1 wire
responsible for toggling boulder retrieval but now since this process is
automatic, we have true control over the timing of boulders spawned &
don't want to leave it in the hands of players

## Changelog
:cl:
qol: adds examines & screentips for crowbar, screwdriver acts to BRM &
refinery machines
qol: adds examines about the number of boulders stored & processed to
BRM & refinery machines
qol: BRM now has its lights turn on/off depending on wether automatic
boulder retrieval is on/off for visual clarity along with examines
qol: refinery machines now display ballon alerts & plays sounds more
frequently when processing boulders for better feedback
fix: vents now spawn boulders of all sizes & not just small ones
fix: expanded gulag boulders now have correct materials in them.
fix: manual tapping of vents now has a cooldown applied as intended.
fix: BRM has its light turned off when area power goes off
fix: boulders ejected from refineries by hand no longer teleport all
over the place occasionally.
fix: refineries no longer eject boulders with 0 durability
fix: Boulders & refineries no longer pile up on top of BRM's &
refineries in long rounds. Their locs have to be clear of boulders
before they spit out more boulders to prevent a large pile of boulders
from causing lag
fix: sheets ejected from lathes no longer get rejected when inserted
back which could happen at random, no more boulders with empty materials
code: splits boulder types into its own file along with other items
code: merges & autodocs procs, vars related to boulders
refactor: repaths BRM to a simpler subtype
refactor: BRM now spawns boulders in batches(batch size can be increased
with upgraded parts) with a boulder appearing every second. After a
batch is processed a 3 second cooldown is applied to stop the conveyer
belt from clogging up, With this BRM wires are removed as there is no
need for timers to be attached to wires which intefers without our batch
processing timings.
/:cl:

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
NovaBot13 pushed a commit to NovaSector/NovaSector that referenced this pull request Feb 18, 2024
## About The Pull Request
**1. Qol**
- Adds screen tips & examines for screwdriver & crowbar acts on BRM,
Refinery & Smelter
- Adds examines to display number of boulders stored inside a refinery &
maximum number of boulders it can hold. Right click screentip to remove
boulders
- Adds examines to display maximum number of boulders than can be
teleported by a BRM & screentips for interacting with wires
- More audio & visual feedback for refinery processing. If a boulder
requires multiple steps you will get a balloon alert saying "crushing"
for refineries & "smelting" for smelters along with a sound per process
tick(which is every 2 seconds so no need for cooldown) giving you a
better idea of what's happening in the pipeline
- BRM now will display all lights when the "Automatic boulder retrieval"
is on & turn off the lights when disabled along with examines giving you
a visual indicator of its state

**2. Code Improvements**
- Splits types of boulders into its own file `boulder_types.dm` for easy
maintainability
- Moves beacon for refinery machines into its own file
`boulder_processing/beacon.dm` for easy maintainability
- Moves the cooldown for processing a boulder `processing_cooldown` into
the refinery machine itself. Since 100's of boulders can be created per
round this var can take up memory quickly so by moving them into the
refinery machine it gives us some savings
- Compressed & merged procs such as `create_mineral_contents()` ,
`flavour_boulder()` etc with the vent code. These procs were only used
by the vent 1 time & by merging the code we removed if conditions to
check if a parent vent was passed or not(since now that's always the
case). Helped in removing boilder plate code

**3. Fixes**
- **Fixes vents always spawning "Small size boulders" & not medium, nor
large boulders.**
 Once a vent generates a boulder it calls  `flavour_boulder()`

https://github.com/tgstation/tgstation/blob/084f56938c0169aeeee0b5f41453f31d072f3f67/code/game/objects/structures/lavaland/ore_vent.dm#L385
however this proc also accepts 2 more params `size` which would always
default to `BOULDER_SIZE_SMALL` and `is_artifact` which is simply unused
in the proc

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L219
Therefore vents would always generate small boulders giving us no
varity. Now the boulder size is set depending on the vent size &
durability for each boulder is set to a random value between 2 & the
boulder max size giving us the flavour we actually wanted

- **Fixes "Expanded Gulag boulders" using "normal gulag material list"
when setting its custom materials.**
If you look at the `add_gulag_minerals()` proc it always picks from the
`gulag_minerals` list & accepts no params

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L235-L236
So when we try to pass params to this proc which in reality doesn't
accept any we were wasting our time doing this

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L274
And for our case `expanded_gulag_minerals` list was simply unused
because our proc doesn't care about it and it went back to just using
`gulag_minerals` list thus ignoring our list

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L282
As i said in the "Code Improvement` section when i moved boulder types
into it's own unique file this was fixed & now expanded gulag boulders
actually has a chance to spawn with bluespace crystals inside them

- **Fixes manual tapping of ore vents by hand not using a cooldown**
`produce_boulder()` accepts a cooldown var for when you need to manually
tap the vent by hand.

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L374
This var was always set to FALSE because we never passed `TRUE` into it.
Not once here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L124
Nor here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L131
Now we just pass `TRUE` so tapping these vents by hand have a cooldown

- **Fixes BRM off icon state never being used**
When the room ran out of power it would still look on. Now we use that
state correctly

- **Fixes Automatic Boulder Retrieval by the BRM not actually being
automatic**
You must have noticed that once you do "Right click" and wait for all
the boulders it can teleport (determined by `boulder_processing_max`) to
be teleported it stops permanently after that. Even if more boulders get
generated it won't do anything, You have to again "Right click" &
retoggle automatic boulder retrieval on again, thus forcing someone to
stand there & monitor the BRM

Now once you set Automatic Boulder Retrieval on you can leave & forget.
It will teleport boulders as & when available thus enabling automation
properly.

- **Fixes boulders ejected from refineries via right click from getting
teleported back into the machines loc**
Fixes
tgstation/tgstation#78524 (comment).
The problem is refinery machines & the BRM keep track of all the
boulders that entered into it via the `boulders_contained` list.

Now we directly check `contents` for boulders so we don't have to
maintain 2 seperate lists to keep track of boulders. It also now uses
`processed_by` var of boulders to ensure refinerries don't retake in the
same boulder it just processed. Not sure where exactly the problem got
fixed but implementing these 2 measures fixed it regardless.

- **Fixes boulders with 0 durability[a.k.a steps] from getting ejected
out**
Fixes
tgstation/tgstation#78524 (comment).
So inside `process()` we constantly decrease the durability of the
boulder till it becomes 0.

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L159

  When it reaches 0 it calls `breakdown_boulder()`

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L164-L165

This proc has a chance to reject the boulder if it could not process any
materials

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L219-L222
  
  **"Without resetting its durability"** over here

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L241

So it ends up rejecting a "0" or worse -1 durability boulder. Now we set
the durability in `remove_boulder()` so regardless of what circumstances
the boulder is ejected it always gets a positive durability

- **Fixes BRM & Refinery from rapidly spitting out boulders in their loc
which causes lag in the long terms**
Fixes #81404. Basically even if there is 1 boulder sitting at a BRM's
loc or an refineries loc. Operations are haulted i.e. the BRM will not
teleport any more boulders & the refinery will keep their already
processed boulders inside till their locs are cleared from boulders.
This prevents large number of boulders from pilling up in long rounds

- **[Priority : High] Fixes refineries incorrectly removing materials
from processed boulders**
Fixes #81109. This bug is quite serious because it can't literarily
affect any random item with custom materials in game. This one line of
code over here can break the entire material economy as we know it

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L217
  
**"DONT DO THIS"**. The `custom_materials` list is a **"read only"**
list & if you ever want to change it call the `set_custom_materials()`
proc with your new values but do not edit this list manually as it is
done here.
  
All lists related to materials are cached by the `SSmaterials`
subsystem. List values are cached & shared across multiple objects so
when you edit those values like here, you might end up effecting an
item/multiple items in some random corner of the map that shares this
list.

This also causes boulders with empty list of materials to get spawned at
random so yeah again plzz don't do this

**4. Refactors**
- Repathes `obj/machinery/boulder_processing/brm` -> just
`obj/machinery/brm`.
Even though semantically it looks nice that the brm is a subtype of
`obj/machinery/boulder_processing` from a code & operation perspective
they have 0 similarities.

1) The BRM does not accept boulders feed into it from a conveyer belt
unlike a refinery but instead picks boulders from `SSore` subsystem &
put it on the conveyer belt. This means procs for accepting boulders
such `CanAllowThrough()`, `breakdown_boulder()`, `accept_boulder()` etc
have no use in the BRM. Their just code clutter at this point
2) The BRM overrides `process()` & does not call its parent proc making
that code wasted
3) It has no use for silo materials & mining points making those vars go
to waste

With so much wasted code its better to just let go off all of it & just
make it a basic instance of `obj/machinery` making maintainence easy

- BRM now teleports boulders in a batch (batch size determined by
`boulders_processing_max` max value from upgraded parts is 7) with a
boulder appearing every 1.5 seconds rather than spawning all at once.
After a batch is processed it has a cooldown of 3 seconds before
repeating the process if automatic boulder retrieval is on. This stops
the conveyer belt from getting crowded with boulders and makes the
refining process more efficient.

With this BRM wires are removed because only it had only 1 wire
responsible for toggling boulder retrieval but now since this process is
automatic, we have true control over the timing of boulders spawned &
don't want to leave it in the hands of players

## Changelog
:cl:
qol: adds examines & screentips for crowbar, screwdriver acts to BRM &
refinery machines
qol: adds examines about the number of boulders stored & processed to
BRM & refinery machines
qol: BRM now has its lights turn on/off depending on wether automatic
boulder retrieval is on/off for visual clarity along with examines
qol: refinery machines now display ballon alerts & plays sounds more
frequently when processing boulders for better feedback
fix: vents now spawn boulders of all sizes & not just small ones
fix: expanded gulag boulders now have correct materials in them.
fix: manual tapping of vents now has a cooldown applied as intended.
fix: BRM has its light turned off when area power goes off
fix: boulders ejected from refineries by hand no longer teleport all
over the place occasionally.
fix: refineries no longer eject boulders with 0 durability
fix: Boulders & refineries no longer pile up on top of BRM's &
refineries in long rounds. Their locs have to be clear of boulders
before they spit out more boulders to prevent a large pile of boulders
from causing lag
fix: sheets ejected from lathes no longer get rejected when inserted
back which could happen at random, no more boulders with empty materials
code: splits boulder types into its own file along with other items
code: merges & autodocs procs, vars related to boulders
refactor: repaths BRM to a simpler subtype
refactor: BRM now spawns boulders in batches(batch size can be increased
with upgraded parts) with a boulder appearing every second. After a
batch is processed a 3 second cooldown is applied to stop the conveyer
belt from clogging up, With this BRM wires are removed as there is no
need for timers to be attached to wires which intefers without our batch
processing timings.
/:cl:

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
lessthnthree pushed a commit to effigy-se/effigy-se that referenced this pull request Feb 18, 2024
## About The Pull Request
**1. Qol**
- Adds screen tips & examines for screwdriver & crowbar acts on BRM,
Refinery & Smelter
- Adds examines to display number of boulders stored inside a refinery &
maximum number of boulders it can hold. Right click screentip to remove
boulders
- Adds examines to display maximum number of boulders than can be
teleported by a BRM & screentips for interacting with wires
- More audio & visual feedback for refinery processing. If a boulder
requires multiple steps you will get a balloon alert saying "crushing"
for refineries & "smelting" for smelters along with a sound per process
tick(which is every 2 seconds so no need for cooldown) giving you a
better idea of what's happening in the pipeline
- BRM now will display all lights when the "Automatic boulder retrieval"
is on & turn off the lights when disabled along with examines giving you
a visual indicator of its state

**2. Code Improvements**
- Splits types of boulders into its own file `boulder_types.dm` for easy
maintainability
- Moves beacon for refinery machines into its own file
`boulder_processing/beacon.dm` for easy maintainability
- Moves the cooldown for processing a boulder `processing_cooldown` into
the refinery machine itself. Since 100's of boulders can be created per
round this var can take up memory quickly so by moving them into the
refinery machine it gives us some savings
- Compressed & merged procs such as `create_mineral_contents()` ,
`flavour_boulder()` etc with the vent code. These procs were only used
by the vent 1 time & by merging the code we removed if conditions to
check if a parent vent was passed or not(since now that's always the
case). Helped in removing boilder plate code

**3. Fixes**
- **Fixes vents always spawning "Small size boulders" & not medium, nor
large boulders.**
 Once a vent generates a boulder it calls  `flavour_boulder()`

https://github.com/tgstation/tgstation/blob/084f56938c0169aeeee0b5f41453f31d072f3f67/code/game/objects/structures/lavaland/ore_vent.dm#L385
however this proc also accepts 2 more params `size` which would always
default to `BOULDER_SIZE_SMALL` and `is_artifact` which is simply unused
in the proc

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L219
Therefore vents would always generate small boulders giving us no
varity. Now the boulder size is set depending on the vent size &
durability for each boulder is set to a random value between 2 & the
boulder max size giving us the flavour we actually wanted

- **Fixes "Expanded Gulag boulders" using "normal gulag material list"
when setting its custom materials.**
If you look at the `add_gulag_minerals()` proc it always picks from the
`gulag_minerals` list & accepts no params

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L235-L236
So when we try to pass params to this proc which in reality doesn't
accept any we were wasting our time doing this

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L274
And for our case `expanded_gulag_minerals` list was simply unused
because our proc doesn't care about it and it went back to just using
`gulag_minerals` list thus ignoring our list

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L282
As i said in the "Code Improvement` section when i moved boulder types
into it's own unique file this was fixed & now expanded gulag boulders
actually has a chance to spawn with bluespace crystals inside them

- **Fixes manual tapping of ore vents by hand not using a cooldown**
`produce_boulder()` accepts a cooldown var for when you need to manually
tap the vent by hand.

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L374
This var was always set to FALSE because we never passed `TRUE` into it.
Not once here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L124
Nor here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L131
Now we just pass `TRUE` so tapping these vents by hand have a cooldown

- **Fixes BRM off icon state never being used**
When the room ran out of power it would still look on. Now we use that
state correctly

- **Fixes Automatic Boulder Retrieval by the BRM not actually being
automatic**
You must have noticed that once you do "Right click" and wait for all
the boulders it can teleport (determined by `boulder_processing_max`) to
be teleported it stops permanently after that. Even if more boulders get
generated it won't do anything, You have to again "Right click" &
retoggle automatic boulder retrieval on again, thus forcing someone to
stand there & monitor the BRM

Now once you set Automatic Boulder Retrieval on you can leave & forget.
It will teleport boulders as & when available thus enabling automation
properly.

- **Fixes boulders ejected from refineries via right click from getting
teleported back into the machines loc**
Fixes
tgstation/tgstation#78524 (comment).
The problem is refinery machines & the BRM keep track of all the
boulders that entered into it via the `boulders_contained` list.

Now we directly check `contents` for boulders so we don't have to
maintain 2 seperate lists to keep track of boulders. It also now uses
`processed_by` var of boulders to ensure refinerries don't retake in the
same boulder it just processed. Not sure where exactly the problem got
fixed but implementing these 2 measures fixed it regardless.

- **Fixes boulders with 0 durability[a.k.a steps] from getting ejected
out**
Fixes
tgstation/tgstation#78524 (comment).
So inside `process()` we constantly decrease the durability of the
boulder till it becomes 0.

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L159

  When it reaches 0 it calls `breakdown_boulder()`

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L164-L165

This proc has a chance to reject the boulder if it could not process any
materials

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L219-L222
  
  **"Without resetting its durability"** over here

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L241

So it ends up rejecting a "0" or worse -1 durability boulder. Now we set
the durability in `remove_boulder()` so regardless of what circumstances
the boulder is ejected it always gets a positive durability

- **Fixes BRM & Refinery from rapidly spitting out boulders in their loc
which causes lag in the long terms**
Fixes #81404. Basically even if there is 1 boulder sitting at a BRM's
loc or an refineries loc. Operations are haulted i.e. the BRM will not
teleport any more boulders & the refinery will keep their already
processed boulders inside till their locs are cleared from boulders.
This prevents large number of boulders from pilling up in long rounds

- **[Priority : High] Fixes refineries incorrectly removing materials
from processed boulders**
Fixes #81109. This bug is quite serious because it can't literarily
affect any random item with custom materials in game. This one line of
code over here can break the entire material economy as we know it

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L217
  
**"DONT DO THIS"**. The `custom_materials` list is a **"read only"**
list & if you ever want to change it call the `set_custom_materials()`
proc with your new values but do not edit this list manually as it is
done here.
  
All lists related to materials are cached by the `SSmaterials`
subsystem. List values are cached & shared across multiple objects so
when you edit those values like here, you might end up effecting an
item/multiple items in some random corner of the map that shares this
list.

This also causes boulders with empty list of materials to get spawned at
random so yeah again plzz don't do this

**4. Refactors**
- Repathes `obj/machinery/boulder_processing/brm` -> just
`obj/machinery/brm`.
Even though semantically it looks nice that the brm is a subtype of
`obj/machinery/boulder_processing` from a code & operation perspective
they have 0 similarities.

1) The BRM does not accept boulders feed into it from a conveyer belt
unlike a refinery but instead picks boulders from `SSore` subsystem &
put it on the conveyer belt. This means procs for accepting boulders
such `CanAllowThrough()`, `breakdown_boulder()`, `accept_boulder()` etc
have no use in the BRM. Their just code clutter at this point
2) The BRM overrides `process()` & does not call its parent proc making
that code wasted
3) It has no use for silo materials & mining points making those vars go
to waste

With so much wasted code its better to just let go off all of it & just
make it a basic instance of `obj/machinery` making maintainence easy

- BRM now teleports boulders in a batch (batch size determined by
`boulders_processing_max` max value from upgraded parts is 7) with a
boulder appearing every 1.5 seconds rather than spawning all at once.
After a batch is processed it has a cooldown of 3 seconds before
repeating the process if automatic boulder retrieval is on. This stops
the conveyer belt from getting crowded with boulders and makes the
refining process more efficient.

With this BRM wires are removed because only it had only 1 wire
responsible for toggling boulder retrieval but now since this process is
automatic, we have true control over the timing of boulders spawned &
don't want to leave it in the hands of players

## Changelog
:cl:
qol: adds examines & screentips for crowbar, screwdriver acts to BRM &
refinery machines
qol: adds examines about the number of boulders stored & processed to
BRM & refinery machines
qol: BRM now has its lights turn on/off depending on wether automatic
boulder retrieval is on/off for visual clarity along with examines
qol: refinery machines now display ballon alerts & plays sounds more
frequently when processing boulders for better feedback
fix: vents now spawn boulders of all sizes & not just small ones
fix: expanded gulag boulders now have correct materials in them.
fix: manual tapping of vents now has a cooldown applied as intended.
fix: BRM has its light turned off when area power goes off
fix: boulders ejected from refineries by hand no longer teleport all
over the place occasionally.
fix: refineries no longer eject boulders with 0 durability
fix: Boulders & refineries no longer pile up on top of BRM's &
refineries in long rounds. Their locs have to be clear of boulders
before they spit out more boulders to prevent a large pile of boulders
from causing lag
fix: sheets ejected from lathes no longer get rejected when inserted
back which could happen at random, no more boulders with empty materials
code: splits boulder types into its own file along with other items
code: merges & autodocs procs, vars related to boulders
refactor: repaths BRM to a simpler subtype
refactor: BRM now spawns boulders in batches(batch size can be increased
with upgraded parts) with a boulder appearing every second. After a
batch is processed a 3 second cooldown is applied to stop the conveyer
belt from clogging up, With this BRM wires are removed as there is no
need for timers to be attached to wires which intefers without our batch
processing timings.
/:cl:

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
vinylspiders added a commit to NovaSector/NovaSector that referenced this pull request Feb 19, 2024
* General maintenance for all things boulder related. (#81358)

## About The Pull Request
**1. Qol**
- Adds screen tips & examines for screwdriver & crowbar acts on BRM,
Refinery & Smelter
- Adds examines to display number of boulders stored inside a refinery &
maximum number of boulders it can hold. Right click screentip to remove
boulders
- Adds examines to display maximum number of boulders than can be
teleported by a BRM & screentips for interacting with wires
- More audio & visual feedback for refinery processing. If a boulder
requires multiple steps you will get a balloon alert saying "crushing"
for refineries & "smelting" for smelters along with a sound per process
tick(which is every 2 seconds so no need for cooldown) giving you a
better idea of what's happening in the pipeline
- BRM now will display all lights when the "Automatic boulder retrieval"
is on & turn off the lights when disabled along with examines giving you
a visual indicator of its state

**2. Code Improvements**
- Splits types of boulders into its own file `boulder_types.dm` for easy
maintainability
- Moves beacon for refinery machines into its own file
`boulder_processing/beacon.dm` for easy maintainability
- Moves the cooldown for processing a boulder `processing_cooldown` into
the refinery machine itself. Since 100's of boulders can be created per
round this var can take up memory quickly so by moving them into the
refinery machine it gives us some savings
- Compressed & merged procs such as `create_mineral_contents()` ,
`flavour_boulder()` etc with the vent code. These procs were only used
by the vent 1 time & by merging the code we removed if conditions to
check if a parent vent was passed or not(since now that's always the
case). Helped in removing boilder plate code

**3. Fixes**
- **Fixes vents always spawning "Small size boulders" & not medium, nor
large boulders.**
 Once a vent generates a boulder it calls  `flavour_boulder()`

https://github.com/tgstation/tgstation/blob/084f56938c0169aeeee0b5f41453f31d072f3f67/code/game/objects/structures/lavaland/ore_vent.dm#L385
however this proc also accepts 2 more params `size` which would always
default to `BOULDER_SIZE_SMALL` and `is_artifact` which is simply unused
in the proc

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L219
Therefore vents would always generate small boulders giving us no
varity. Now the boulder size is set depending on the vent size &
durability for each boulder is set to a random value between 2 & the
boulder max size giving us the flavour we actually wanted

- **Fixes "Expanded Gulag boulders" using "normal gulag material list"
when setting its custom materials.**
If you look at the `add_gulag_minerals()` proc it always picks from the
`gulag_minerals` list & accepts no params

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L235-L236
So when we try to pass params to this proc which in reality doesn't
accept any we were wasting our time doing this

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L274
And for our case `expanded_gulag_minerals` list was simply unused
because our proc doesn't care about it and it went back to just using
`gulag_minerals` list thus ignoring our list

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L282
As i said in the "Code Improvement` section when i moved boulder types
into it's own unique file this was fixed & now expanded gulag boulders
actually has a chance to spawn with bluespace crystals inside them

- **Fixes manual tapping of ore vents by hand not using a cooldown**
`produce_boulder()` accepts a cooldown var for when you need to manually
tap the vent by hand.

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L374
This var was always set to FALSE because we never passed `TRUE` into it.
Not once here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L124
Nor here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L131
Now we just pass `TRUE` so tapping these vents by hand have a cooldown

- **Fixes BRM off icon state never being used**
When the room ran out of power it would still look on. Now we use that
state correctly

- **Fixes Automatic Boulder Retrieval by the BRM not actually being
automatic**
You must have noticed that once you do "Right click" and wait for all
the boulders it can teleport (determined by `boulder_processing_max`) to
be teleported it stops permanently after that. Even if more boulders get
generated it won't do anything, You have to again "Right click" &
retoggle automatic boulder retrieval on again, thus forcing someone to
stand there & monitor the BRM

Now once you set Automatic Boulder Retrieval on you can leave & forget.
It will teleport boulders as & when available thus enabling automation
properly.

- **Fixes boulders ejected from refineries via right click from getting
teleported back into the machines loc**
Fixes
tgstation/tgstation#78524 (comment).
The problem is refinery machines & the BRM keep track of all the
boulders that entered into it via the `boulders_contained` list.

Now we directly check `contents` for boulders so we don't have to
maintain 2 seperate lists to keep track of boulders. It also now uses
`processed_by` var of boulders to ensure refinerries don't retake in the
same boulder it just processed. Not sure where exactly the problem got
fixed but implementing these 2 measures fixed it regardless.

- **Fixes boulders with 0 durability[a.k.a steps] from getting ejected
out**
Fixes
tgstation/tgstation#78524 (comment).
So inside `process()` we constantly decrease the durability of the
boulder till it becomes 0.

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L159

  When it reaches 0 it calls `breakdown_boulder()`

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L164-L165

This proc has a chance to reject the boulder if it could not process any
materials

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L219-L222
  
  **"Without resetting its durability"** over here

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L241

So it ends up rejecting a "0" or worse -1 durability boulder. Now we set
the durability in `remove_boulder()` so regardless of what circumstances
the boulder is ejected it always gets a positive durability

- **Fixes BRM & Refinery from rapidly spitting out boulders in their loc
which causes lag in the long terms**
Fixes #81404. Basically even if there is 1 boulder sitting at a BRM's
loc or an refineries loc. Operations are haulted i.e. the BRM will not
teleport any more boulders & the refinery will keep their already
processed boulders inside till their locs are cleared from boulders.
This prevents large number of boulders from pilling up in long rounds

- **[Priority : High] Fixes refineries incorrectly removing materials
from processed boulders**
Fixes #81109. This bug is quite serious because it can't literarily
affect any random item with custom materials in game. This one line of
code over here can break the entire material economy as we know it

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L217
  
**"DONT DO THIS"**. The `custom_materials` list is a **"read only"**
list & if you ever want to change it call the `set_custom_materials()`
proc with your new values but do not edit this list manually as it is
done here.
  
All lists related to materials are cached by the `SSmaterials`
subsystem. List values are cached & shared across multiple objects so
when you edit those values like here, you might end up effecting an
item/multiple items in some random corner of the map that shares this
list.

This also causes boulders with empty list of materials to get spawned at
random so yeah again plzz don't do this

**4. Refactors**
- Repathes `obj/machinery/boulder_processing/brm` -> just
`obj/machinery/brm`.
Even though semantically it looks nice that the brm is a subtype of
`obj/machinery/boulder_processing` from a code & operation perspective
they have 0 similarities.

1) The BRM does not accept boulders feed into it from a conveyer belt
unlike a refinery but instead picks boulders from `SSore` subsystem &
put it on the conveyer belt. This means procs for accepting boulders
such `CanAllowThrough()`, `breakdown_boulder()`, `accept_boulder()` etc
have no use in the BRM. Their just code clutter at this point
2) The BRM overrides `process()` & does not call its parent proc making
that code wasted
3) It has no use for silo materials & mining points making those vars go
to waste

With so much wasted code its better to just let go off all of it & just
make it a basic instance of `obj/machinery` making maintainence easy

- BRM now teleports boulders in a batch (batch size determined by
`boulders_processing_max` max value from upgraded parts is 7) with a
boulder appearing every 1.5 seconds rather than spawning all at once.
After a batch is processed it has a cooldown of 3 seconds before
repeating the process if automatic boulder retrieval is on. This stops
the conveyer belt from getting crowded with boulders and makes the
refining process more efficient.

With this BRM wires are removed because only it had only 1 wire
responsible for toggling boulder retrieval but now since this process is
automatic, we have true control over the timing of boulders spawned &
don't want to leave it in the hands of players

## Changelog
:cl:
qol: adds examines & screentips for crowbar, screwdriver acts to BRM &
refinery machines
qol: adds examines about the number of boulders stored & processed to
BRM & refinery machines
qol: BRM now has its lights turn on/off depending on wether automatic
boulder retrieval is on/off for visual clarity along with examines
qol: refinery machines now display ballon alerts & plays sounds more
frequently when processing boulders for better feedback
fix: vents now spawn boulders of all sizes & not just small ones
fix: expanded gulag boulders now have correct materials in them.
fix: manual tapping of vents now has a cooldown applied as intended.
fix: BRM has its light turned off when area power goes off
fix: boulders ejected from refineries by hand no longer teleport all
over the place occasionally.
fix: refineries no longer eject boulders with 0 durability
fix: Boulders & refineries no longer pile up on top of BRM's &
refineries in long rounds. Their locs have to be clear of boulders
before they spit out more boulders to prevent a large pile of boulders
from causing lag
fix: sheets ejected from lathes no longer get rejected when inserted
back which could happen at random, no more boulders with empty materials
code: splits boulder types into its own file along with other items
code: merges & autodocs procs, vars related to boulders
refactor: repaths BRM to a simpler subtype
refactor: BRM now spawns boulders in batches(batch size can be increased
with upgraded parts) with a boulder appearing every second. After a
batch is processed a 3 second cooldown is applied to stop the conveyer
belt from clogging up, With this BRM wires are removed as there is no
need for timers to be attached to wires which intefers without our batch
processing timings.
/:cl:

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>

* General maintenance for all things boulder related.

* UpdatePaths

---------

Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
Co-authored-by: Mal <13398309+vinylspiders@users.noreply.github.com>
Iajret pushed a commit to Fluffy-Frontier/FluffySTG that referenced this pull request Feb 19, 2024
* General maintenance for all things boulder related. (#81358)

## About The Pull Request
**1. Qol**
- Adds screen tips & examines for screwdriver & crowbar acts on BRM,
Refinery & Smelter
- Adds examines to display number of boulders stored inside a refinery &
maximum number of boulders it can hold. Right click screentip to remove
boulders
- Adds examines to display maximum number of boulders than can be
teleported by a BRM & screentips for interacting with wires
- More audio & visual feedback for refinery processing. If a boulder
requires multiple steps you will get a balloon alert saying "crushing"
for refineries & "smelting" for smelters along with a sound per process
tick(which is every 2 seconds so no need for cooldown) giving you a
better idea of what's happening in the pipeline
- BRM now will display all lights when the "Automatic boulder retrieval"
is on & turn off the lights when disabled along with examines giving you
a visual indicator of its state

**2. Code Improvements**
- Splits types of boulders into its own file `boulder_types.dm` for easy
maintainability
- Moves beacon for refinery machines into its own file
`boulder_processing/beacon.dm` for easy maintainability
- Moves the cooldown for processing a boulder `processing_cooldown` into
the refinery machine itself. Since 100's of boulders can be created per
round this var can take up memory quickly so by moving them into the
refinery machine it gives us some savings
- Compressed & merged procs such as `create_mineral_contents()` ,
`flavour_boulder()` etc with the vent code. These procs were only used
by the vent 1 time & by merging the code we removed if conditions to
check if a parent vent was passed or not(since now that's always the
case). Helped in removing boilder plate code

**3. Fixes**
- **Fixes vents always spawning "Small size boulders" & not medium, nor
large boulders.**
 Once a vent generates a boulder it calls  `flavour_boulder()`

https://github.com/tgstation/tgstation/blob/084f56938c0169aeeee0b5f41453f31d072f3f67/code/game/objects/structures/lavaland/ore_vent.dm#L385
however this proc also accepts 2 more params `size` which would always
default to `BOULDER_SIZE_SMALL` and `is_artifact` which is simply unused
in the proc

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L219
Therefore vents would always generate small boulders giving us no
varity. Now the boulder size is set depending on the vent size &
durability for each boulder is set to a random value between 2 & the
boulder max size giving us the flavour we actually wanted

- **Fixes "Expanded Gulag boulders" using "normal gulag material list"
when setting its custom materials.**
If you look at the `add_gulag_minerals()` proc it always picks from the
`gulag_minerals` list & accepts no params

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L235-L236
So when we try to pass params to this proc which in reality doesn't
accept any we were wasting our time doing this

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L274
And for our case `expanded_gulag_minerals` list was simply unused
because our proc doesn't care about it and it went back to just using
`gulag_minerals` list thus ignoring our list

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L282
As i said in the "Code Improvement` section when i moved boulder types
into it's own unique file this was fixed & now expanded gulag boulders
actually has a chance to spawn with bluespace crystals inside them

- **Fixes manual tapping of ore vents by hand not using a cooldown**
`produce_boulder()` accepts a cooldown var for when you need to manually
tap the vent by hand.

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L374
This var was always set to FALSE because we never passed `TRUE` into it.
Not once here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L124
Nor here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L131
Now we just pass `TRUE` so tapping these vents by hand have a cooldown

- **Fixes BRM off icon state never being used**
When the room ran out of power it would still look on. Now we use that
state correctly

- **Fixes Automatic Boulder Retrieval by the BRM not actually being
automatic**
You must have noticed that once you do "Right click" and wait for all
the boulders it can teleport (determined by `boulder_processing_max`) to
be teleported it stops permanently after that. Even if more boulders get
generated it won't do anything, You have to again "Right click" &
retoggle automatic boulder retrieval on again, thus forcing someone to
stand there & monitor the BRM

Now once you set Automatic Boulder Retrieval on you can leave & forget.
It will teleport boulders as & when available thus enabling automation
properly.

- **Fixes boulders ejected from refineries via right click from getting
teleported back into the machines loc**
Fixes
tgstation/tgstation#78524 (comment).
The problem is refinery machines & the BRM keep track of all the
boulders that entered into it via the `boulders_contained` list.

Now we directly check `contents` for boulders so we don't have to
maintain 2 seperate lists to keep track of boulders. It also now uses
`processed_by` var of boulders to ensure refinerries don't retake in the
same boulder it just processed. Not sure where exactly the problem got
fixed but implementing these 2 measures fixed it regardless.

- **Fixes boulders with 0 durability[a.k.a steps] from getting ejected
out**
Fixes
tgstation/tgstation#78524 (comment).
So inside `process()` we constantly decrease the durability of the
boulder till it becomes 0.

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L159

  When it reaches 0 it calls `breakdown_boulder()`

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L164-L165

This proc has a chance to reject the boulder if it could not process any
materials

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L219-L222
  
  **"Without resetting its durability"** over here

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L241

So it ends up rejecting a "0" or worse -1 durability boulder. Now we set
the durability in `remove_boulder()` so regardless of what circumstances
the boulder is ejected it always gets a positive durability

- **Fixes BRM & Refinery from rapidly spitting out boulders in their loc
which causes lag in the long terms**
Fixes #81404. Basically even if there is 1 boulder sitting at a BRM's
loc or an refineries loc. Operations are haulted i.e. the BRM will not
teleport any more boulders & the refinery will keep their already
processed boulders inside till their locs are cleared from boulders.
This prevents large number of boulders from pilling up in long rounds

- **[Priority : High] Fixes refineries incorrectly removing materials
from processed boulders**
Fixes #81109. This bug is quite serious because it can't literarily
affect any random item with custom materials in game. This one line of
code over here can break the entire material economy as we know it

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L217
  
**"DONT DO THIS"**. The `custom_materials` list is a **"read only"**
list & if you ever want to change it call the `set_custom_materials()`
proc with your new values but do not edit this list manually as it is
done here.
  
All lists related to materials are cached by the `SSmaterials`
subsystem. List values are cached & shared across multiple objects so
when you edit those values like here, you might end up effecting an
item/multiple items in some random corner of the map that shares this
list.

This also causes boulders with empty list of materials to get spawned at
random so yeah again plzz don't do this

**4. Refactors**
- Repathes `obj/machinery/boulder_processing/brm` -> just
`obj/machinery/brm`.
Even though semantically it looks nice that the brm is a subtype of
`obj/machinery/boulder_processing` from a code & operation perspective
they have 0 similarities.

1) The BRM does not accept boulders feed into it from a conveyer belt
unlike a refinery but instead picks boulders from `SSore` subsystem &
put it on the conveyer belt. This means procs for accepting boulders
such `CanAllowThrough()`, `breakdown_boulder()`, `accept_boulder()` etc
have no use in the BRM. Their just code clutter at this point
2) The BRM overrides `process()` & does not call its parent proc making
that code wasted
3) It has no use for silo materials & mining points making those vars go
to waste

With so much wasted code its better to just let go off all of it & just
make it a basic instance of `obj/machinery` making maintainence easy

- BRM now teleports boulders in a batch (batch size determined by
`boulders_processing_max` max value from upgraded parts is 7) with a
boulder appearing every 1.5 seconds rather than spawning all at once.
After a batch is processed it has a cooldown of 3 seconds before
repeating the process if automatic boulder retrieval is on. This stops
the conveyer belt from getting crowded with boulders and makes the
refining process more efficient.

With this BRM wires are removed because only it had only 1 wire
responsible for toggling boulder retrieval but now since this process is
automatic, we have true control over the timing of boulders spawned &
don't want to leave it in the hands of players

## Changelog
:cl:
qol: adds examines & screentips for crowbar, screwdriver acts to BRM &
refinery machines
qol: adds examines about the number of boulders stored & processed to
BRM & refinery machines
qol: BRM now has its lights turn on/off depending on wether automatic
boulder retrieval is on/off for visual clarity along with examines
qol: refinery machines now display ballon alerts & plays sounds more
frequently when processing boulders for better feedback
fix: vents now spawn boulders of all sizes & not just small ones
fix: expanded gulag boulders now have correct materials in them.
fix: manual tapping of vents now has a cooldown applied as intended.
fix: BRM has its light turned off when area power goes off
fix: boulders ejected from refineries by hand no longer teleport all
over the place occasionally.
fix: refineries no longer eject boulders with 0 durability
fix: Boulders & refineries no longer pile up on top of BRM's &
refineries in long rounds. Their locs have to be clear of boulders
before they spit out more boulders to prevent a large pile of boulders
from causing lag
fix: sheets ejected from lathes no longer get rejected when inserted
back which could happen at random, no more boulders with empty materials
code: splits boulder types into its own file along with other items
code: merges & autodocs procs, vars related to boulders
refactor: repaths BRM to a simpler subtype
refactor: BRM now spawns boulders in batches(batch size can be increased
with upgraded parts) with a boulder appearing every second. After a
batch is processed a 3 second cooldown is applied to stop the conveyer
belt from clogging up, With this BRM wires are removed as there is no
need for timers to be attached to wires which intefers without our batch
processing timings.
/:cl:

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>

* General maintenance for all things boulder related.

* UpdatePaths

---------

Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
Co-authored-by: Mal <13398309+vinylspiders@users.noreply.github.com>
Iajret pushed a commit to Fluffy-Frontier/FluffySTG that referenced this pull request Feb 19, 2024
* General maintenance for all things boulder related. (#81358)

## About The Pull Request
**1. Qol**
- Adds screen tips & examines for screwdriver & crowbar acts on BRM,
Refinery & Smelter
- Adds examines to display number of boulders stored inside a refinery &
maximum number of boulders it can hold. Right click screentip to remove
boulders
- Adds examines to display maximum number of boulders than can be
teleported by a BRM & screentips for interacting with wires
- More audio & visual feedback for refinery processing. If a boulder
requires multiple steps you will get a balloon alert saying "crushing"
for refineries & "smelting" for smelters along with a sound per process
tick(which is every 2 seconds so no need for cooldown) giving you a
better idea of what's happening in the pipeline
- BRM now will display all lights when the "Automatic boulder retrieval"
is on & turn off the lights when disabled along with examines giving you
a visual indicator of its state

**2. Code Improvements**
- Splits types of boulders into its own file `boulder_types.dm` for easy
maintainability
- Moves beacon for refinery machines into its own file
`boulder_processing/beacon.dm` for easy maintainability
- Moves the cooldown for processing a boulder `processing_cooldown` into
the refinery machine itself. Since 100's of boulders can be created per
round this var can take up memory quickly so by moving them into the
refinery machine it gives us some savings
- Compressed & merged procs such as `create_mineral_contents()` ,
`flavour_boulder()` etc with the vent code. These procs were only used
by the vent 1 time & by merging the code we removed if conditions to
check if a parent vent was passed or not(since now that's always the
case). Helped in removing boilder plate code

**3. Fixes**
- **Fixes vents always spawning "Small size boulders" & not medium, nor
large boulders.**
 Once a vent generates a boulder it calls  `flavour_boulder()`

https://github.com/tgstation/tgstation/blob/084f56938c0169aeeee0b5f41453f31d072f3f67/code/game/objects/structures/lavaland/ore_vent.dm#L385
however this proc also accepts 2 more params `size` which would always
default to `BOULDER_SIZE_SMALL` and `is_artifact` which is simply unused
in the proc

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L219
Therefore vents would always generate small boulders giving us no
varity. Now the boulder size is set depending on the vent size &
durability for each boulder is set to a random value between 2 & the
boulder max size giving us the flavour we actually wanted

- **Fixes "Expanded Gulag boulders" using "normal gulag material list"
when setting its custom materials.**
If you look at the `add_gulag_minerals()` proc it always picks from the
`gulag_minerals` list & accepts no params

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L235-L236
So when we try to pass params to this proc which in reality doesn't
accept any we were wasting our time doing this

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L274
And for our case `expanded_gulag_minerals` list was simply unused
because our proc doesn't care about it and it went back to just using
`gulag_minerals` list thus ignoring our list

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L282
As i said in the "Code Improvement` section when i moved boulder types
into it's own unique file this was fixed & now expanded gulag boulders
actually has a chance to spawn with bluespace crystals inside them

- **Fixes manual tapping of ore vents by hand not using a cooldown**
`produce_boulder()` accepts a cooldown var for when you need to manually
tap the vent by hand.

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L374
This var was always set to FALSE because we never passed `TRUE` into it.
Not once here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L124
Nor here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L131
Now we just pass `TRUE` so tapping these vents by hand have a cooldown

- **Fixes BRM off icon state never being used**
When the room ran out of power it would still look on. Now we use that
state correctly

- **Fixes Automatic Boulder Retrieval by the BRM not actually being
automatic**
You must have noticed that once you do "Right click" and wait for all
the boulders it can teleport (determined by `boulder_processing_max`) to
be teleported it stops permanently after that. Even if more boulders get
generated it won't do anything, You have to again "Right click" &
retoggle automatic boulder retrieval on again, thus forcing someone to
stand there & monitor the BRM

Now once you set Automatic Boulder Retrieval on you can leave & forget.
It will teleport boulders as & when available thus enabling automation
properly.

- **Fixes boulders ejected from refineries via right click from getting
teleported back into the machines loc**
Fixes
tgstation/tgstation#78524 (comment).
The problem is refinery machines & the BRM keep track of all the
boulders that entered into it via the `boulders_contained` list.

Now we directly check `contents` for boulders so we don't have to
maintain 2 seperate lists to keep track of boulders. It also now uses
`processed_by` var of boulders to ensure refinerries don't retake in the
same boulder it just processed. Not sure where exactly the problem got
fixed but implementing these 2 measures fixed it regardless.

- **Fixes boulders with 0 durability[a.k.a steps] from getting ejected
out**
Fixes
tgstation/tgstation#78524 (comment).
So inside `process()` we constantly decrease the durability of the
boulder till it becomes 0.

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L159

  When it reaches 0 it calls `breakdown_boulder()`

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L164-L165

This proc has a chance to reject the boulder if it could not process any
materials

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L219-L222
  
  **"Without resetting its durability"** over here

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L241

So it ends up rejecting a "0" or worse -1 durability boulder. Now we set
the durability in `remove_boulder()` so regardless of what circumstances
the boulder is ejected it always gets a positive durability

- **Fixes BRM & Refinery from rapidly spitting out boulders in their loc
which causes lag in the long terms**
Fixes #81404. Basically even if there is 1 boulder sitting at a BRM's
loc or an refineries loc. Operations are haulted i.e. the BRM will not
teleport any more boulders & the refinery will keep their already
processed boulders inside till their locs are cleared from boulders.
This prevents large number of boulders from pilling up in long rounds

- **[Priority : High] Fixes refineries incorrectly removing materials
from processed boulders**
Fixes #81109. This bug is quite serious because it can't literarily
affect any random item with custom materials in game. This one line of
code over here can break the entire material economy as we know it

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L217
  
**"DONT DO THIS"**. The `custom_materials` list is a **"read only"**
list & if you ever want to change it call the `set_custom_materials()`
proc with your new values but do not edit this list manually as it is
done here.
  
All lists related to materials are cached by the `SSmaterials`
subsystem. List values are cached & shared across multiple objects so
when you edit those values like here, you might end up effecting an
item/multiple items in some random corner of the map that shares this
list.

This also causes boulders with empty list of materials to get spawned at
random so yeah again plzz don't do this

**4. Refactors**
- Repathes `obj/machinery/boulder_processing/brm` -> just
`obj/machinery/brm`.
Even though semantically it looks nice that the brm is a subtype of
`obj/machinery/boulder_processing` from a code & operation perspective
they have 0 similarities.

1) The BRM does not accept boulders feed into it from a conveyer belt
unlike a refinery but instead picks boulders from `SSore` subsystem &
put it on the conveyer belt. This means procs for accepting boulders
such `CanAllowThrough()`, `breakdown_boulder()`, `accept_boulder()` etc
have no use in the BRM. Their just code clutter at this point
2) The BRM overrides `process()` & does not call its parent proc making
that code wasted
3) It has no use for silo materials & mining points making those vars go
to waste

With so much wasted code its better to just let go off all of it & just
make it a basic instance of `obj/machinery` making maintainence easy

- BRM now teleports boulders in a batch (batch size determined by
`boulders_processing_max` max value from upgraded parts is 7) with a
boulder appearing every 1.5 seconds rather than spawning all at once.
After a batch is processed it has a cooldown of 3 seconds before
repeating the process if automatic boulder retrieval is on. This stops
the conveyer belt from getting crowded with boulders and makes the
refining process more efficient.

With this BRM wires are removed because only it had only 1 wire
responsible for toggling boulder retrieval but now since this process is
automatic, we have true control over the timing of boulders spawned &
don't want to leave it in the hands of players

## Changelog
:cl:
qol: adds examines & screentips for crowbar, screwdriver acts to BRM &
refinery machines
qol: adds examines about the number of boulders stored & processed to
BRM & refinery machines
qol: BRM now has its lights turn on/off depending on wether automatic
boulder retrieval is on/off for visual clarity along with examines
qol: refinery machines now display ballon alerts & plays sounds more
frequently when processing boulders for better feedback
fix: vents now spawn boulders of all sizes & not just small ones
fix: expanded gulag boulders now have correct materials in them.
fix: manual tapping of vents now has a cooldown applied as intended.
fix: BRM has its light turned off when area power goes off
fix: boulders ejected from refineries by hand no longer teleport all
over the place occasionally.
fix: refineries no longer eject boulders with 0 durability
fix: Boulders & refineries no longer pile up on top of BRM's &
refineries in long rounds. Their locs have to be clear of boulders
before they spit out more boulders to prevent a large pile of boulders
from causing lag
fix: sheets ejected from lathes no longer get rejected when inserted
back which could happen at random, no more boulders with empty materials
code: splits boulder types into its own file along with other items
code: merges & autodocs procs, vars related to boulders
refactor: repaths BRM to a simpler subtype
refactor: BRM now spawns boulders in batches(batch size can be increased
with upgraded parts) with a boulder appearing every second. After a
batch is processed a 3 second cooldown is applied to stop the conveyer
belt from clogging up, With this BRM wires are removed as there is no
need for timers to be attached to wires which intefers without our batch
processing timings.
/:cl:

---------



* General maintenance for all things boulder related.

* UpdatePaths

---------

Co-authored-by: NovaBot <154629622+NovaBot13@users.noreply.github.com>
Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
Co-authored-by: Mal <13398309+vinylspiders@users.noreply.github.com>
Useroth pushed a commit to Skyrat-SS13/Skyrat-tg that referenced this pull request Feb 21, 2024
## About The Pull Request
**1. Qol**
- Adds screen tips & examines for screwdriver & crowbar acts on BRM,
Refinery & Smelter
- Adds examines to display number of boulders stored inside a refinery &
maximum number of boulders it can hold. Right click screentip to remove
boulders
- Adds examines to display maximum number of boulders than can be
teleported by a BRM & screentips for interacting with wires
- More audio & visual feedback for refinery processing. If a boulder
requires multiple steps you will get a balloon alert saying "crushing"
for refineries & "smelting" for smelters along with a sound per process
tick(which is every 2 seconds so no need for cooldown) giving you a
better idea of what's happening in the pipeline
- BRM now will display all lights when the "Automatic boulder retrieval"
is on & turn off the lights when disabled along with examines giving you
a visual indicator of its state

**2. Code Improvements**
- Splits types of boulders into its own file `boulder_types.dm` for easy
maintainability
- Moves beacon for refinery machines into its own file
`boulder_processing/beacon.dm` for easy maintainability
- Moves the cooldown for processing a boulder `processing_cooldown` into
the refinery machine itself. Since 100's of boulders can be created per
round this var can take up memory quickly so by moving them into the
refinery machine it gives us some savings
- Compressed & merged procs such as `create_mineral_contents()` ,
`flavour_boulder()` etc with the vent code. These procs were only used
by the vent 1 time & by merging the code we removed if conditions to
check if a parent vent was passed or not(since now that's always the
case). Helped in removing boilder plate code

**3. Fixes**
- **Fixes vents always spawning "Small size boulders" & not medium, nor
large boulders.**
 Once a vent generates a boulder it calls  `flavour_boulder()`

https://github.com/tgstation/tgstation/blob/084f56938c0169aeeee0b5f41453f31d072f3f67/code/game/objects/structures/lavaland/ore_vent.dm#L385
however this proc also accepts 2 more params `size` which would always
default to `BOULDER_SIZE_SMALL` and `is_artifact` which is simply unused
in the proc

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L219
Therefore vents would always generate small boulders giving us no
varity. Now the boulder size is set depending on the vent size &
durability for each boulder is set to a random value between 2 & the
boulder max size giving us the flavour we actually wanted

- **Fixes "Expanded Gulag boulders" using "normal gulag material list"
when setting its custom materials.**
If you look at the `add_gulag_minerals()` proc it always picks from the
`gulag_minerals` list & accepts no params

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L235-L236
So when we try to pass params to this proc which in reality doesn't
accept any we were wasting our time doing this

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L274
And for our case `expanded_gulag_minerals` list was simply unused
because our proc doesn't care about it and it went back to just using
`gulag_minerals` list thus ignoring our list

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L282
As i said in the "Code Improvement` section when i moved boulder types
into it's own unique file this was fixed & now expanded gulag boulders
actually has a chance to spawn with bluespace crystals inside them

- **Fixes manual tapping of ore vents by hand not using a cooldown**
`produce_boulder()` accepts a cooldown var for when you need to manually
tap the vent by hand.

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L374
This var was always set to FALSE because we never passed `TRUE` into it.
Not once here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L124
Nor here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L131
Now we just pass `TRUE` so tapping these vents by hand have a cooldown

- **Fixes BRM off icon state never being used**
When the room ran out of power it would still look on. Now we use that
state correctly

- **Fixes Automatic Boulder Retrieval by the BRM not actually being
automatic**
You must have noticed that once you do "Right click" and wait for all
the boulders it can teleport (determined by `boulder_processing_max`) to
be teleported it stops permanently after that. Even if more boulders get
generated it won't do anything, You have to again "Right click" &
retoggle automatic boulder retrieval on again, thus forcing someone to
stand there & monitor the BRM

Now once you set Automatic Boulder Retrieval on you can leave & forget.
It will teleport boulders as & when available thus enabling automation
properly.

- **Fixes boulders ejected from refineries via right click from getting
teleported back into the machines loc**
Fixes
tgstation/tgstation#78524 (comment).
The problem is refinery machines & the BRM keep track of all the
boulders that entered into it via the `boulders_contained` list.

Now we directly check `contents` for boulders so we don't have to
maintain 2 seperate lists to keep track of boulders. It also now uses
`processed_by` var of boulders to ensure refinerries don't retake in the
same boulder it just processed. Not sure where exactly the problem got
fixed but implementing these 2 measures fixed it regardless.

- **Fixes boulders with 0 durability[a.k.a steps] from getting ejected
out**
Fixes
tgstation/tgstation#78524 (comment).
So inside `process()` we constantly decrease the durability of the
boulder till it becomes 0.

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L159

  When it reaches 0 it calls `breakdown_boulder()`

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L164-L165

This proc has a chance to reject the boulder if it could not process any
materials

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L219-L222
  
  **"Without resetting its durability"** over here

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L241

So it ends up rejecting a "0" or worse -1 durability boulder. Now we set
the durability in `remove_boulder()` so regardless of what circumstances
the boulder is ejected it always gets a positive durability

- **Fixes BRM & Refinery from rapidly spitting out boulders in their loc
which causes lag in the long terms**
Fixes #81404. Basically even if there is 1 boulder sitting at a BRM's
loc or an refineries loc. Operations are haulted i.e. the BRM will not
teleport any more boulders & the refinery will keep their already
processed boulders inside till their locs are cleared from boulders.
This prevents large number of boulders from pilling up in long rounds

- **[Priority : High] Fixes refineries incorrectly removing materials
from processed boulders**
Fixes #81109. This bug is quite serious because it can't literarily
affect any random item with custom materials in game. This one line of
code over here can break the entire material economy as we know it

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L217
  
**"DONT DO THIS"**. The `custom_materials` list is a **"read only"**
list & if you ever want to change it call the `set_custom_materials()`
proc with your new values but do not edit this list manually as it is
done here.
  
All lists related to materials are cached by the `SSmaterials`
subsystem. List values are cached & shared across multiple objects so
when you edit those values like here, you might end up effecting an
item/multiple items in some random corner of the map that shares this
list.

This also causes boulders with empty list of materials to get spawned at
random so yeah again plzz don't do this

**4. Refactors**
- Repathes `obj/machinery/boulder_processing/brm` -> just
`obj/machinery/brm`.
Even though semantically it looks nice that the brm is a subtype of
`obj/machinery/boulder_processing` from a code & operation perspective
they have 0 similarities.

1) The BRM does not accept boulders feed into it from a conveyer belt
unlike a refinery but instead picks boulders from `SSore` subsystem &
put it on the conveyer belt. This means procs for accepting boulders
such `CanAllowThrough()`, `breakdown_boulder()`, `accept_boulder()` etc
have no use in the BRM. Their just code clutter at this point
2) The BRM overrides `process()` & does not call its parent proc making
that code wasted
3) It has no use for silo materials & mining points making those vars go
to waste

With so much wasted code its better to just let go off all of it & just
make it a basic instance of `obj/machinery` making maintainence easy

- BRM now teleports boulders in a batch (batch size determined by
`boulders_processing_max` max value from upgraded parts is 7) with a
boulder appearing every 1.5 seconds rather than spawning all at once.
After a batch is processed it has a cooldown of 3 seconds before
repeating the process if automatic boulder retrieval is on. This stops
the conveyer belt from getting crowded with boulders and makes the
refining process more efficient.

With this BRM wires are removed because only it had only 1 wire
responsible for toggling boulder retrieval but now since this process is
automatic, we have true control over the timing of boulders spawned &
don't want to leave it in the hands of players

## Changelog
:cl:
qol: adds examines & screentips for crowbar, screwdriver acts to BRM &
refinery machines
qol: adds examines about the number of boulders stored & processed to
BRM & refinery machines
qol: BRM now has its lights turn on/off depending on wether automatic
boulder retrieval is on/off for visual clarity along with examines
qol: refinery machines now display ballon alerts & plays sounds more
frequently when processing boulders for better feedback
fix: vents now spawn boulders of all sizes & not just small ones
fix: expanded gulag boulders now have correct materials in them.
fix: manual tapping of vents now has a cooldown applied as intended.
fix: BRM has its light turned off when area power goes off
fix: boulders ejected from refineries by hand no longer teleport all
over the place occasionally.
fix: refineries no longer eject boulders with 0 durability
fix: Boulders & refineries no longer pile up on top of BRM's &
refineries in long rounds. Their locs have to be clear of boulders
before they spit out more boulders to prevent a large pile of boulders
from causing lag
fix: sheets ejected from lathes no longer get rejected when inserted
back which could happen at random, no more boulders with empty materials
code: splits boulder types into its own file along with other items
code: merges & autodocs procs, vars related to boulders
refactor: repaths BRM to a simpler subtype
refactor: BRM now spawns boulders in batches(batch size can be increased
with upgraded parts) with a boulder appearing every second. After a
batch is processed a 3 second cooldown is applied to stop the conveyer
belt from clogging up, With this BRM wires are removed as there is no
need for timers to be attached to wires which intefers without our batch
processing timings.
/:cl:

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
Useroth added a commit to Skyrat-SS13/Skyrat-tg that referenced this pull request Feb 22, 2024
* General maintenance for all things boulder related. (#81358)

## About The Pull Request
**1. Qol**
- Adds screen tips & examines for screwdriver & crowbar acts on BRM,
Refinery & Smelter
- Adds examines to display number of boulders stored inside a refinery &
maximum number of boulders it can hold. Right click screentip to remove
boulders
- Adds examines to display maximum number of boulders than can be
teleported by a BRM & screentips for interacting with wires
- More audio & visual feedback for refinery processing. If a boulder
requires multiple steps you will get a balloon alert saying "crushing"
for refineries & "smelting" for smelters along with a sound per process
tick(which is every 2 seconds so no need for cooldown) giving you a
better idea of what's happening in the pipeline
- BRM now will display all lights when the "Automatic boulder retrieval"
is on & turn off the lights when disabled along with examines giving you
a visual indicator of its state

**2. Code Improvements**
- Splits types of boulders into its own file `boulder_types.dm` for easy
maintainability
- Moves beacon for refinery machines into its own file
`boulder_processing/beacon.dm` for easy maintainability
- Moves the cooldown for processing a boulder `processing_cooldown` into
the refinery machine itself. Since 100's of boulders can be created per
round this var can take up memory quickly so by moving them into the
refinery machine it gives us some savings
- Compressed & merged procs such as `create_mineral_contents()` ,
`flavour_boulder()` etc with the vent code. These procs were only used
by the vent 1 time & by merging the code we removed if conditions to
check if a parent vent was passed or not(since now that's always the
case). Helped in removing boilder plate code

**3. Fixes**
- **Fixes vents always spawning "Small size boulders" & not medium, nor
large boulders.**
 Once a vent generates a boulder it calls  `flavour_boulder()`

https://github.com/tgstation/tgstation/blob/084f56938c0169aeeee0b5f41453f31d072f3f67/code/game/objects/structures/lavaland/ore_vent.dm#L385
however this proc also accepts 2 more params `size` which would always
default to `BOULDER_SIZE_SMALL` and `is_artifact` which is simply unused
in the proc

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L219
Therefore vents would always generate small boulders giving us no
varity. Now the boulder size is set depending on the vent size &
durability for each boulder is set to a random value between 2 & the
boulder max size giving us the flavour we actually wanted

- **Fixes "Expanded Gulag boulders" using "normal gulag material list"
when setting its custom materials.**
If you look at the `add_gulag_minerals()` proc it always picks from the
`gulag_minerals` list & accepts no params

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L235-L236
So when we try to pass params to this proc which in reality doesn't
accept any we were wasting our time doing this

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L274
And for our case `expanded_gulag_minerals` list was simply unused
because our proc doesn't care about it and it went back to just using
`gulag_minerals` list thus ignoring our list

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L282
As i said in the "Code Improvement` section when i moved boulder types
into it's own unique file this was fixed & now expanded gulag boulders
actually has a chance to spawn with bluespace crystals inside them

- **Fixes manual tapping of ore vents by hand not using a cooldown**
`produce_boulder()` accepts a cooldown var for when you need to manually
tap the vent by hand.

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L374
This var was always set to FALSE because we never passed `TRUE` into it.
Not once here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L124
Nor here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L131
Now we just pass `TRUE` so tapping these vents by hand have a cooldown

- **Fixes BRM off icon state never being used**
When the room ran out of power it would still look on. Now we use that
state correctly

- **Fixes Automatic Boulder Retrieval by the BRM not actually being
automatic**
You must have noticed that once you do "Right click" and wait for all
the boulders it can teleport (determined by `boulder_processing_max`) to
be teleported it stops permanently after that. Even if more boulders get
generated it won't do anything, You have to again "Right click" &
retoggle automatic boulder retrieval on again, thus forcing someone to
stand there & monitor the BRM

Now once you set Automatic Boulder Retrieval on you can leave & forget.
It will teleport boulders as & when available thus enabling automation
properly.

- **Fixes boulders ejected from refineries via right click from getting
teleported back into the machines loc**
Fixes
tgstation/tgstation#78524 (comment).
The problem is refinery machines & the BRM keep track of all the
boulders that entered into it via the `boulders_contained` list.

Now we directly check `contents` for boulders so we don't have to
maintain 2 seperate lists to keep track of boulders. It also now uses
`processed_by` var of boulders to ensure refinerries don't retake in the
same boulder it just processed. Not sure where exactly the problem got
fixed but implementing these 2 measures fixed it regardless.

- **Fixes boulders with 0 durability[a.k.a steps] from getting ejected
out**
Fixes
tgstation/tgstation#78524 (comment).
So inside `process()` we constantly decrease the durability of the
boulder till it becomes 0.

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L159

  When it reaches 0 it calls `breakdown_boulder()`

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L164-L165

This proc has a chance to reject the boulder if it could not process any
materials

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L219-L222
  
  **"Without resetting its durability"** over here

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L241

So it ends up rejecting a "0" or worse -1 durability boulder. Now we set
the durability in `remove_boulder()` so regardless of what circumstances
the boulder is ejected it always gets a positive durability

- **Fixes BRM & Refinery from rapidly spitting out boulders in their loc
which causes lag in the long terms**
Fixes #81404. Basically even if there is 1 boulder sitting at a BRM's
loc or an refineries loc. Operations are haulted i.e. the BRM will not
teleport any more boulders & the refinery will keep their already
processed boulders inside till their locs are cleared from boulders.
This prevents large number of boulders from pilling up in long rounds

- **[Priority : High] Fixes refineries incorrectly removing materials
from processed boulders**
Fixes #81109. This bug is quite serious because it can't literarily
affect any random item with custom materials in game. This one line of
code over here can break the entire material economy as we know it

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L217
  
**"DONT DO THIS"**. The `custom_materials` list is a **"read only"**
list & if you ever want to change it call the `set_custom_materials()`
proc with your new values but do not edit this list manually as it is
done here.
  
All lists related to materials are cached by the `SSmaterials`
subsystem. List values are cached & shared across multiple objects so
when you edit those values like here, you might end up effecting an
item/multiple items in some random corner of the map that shares this
list.

This also causes boulders with empty list of materials to get spawned at
random so yeah again plzz don't do this

**4. Refactors**
- Repathes `obj/machinery/boulder_processing/brm` -> just
`obj/machinery/brm`.
Even though semantically it looks nice that the brm is a subtype of
`obj/machinery/boulder_processing` from a code & operation perspective
they have 0 similarities.

1) The BRM does not accept boulders feed into it from a conveyer belt
unlike a refinery but instead picks boulders from `SSore` subsystem &
put it on the conveyer belt. This means procs for accepting boulders
such `CanAllowThrough()`, `breakdown_boulder()`, `accept_boulder()` etc
have no use in the BRM. Their just code clutter at this point
2) The BRM overrides `process()` & does not call its parent proc making
that code wasted
3) It has no use for silo materials & mining points making those vars go
to waste

With so much wasted code its better to just let go off all of it & just
make it a basic instance of `obj/machinery` making maintainence easy

- BRM now teleports boulders in a batch (batch size determined by
`boulders_processing_max` max value from upgraded parts is 7) with a
boulder appearing every 1.5 seconds rather than spawning all at once.
After a batch is processed it has a cooldown of 3 seconds before
repeating the process if automatic boulder retrieval is on. This stops
the conveyer belt from getting crowded with boulders and makes the
refining process more efficient.

With this BRM wires are removed because only it had only 1 wire
responsible for toggling boulder retrieval but now since this process is
automatic, we have true control over the timing of boulders spawned &
don't want to leave it in the hands of players

## Changelog
:cl:
qol: adds examines & screentips for crowbar, screwdriver acts to BRM &
refinery machines
qol: adds examines about the number of boulders stored & processed to
BRM & refinery machines
qol: BRM now has its lights turn on/off depending on wether automatic
boulder retrieval is on/off for visual clarity along with examines
qol: refinery machines now display ballon alerts & plays sounds more
frequently when processing boulders for better feedback
fix: vents now spawn boulders of all sizes & not just small ones
fix: expanded gulag boulders now have correct materials in them.
fix: manual tapping of vents now has a cooldown applied as intended.
fix: BRM has its light turned off when area power goes off
fix: boulders ejected from refineries by hand no longer teleport all
over the place occasionally.
fix: refineries no longer eject boulders with 0 durability
fix: Boulders & refineries no longer pile up on top of BRM's &
refineries in long rounds. Their locs have to be clear of boulders
before they spit out more boulders to prevent a large pile of boulders
from causing lag
fix: sheets ejected from lathes no longer get rejected when inserted
back which could happen at random, no more boulders with empty materials
code: splits boulder types into its own file along with other items
code: merges & autodocs procs, vars related to boulders
refactor: repaths BRM to a simpler subtype
refactor: BRM now spawns boulders in batches(batch size can be increased
with upgraded parts) with a boulder appearing every second. After a
batch is processed a 3 second cooldown is applied to stop the conveyer
belt from clogging up, With this BRM wires are removed as there is no
need for timers to be attached to wires which intefers without our batch
processing timings.
/:cl:

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>

* [NO GBP]Some BRM Fixes (#81551)

## About The Pull Request
- The time from which the boulder is picked to when it's teleported onto
the conveyer belt is 1.5 seconds. During that time the boulder could get
deleted due to many factors and we lose our materials. No one like's
that that so now both steps are combined into 1 proc so we no longer
loose boulders during teleportation.
- Batch processing cooldown was not working when
`boulder_processing_max` is > 1. Now it does

## Changelog
:cl:
fix: boulders are no longer lost when teleported by the BRM
fix: batch processing cooldown works when teleporting multiple boulders
/:cl:

* Path replacements in maps

---------

Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
Co-authored-by: Useroth <37159550+Useroth@users.noreply.github.com>
larentoun pushed a commit to larentoun/tgstation that referenced this pull request Mar 1, 2024
## About The Pull Request
**1. Qol**
- Adds screen tips & examines for screwdriver & crowbar acts on BRM,
Refinery & Smelter
- Adds examines to display number of boulders stored inside a refinery &
maximum number of boulders it can hold. Right click screentip to remove
boulders
- Adds examines to display maximum number of boulders than can be
teleported by a BRM & screentips for interacting with wires
- More audio & visual feedback for refinery processing. If a boulder
requires multiple steps you will get a balloon alert saying "crushing"
for refineries & "smelting" for smelters along with a sound per process
tick(which is every 2 seconds so no need for cooldown) giving you a
better idea of what's happening in the pipeline
- BRM now will display all lights when the "Automatic boulder retrieval"
is on & turn off the lights when disabled along with examines giving you
a visual indicator of its state

**2. Code Improvements**
- Splits types of boulders into its own file `boulder_types.dm` for easy
maintainability
- Moves beacon for refinery machines into its own file
`boulder_processing/beacon.dm` for easy maintainability
- Moves the cooldown for processing a boulder `processing_cooldown` into
the refinery machine itself. Since 100's of boulders can be created per
round this var can take up memory quickly so by moving them into the
refinery machine it gives us some savings
- Compressed & merged procs such as `create_mineral_contents()` ,
`flavour_boulder()` etc with the vent code. These procs were only used
by the vent 1 time & by merging the code we removed if conditions to
check if a parent vent was passed or not(since now that's always the
case). Helped in removing boilder plate code

**3. Fixes**
- **Fixes vents always spawning "Small size boulders" & not medium, nor
large boulders.**
 Once a vent generates a boulder it calls  `flavour_boulder()`

https://github.com/tgstation/tgstation/blob/084f56938c0169aeeee0b5f41453f31d072f3f67/code/game/objects/structures/lavaland/ore_vent.dm#L385
however this proc also accepts 2 more params `size` which would always
default to `BOULDER_SIZE_SMALL` and `is_artifact` which is simply unused
in the proc

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L219
Therefore vents would always generate small boulders giving us no
varity. Now the boulder size is set depending on the vent size &
durability for each boulder is set to a random value between 2 & the
boulder max size giving us the flavour we actually wanted

- **Fixes "Expanded Gulag boulders" using "normal gulag material list"
when setting its custom materials.**
If you look at the `add_gulag_minerals()` proc it always picks from the
`gulag_minerals` list & accepts no params

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L235-L236
So when we try to pass params to this proc which in reality doesn't
accept any we were wasting our time doing this

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L274
And for our case `expanded_gulag_minerals` list was simply unused
because our proc doesn't care about it and it went back to just using
`gulag_minerals` list thus ignoring our list

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L282
As i said in the "Code Improvement` section when i moved boulder types
into it's own unique file this was fixed & now expanded gulag boulders
actually has a chance to spawn with bluespace crystals inside them

- **Fixes manual tapping of ore vents by hand not using a cooldown**
`produce_boulder()` accepts a cooldown var for when you need to manually
tap the vent by hand.

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L374
This var was always set to FALSE because we never passed `TRUE` into it.
Not once here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L124
Nor here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L131
Now we just pass `TRUE` so tapping these vents by hand have a cooldown

- **Fixes BRM off icon state never being used**
When the room ran out of power it would still look on. Now we use that
state correctly

- **Fixes Automatic Boulder Retrieval by the BRM not actually being
automatic**
You must have noticed that once you do "Right click" and wait for all
the boulders it can teleport (determined by `boulder_processing_max`) to
be teleported it stops permanently after that. Even if more boulders get
generated it won't do anything, You have to again "Right click" &
retoggle automatic boulder retrieval on again, thus forcing someone to
stand there & monitor the BRM

Now once you set Automatic Boulder Retrieval on you can leave & forget.
It will teleport boulders as & when available thus enabling automation
properly.

- **Fixes boulders ejected from refineries via right click from getting
teleported back into the machines loc**
Fixes
tgstation#78524 (comment).
The problem is refinery machines & the BRM keep track of all the
boulders that entered into it via the `boulders_contained` list.

Now we directly check `contents` for boulders so we don't have to
maintain 2 seperate lists to keep track of boulders. It also now uses
`processed_by` var of boulders to ensure refinerries don't retake in the
same boulder it just processed. Not sure where exactly the problem got
fixed but implementing these 2 measures fixed it regardless.

- **Fixes boulders with 0 durability[a.k.a steps] from getting ejected
out**
Fixes
tgstation#78524 (comment).
So inside `process()` we constantly decrease the durability of the
boulder till it becomes 0.

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L159

  When it reaches 0 it calls `breakdown_boulder()`

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L164-L165

This proc has a chance to reject the boulder if it could not process any
materials

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L219-L222
  
  **"Without resetting its durability"** over here

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L241

So it ends up rejecting a "0" or worse -1 durability boulder. Now we set
the durability in `remove_boulder()` so regardless of what circumstances
the boulder is ejected it always gets a positive durability

- **Fixes BRM & Refinery from rapidly spitting out boulders in their loc
which causes lag in the long terms**
Fixes tgstation#81404. Basically even if there is 1 boulder sitting at a BRM's
loc or an refineries loc. Operations are haulted i.e. the BRM will not
teleport any more boulders & the refinery will keep their already
processed boulders inside till their locs are cleared from boulders.
This prevents large number of boulders from pilling up in long rounds

- **[Priority : High] Fixes refineries incorrectly removing materials
from processed boulders**
Fixes tgstation#81109. This bug is quite serious because it can't literarily
affect any random item with custom materials in game. This one line of
code over here can break the entire material economy as we know it

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L217
  
**"DONT DO THIS"**. The `custom_materials` list is a **"read only"**
list & if you ever want to change it call the `set_custom_materials()`
proc with your new values but do not edit this list manually as it is
done here.
  
All lists related to materials are cached by the `SSmaterials`
subsystem. List values are cached & shared across multiple objects so
when you edit those values like here, you might end up effecting an
item/multiple items in some random corner of the map that shares this
list.

This also causes boulders with empty list of materials to get spawned at
random so yeah again plzz don't do this

**4. Refactors**
- Repathes `obj/machinery/boulder_processing/brm` -> just
`obj/machinery/brm`.
Even though semantically it looks nice that the brm is a subtype of
`obj/machinery/boulder_processing` from a code & operation perspective
they have 0 similarities.

1) The BRM does not accept boulders feed into it from a conveyer belt
unlike a refinery but instead picks boulders from `SSore` subsystem &
put it on the conveyer belt. This means procs for accepting boulders
such `CanAllowThrough()`, `breakdown_boulder()`, `accept_boulder()` etc
have no use in the BRM. Their just code clutter at this point
2) The BRM overrides `process()` & does not call its parent proc making
that code wasted
3) It has no use for silo materials & mining points making those vars go
to waste

With so much wasted code its better to just let go off all of it & just
make it a basic instance of `obj/machinery` making maintainence easy

- BRM now teleports boulders in a batch (batch size determined by
`boulders_processing_max` max value from upgraded parts is 7) with a
boulder appearing every 1.5 seconds rather than spawning all at once.
After a batch is processed it has a cooldown of 3 seconds before
repeating the process if automatic boulder retrieval is on. This stops
the conveyer belt from getting crowded with boulders and makes the
refining process more efficient.

With this BRM wires are removed because only it had only 1 wire
responsible for toggling boulder retrieval but now since this process is
automatic, we have true control over the timing of boulders spawned &
don't want to leave it in the hands of players

## Changelog
:cl:
qol: adds examines & screentips for crowbar, screwdriver acts to BRM &
refinery machines
qol: adds examines about the number of boulders stored & processed to
BRM & refinery machines
qol: BRM now has its lights turn on/off depending on wether automatic
boulder retrieval is on/off for visual clarity along with examines
qol: refinery machines now display ballon alerts & plays sounds more
frequently when processing boulders for better feedback
fix: vents now spawn boulders of all sizes & not just small ones
fix: expanded gulag boulders now have correct materials in them.
fix: manual tapping of vents now has a cooldown applied as intended.
fix: BRM has its light turned off when area power goes off
fix: boulders ejected from refineries by hand no longer teleport all
over the place occasionally.
fix: refineries no longer eject boulders with 0 durability
fix: Boulders & refineries no longer pile up on top of BRM's &
refineries in long rounds. Their locs have to be clear of boulders
before they spit out more boulders to prevent a large pile of boulders
from causing lag
fix: sheets ejected from lathes no longer get rejected when inserted
back which could happen at random, no more boulders with empty materials
code: splits boulder types into its own file along with other items
code: merges & autodocs procs, vars related to boulders
refactor: repaths BRM to a simpler subtype
refactor: BRM now spawns boulders in batches(batch size can be increased
with upgraded parts) with a boulder appearing every second. After a
batch is processed a 3 second cooldown is applied to stop the conveyer
belt from clogging up, With this BRM wires are removed as there is no
need for timers to be attached to wires which intefers without our batch
processing timings.
/:cl:

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
larentoun pushed a commit to larentoun/tgstation that referenced this pull request Mar 1, 2024
## About The Pull Request
**1. Qol**
- Adds screen tips & examines for screwdriver & crowbar acts on BRM,
Refinery & Smelter
- Adds examines to display number of boulders stored inside a refinery &
maximum number of boulders it can hold. Right click screentip to remove
boulders
- Adds examines to display maximum number of boulders than can be
teleported by a BRM & screentips for interacting with wires
- More audio & visual feedback for refinery processing. If a boulder
requires multiple steps you will get a balloon alert saying "crushing"
for refineries & "smelting" for smelters along with a sound per process
tick(which is every 2 seconds so no need for cooldown) giving you a
better idea of what's happening in the pipeline
- BRM now will display all lights when the "Automatic boulder retrieval"
is on & turn off the lights when disabled along with examines giving you
a visual indicator of its state

**2. Code Improvements**
- Splits types of boulders into its own file `boulder_types.dm` for easy
maintainability
- Moves beacon for refinery machines into its own file
`boulder_processing/beacon.dm` for easy maintainability
- Moves the cooldown for processing a boulder `processing_cooldown` into
the refinery machine itself. Since 100's of boulders can be created per
round this var can take up memory quickly so by moving them into the
refinery machine it gives us some savings
- Compressed & merged procs such as `create_mineral_contents()` ,
`flavour_boulder()` etc with the vent code. These procs were only used
by the vent 1 time & by merging the code we removed if conditions to
check if a parent vent was passed or not(since now that's always the
case). Helped in removing boilder plate code

**3. Fixes**
- **Fixes vents always spawning "Small size boulders" & not medium, nor
large boulders.**
 Once a vent generates a boulder it calls  `flavour_boulder()`

https://github.com/tgstation/tgstation/blob/084f56938c0169aeeee0b5f41453f31d072f3f67/code/game/objects/structures/lavaland/ore_vent.dm#L385
however this proc also accepts 2 more params `size` which would always
default to `BOULDER_SIZE_SMALL` and `is_artifact` which is simply unused
in the proc

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L219
Therefore vents would always generate small boulders giving us no
varity. Now the boulder size is set depending on the vent size &
durability for each boulder is set to a random value between 2 & the
boulder max size giving us the flavour we actually wanted

- **Fixes "Expanded Gulag boulders" using "normal gulag material list"
when setting its custom materials.**
If you look at the `add_gulag_minerals()` proc it always picks from the
`gulag_minerals` list & accepts no params

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L235-L236
So when we try to pass params to this proc which in reality doesn't
accept any we were wasting our time doing this

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L274
And for our case `expanded_gulag_minerals` list was simply unused
because our proc doesn't care about it and it went back to just using
`gulag_minerals` list thus ignoring our list

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L282
As i said in the "Code Improvement` section when i moved boulder types
into it's own unique file this was fixed & now expanded gulag boulders
actually has a chance to spawn with bluespace crystals inside them

- **Fixes manual tapping of ore vents by hand not using a cooldown**
`produce_boulder()` accepts a cooldown var for when you need to manually
tap the vent by hand.

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L374
This var was always set to FALSE because we never passed `TRUE` into it.
Not once here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L124
Nor here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L131
Now we just pass `TRUE` so tapping these vents by hand have a cooldown

- **Fixes BRM off icon state never being used**
When the room ran out of power it would still look on. Now we use that
state correctly

- **Fixes Automatic Boulder Retrieval by the BRM not actually being
automatic**
You must have noticed that once you do "Right click" and wait for all
the boulders it can teleport (determined by `boulder_processing_max`) to
be teleported it stops permanently after that. Even if more boulders get
generated it won't do anything, You have to again "Right click" &
retoggle automatic boulder retrieval on again, thus forcing someone to
stand there & monitor the BRM

Now once you set Automatic Boulder Retrieval on you can leave & forget.
It will teleport boulders as & when available thus enabling automation
properly.

- **Fixes boulders ejected from refineries via right click from getting
teleported back into the machines loc**
Fixes
tgstation#78524 (comment).
The problem is refinery machines & the BRM keep track of all the
boulders that entered into it via the `boulders_contained` list.

Now we directly check `contents` for boulders so we don't have to
maintain 2 seperate lists to keep track of boulders. It also now uses
`processed_by` var of boulders to ensure refinerries don't retake in the
same boulder it just processed. Not sure where exactly the problem got
fixed but implementing these 2 measures fixed it regardless.

- **Fixes boulders with 0 durability[a.k.a steps] from getting ejected
out**
Fixes
tgstation#78524 (comment).
So inside `process()` we constantly decrease the durability of the
boulder till it becomes 0.

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L159

  When it reaches 0 it calls `breakdown_boulder()`

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L164-L165

This proc has a chance to reject the boulder if it could not process any
materials

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L219-L222
  
  **"Without resetting its durability"** over here

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L241

So it ends up rejecting a "0" or worse -1 durability boulder. Now we set
the durability in `remove_boulder()` so regardless of what circumstances
the boulder is ejected it always gets a positive durability

- **Fixes BRM & Refinery from rapidly spitting out boulders in their loc
which causes lag in the long terms**
Fixes tgstation#81404. Basically even if there is 1 boulder sitting at a BRM's
loc or an refineries loc. Operations are haulted i.e. the BRM will not
teleport any more boulders & the refinery will keep their already
processed boulders inside till their locs are cleared from boulders.
This prevents large number of boulders from pilling up in long rounds

- **[Priority : High] Fixes refineries incorrectly removing materials
from processed boulders**
Fixes tgstation#81109. This bug is quite serious because it can't literarily
affect any random item with custom materials in game. This one line of
code over here can break the entire material economy as we know it

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L217
  
**"DONT DO THIS"**. The `custom_materials` list is a **"read only"**
list & if you ever want to change it call the `set_custom_materials()`
proc with your new values but do not edit this list manually as it is
done here.
  
All lists related to materials are cached by the `SSmaterials`
subsystem. List values are cached & shared across multiple objects so
when you edit those values like here, you might end up effecting an
item/multiple items in some random corner of the map that shares this
list.

This also causes boulders with empty list of materials to get spawned at
random so yeah again plzz don't do this

**4. Refactors**
- Repathes `obj/machinery/boulder_processing/brm` -> just
`obj/machinery/brm`.
Even though semantically it looks nice that the brm is a subtype of
`obj/machinery/boulder_processing` from a code & operation perspective
they have 0 similarities.

1) The BRM does not accept boulders feed into it from a conveyer belt
unlike a refinery but instead picks boulders from `SSore` subsystem &
put it on the conveyer belt. This means procs for accepting boulders
such `CanAllowThrough()`, `breakdown_boulder()`, `accept_boulder()` etc
have no use in the BRM. Their just code clutter at this point
2) The BRM overrides `process()` & does not call its parent proc making
that code wasted
3) It has no use for silo materials & mining points making those vars go
to waste

With so much wasted code its better to just let go off all of it & just
make it a basic instance of `obj/machinery` making maintainence easy

- BRM now teleports boulders in a batch (batch size determined by
`boulders_processing_max` max value from upgraded parts is 7) with a
boulder appearing every 1.5 seconds rather than spawning all at once.
After a batch is processed it has a cooldown of 3 seconds before
repeating the process if automatic boulder retrieval is on. This stops
the conveyer belt from getting crowded with boulders and makes the
refining process more efficient.

With this BRM wires are removed because only it had only 1 wire
responsible for toggling boulder retrieval but now since this process is
automatic, we have true control over the timing of boulders spawned &
don't want to leave it in the hands of players

## Changelog
:cl:
qol: adds examines & screentips for crowbar, screwdriver acts to BRM &
refinery machines
qol: adds examines about the number of boulders stored & processed to
BRM & refinery machines
qol: BRM now has its lights turn on/off depending on wether automatic
boulder retrieval is on/off for visual clarity along with examines
qol: refinery machines now display ballon alerts & plays sounds more
frequently when processing boulders for better feedback
fix: vents now spawn boulders of all sizes & not just small ones
fix: expanded gulag boulders now have correct materials in them.
fix: manual tapping of vents now has a cooldown applied as intended.
fix: BRM has its light turned off when area power goes off
fix: boulders ejected from refineries by hand no longer teleport all
over the place occasionally.
fix: refineries no longer eject boulders with 0 durability
fix: Boulders & refineries no longer pile up on top of BRM's &
refineries in long rounds. Their locs have to be clear of boulders
before they spit out more boulders to prevent a large pile of boulders
from causing lag
fix: sheets ejected from lathes no longer get rejected when inserted
back which could happen at random, no more boulders with empty materials
code: splits boulder types into its own file along with other items
code: merges & autodocs procs, vars related to boulders
refactor: repaths BRM to a simpler subtype
refactor: BRM now spawns boulders in batches(batch size can be increased
with upgraded parts) with a boulder appearing every second. After a
batch is processed a 3 second cooldown is applied to stop the conveyer
belt from clogging up, With this BRM wires are removed as there is no
need for timers to be attached to wires which intefers without our batch
processing timings.
/:cl:

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
larentoun pushed a commit to ss220club/Bandastation that referenced this pull request Mar 1, 2024
## About The Pull Request
**1. Qol**
- Adds screen tips & examines for screwdriver & crowbar acts on BRM,
Refinery & Smelter
- Adds examines to display number of boulders stored inside a refinery &
maximum number of boulders it can hold. Right click screentip to remove
boulders
- Adds examines to display maximum number of boulders than can be
teleported by a BRM & screentips for interacting with wires
- More audio & visual feedback for refinery processing. If a boulder
requires multiple steps you will get a balloon alert saying "crushing"
for refineries & "smelting" for smelters along with a sound per process
tick(which is every 2 seconds so no need for cooldown) giving you a
better idea of what's happening in the pipeline
- BRM now will display all lights when the "Automatic boulder retrieval"
is on & turn off the lights when disabled along with examines giving you
a visual indicator of its state

**2. Code Improvements**
- Splits types of boulders into its own file `boulder_types.dm` for easy
maintainability
- Moves beacon for refinery machines into its own file
`boulder_processing/beacon.dm` for easy maintainability
- Moves the cooldown for processing a boulder `processing_cooldown` into
the refinery machine itself. Since 100's of boulders can be created per
round this var can take up memory quickly so by moving them into the
refinery machine it gives us some savings
- Compressed & merged procs such as `create_mineral_contents()` ,
`flavour_boulder()` etc with the vent code. These procs were only used
by the vent 1 time & by merging the code we removed if conditions to
check if a parent vent was passed or not(since now that's always the
case). Helped in removing boilder plate code

**3. Fixes**
- **Fixes vents always spawning "Small size boulders" & not medium, nor
large boulders.**
 Once a vent generates a boulder it calls  `flavour_boulder()`

https://github.com/tgstation/tgstation/blob/084f56938c0169aeeee0b5f41453f31d072f3f67/code/game/objects/structures/lavaland/ore_vent.dm#L385
however this proc also accepts 2 more params `size` which would always
default to `BOULDER_SIZE_SMALL` and `is_artifact` which is simply unused
in the proc

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L219
Therefore vents would always generate small boulders giving us no
varity. Now the boulder size is set depending on the vent size &
durability for each boulder is set to a random value between 2 & the
boulder max size giving us the flavour we actually wanted

- **Fixes "Expanded Gulag boulders" using "normal gulag material list"
when setting its custom materials.**
If you look at the `add_gulag_minerals()` proc it always picks from the
`gulag_minerals` list & accepts no params

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L235-L236
So when we try to pass params to this proc which in reality doesn't
accept any we were wasting our time doing this

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L274
And for our case `expanded_gulag_minerals` list was simply unused
because our proc doesn't care about it and it went back to just using
`gulag_minerals` list thus ignoring our list

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L282
As i said in the "Code Improvement` section when i moved boulder types
into it's own unique file this was fixed & now expanded gulag boulders
actually has a chance to spawn with bluespace crystals inside them

- **Fixes manual tapping of ore vents by hand not using a cooldown**
`produce_boulder()` accepts a cooldown var for when you need to manually
tap the vent by hand.

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L374
This var was always set to FALSE because we never passed `TRUE` into it.
Not once here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L124
Nor here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L131
Now we just pass `TRUE` so tapping these vents by hand have a cooldown

- **Fixes BRM off icon state never being used**
When the room ran out of power it would still look on. Now we use that
state correctly

- **Fixes Automatic Boulder Retrieval by the BRM not actually being
automatic**
You must have noticed that once you do "Right click" and wait for all
the boulders it can teleport (determined by `boulder_processing_max`) to
be teleported it stops permanently after that. Even if more boulders get
generated it won't do anything, You have to again "Right click" &
retoggle automatic boulder retrieval on again, thus forcing someone to
stand there & monitor the BRM

Now once you set Automatic Boulder Retrieval on you can leave & forget.
It will teleport boulders as & when available thus enabling automation
properly.

- **Fixes boulders ejected from refineries via right click from getting
teleported back into the machines loc**
Fixes
tgstation#78524 (comment).
The problem is refinery machines & the BRM keep track of all the
boulders that entered into it via the `boulders_contained` list.

Now we directly check `contents` for boulders so we don't have to
maintain 2 seperate lists to keep track of boulders. It also now uses
`processed_by` var of boulders to ensure refinerries don't retake in the
same boulder it just processed. Not sure where exactly the problem got
fixed but implementing these 2 measures fixed it regardless.

- **Fixes boulders with 0 durability[a.k.a steps] from getting ejected
out**
Fixes
tgstation#78524 (comment).
So inside `process()` we constantly decrease the durability of the
boulder till it becomes 0.

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L159

  When it reaches 0 it calls `breakdown_boulder()`

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L164-L165

This proc has a chance to reject the boulder if it could not process any
materials

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L219-L222
  
  **"Without resetting its durability"** over here

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L241

So it ends up rejecting a "0" or worse -1 durability boulder. Now we set
the durability in `remove_boulder()` so regardless of what circumstances
the boulder is ejected it always gets a positive durability

- **Fixes BRM & Refinery from rapidly spitting out boulders in their loc
which causes lag in the long terms**
Fixes tgstation#81404. Basically even if there is 1 boulder sitting at a BRM's
loc or an refineries loc. Operations are haulted i.e. the BRM will not
teleport any more boulders & the refinery will keep their already
processed boulders inside till their locs are cleared from boulders.
This prevents large number of boulders from pilling up in long rounds

- **[Priority : High] Fixes refineries incorrectly removing materials
from processed boulders**
Fixes tgstation#81109. This bug is quite serious because it can't literarily
affect any random item with custom materials in game. This one line of
code over here can break the entire material economy as we know it

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L217
  
**"DONT DO THIS"**. The `custom_materials` list is a **"read only"**
list & if you ever want to change it call the `set_custom_materials()`
proc with your new values but do not edit this list manually as it is
done here.
  
All lists related to materials are cached by the `SSmaterials`
subsystem. List values are cached & shared across multiple objects so
when you edit those values like here, you might end up effecting an
item/multiple items in some random corner of the map that shares this
list.

This also causes boulders with empty list of materials to get spawned at
random so yeah again plzz don't do this

**4. Refactors**
- Repathes `obj/machinery/boulder_processing/brm` -> just
`obj/machinery/brm`.
Even though semantically it looks nice that the brm is a subtype of
`obj/machinery/boulder_processing` from a code & operation perspective
they have 0 similarities.

1) The BRM does not accept boulders feed into it from a conveyer belt
unlike a refinery but instead picks boulders from `SSore` subsystem &
put it on the conveyer belt. This means procs for accepting boulders
such `CanAllowThrough()`, `breakdown_boulder()`, `accept_boulder()` etc
have no use in the BRM. Their just code clutter at this point
2) The BRM overrides `process()` & does not call its parent proc making
that code wasted
3) It has no use for silo materials & mining points making those vars go
to waste

With so much wasted code its better to just let go off all of it & just
make it a basic instance of `obj/machinery` making maintainence easy

- BRM now teleports boulders in a batch (batch size determined by
`boulders_processing_max` max value from upgraded parts is 7) with a
boulder appearing every 1.5 seconds rather than spawning all at once.
After a batch is processed it has a cooldown of 3 seconds before
repeating the process if automatic boulder retrieval is on. This stops
the conveyer belt from getting crowded with boulders and makes the
refining process more efficient.

With this BRM wires are removed because only it had only 1 wire
responsible for toggling boulder retrieval but now since this process is
automatic, we have true control over the timing of boulders spawned &
don't want to leave it in the hands of players

## Changelog
:cl:
qol: adds examines & screentips for crowbar, screwdriver acts to BRM &
refinery machines
qol: adds examines about the number of boulders stored & processed to
BRM & refinery machines
qol: BRM now has its lights turn on/off depending on wether automatic
boulder retrieval is on/off for visual clarity along with examines
qol: refinery machines now display ballon alerts & plays sounds more
frequently when processing boulders for better feedback
fix: vents now spawn boulders of all sizes & not just small ones
fix: expanded gulag boulders now have correct materials in them.
fix: manual tapping of vents now has a cooldown applied as intended.
fix: BRM has its light turned off when area power goes off
fix: boulders ejected from refineries by hand no longer teleport all
over the place occasionally.
fix: refineries no longer eject boulders with 0 durability
fix: Boulders & refineries no longer pile up on top of BRM's &
refineries in long rounds. Their locs have to be clear of boulders
before they spit out more boulders to prevent a large pile of boulders
from causing lag
fix: sheets ejected from lathes no longer get rejected when inserted
back which could happen at random, no more boulders with empty materials
code: splits boulder types into its own file along with other items
code: merges & autodocs procs, vars related to boulders
refactor: repaths BRM to a simpler subtype
refactor: BRM now spawns boulders in batches(batch size can be increased
with upgraded parts) with a boulder appearing every second. After a
batch is processed a 3 second cooldown is applied to stop the conveyer
belt from clogging up, With this BRM wires are removed as there is no
need for timers to be attached to wires which intefers without our batch
processing timings.
/:cl:

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
larentoun pushed a commit to ss220club/Bandastation that referenced this pull request Mar 1, 2024
## About The Pull Request
**1. Qol**
- Adds screen tips & examines for screwdriver & crowbar acts on BRM,
Refinery & Smelter
- Adds examines to display number of boulders stored inside a refinery &
maximum number of boulders it can hold. Right click screentip to remove
boulders
- Adds examines to display maximum number of boulders than can be
teleported by a BRM & screentips for interacting with wires
- More audio & visual feedback for refinery processing. If a boulder
requires multiple steps you will get a balloon alert saying "crushing"
for refineries & "smelting" for smelters along with a sound per process
tick(which is every 2 seconds so no need for cooldown) giving you a
better idea of what's happening in the pipeline
- BRM now will display all lights when the "Automatic boulder retrieval"
is on & turn off the lights when disabled along with examines giving you
a visual indicator of its state

**2. Code Improvements**
- Splits types of boulders into its own file `boulder_types.dm` for easy
maintainability
- Moves beacon for refinery machines into its own file
`boulder_processing/beacon.dm` for easy maintainability
- Moves the cooldown for processing a boulder `processing_cooldown` into
the refinery machine itself. Since 100's of boulders can be created per
round this var can take up memory quickly so by moving them into the
refinery machine it gives us some savings
- Compressed & merged procs such as `create_mineral_contents()` ,
`flavour_boulder()` etc with the vent code. These procs were only used
by the vent 1 time & by merging the code we removed if conditions to
check if a parent vent was passed or not(since now that's always the
case). Helped in removing boilder plate code

**3. Fixes**
- **Fixes vents always spawning "Small size boulders" & not medium, nor
large boulders.**
 Once a vent generates a boulder it calls  `flavour_boulder()`

https://github.com/tgstation/tgstation/blob/084f56938c0169aeeee0b5f41453f31d072f3f67/code/game/objects/structures/lavaland/ore_vent.dm#L385
however this proc also accepts 2 more params `size` which would always
default to `BOULDER_SIZE_SMALL` and `is_artifact` which is simply unused
in the proc

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L219
Therefore vents would always generate small boulders giving us no
varity. Now the boulder size is set depending on the vent size &
durability for each boulder is set to a random value between 2 & the
boulder max size giving us the flavour we actually wanted

- **Fixes "Expanded Gulag boulders" using "normal gulag material list"
when setting its custom materials.**
If you look at the `add_gulag_minerals()` proc it always picks from the
`gulag_minerals` list & accepts no params

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L235-L236
So when we try to pass params to this proc which in reality doesn't
accept any we were wasting our time doing this

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L274
And for our case `expanded_gulag_minerals` list was simply unused
because our proc doesn't care about it and it went back to just using
`gulag_minerals` list thus ignoring our list

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L282
As i said in the "Code Improvement` section when i moved boulder types
into it's own unique file this was fixed & now expanded gulag boulders
actually has a chance to spawn with bluespace crystals inside them

- **Fixes manual tapping of ore vents by hand not using a cooldown**
`produce_boulder()` accepts a cooldown var for when you need to manually
tap the vent by hand.

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L374
This var was always set to FALSE because we never passed `TRUE` into it.
Not once here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L124
Nor here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L131
Now we just pass `TRUE` so tapping these vents by hand have a cooldown

- **Fixes BRM off icon state never being used**
When the room ran out of power it would still look on. Now we use that
state correctly

- **Fixes Automatic Boulder Retrieval by the BRM not actually being
automatic**
You must have noticed that once you do "Right click" and wait for all
the boulders it can teleport (determined by `boulder_processing_max`) to
be teleported it stops permanently after that. Even if more boulders get
generated it won't do anything, You have to again "Right click" &
retoggle automatic boulder retrieval on again, thus forcing someone to
stand there & monitor the BRM

Now once you set Automatic Boulder Retrieval on you can leave & forget.
It will teleport boulders as & when available thus enabling automation
properly.

- **Fixes boulders ejected from refineries via right click from getting
teleported back into the machines loc**
Fixes
tgstation#78524 (comment).
The problem is refinery machines & the BRM keep track of all the
boulders that entered into it via the `boulders_contained` list.

Now we directly check `contents` for boulders so we don't have to
maintain 2 seperate lists to keep track of boulders. It also now uses
`processed_by` var of boulders to ensure refinerries don't retake in the
same boulder it just processed. Not sure where exactly the problem got
fixed but implementing these 2 measures fixed it regardless.

- **Fixes boulders with 0 durability[a.k.a steps] from getting ejected
out**
Fixes
tgstation#78524 (comment).
So inside `process()` we constantly decrease the durability of the
boulder till it becomes 0.

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L159

  When it reaches 0 it calls `breakdown_boulder()`

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L164-L165

This proc has a chance to reject the boulder if it could not process any
materials

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L219-L222
  
  **"Without resetting its durability"** over here

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L241

So it ends up rejecting a "0" or worse -1 durability boulder. Now we set
the durability in `remove_boulder()` so regardless of what circumstances
the boulder is ejected it always gets a positive durability

- **Fixes BRM & Refinery from rapidly spitting out boulders in their loc
which causes lag in the long terms**
Fixes tgstation#81404. Basically even if there is 1 boulder sitting at a BRM's
loc or an refineries loc. Operations are haulted i.e. the BRM will not
teleport any more boulders & the refinery will keep their already
processed boulders inside till their locs are cleared from boulders.
This prevents large number of boulders from pilling up in long rounds

- **[Priority : High] Fixes refineries incorrectly removing materials
from processed boulders**
Fixes tgstation#81109. This bug is quite serious because it can't literarily
affect any random item with custom materials in game. This one line of
code over here can break the entire material economy as we know it

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L217
  
**"DONT DO THIS"**. The `custom_materials` list is a **"read only"**
list & if you ever want to change it call the `set_custom_materials()`
proc with your new values but do not edit this list manually as it is
done here.
  
All lists related to materials are cached by the `SSmaterials`
subsystem. List values are cached & shared across multiple objects so
when you edit those values like here, you might end up effecting an
item/multiple items in some random corner of the map that shares this
list.

This also causes boulders with empty list of materials to get spawned at
random so yeah again plzz don't do this

**4. Refactors**
- Repathes `obj/machinery/boulder_processing/brm` -> just
`obj/machinery/brm`.
Even though semantically it looks nice that the brm is a subtype of
`obj/machinery/boulder_processing` from a code & operation perspective
they have 0 similarities.

1) The BRM does not accept boulders feed into it from a conveyer belt
unlike a refinery but instead picks boulders from `SSore` subsystem &
put it on the conveyer belt. This means procs for accepting boulders
such `CanAllowThrough()`, `breakdown_boulder()`, `accept_boulder()` etc
have no use in the BRM. Their just code clutter at this point
2) The BRM overrides `process()` & does not call its parent proc making
that code wasted
3) It has no use for silo materials & mining points making those vars go
to waste

With so much wasted code its better to just let go off all of it & just
make it a basic instance of `obj/machinery` making maintainence easy

- BRM now teleports boulders in a batch (batch size determined by
`boulders_processing_max` max value from upgraded parts is 7) with a
boulder appearing every 1.5 seconds rather than spawning all at once.
After a batch is processed it has a cooldown of 3 seconds before
repeating the process if automatic boulder retrieval is on. This stops
the conveyer belt from getting crowded with boulders and makes the
refining process more efficient.

With this BRM wires are removed because only it had only 1 wire
responsible for toggling boulder retrieval but now since this process is
automatic, we have true control over the timing of boulders spawned &
don't want to leave it in the hands of players

## Changelog
:cl:
qol: adds examines & screentips for crowbar, screwdriver acts to BRM &
refinery machines
qol: adds examines about the number of boulders stored & processed to
BRM & refinery machines
qol: BRM now has its lights turn on/off depending on wether automatic
boulder retrieval is on/off for visual clarity along with examines
qol: refinery machines now display ballon alerts & plays sounds more
frequently when processing boulders for better feedback
fix: vents now spawn boulders of all sizes & not just small ones
fix: expanded gulag boulders now have correct materials in them.
fix: manual tapping of vents now has a cooldown applied as intended.
fix: BRM has its light turned off when area power goes off
fix: boulders ejected from refineries by hand no longer teleport all
over the place occasionally.
fix: refineries no longer eject boulders with 0 durability
fix: Boulders & refineries no longer pile up on top of BRM's &
refineries in long rounds. Their locs have to be clear of boulders
before they spit out more boulders to prevent a large pile of boulders
from causing lag
fix: sheets ejected from lathes no longer get rejected when inserted
back which could happen at random, no more boulders with empty materials
code: splits boulder types into its own file along with other items
code: merges & autodocs procs, vars related to boulders
refactor: repaths BRM to a simpler subtype
refactor: BRM now spawns boulders in batches(batch size can be increased
with upgraded parts) with a boulder appearing every second. After a
batch is processed a 3 second cooldown is applied to stop the conveyer
belt from clogging up, With this BRM wires are removed as there is no
need for timers to be attached to wires which intefers without our batch
processing timings.
/:cl:

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
Jolly-66 pushed a commit to TaleStation/TaleStation that referenced this pull request Apr 21, 2024
**1. Qol**
- Adds screen tips & examines for screwdriver & crowbar acts on BRM,
Refinery & Smelter
- Adds examines to display number of boulders stored inside a refinery &
maximum number of boulders it can hold. Right click screentip to remove
boulders
- Adds examines to display maximum number of boulders than can be
teleported by a BRM & screentips for interacting with wires
- More audio & visual feedback for refinery processing. If a boulder
requires multiple steps you will get a balloon alert saying "crushing"
for refineries & "smelting" for smelters along with a sound per process
tick(which is every 2 seconds so no need for cooldown) giving you a
better idea of what's happening in the pipeline
- BRM now will display all lights when the "Automatic boulder retrieval"
is on & turn off the lights when disabled along with examines giving you
a visual indicator of its state

**2. Code Improvements**
- Splits types of boulders into its own file `boulder_types.dm` for easy
maintainability
- Moves beacon for refinery machines into its own file
`boulder_processing/beacon.dm` for easy maintainability
- Moves the cooldown for processing a boulder `processing_cooldown` into
the refinery machine itself. Since 100's of boulders can be created per
round this var can take up memory quickly so by moving them into the
refinery machine it gives us some savings
- Compressed & merged procs such as `create_mineral_contents()` ,
`flavour_boulder()` etc with the vent code. These procs were only used
by the vent 1 time & by merging the code we removed if conditions to
check if a parent vent was passed or not(since now that's always the
case). Helped in removing boilder plate code

**3. Fixes**
- **Fixes vents always spawning "Small size boulders" & not medium, nor
large boulders.**
 Once a vent generates a boulder it calls  `flavour_boulder()`

https://github.com/tgstation/tgstation/blob/084f56938c0169aeeee0b5f41453f31d072f3f67/code/game/objects/structures/lavaland/ore_vent.dm#L385
however this proc also accepts 2 more params `size` which would always
default to `BOULDER_SIZE_SMALL` and `is_artifact` which is simply unused
in the proc

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L219
Therefore vents would always generate small boulders giving us no
varity. Now the boulder size is set depending on the vent size &
durability for each boulder is set to a random value between 2 & the
boulder max size giving us the flavour we actually wanted

- **Fixes "Expanded Gulag boulders" using "normal gulag material list"
when setting its custom materials.**
If you look at the `add_gulag_minerals()` proc it always picks from the
`gulag_minerals` list & accepts no params

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L235-L236
So when we try to pass params to this proc which in reality doesn't
accept any we were wasting our time doing this

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L274
And for our case `expanded_gulag_minerals` list was simply unused
because our proc doesn't care about it and it went back to just using
`gulag_minerals` list thus ignoring our list

https://github.com/tgstation/tgstation/blob/fb83617ff94d6294b0d48c8c6c57488237508d11/code/modules/mining/boulder_processing/boulder.dm#L282
As i said in the "Code Improvement` section when i moved boulder types
into it's own unique file this was fixed & now expanded gulag boulders
actually has a chance to spawn with bluespace crystals inside them

- **Fixes manual tapping of ore vents by hand not using a cooldown**
`produce_boulder()` accepts a cooldown var for when you need to manually
tap the vent by hand.

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L374
This var was always set to FALSE because we never passed `TRUE` into it.
Not once here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L124
Nor here

https://github.com/tgstation/tgstation/blob/e8b5b52d54a60b651d72e610cfb35a237aef6efe/code/game/objects/structures/lavaland/ore_vent.dm#L131
Now we just pass `TRUE` so tapping these vents by hand have a cooldown

- **Fixes BRM off icon state never being used**
When the room ran out of power it would still look on. Now we use that
state correctly

- **Fixes Automatic Boulder Retrieval by the BRM not actually being
automatic**
You must have noticed that once you do "Right click" and wait for all
the boulders it can teleport (determined by `boulder_processing_max`) to
be teleported it stops permanently after that. Even if more boulders get
generated it won't do anything, You have to again "Right click" &
retoggle automatic boulder retrieval on again, thus forcing someone to
stand there & monitor the BRM

Now once you set Automatic Boulder Retrieval on you can leave & forget.
It will teleport boulders as & when available thus enabling automation
properly.

- **Fixes boulders ejected from refineries via right click from getting
teleported back into the machines loc**
Fixes
tgstation/tgstation#78524 (comment).
The problem is refinery machines & the BRM keep track of all the
boulders that entered into it via the `boulders_contained` list.

Now we directly check `contents` for boulders so we don't have to
maintain 2 seperate lists to keep track of boulders. It also now uses
`processed_by` var of boulders to ensure refinerries don't retake in the
same boulder it just processed. Not sure where exactly the problem got
fixed but implementing these 2 measures fixed it regardless.

- **Fixes boulders with 0 durability[a.k.a steps] from getting ejected
out**
Fixes
tgstation/tgstation#78524 (comment).
So inside `process()` we constantly decrease the durability of the
boulder till it becomes 0.

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L159

  When it reaches 0 it calls `breakdown_boulder()`

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L164-L165

This proc has a chance to reject the boulder if it could not process any
materials

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L219-L222

  **"Without resetting its durability"** over here

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L241

So it ends up rejecting a "0" or worse -1 durability boulder. Now we set
the durability in `remove_boulder()` so regardless of what circumstances
the boulder is ejected it always gets a positive durability

- **Fixes BRM & Refinery from rapidly spitting out boulders in their loc
which causes lag in the long terms**
Fixes #81404. Basically even if there is 1 boulder sitting at a BRM's
loc or an refineries loc. Operations are haulted i.e. the BRM will not
teleport any more boulders & the refinery will keep their already
processed boulders inside till their locs are cleared from boulders.
This prevents large number of boulders from pilling up in long rounds

- **[Priority : High] Fixes refineries incorrectly removing materials
from processed boulders**
Fixes #81109. This bug is quite serious because it can't literarily
affect any random item with custom materials in game. This one line of
code over here can break the entire material economy as we know it

https://github.com/tgstation/tgstation/blob/0a496f180c627b9de26d3982d775cbf323fbc459/code/modules/mining/boulder_processing/_boulder_processing.dm#L217

**"DONT DO THIS"**. The `custom_materials` list is a **"read only"**
list & if you ever want to change it call the `set_custom_materials()`
proc with your new values but do not edit this list manually as it is
done here.

All lists related to materials are cached by the `SSmaterials`
subsystem. List values are cached & shared across multiple objects so
when you edit those values like here, you might end up effecting an
item/multiple items in some random corner of the map that shares this
list.

This also causes boulders with empty list of materials to get spawned at
random so yeah again plzz don't do this

**4. Refactors**
- Repathes `obj/machinery/boulder_processing/brm` -> just
`obj/machinery/brm`.
Even though semantically it looks nice that the brm is a subtype of
`obj/machinery/boulder_processing` from a code & operation perspective
they have 0 similarities.

1) The BRM does not accept boulders feed into it from a conveyer belt
unlike a refinery but instead picks boulders from `SSore` subsystem &
put it on the conveyer belt. This means procs for accepting boulders
such `CanAllowThrough()`, `breakdown_boulder()`, `accept_boulder()` etc
have no use in the BRM. Their just code clutter at this point
2) The BRM overrides `process()` & does not call its parent proc making
that code wasted
3) It has no use for silo materials & mining points making those vars go
to waste

With so much wasted code its better to just let go off all of it & just
make it a basic instance of `obj/machinery` making maintainence easy

- BRM now teleports boulders in a batch (batch size determined by
`boulders_processing_max` max value from upgraded parts is 7) with a
boulder appearing every 1.5 seconds rather than spawning all at once.
After a batch is processed it has a cooldown of 3 seconds before
repeating the process if automatic boulder retrieval is on. This stops
the conveyer belt from getting crowded with boulders and makes the
refining process more efficient.

With this BRM wires are removed because only it had only 1 wire
responsible for toggling boulder retrieval but now since this process is
automatic, we have true control over the timing of boulders spawned &
don't want to leave it in the hands of players

:cl:
qol: adds examines & screentips for crowbar, screwdriver acts to BRM &
refinery machines
qol: adds examines about the number of boulders stored & processed to
BRM & refinery machines
qol: BRM now has its lights turn on/off depending on wether automatic
boulder retrieval is on/off for visual clarity along with examines
qol: refinery machines now display ballon alerts & plays sounds more
frequently when processing boulders for better feedback
fix: vents now spawn boulders of all sizes & not just small ones
fix: expanded gulag boulders now have correct materials in them.
fix: manual tapping of vents now has a cooldown applied as intended.
fix: BRM has its light turned off when area power goes off
fix: boulders ejected from refineries by hand no longer teleport all
over the place occasionally.
fix: refineries no longer eject boulders with 0 durability
fix: Boulders & refineries no longer pile up on top of BRM's &
refineries in long rounds. Their locs have to be clear of boulders
before they spit out more boulders to prevent a large pile of boulders
from causing lag
fix: sheets ejected from lathes no longer get rejected when inserted
back which could happen at random, no more boulders with empty materials
code: splits boulder types into its own file along with other items
code: merges & autodocs procs, vars related to boulders
refactor: repaths BRM to a simpler subtype
refactor: BRM now spawns boulders in batches(batch size can be increased
with upgraded parts) with a boulder appearing every second. After a
batch is processed a 3 second cooldown is applied to stop the conveyer
belt from clogging up, With this BRM wires are removed as there is no
need for timers to be attached to wires which intefers without our batch
processing timings.
/:cl:

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
@Krypandenej
Copy link
Contributor

There's a bug with this where surrounding the vent with doors stops mobs from spawning. Or is this intended?

@LemonInTheDark
Copy link
Member

LemonInTheDark commented May 15, 2024

brother you should make an issue report but also that sounds like it'd be hard to do accidentally code side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Exposes new bugs in interesting ways Map Edit Thank you for your tile-placing service. It's always appreciated. Sound Oh god my ears, they bleed, did you normalise the volume? Sprites A bikeshed full of soulless bikes. UI We make the game less playable, but with round edges
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet