diff --git a/code/game/machinery/vending.dm b/code/game/machinery/vending.dm index c1c077ce803..3ba86764baf 100644 --- a/code/game/machinery/vending.dm +++ b/code/game/machinery/vending.dm @@ -57,6 +57,7 @@ var/obj/item/weapon/coin/coin var/datum/wires/vending/wires = null + /obj/machinery/vending/New() ..() wires = new(src) @@ -81,13 +82,7 @@ return -/obj/machinery/vending/Destroy() - del(wires) - wires = null - del(coin) - coin = null - ..() - + /obj/machinery/vending/ex_act(severity) switch(severity) if(1.0) @@ -101,14 +96,7 @@ 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() @@ -116,7 +104,7 @@ del(src) -/obj/machinery/vending/proc/build_inventory(var/list/productlist,hidden=0,req_coin=0,start_empty = null) +/obj/machinery/vending/proc/build_inventory(var/list/productlist,hidden=0,req_coin=0) for(var/typepath in productlist) var/amount = productlist[typepath] var/price = prices[typepath] @@ -126,8 +114,7 @@ var/datum/data/vending_product/R = new /datum/data/vending_product() R.product_path = typepath - if(!start_empty) - R.amount = amount + R.amount = amount R.max_amount = amount R.price = price R.display_color = pick("red","blue","green") @@ -179,28 +166,13 @@ 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) && anchored) - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) + else if(istype(W, /obj/item/weapon/screwdriver)) panel_open = !panel_open user << "You [panel_open ? "open" : "close"] the maintenance panel." overlays.Cut() @@ -212,15 +184,36 @@ 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." @@ -241,8 +234,6 @@ 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)) @@ -670,16 +661,6 @@ 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." @@ -692,15 +673,7 @@ 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" @@ -726,16 +699,6 @@ 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." @@ -761,16 +724,7 @@ /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" @@ -784,16 +738,6 @@ 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." @@ -839,6 +783,7 @@ /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." @@ -930,17 +875,6 @@ 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" @@ -1054,7 +988,7 @@ products = list(/obj/item/clothing/shoes/black = 10,/obj/item/clothing/shoes/brown = 10,/obj/item/clothing/shoes/blue = 10,/obj/item/clothing/shoes/green = 10,/obj/item/clothing/shoes/yellow = 10,/obj/item/clothing/shoes/purple = 10,/obj/item/clothing/shoes/red = 10,/obj/item/clothing/shoes/white = 10) contraband = list(/obj/item/clothing/shoes/jackboots = 5,/obj/item/clothing/shoes/orange = 5) premium = list(/obj/item/clothing/shoes/rainbow = 1) - + /obj/machinery/vending/syndicigs name = "Suspicious Cigarette Machine" desc = "Smoke 'em if you've got 'em." @@ -1072,5 +1006,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