Files
Alexis 21b4095dfd [MDB IGNORE] [IDB IGNORE] Upstream Sync - 04/17/2026 (#5453)
Upstream 04/17/2026

fixes https://github.com/Bubberstation/Bubberstation/issues/5549

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com>
Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com>
Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com>
Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com>
Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com>
Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com>
Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com>
Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com>
Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com>
Co-authored-by: loganuk <fakeemail123@aol.com>
Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com>
Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com>
Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com>
Co-authored-by: Lucy <lucy@absolucy.moe>
Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com>
Co-authored-by: Isratosh <Isratosh@hotmail.com>
Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com>
Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com>
Co-authored-by: Alexander V. <volas@ya.ru>
Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com>
Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
Co-authored-by: Cameron Lennox <killer65311@gmail.com>
Co-authored-by: Tim <timothymtorres@gmail.com>
Co-authored-by: Iamgoofball <iamgoofball@gmail.com>
Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com>
Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com>
Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com>
Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com>
Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com>
Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com>
Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com>
Co-authored-by: Josh <josh.adam.powell@gmail.com>
Co-authored-by: Josh Powell <josh.powell@softwire.com>
Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com>
Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com>
Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com>
Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
2026-05-16 00:56:00 +02:00

196 lines
6.3 KiB
Plaintext

/datum/export/material
abstract_type = /datum/export/material
cost = 5 // Cost per SHEET_MATERIAL_AMOUNT, which is 100cm3 as of May 2023.
k_hit_percentile = 0.2 / MAX_STACK_SIZE //Meaning selling 1 full stack of materials will decrease subsequent sales by 20%
k_recovery_time = 8 MINUTES
message = "cm3 of developer's tears. Please, report this on github"
amount_report_multiplier = SHEET_MATERIAL_AMOUNT
export_types = list(
/obj/item/stack/sheet/mineral,
/obj/item/stack/tile/mineral,
/obj/item/stack/ore,
/obj/item/coin,
)
/// Material id we are trying to export.
var/datum/material/material_id = null
/// Whether we use the shared static export types or not. Set to FALSE when using different export types.
var/use_shared_exports = TRUE
// Yes, it's a base type containing export_types.
// But it has no material_id, so any applies_to check will return false, and these types reduce amount of copypasta a lot
/datum/export/material/New()
var/temp_exports = export_types
export_types = null
. = ..()
export_types = init_export_types(temp_exports)
/**
* Inits an list of exports for this type.
* For performance, unless use_shared_exports is FALSE,
* this returns a static list of types we check for export
* that is shared by everything under the same abstract type.
*
* Arguments
* * export_data - exports whos type cache we are trying to create
*/
/datum/export/material/proc/init_export_types(export_data)
PROTECTED_PROC(TRUE)
if(!use_shared_exports)
return generate_export_typecache(export_data)
var/static/list/shared_exports = list()
if(isnull(shared_exports[abstract_type]))
shared_exports[abstract_type] = generate_export_typecache(export_data)
return shared_exports[abstract_type]
/datum/export/material/proc/generate_export_typecache(export_data)
return typecacheof(export_data, only_root_path = !include_subtypes)
/datum/export/material/get_amount(obj/exported_item)
if(!isitem(exported_item))
return 0
var/obj/item/our_item = exported_item
var/list/mat_comp = our_item.get_material_composition()
var/datum/material/mat_ref = ispath(material_id) ? locate(material_id) in mat_comp : SSmaterials.get_material(material_id)
var/amount = mat_comp[mat_ref]
if(!amount)
return 0
if(istype(our_item, /obj/item/stack/ore))
amount *= 0.8 // Station's ore redemption equipment is really goddamn good.
return round(amount / SHEET_MATERIAL_AMOUNT)
// Materials. Static materials exist as parent types, while materials subject to the stock market have a fluid cost as determined by material/market types
// If you're adding a new material to the stock market, make sure its export type is added here.
/datum/export/material/plasma
cost = CARGO_CRATE_VALUE * 0.4
k_elasticity = 0
material_id = /datum/material/plasma
message = "cm3 of plasma"
/datum/export/material/bananium
cost = CARGO_CRATE_VALUE * 2
material_id = /datum/material/bananium
message = "cm3 of bananium"
/datum/export/material/adamantine
cost = CARGO_CRATE_VALUE
material_id = /datum/material/adamantine
message = "cm3 of adamantine"
/datum/export/material/mythril
cost = CARGO_CRATE_VALUE * 3
material_id = /datum/material/mythril
message = "cm3 of mythril"
/datum/export/material/plastic
cost = CARGO_CRATE_VALUE * 0.05
message = "cm3 of plastic"
material_id = /datum/material/plastic
/datum/export/material/runite
cost = CARGO_CRATE_VALUE * 1.2
message = "cm3 of runite"
material_id = /datum/material/runite
/datum/export/material/hot_ice
cost = CARGO_CRATE_VALUE * 0.8
message = "cm3 of Hot Ice"
material_id = /datum/material/hot_ice
export_types = /obj/item/stack/sheet/hot_ice
use_shared_exports = FALSE
/datum/export/material/metal_hydrogen
cost = CARGO_CRATE_VALUE * 1.05
message = "cm3 of metallic hydrogen"
material_id = /datum/material/metalhydrogen
export_types = /obj/item/stack/sheet/mineral/metal_hydrogen
use_shared_exports = FALSE
/datum/export/material/market
abstract_type = /datum/export/material/market
cost = 1
/datum/export/material/market/generate_export_typecache(export_data)
. = ..()
// Always include the stock block for any market exports.
.[/obj/item/stock_block] = TRUE
return .
/datum/export/material/market/get_base_cost(obj/exported_obj)
. = ..()
if(!istype(exported_obj, /obj/item/stock_block))
return . * SSstock_market.materials_prices[material_id]
var/obj/item/stock_block/exported_block = exported_obj
return . * (exported_block.fluid ? SSstock_market.materials_prices[exported_block.custom_materials[1].type] : exported_block.export_value)
/datum/export/material/market/sell_object(obj/sold_item, datum/export_report/report, dry_run, apply_elastic)
. = ..()
if(dry_run)
return
var/sheets = get_amount(sold_item)
if(!sheets)
return
//This formula should impact lower quantity materials greater, and higher quantity materials less. Still, it's a bit rough. Tweaking may be needed.
//decrease the market price
SSstock_market.adjust_material_price(material_id, -SSstock_market.materials_prices[material_id] * (sheets / (sheets + SSstock_market.materials_quantity[material_id])))
//increase the stock
SSstock_market.adjust_material_quantity(material_id, sheets)
/datum/export/material/market/diamond
material_id = /datum/material/diamond
message = "cm3 of diamonds"
/datum/export/material/market/uranium
material_id = /datum/material/uranium
message = "cm3 of uranium"
/datum/export/material/market/gold
material_id = /datum/material/gold
message = "cm3 of gold"
/datum/export/material/market/silver
material_id = /datum/material/silver
message = "cm3 of silver"
/datum/export/material/market/titanium
material_id = /datum/material/titanium
message = "cm3 of titanium"
/datum/export/material/market/bscrystal
message = "of bluespace crystals"
material_id = /datum/material/bluespace
export_types = list(
/obj/item/stack/sheet/bluespace_crystal,
/obj/item/stack/ore/bluespace_crystal,
)
use_shared_exports = FALSE
/datum/export/material/market/iron
message = "cm3 of iron"
material_id = /datum/material/iron
export_types = list(
/obj/item/stack/sheet/iron,
/obj/item/stack/tile/iron,
/obj/item/stack/rods,
/obj/item/stack/ore,
/obj/item/coin,
)
use_shared_exports = FALSE
/datum/export/material/market/glass
message = "cm3 of glass"
material_id = /datum/material/glass
export_types = list(
/obj/item/stack/sheet/glass,
/obj/item/stack/ore,
/obj/item/shard,
)
use_shared_exports = FALSE