From 074e21e16c325818ba72a183b51ca4efbf0210a1 Mon Sep 17 00:00:00 2001 From: Ben <91219575+Ben10083@users.noreply.github.com> Date: Mon, 15 Sep 2025 08:11:46 -0400 Subject: [PATCH] Cargo Price Inflation (#21258) Refactors cargo pricing code to properly adjust prices based on sector and category (earlier it would multiply the price by each category's multiplier, leading to prices above intended price point) --------- Co-authored-by: Ben10083 --- code/controllers/subsystems/cargo.dm | 1 + code/modules/cargo/items/cargo_items.dm | 10 +++- .../changelogs/Ben10083 - Cargo_Price_Fix.yml | 58 +++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 html/changelogs/Ben10083 - Cargo_Price_Fix.yml diff --git a/code/controllers/subsystems/cargo.dm b/code/controllers/subsystems/cargo.dm index 629043be03d..690cff3b6db 100644 --- a/code/controllers/subsystems/cargo.dm +++ b/code/controllers/subsystems/cargo.dm @@ -102,6 +102,7 @@ SUBSYSTEM_DEF(cargo) /datum/controller/subsystem/cargo/proc/load_cargo_suppliers() for(var/singleton/cargo_supplier/S as anything in (GET_SINGLETON_SUBTYPE_LIST(/singleton/cargo_supplier))) log_subsystem_cargo("Loading supplier '[S.name]', with short name '[S.short_name]'.") + S.price_modifier = S.get_total_price_coefficient() SScargo.cargo_suppliers[S.short_name] = S /datum/controller/subsystem/cargo/proc/load_cargo_items() diff --git a/code/modules/cargo/items/cargo_items.dm b/code/modules/cargo/items/cargo_items.dm index 99f4ce26b15..548c46ce161 100644 --- a/code/modules/cargo/items/cargo_items.dm +++ b/code/modules/cargo/items/cargo_items.dm @@ -46,9 +46,17 @@ /// Sets the item's adjusted_price according to different price modifiers. Returns nothing. /singleton/cargo_item/proc/get_adjusted_price() var/return_price = price + var/item_category = SScargo.get_category_by_name(category) + var/item_supplier = SScargo.get_supplier_by_name(supplier) + + for(var/supplier_name in SScargo.cargo_suppliers) + var/singleton/cargo_supplier/cs = SScargo.get_supplier_by_name(supplier_name) + if(cs == item_supplier) + return_price *= cs.price_modifier + for(var/category_name in SScargo.cargo_categories) var/singleton/cargo_category/cc = SScargo.get_category_by_name(category_name) - if(cc) + if(cc == item_category) return_price *= cc.price_modifier adjusted_price = return_price diff --git a/html/changelogs/Ben10083 - Cargo_Price_Fix.yml b/html/changelogs/Ben10083 - Cargo_Price_Fix.yml new file mode 100644 index 00000000000..75b1b7bb481 --- /dev/null +++ b/html/changelogs/Ben10083 - Cargo_Price_Fix.yml @@ -0,0 +1,58 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# - (fixes bugs) +# wip +# - (work in progress) +# qol +# - (quality of life) +# soundadd +# - (adds a sound) +# sounddel +# - (removes a sound) +# rscadd +# - (adds a feature) +# rscdel +# - (removes a feature) +# imageadd +# - (adds an image or sprite) +# imagedel +# - (removes an image or sprite) +# spellcheck +# - (fixes spelling or grammar) +# experiment +# - (experimental change) +# balance +# - (balance changes) +# code_imp +# - (misc internal code change) +# refactor +# - (refactors code) +# config +# - (makes a change to the config files) +# admin +# - (makes changes to administrator tools) +# server +# - (miscellaneous changes to server) +################################# + +# Your name. +author: Ben10083 + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit. +# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog. +changes: + - refactor: "Adds Inflation.... by refactoring cargo pricing code to properly adjust prices based on category and supplier price modifiers."