mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-27 14:07:51 +01:00
Vending machine refilling
This commit is contained in:
@@ -1006,3 +1006,39 @@ var/list/all_supply_groups = list("Operations","Security","Hospitality","Enginee
|
||||
containername = "Beekeeping crate"
|
||||
access = access_hydroponics
|
||||
group = "Hydroponics"
|
||||
|
||||
|
||||
/datum/supply_packs/organic/vending
|
||||
name = "Bartending Supply Crate"
|
||||
contains = list(/obj/item/weapon/vending_refill/boozeomat,
|
||||
/obj/item/weapon/vending_refill/coffee)
|
||||
cost = 15
|
||||
containername = "bartending supply crate"
|
||||
|
||||
/datum/supply_packs/organic/vending/snack
|
||||
name = "Snack Supply Crate"
|
||||
contains = list(/obj/item/weapon/vending_refill/snack,
|
||||
/obj/item/weapon/vending_refill/snack,
|
||||
/obj/item/weapon/vending_refill/snack)
|
||||
cost = 15
|
||||
containername = "snacks supply crate"
|
||||
|
||||
/datum/supply_packs/organic/vending/cola
|
||||
name = "Softdrinks Supply Crate"
|
||||
contains = list(/obj/item/weapon/vending_refill/cola,
|
||||
/obj/item/weapon/vending_refill/cola)
|
||||
cost = 15
|
||||
containername = "softdrinks supply crate"
|
||||
|
||||
/datum/supply_packs/organic/vending/cigarette
|
||||
name = "Cigarette Supply Crate"
|
||||
contains = list(/obj/item/weapon/vending_refill/cigarette)
|
||||
cost = 15
|
||||
containername = "cigarette supply crate"
|
||||
|
||||
/datum/supply_packs/misc/autodrobe
|
||||
name = "Autodrobe Supply crate"
|
||||
contains = list(/obj/item/weapon/vending_refill/autodrobe,
|
||||
/obj/item/weapon/vending_refill/autodrobe)
|
||||
cost = 15
|
||||
containername = "autodrobe supply crate"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
var/product_name = "generic"
|
||||
var/product_path = null
|
||||
var/amount = 0
|
||||
var/max_amount = 0
|
||||
var/price = 0
|
||||
var/display_color = "blue"
|
||||
|
||||
@@ -52,7 +53,7 @@
|
||||
var/const/WIRE_SHOOTINV = 4
|
||||
var/datum/wires/vending/wires = null
|
||||
var/scan_id = 1
|
||||
|
||||
var/obj/item/weapon/vending_refill/refill_canister = null //The type of refill canisters used by this machine.
|
||||
|
||||
|
||||
/obj/machinery/vending/New()
|
||||
@@ -118,6 +119,7 @@
|
||||
R.product_name = temp.name
|
||||
R.product_path = typepath
|
||||
R.amount = amount
|
||||
R.max_amount = amount
|
||||
R.price = price
|
||||
R.display_color = pick("red","blue","green")
|
||||
|
||||
@@ -130,6 +132,36 @@
|
||||
// world << "Added: [R.product_name]] - [R.amount] - [R.product_path]"
|
||||
return
|
||||
|
||||
/obj/machinery/vending/proc/refill_inventory(obj/item/weapon/vending_refill/refill, datum/data/vending_product/machine, mob/user)
|
||||
var/total = 0
|
||||
|
||||
var/to_restock = 0
|
||||
for(var/datum/data/vending_product/machine_content in machine)
|
||||
to_restock += machine_content.max_amount - machine_content.amount
|
||||
|
||||
if(to_restock <= refill.charges)
|
||||
for(var/datum/data/vending_product/machine_content in machine)
|
||||
if(machine_content.amount != machine_content.max_amount)
|
||||
usr << "<span class='notice'>[machine_content.max_amount - machine_content.amount] of [machine_content.product_name]</span>"
|
||||
machine_content.amount = machine_content.max_amount
|
||||
refill.charges -= to_restock
|
||||
total = to_restock
|
||||
else
|
||||
var/tmp_charges = refill.charges
|
||||
for(var/datum/data/vending_product/machine_content in machine)
|
||||
var/restock = Ceiling(((machine_content.max_amount - machine_content.amount)/to_restock)*tmp_charges)
|
||||
if(restock > refill.charges)
|
||||
restock = refill.charges
|
||||
machine_content.amount += restock
|
||||
refill.charges -= restock
|
||||
total += restock
|
||||
if(restock)
|
||||
usr << "<span class='notice'>[restock] of [machine_content.product_name]</span>"
|
||||
if(refill.charges == 0) //due to rounding, we ran out of refill charges, exit.
|
||||
break
|
||||
return total
|
||||
|
||||
|
||||
/obj/machinery/vending/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
if (istype(W, /obj/item/weapon/card/emag))
|
||||
src.emagged = 1
|
||||
@@ -163,9 +195,23 @@
|
||||
else if(istype(W, /obj/item/weapon/card) && currently_vending)
|
||||
var/obj/item/weapon/card/I = W
|
||||
scan_card(I)
|
||||
|
||||
|
||||
|
||||
else if(istype(W, refill_canister) && refill_canister != null)
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
user << "<span class='notice'>It does nothing.</span>"
|
||||
else if(panel_open)
|
||||
//if the panel is open we attempt to refill the machine
|
||||
var/obj/item/weapon/vending_refill/canister = W
|
||||
if(canister.charges == 0)
|
||||
user << "<span class='notice'>This [canister.name] is empty!</span>"
|
||||
else
|
||||
var/transfered = refill_inventory(canister,product_records,user)
|
||||
if(transfered)
|
||||
user << "<span class='notice'>You loaded [transfered] items in \the [name].</span>"
|
||||
else
|
||||
user << "<span class='notice'>The [name] is fully stocked.</span>"
|
||||
return;
|
||||
else
|
||||
user << "<span class='notice'>You should probably unscrew the service panel first.</span>"
|
||||
else
|
||||
..()
|
||||
|
||||
@@ -542,7 +588,7 @@
|
||||
vend_delay = 15
|
||||
product_slogans = "I hope nobody asks me for a bloody cup o' tea...;Alcohol is humanity's friend. Would you abandon a friend?;Quite delighted to serve you!;Is nobody thirsty on this station?"
|
||||
product_ads = "Drink up!;Booze is good for you!;Alcohol is humanity's best friend.;Quite delighted to serve you!;Care for a nice, cold beer?;Nothing cures you like booze!;Have a sip!;Have a drink!;Have a beer!;Beer is good for you!;Only the finest alcohol!;Best quality booze since 2053!;Award-winning wine!;Maximum alcohol!;Man loves beer.;A toast for progress!"
|
||||
|
||||
refill_canister = /obj/item/weapon/vending_refill/boozeomat
|
||||
/obj/machinery/vending/assist
|
||||
products = list( /obj/item/device/assembly/prox_sensor = 5,/obj/item/device/assembly/igniter = 3,/obj/item/device/assembly/signaler = 4,
|
||||
/obj/item/weapon/wirecutters = 1, /obj/item/weapon/cartridge/signal = 4)
|
||||
@@ -559,7 +605,7 @@
|
||||
products = list(/obj/item/weapon/reagent_containers/food/drinks/coffee = 25,/obj/item/weapon/reagent_containers/food/drinks/tea = 25,/obj/item/weapon/reagent_containers/food/drinks/h_chocolate = 25)
|
||||
contraband = list(/obj/item/weapon/reagent_containers/food/drinks/ice = 10)
|
||||
prices = list(/obj/item/weapon/reagent_containers/food/drinks/coffee = 25, /obj/item/weapon/reagent_containers/food/drinks/tea = 25, /obj/item/weapon/reagent_containers/food/drinks/h_chocolate = 25)
|
||||
|
||||
refill_canister = /obj/item/weapon/vending_refill/coffee
|
||||
|
||||
|
||||
|
||||
@@ -576,7 +622,7 @@
|
||||
prices = list(/obj/item/weapon/reagent_containers/food/snacks/candy = 20,/obj/item/weapon/reagent_containers/food/drinks/dry_ramen = 30,/obj/item/weapon/reagent_containers/food/snacks/chips =25,
|
||||
/obj/item/weapon/reagent_containers/food/snacks/sosjerky = 30,/obj/item/weapon/reagent_containers/food/snacks/no_raisin = 20,/obj/item/weapon/reagent_containers/food/snacks/spacetwinkie = 30,
|
||||
/obj/item/weapon/reagent_containers/food/snacks/cheesiehonkers = 25)
|
||||
|
||||
refill_canister = /obj/item/weapon/vending_refill/snack
|
||||
/obj/machinery/vending/chinese
|
||||
name = "Mr. Chang"
|
||||
desc = "A self-serving chinese food machine, for all your chinese food needs."
|
||||
@@ -600,7 +646,7 @@
|
||||
prices = list(/obj/item/weapon/reagent_containers/food/drinks/soda_cans/cola = 20,/obj/item/weapon/reagent_containers/food/drinks/soda_cans/space_mountain_wind = 20,
|
||||
/obj/item/weapon/reagent_containers/food/drinks/soda_cans/dr_gibb = 20,/obj/item/weapon/reagent_containers/food/drinks/soda_cans/starkist = 20,
|
||||
/obj/item/weapon/reagent_containers/food/drinks/soda_cans/space_up = 20)
|
||||
|
||||
refill_canister = /obj/item/weapon/vending_refill/cola
|
||||
//This one's from bay12
|
||||
/obj/machinery/vending/cart
|
||||
name = "PTech"
|
||||
@@ -624,7 +670,7 @@
|
||||
contraband = list(/obj/item/weapon/lighter/zippo = 4)
|
||||
premium = list(/obj/item/clothing/mask/cigarette/cigar/havana = 2)
|
||||
prices = list(/obj/item/weapon/storage/fancy/cigarettes = 60,/obj/item/weapon/storage/box/matches = 10,/obj/item/weapon/lighter/random = 60)
|
||||
|
||||
refill_canister = /obj/item/weapon/vending_refill/cigarette
|
||||
|
||||
/obj/machinery/vending/medical
|
||||
name = "NanoMed Plus"
|
||||
@@ -749,7 +795,7 @@
|
||||
/obj/item/clothing/head/rabbitears =1) //Pretty much everything that had a chance to spawn.
|
||||
contraband = list(/obj/item/clothing/suit/cardborg = 1,/obj/item/clothing/head/cardborg = 1,/obj/item/clothing/suit/judgerobe = 1,/obj/item/clothing/head/powdered_wig = 1)
|
||||
premium = list(/obj/item/clothing/suit/hgpirate = 1, /obj/item/clothing/head/hgpiratecap = 1, /obj/item/clothing/head/helmet/roman = 1, /obj/item/clothing/head/helmet/roman/legionaire = 1, /obj/item/clothing/under/roman = 1, /obj/item/clothing/shoes/roman = 1, /obj/item/weapon/shield/riot/roman = 1)
|
||||
|
||||
refill_canister = /obj/item/weapon/vending_refill/autodrobe
|
||||
/obj/machinery/vending/dinnerware
|
||||
name = "Dinnerware"
|
||||
desc = "A kitchen and restaurant equipment vendor"
|
||||
|
||||
Reference in New Issue
Block a user