From df26dfaf030ba4490c32f585bbd3280e15879e63 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 15 Nov 2023 13:06:49 +0100 Subject: [PATCH] [MIRROR] Fixes to the Galactic Material Market regarding market quantity. [MDB IGNORE] (#25022) * Fixes to the Galactic Material Market regarding market quantity. (#79307) ## About The Pull Request This PR makes a fix to market quantity of materials on the GMM. In short, when you buy sheets, they get removed from the market's pool of available resources. When buying resources, they now shift up and down based on a fraction of their inherent base_market_quantity, and not their current quantity, preventing situations where a material can fully deplete all its stock forever. I've also tweaked the numbers to try and keep those changes from swinging too far wide as a result of this change. Respecting quantity of materials should additionally help to decrease the quantity of bike rounds in-game as well as the rare but horrifying billion credit round. ## Why It's Good For The Game Respecting quantity of materials should additionally help to decrease the quantity of bike rounds in-game as well as the rare but horrifying billion credit round. Also, I namely just completely missed this during the original PR and I've been out of state for a few weeks so I've been meaning to get around to fixing this. Fixes #79116. Fixes #79247. ## Changelog :cl: fix: The Galactic Material Market now respects quantity of materials purchased, removing them from the market when bought and preventing you from ordering more than are available at a given time. /:cl: --------- Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@ users.noreply.github.com> * Fixes to the Galactic Material Market regarding market quantity. --------- Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@ users.noreply.github.com> --- code/controllers/subsystem/stock_market.dm | 9 +++++---- code/modules/cargo/packs/_packs.dm | 13 +++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/code/controllers/subsystem/stock_market.dm b/code/controllers/subsystem/stock_market.dm index 7c2cb71dc49..c0d85eaf85d 100644 --- a/code/controllers/subsystem/stock_market.dm +++ b/code/controllers/subsystem/stock_market.dm @@ -51,6 +51,7 @@ SUBSYSTEM_DEF(stock_market) price_minimum = round(initial(mat.minimum_value_override) * SHEET_MATERIAL_AMOUNT) var/price_maximum = round(initial(mat.value_per_unit) * SHEET_MATERIAL_AMOUNT * 3) var/price_baseline = initial(mat.value_per_unit) * SHEET_MATERIAL_AMOUNT + var/quantity_baseline = initial(mat.tradable_base_quantity) var/stock_quantity = materials_quantity[mat] @@ -84,15 +85,15 @@ SUBSYSTEM_DEF(stock_market) switch(trend) if(MARKET_TREND_UPWARD) price_change = ROUND_UP(gaussian(price_units * 0.1, price_baseline * 0.05)) //If we don't ceil, small numbers will get trapped at low values - quantity_change = -round(gaussian(stock_quantity * 0.1, stock_quantity * 0.05)) + quantity_change = -round(gaussian(quantity_baseline * 0.05, quantity_baseline * 0.05)) if(MARKET_TREND_STABLE) price_change = round(gaussian(0, price_baseline * 0.01)) - quantity_change = round(gaussian(0, stock_quantity * 0.01)) + quantity_change = round(gaussian(0, quantity_baseline * 0.01)) if(MARKET_TREND_DOWNWARD) price_change = -ROUND_UP(gaussian(price_units * 0.1, price_baseline * 0.05)) - quantity_change = round(gaussian(stock_quantity * 0.1, stock_quantity * 0.05)) + quantity_change = round(gaussian(quantity_baseline * 0.05, quantity_baseline * 0.05)) materials_prices[mat] = round(clamp(price_units + price_change, price_minimum, price_maximum)) - materials_quantity[mat] = round(clamp(stock_quantity + quantity_change, 0, initial(mat.tradable_base_quantity) * 2)) + materials_quantity[mat] = round(clamp(stock_quantity + quantity_change, 0, quantity_baseline * 2)) /** * Market events are a way to spice up the market and make it more interesting. diff --git a/code/modules/cargo/packs/_packs.dm b/code/modules/cargo/packs/_packs.dm index aaeb55f2533..51ec71649dd 100644 --- a/code/modules/cargo/packs/_packs.dm +++ b/code/modules/cargo/packs/_packs.dm @@ -122,3 +122,16 @@ name = "[purchaser]'s Materials Order" src.cost = cost src.contains = contains + +/datum/supply_pack/custom/minerals/fill(obj/structure/closet/crate/C) + . = ..() + //Remove our material sheets from SSstock_market's materials_quantity equal to the quantity within the crate. + for(var/obj/item/stack/sheet/possible_stack as anything in contains) + if(!ispath(possible_stack, /obj/item/stack/sheet)) + continue + if(!possible_stack.material_type) + continue + if(!SSstock_market.materials_quantity[possible_stack.material_type]) + continue + SSstock_market.materials_quantity[possible_stack.material_type] -= contains[possible_stack] + SSstock_market.materials_prices[possible_stack.material_type] += round((SSstock_market.materials_prices[possible_stack.material_type]) * (contains[possible_stack] / (SSstock_market.materials_quantity[possible_stack.material_type] - contains[possible_stack])))