Files
Bubberstation/code/modules/vending/sustenance.dm
Bloop 8d9f1689ba Decouples free vending machine behavior from the 'onstation' var (#86548)
## About The Pull Request

The `onstation` var was being used for too many things (AI brand
intelligence + whether the products are free or not), and was
overcomplicating the logic.

On top of that it makes things like trying to make a vending machine
that is considered offstation for purposes of the brand intelligence
event but that still dispenses free goods needlessly difficult.

This PR just decouples the two behaviors and gives the 'free' behavior
its own var.

As a result, the majority of the of `onstation` map varedits are no
longer necessary

Tested with various edge cases, all seem working as intended:

<details><summary>arrivals (onstation, all_free_products = null /
FALSE)</summary>


![dreamseeker_bkpGCsXoaN](https://github.com/user-attachments/assets/3f92a454-ac04-41f8-9235-281a0c8dd309)

</details>

<details><summary>arrivals (onstation, all_free_products =
TRUE)</summary>


![dreamseeker_7Osn49NoHg](https://github.com/user-attachments/assets/374e2632-c727-44e3-aa47-f31d5db375ca)

</details>

<details><summary>spacehotel (not onstation, all_free_products =
null)</summary>


![dreamseeker_dtQFNIRlxl](https://github.com/user-attachments/assets/1dc859d9-ac8d-4d38-946f-8070f1176915)

</details>

<details><summary>hauntedruins (not onstation, all_free_products =
FALSE)</summary>


![dreamseeker_JLcsJCaOIK](https://github.com/user-attachments/assets/02948139-615a-477e-b0c5-f0da8d721cae)

</details>

<details><summary>silverscale shuttle (not onstation, all_free_products
= TRUE)</summary>


![dreamseeker_FNgw2JILVg](https://github.com/user-attachments/assets/7deef056-e331-48e6-88a8-fdfd22d706d4)

</details>

<details><summary>labor camp (not onstation, all_free_products =
FALSE)</summary>


![dreamseeker_NWT6dxYV9d](https://github.com/user-attachments/assets/ea0c3ddd-a4dd-477a-8838-ae1ddf8ad198)

</details>


## Why It's Good For The Game

Less complicated vending machines, less varedits in our maps. Less
confusing code. Ability to spawn a vending machine and varedit it to be
free without affecting any other systems.

## Changelog
N/A
2024-09-13 13:44:55 +02:00

74 lines
3.3 KiB
Plaintext

/obj/machinery/vending/sustenance
name = "\improper Sustenance Vendor"
desc = "A vending machine which vends food, as required by section 47-C of the NT's Prisoner Ethical Treatment Agreement."
product_slogans = "Enjoy your meal.;Enough calories to support strenuous labor."
product_ads = "Sufficiently healthy.;Efficiently produced tofu!;Mmm! So good!;Have a meal.;You need food to live!;Even prisoners deserve their daily bread!;Have some more candy corn!;Try our new ice cups!"
light_mask = "snack-light-mask"
icon_state = "sustenance"
panel_type = "panel2"
products = list(
/obj/item/food/tofu/prison = 24,
/obj/item/food/breadslice/moldy = 15,
/obj/item/reagent_containers/cup/glass/ice/prison = 12,
/obj/item/food/candy_corn/prison = 6,
/obj/item/kitchen/spoon/plastic = 6,
)
contraband = list(
/obj/item/knife = 6,
/obj/item/kitchen/spoon = 6,
/obj/item/reagent_containers/cup/glass/coffee = 12,
/obj/item/tank/internals/emergency_oxygen = 6,
/obj/item/clothing/mask/breath = 6,
)
refill_canister = /obj/item/vending_refill/sustenance
default_price = PAYCHECK_LOWER
extra_price = PAYCHECK_LOWER * 0.6
payment_department = NO_FREEBIES
/obj/item/vending_refill/sustenance
machine_name = "Sustenance Vendor"
icon_state = "refill_snack"
//Labor camp subtype that uses labor points obtained from mining and processing ore
/obj/machinery/vending/sustenance/labor_camp
name = "\improper Labor Camp Sustenance Vendor"
desc = "A vending machine which vends food, as required by section 47-C of the NT's Prisoner Ethical Treatment Agreement. \
This one, however, processes labor points for its products if the user is incarcerated."
icon_state = "sustenance_labor"
all_products_free = FALSE
displayed_currency_icon = "digging"
displayed_currency_name = " LP"
/obj/machinery/vending/sustenance/interact(mob/user)
if(isliving(user))
var/mob/living/living_user = user
if(!(machine_stat & NOPOWER) && !istype(living_user.get_idcard(TRUE), /obj/item/card/id/advanced/prisoner))
speak("No valid prisoner account found. Vending is not permitted.")
return
return ..()
/obj/machinery/vending/sustenance/labor_camp/proceed_payment(obj/item/card/id/paying_id_card, mob/living/mob_paying, datum/data/vending_product/product_to_vend, price_to_use)
if(!istype(paying_id_card, /obj/item/card/id/advanced/prisoner))
speak("I don't take bribes! Pay with labor points!")
return FALSE
var/obj/item/card/id/advanced/prisoner/paying_scum_id = paying_id_card
if(coin_records.Find(product_to_vend) || hidden_records.Find(product_to_vend))
price_to_use = product_to_vend.custom_premium_price ? product_to_vend.custom_premium_price : extra_price
if(LAZYLEN(product_to_vend.returned_products))
price_to_use = 0 //returned items are free
if(price_to_use && !(paying_scum_id.points >= price_to_use)) //not enough good prisoner points
speak("You do not possess enough points to purchase [product_to_vend.name].")
flick(icon_deny, src)
vend_ready = TRUE
return FALSE
paying_scum_id.points -= price_to_use
return TRUE
/obj/machinery/vending/sustenance/labor_camp/fetch_balance_to_use(obj/item/card/id/passed_id)
if(!istype(passed_id, /obj/item/card/id/advanced/prisoner))
return null //no points balance - no balance at all
var/obj/item/card/id/advanced/prisoner/paying_scum_id = passed_id
return paying_scum_id.points