diff --git a/code/game/machinery/vending.dm b/code/game/machinery/vending.dm index 3ba86764baf..84807103cae 100644 --- a/code/game/machinery/vending.dm +++ b/code/game/machinery/vending.dm @@ -57,7 +57,6 @@ var/obj/item/weapon/coin/coin var/datum/wires/vending/wires = null - /obj/machinery/vending/New() ..() wires = new(src) @@ -82,7 +81,13 @@ return - +/obj/machinery/vending/Destroy() + del(wires) + wires = null + del(coin) + coin = null + ..() + /obj/machinery/vending/ex_act(severity) switch(severity) if(1.0) @@ -96,7 +101,14 @@ if(prob(25)) malfunction() - +/obj/machinery/vending/RefreshParts() //Better would be to make constructable child + if(component_parts) + build_inventory(products, start_empty = 1) + build_inventory(contraband, 1, 1) + build_inventory(premium, 0, 1, 1) + for(var/obj/item/weapon/vending_refill/VR in component_parts) + refill_inventory(VR, product_records) + /obj/machinery/vending/blob_act() if(prob(75)) malfunction() @@ -104,7 +116,7 @@ del(src) -/obj/machinery/vending/proc/build_inventory(var/list/productlist,hidden=0,req_coin=0) +/obj/machinery/vending/proc/build_inventory(var/list/productlist,hidden=0,req_coin=0,start_empty = null) for(var/typepath in productlist) var/amount = productlist[typepath] var/price = prices[typepath] @@ -114,7 +126,8 @@ var/datum/data/vending_product/R = new /datum/data/vending_product() R.product_path = typepath - R.amount = amount + if(!start_empty) + R.amount = amount R.max_amount = amount R.price = price R.display_color = pick("red","blue","green") @@ -166,13 +179,28 @@ break return total - /obj/machinery/vending/attackby(obj/item/weapon/W, mob/user) + if(panel_open) + if(default_unfasten_wrench(user, W, time = 60)) + return + + if(component_parts && istype(W, /obj/item/weapon/crowbar)) + var/datum/data/vending_product/machine = product_records + for(var/datum/data/vending_product/machine_content in machine) + while(machine_content.amount !=0) + for(var/obj/item/weapon/vending_refill/VR in component_parts) + VR.charges++ + machine_content.amount-- + if(!machine_content.amount) + break + default_deconstruction_crowbar(W) + if(istype(W, /obj/item/weapon/card/emag)) emagged = 1 user << "You short out the product lock on [src]" return - else if(istype(W, /obj/item/weapon/screwdriver)) + else if(istype(W, /obj/item/weapon/screwdriver) && anchored) + playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) panel_open = !panel_open user << "You [panel_open ? "open" : "close"] the maintenance panel." overlays.Cut() @@ -184,36 +212,15 @@ if(panel_open) attack_hand(user) return + else if(istype(W, /obj/item/weapon/card) && currently_vending) + var/obj/item/weapon/card/I = W + scan_card(I) else if(istype(W, /obj/item/weapon/coin) && premium.len > 0) user.drop_item() W.loc = src coin = W user << "You insert [W] into [src]." return - - else if(istype(W, /obj/item/weapon/wrench)) - - if(do_after(user, 20)) - if(!src) return - playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1) - switch (anchored) - if (0) - anchored = 1 - user.visible_message("[user] tightens the bolts securing \the [src] to the floor.", "You tighten the bolts securing \the [src] to the floor.") - if (1) - user.visible_message("[user] unfastens the bolts securing \the [src] to the floor.", "You unfasten the bolts securing \the [src] to the floor.") - anchored = 0 - return - - else if(src.panel_open) - for(var/datum/data/vending_product/R in product_records) - if(istype(W, R.product_path)) - stock(R, user) - del(W) - - 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 << "It does nothing." @@ -234,6 +241,8 @@ else ..() + + /obj/machinery/vending/proc/scan_card(var/obj/item/weapon/card/I) if(!currently_vending) return if (istype(I, /obj/item/weapon/card/id)) @@ -661,6 +670,16 @@ contraband = list(/obj/item/device/flashlight = 5,/obj/item/device/assembly/timer = 2) product_ads = "Only the finest!;Have some tools.;The most robust equipment.;The finest gear in space!" +/obj/machinery/vending/boozeomat/New() + ..() + component_parts = list() + var/obj/item/weapon/circuitboard/vendor/V = new(null) + V.set_type(type) + component_parts += V + component_parts += new /obj/item/weapon/vending_refill/boozeomat(0) + component_parts += new /obj/item/weapon/vending_refill/boozeomat(0) + component_parts += new /obj/item/weapon/vending_refill/boozeomat(0) + /obj/machinery/vending/coffee name = "Hot Drinks machine" desc = "A vending machine which dispenses hot drinks." @@ -673,7 +692,15 @@ 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 - +/obj/machinery/vending/coffee/New() + ..() + component_parts = list() + var/obj/item/weapon/circuitboard/vendor/V = new(null) + V.set_type(type) + component_parts += V + component_parts += new /obj/item/weapon/vending_refill/coffee(0) + component_parts += new /obj/item/weapon/vending_refill/coffee(0) + component_parts += new /obj/item/weapon/vending_refill/coffee(0) /obj/machinery/vending/snack name = "Getmore Chocolate Corp" @@ -699,6 +726,16 @@ prices = list(/obj/item/weapon/reagent_containers/food/snacks/chinese/chowmein = 50, /obj/item/weapon/reagent_containers/food/snacks/chinese/tao = 50, /obj/item/weapon/reagent_containers/food/snacks/chinese/newdles = 50, /obj/item/weapon/reagent_containers/food/snacks/chinese/rice = 50, /obj/item/weapon/reagent_containers/food/snacks/wingfangchu = 50) +/obj/machinery/vending/snack/New() + ..() + component_parts = list() + var/obj/item/weapon/circuitboard/vendor/V = new(null) + V.set_type(type) + component_parts += V + component_parts += new /obj/item/weapon/vending_refill/snack(0) + component_parts += new /obj/item/weapon/vending_refill/snack(0) + component_parts += new /obj/item/weapon/vending_refill/snack(0) + /obj/machinery/vending/cola name = "Robust Softdrinks" desc = "A softdrink vendor provided by Robust Industries, LLC." @@ -724,7 +761,16 @@ /obj/item/weapon/cartridge/janitor = 10,/obj/item/weapon/cartridge/signal/toxins = 10,/obj/item/device/pda/heads = 10, /obj/item/weapon/cartridge/captain = 3,/obj/item/weapon/cartridge/quartermaster = 10) - +/obj/machinery/vending/cola/New() + ..() + component_parts = list() + var/obj/item/weapon/circuitboard/vendor/V = new(null) + V.set_type(type) + component_parts += V + component_parts += new /obj/item/weapon/vending_refill/cola(0) + component_parts += new /obj/item/weapon/vending_refill/cola(0) + component_parts += new /obj/item/weapon/vending_refill/cola(0) + /obj/machinery/vending/cigarette name = "Cigarette machine" //OCD had to be uppercase to look nice with the new formating desc = "If you want to get cancer, might as well do it in style" @@ -738,6 +784,16 @@ prices = list(/obj/item/weapon/storage/fancy/cigarettes = 60,/obj/item/weapon/storage/box/matches = 10,/obj/item/weapon/lighter/random = 60, /obj/item/weapon/rollingpaperpack = 20) refill_canister = /obj/item/weapon/vending_refill/cigarette +/obj/machinery/vending/cigarette/New() + ..() + component_parts = list() + var/obj/item/weapon/circuitboard/vendor/V = new(null) + V.set_type(type) + component_parts += V + component_parts += new /obj/item/weapon/vending_refill/cigarette(0) + component_parts += new /obj/item/weapon/vending_refill/cigarette(0) + component_parts += new /obj/item/weapon/vending_refill/cigarette(0) + /obj/machinery/vending/medical name = "NanoMed Plus" desc = "Medical drug dispenser." @@ -783,7 +839,6 @@ /obj/item/stack/medical/ointment =3,/obj/item/device/healthanalyzer = 3) contraband = list(/obj/item/weapon/reagent_containers/pill/tox = 3) - /obj/machinery/vending/wallmed1/syndicate name = "SyndiMed Plus" desc = "EVIL wall-mounted Medical Equipment dispenser." @@ -875,6 +930,17 @@ 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,/obj/item/weapon/gun/magic/wand = 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) refill_canister = /obj/item/weapon/vending_refill/autodrobe + +/obj/machinery/vending/cigarette/New() + ..() + component_parts = list() + var/obj/item/weapon/circuitboard/vendor/V = new(null) + V.set_type(type) + component_parts += V + component_parts += new /obj/item/weapon/vending_refill/cigarette(0) + component_parts += new /obj/item/weapon/vending_refill/cigarette(0) + component_parts += new /obj/item/weapon/vending_refill/cigarette(0) + /obj/machinery/vending/dinnerware name = "Dinnerware" desc = "A kitchen and restaurant equipment vendor" @@ -1006,4 +1072,4 @@ icon_state = "snack" products = list(/obj/item/weapon/reagent_containers/food/snacks/chips =6,/obj/item/weapon/reagent_containers/food/snacks/sosjerky = 6, /obj/item/weapon/reagent_containers/food/snacks/syndicake = 6, /obj/item/weapon/reagent_containers/food/snacks/cheesiehonkers = 6) - refill_canister = /obj/item/weapon/vending_refill/snack + refill_canister = /obj/item/weapon/vending_refill/snack \ No newline at end of file