Skip to content

Commit

Permalink
[MIRROR] Arcargo: Vendor Cargo and Vending Machine Update (#1312) (#2306
Browse files Browse the repository at this point in the history
)

* Arcargo: Vendor Cargo and Vending Machine Update (#81582)

Another one.

## About The Pull Request
This pull request originally had a design doc that @Fikou and I worked
on, but that was never really polished up for publishing quality so I'll
forgo it for now and be as descript as possible here.

### Core changes
- This pull request adds a new NTOS app to the game, the restock
tracker. The restock tracker shows a comprehensive list of vending
machines across the station, as long as there is a need for that vending
machine to get restocked.
- This has also been pre-installed into the cargo data disks.
(`/obj/item/computer_disk/quartermaster`)
- Vending machines now store a total of 20% of the cost of any purchase
made within themselves into a small pool of cash. This only applies to
premium and normal purchases, not to contraband, as they're technically
not sanctioned by the company.
- The restock tracker app will also track which vending machines have
the most credits stored internally inside them.
- By refilling a vending machine, the stored credits within are paid out
to any crewmember who goes and restocks the station, while also paying
out *half that amount to the cargo budget*, serving as a basic but
otherwise easy tertiary money making method on the same level of
complexity as doing bounties, with the added benefit of actually helping
to assist the station for jobs like... assistant.


![image](https://github.com/tgstation/tgstation/assets/41715314/59cee2d9-7e60-4733-8a76-d88fe5b8c3f2)

### Break Stuff
- Anyway, when you try and smash a vending machine open with a melee
weapon of choice, it can now pay out 50 credits at a time as a way to
make money at zero risk to yourself.
- ~~Except for the horrible risk to yourself.~~

![image](https://github.com/tgstation/tgstation/assets/41715314/23208bf0-8484-40b9-b753-0ffdb57d770f)

### Cargo Specific Changes
- Restock units may now be sold for a small profit as well, to
incentivize cargo to keep the station stocked further.
- The `STATION_TRAIT_VENDING_SHORTAGE` trait will now add a small amount
of existing credits into the vending machines on station, to incentivize
cargo to fix the issue during the round and not just push for an early
shuttle call. Or, more accurately, provide the crew with a money making
scheme to engage better with the station trait as it stands.

### This also refactors behavior on vending machines
- This pull request also finally changes it so that vending machines now
use the payment component, which as a consequence allows for the
following improvements:
* Vending machines may now pull from physical credits on your person,
not just requiring you to have money on your ID card.
* Vending machines may also use credits being pulled by the player
interacting with the vending machine, allowing for handless mobs to be
able to purchase items from a vending machine.
* Finally makes the "use-for-everything buying things component" used by
the most utilized component of the in-game economy, to reduce the
quantity of unique implementations of purchasing things in the code.
- Existing vending specific checks are retained on before handing off
behavior to the payment component, for behavior such as purchasing
cigarettes/alcohol under the age of 18/21.

Notes:
- Vending machines will lose their internal credits stored when
deconstructed, as a security measure.
- Vending machines will now show the total amount of credits that a mob
has on their person, combining physical credits as well as credits held
in their ID card to accurately portray their total wealth across the mob
in question.

## Why It's Good For The Game

First off, this is largely an excuse to move vending machine behavior
over to the payment component for the purposes to less code copy-paste,
and to try and make the implementation more wide-spread.

Second, this implements a new tertiary economy method to the game, in
the same design space as bounties, which serve as common methods of
making money without necessarily being specific to their job in
question, with the primary goal of providing small amounts of work to
the crew and a basic interaction with the economy system.

Additionally, it gives cargo more things they can do to assist the
station, and a way to know which parts of the station need support as a
result.
It improves the interaction between the vending shortage station trait
as well, making it a challenge with depth as opposed to a more
oppressive round change that players would rather reroll the game over.

Additionally, this makes a few price tweaks to vending restock modules
as well to help incentivize buying some of the more minor restock kits,
and a few select bumps on restocks that cover wide enough territory to
necessitate fewer restocks.

* Arcargo: Vendor Cargo and Vending Machine Update

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: ArcaneMusic <[email protected]>
  • Loading branch information
3 people authored Mar 8, 2024
1 parent cc03394 commit bfc5fd3
Show file tree
Hide file tree
Showing 20 changed files with 257 additions and 48 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/economy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#define PAYMENT_CLINICAL "clinical"
#define PAYMENT_FRIENDLY "friendly"
#define PAYMENT_ANGRY "angry"
#define PAYMENT_VENDING "vending"

#define MARKET_TREND_UPWARD 1
#define MARKET_TREND_DOWNWARD -1
Expand Down
7 changes: 7 additions & 0 deletions code/__HELPERS/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,10 @@ GLOBAL_LIST_INIT(WALLITEMS_EXTERIOR, typecacheof(list(
/obj/structure/camera_assembly,
/obj/structure/light_construct,
)))

/// A static typecache of all the money-based items that can be actively used as currency.
GLOBAL_LIST_INIT(allowed_money, typecacheof(list(
/obj/item/coin,
/obj/item/holochip,
/obj/item/stack/spacecash,
)))
22 changes: 14 additions & 8 deletions code/datums/components/payment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
var/datum/bank_account/target_acc
///Does this payment component respect same-department-discount?
var/department_discount = FALSE
///A static typecache of all the money-based items that can be actively used as currency.
var/static/list/allowed_money = typecacheof(list(
/obj/item/stack/spacecash,
/obj/item/holochip,
/obj/item/coin))

/datum/component/payment/Initialize(_cost, _target, _style)
target_acc = _target
Expand Down Expand Up @@ -80,13 +75,13 @@
//Here is all the possible non-ID payment methods.
var/list/counted_money = list()
var/physical_cash_total = 0
for(var/obj/item/credit in typecache_filter_list(user.get_all_contents(), allowed_money)) //Coins, cash, and credits.
for(var/obj/item/credit in typecache_filter_list(user.get_all_contents(), GLOB.allowed_money)) //Coins, cash, and credits.
if(physical_cash_total > total_cost)
break
physical_cash_total += credit.get_item_credit_value()
counted_money += credit

if(is_type_in_typecache(user.pulling, allowed_money) && (physical_cash_total < total_cost)) //Coins(Pulled).
if(is_type_in_typecache(user.pulling, GLOB.allowed_money) && (physical_cash_total < total_cost)) //Coins(Pulled).
var/obj/item/counted_credit = user.pulling
physical_cash_total += counted_credit.get_item_credit_value()
counted_money += counted_credit
Expand Down Expand Up @@ -134,9 +129,11 @@
* Attempts to charge a mob, user, an integer number of credits, total_cost, directly from an ID card/bank account.
*/
/datum/component/payment/proc/handle_card(mob/living/user, obj/item/card/id/idcard, total_cost)
var/atom/atom_parent = parent
var/atom/movable/atom_parent = parent

if(!idcard)
if(transaction_style == PAYMENT_VENDING)
to_chat(user, span_warning("No card found."))
return FALSE
if(!idcard?.registered_account)
switch(transaction_style)
Expand All @@ -146,6 +143,13 @@
to_chat(user, span_warning("ARE YOU JOKING. YOU DON'T HAVE A BANK ACCOUNT ON YOUR ID YOU IDIOT."))
if(PAYMENT_CLINICAL)
to_chat(user, span_warning("ID Card lacks a bank account. Advancing."))
if(PAYMENT_VENDING)
to_chat(user, span_warning("No account found."))

return FALSE

if(!idcard.registered_account.account_job)
atom_parent.say("Departmental accounts have been blacklisted from personal expenses due to embezzlement.")
return FALSE

if(!(idcard.registered_account.has_money(total_cost)))
Expand All @@ -156,6 +160,8 @@
to_chat(user, span_warning("YOU MORON. YOU ABSOLUTE BAFOON. YOU INSUFFERABLE TOOL. YOU ARE POOR."))
if(PAYMENT_CLINICAL)
to_chat(user, span_warning("ID Card lacks funds. Aborting."))
if(PAYMENT_VENDING)
to_chat(user, span_warning("You do not possess the funds to purchase that."))
atom_parent.balloon_alert(user, "needs [total_cost] credit\s!")
return FALSE
target_acc.transfer_money(idcard.registered_account, total_cost, "Nanotrasen: Usage of Corporate Machinery")
Expand Down
6 changes: 4 additions & 2 deletions code/game/objects/items/vending_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
w_class = WEIGHT_CLASS_BULKY
armor_type = /datum/armor/item_vending_refill

// Built automatically from the corresponding vending machine.
// If null, considered to be full. Otherwise, is list(/typepath = amount).
/**
* Built automatically from the corresponding vending machine.
* If null, considered to be full. Otherwise, is list(/typepath = amount).
*/
var/list/products
var/list/product_categories
var/list/contraband
Expand Down
6 changes: 6 additions & 0 deletions code/modules/cargo/exports/parts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@
unit_name = "data disk"
export_types = list(/obj/item/computer_disk)
include_subtypes = TRUE

/datum/export/refill_canister
cost = CARGO_CRATE_VALUE * 0.5 //If someone want to make this worth more as it empties, go ahead
unit_name = "vending refill canister"
message = "Thank you for restocking the station!"
export_types = list(/obj/item/vending_refill)
1 change: 1 addition & 0 deletions code/modules/cargo/markets/market_uplink.dm
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
icon_state = "uplink"
//The original black market uplink
accessible_markets = list(/datum/market/blackmarket)
custom_premium_price = PAYCHECK_CREW * 2.5


/datum/crafting_recipe/blackmarket_uplink
Expand Down
20 changes: 10 additions & 10 deletions code/modules/cargo/packs/vending_restock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/datum/supply_pack/vending/bartending
name = "Booze-o-mat and Coffee Supply Crate"
desc = "Bring on the booze and coffee vending machine refills."
cost = CARGO_CRATE_VALUE * 4
cost = CARGO_CRATE_VALUE * 2
contains = list(/obj/item/vending_refill/boozeomat,
/obj/item/vending_refill/coffee,
)
Expand All @@ -14,7 +14,7 @@
name = "Cigarette Supply Crate"
desc = "Don't believe the reports - smoke today! Contains a \
cigarette vending machine refill."
cost = CARGO_CRATE_VALUE * 3
cost = CARGO_CRATE_VALUE * 2
contains = list(/obj/item/vending_refill/cigarette)
crate_name = "cigarette supply crate"
crate_type = /obj/structure/closet/crate
Expand Down Expand Up @@ -62,7 +62,7 @@
/datum/supply_pack/vending/imported
name = "Imported Vending Machines"
desc = "Vending machines famous in other parts of the galaxy."
cost = CARGO_CRATE_VALUE * 8
cost = CARGO_CRATE_VALUE * 5
contains = list(/obj/item/vending_refill/sustenance,
/obj/item/vending_refill/robotics,
/obj/item/vending_refill/sovietsoda,
Expand All @@ -74,7 +74,7 @@
name = "Medical Vending Crate"
desc = "Contains one NanoMed Plus refill, one NanoDrug Plus refill, \
and one wall-mounted NanoMed refill."
cost = CARGO_CRATE_VALUE * 5
cost = CARGO_CRATE_VALUE * 3.5
contains = list(/obj/item/vending_refill/medical,
/obj/item/vending_refill/drugs,
/obj/item/vending_refill/wallmed,
Expand All @@ -85,7 +85,7 @@
name = "PTech Supply Crate"
desc = "Not enough cartridges after half the crew lost their PDA \
to explosions? This may fix it."
cost = CARGO_CRATE_VALUE * 3
cost = CARGO_CRATE_VALUE * 2.5
contains = list(/obj/item/vending_refill/cart)
crate_name = "\improper PTech supply crate"

Expand All @@ -103,22 +103,22 @@
name = "Snack Supply Crate"
desc = "One vending machine refill of cavity-bringin' goodness! \
The number one dentist recommended order!"
cost = CARGO_CRATE_VALUE * 3
cost = CARGO_CRATE_VALUE * 2
contains = list(/obj/item/vending_refill/snack)
crate_name = "snacks supply crate"

/datum/supply_pack/vending/cola
name = "Softdrinks Supply Crate"
desc = "Got whacked by a toolbox, but you still have those pesky teeth? \
Get rid of those pearly whites with this soda machine refill, today!"
cost = CARGO_CRATE_VALUE * 3
cost = CARGO_CRATE_VALUE * 2
contains = list(/obj/item/vending_refill/cola)
crate_name = "soft drinks supply crate"

/datum/supply_pack/vending/vendomat
name = "Part-Mart & YouTool Supply Crate"
desc = "More tools for your IED testing facility."
cost = CARGO_CRATE_VALUE * 2
cost = CARGO_CRATE_VALUE * 3
contains = list(/obj/item/vending_refill/assist,
/obj/item/vending_refill/youtool,
)
Expand All @@ -138,7 +138,7 @@
name = "Autodrobe Supply Crate"
desc = "Autodrobe missing your favorite dress? Solve that issue today \
with this autodrobe refill."
cost = CARGO_CRATE_VALUE * 3
cost = CARGO_CRATE_VALUE * 2
contains = list(/obj/item/vending_refill/autodrobe)
crate_name = "autodrobe supply crate"

Expand Down Expand Up @@ -200,7 +200,7 @@
name = "Science Wardrobe Supply Crate"
desc = "This crate contains refills for the SciDrobe, \
GeneDrobe, and RoboDrobe."
cost = CARGO_CRATE_VALUE * 3
cost = CARGO_CRATE_VALUE * 4.5
contains = list(/obj/item/vending_refill/wardrobe/robo_wardrobe,
/obj/item/vending_refill/wardrobe/gene_wardrobe,
/obj/item/vending_refill/wardrobe/science_wardrobe,
Expand Down
17 changes: 17 additions & 0 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2706,3 +2706,20 @@ GLOBAL_LIST_EMPTY(fire_appearances)
end_look_down()
else
look_down()

/**
* Totals the physical cash on the mob and returns the total.
*/
/mob/living/verb/tally_physical_credits()
//Here is all the possible non-ID payment methods.
var/list/counted_money = list()
var/physical_cash_total = 0
for(var/obj/item/credit as anything in typecache_filter_list(get_all_contents(), GLOB.allowed_money)) //Coins, cash, and credits.
physical_cash_total += credit.get_item_credit_value()
counted_money += credit

if(is_type_in_typecache(pulling, GLOB.allowed_money)) //Coins(Pulled).
var/obj/item/counted_credit = pulling
physical_cash_total += counted_credit.get_item_credit_value()
counted_money += counted_credit
return round(physical_cash_total)
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
starting_programs = list(
/datum/computer_file/program/shipping,
/datum/computer_file/program/budgetorders,
/datum/computer_file/program/restock_tracker,
)

/**
Expand All @@ -123,6 +124,6 @@
/datum/computer_file/program/alarm_monitor,
/datum/computer_file/program/atmosscan,
/datum/computer_file/program/supermatter_monitor,

)

Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
/datum/computer_file/program/robocontrol,
/datum/computer_file/program/budgetorders,
/datum/computer_file/program/shipping,
/datum/computer_file/program/restock_tracker,
)

/**
Expand Down Expand Up @@ -264,6 +265,7 @@
/datum/computer_file/program/shipping,
/datum/computer_file/program/budgetorders,
/datum/computer_file/program/robocontrol,
/datum/computer_file/program/restock_tracker,
)

/obj/item/modular_computer/pda/shaftminer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/datum/computer_file/program/restock_tracker
filename = "restockapp"
filedesc = "NT Restock Tracker"
downloader_category = PROGRAM_CATEGORY_SUPPLY
program_open_overlay = "restock"
extended_desc = "Nanotrasen IoT network listing all the vending machines found on station, and how well stocked they are each. Profitable!"
program_flags = PROGRAM_ON_NTNET_STORE | PROGRAM_REQUIRES_NTNET
can_run_on_flags = PROGRAM_LAPTOP | PROGRAM_PDA
size = 4
program_icon = "cash-register"
tgui_id = "NtosRestock"

/datum/computer_file/program/restock_tracker/ui_data()
var/list/data = list()
var/list/vending_list = list()
var/id_increment = 1
for(var/obj/machinery/vending/vendor as anything in GLOB.vending_machines_to_restock)
var/stock = vendor.total_loaded_stock()
var/max_stock = vendor.total_max_stock()
if((max_stock == 0 || (stock >= max_stock)) && vendor.credits_contained == 0)
continue
vending_list += list(list(
"name" = vendor.name,
"location" = get_area_name(vendor),
"credits" = vendor.credits_contained,
"percentage" = (stock / max_stock) * 100,
"id" = id_increment,
))
id_increment++
data["vending_list"] = vending_list
return data
Loading

0 comments on commit bfc5fd3

Please sign in to comment.