Files
Bubberstation/code/modules/shuttle/mobile_port/variants
SyncIt21 749643cddb Reworks cargo market elasticity (#93235)
## About The Pull Request
What it says on the tin. Cargo now has new math for market elasticity,
each parameter and what it does is explained below

**1. Refactor**
1. **k_elasticity**: This is the elasticity as before applied on all
exports except now this is a floating-point value that swings from
`0->1` instead of 10e-10 like is the current case. This in laymen terms
is the percentile of an items actual cost that is sold on cargo [0 means
you get no credits, 0.5 means you get 50% of the items cost, 1 means you
get 100% of the items cost]. Whenever an item is sold on cargo this
value decreases by an amount that is determined by the next variable

2. **k_hit_percentile(default 5%)**: This is the value by which an
export `k_elasticity` decreases whenever an export is successful for
every unit of an item sold. The real formulae by which the exports
elasticity decreases is dependent on the total amount sold and is as
follows
<pre>k_elasticity -= amount sold (1 for most cases except stacks) *
k_hit_percentile</pre>
So subsequent exports yield lesser profits cause the elasticity
decreases. Now the rate at which the elasticity recovers is as follows

3. **k_recovery_time(default 10 minutes)**: This is the time (minimum
unit should be seconds) it takes for the elasticity to rebound back to
100% after it has reached full 0 but recovery process starts immediately
if it decreases at any point. So if elasticity becomes say 50% it means
it would take 5 minutes to reach 100% again

**2. Some Balance changes**
1. Profits earned from exporting gas is linear per mole sold so the more
gas you put in the more profits you get HOWEVER the max number of
credits you can make per canister is 15000 cr
2. Selling fish yields higher prices because it's no longer subject to
the old elasticity formula
3. Selling 50 sheets of anything will decrease future sale price by 10%
and will take 8 minutes to rebound back to 100% if it reaches 0

**3. Improvements:**
- `SSProcessing` subsystem no longer processes more than 180+ export
datums from round start itself but now starts out empty. It instead
processes only those exports whose elasticity has been impacted and
later cancels it after elasticity has reached 100% so performance of
this subsystem has been drastically improved
- export datums now respect `abstract_type` meaning they won't be
created and can be used as a skeleton body for subtypes. So datums like
`datum/material` & `datum/material/market` are not created anymore but
only their subtypes are so we save processing power & memory
 - Shaved of a lot of dead exports that went unused

## Changelog
🆑
balance: cargo exports now have different prices with applied elasticity
code: Improved performance of export code
qol: stock blocks can be recycled for materials & show up as stock
blocks in order console sold items
refactor: refactored cargo export code in whole. Report bugs on GitHub
/🆑

---------

Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com>
2025-10-18 04:36:09 -04:00
..
2025-10-07 20:28:59 +02:00
2025-10-07 20:28:59 +02:00