Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////
- // Parcel Packagers //
- //////////////////////
- //These are the machines that package things into parcels
- //They immediately pay out some spacecash to the user
- //Produced parcels have to be delivered to cargo
- //It's important to keep track of what department owns the machine
- //Export Parcel Packager: used to export physical goods
- //Export Chemical Bottler: used to export reagents
- //Export Power Supply: used to export large batteries with power produced in the engine
- /obj/machinery/cash_parcel
- name = "Export Parcel Packager"
- desc = "Prepares export parcels and pays out space cash for them."
- density = 1
- anchored = 1
- icon = 'icons/obj/chemical.dmi' //gonna need a new one
- icon_state = "dispenser"
- use_power = 1
- idle_power_usage = 50
- var/parcel_points = 0 //ammount of points currently stored. Maxes out at 100, costs 50 to remove an export parcel
- var/department = null //what department owns this machine. At null, no department will earn cash from it
- /obj/machinery/cash_parcel/New()
- ..()
- component_parts = list()
- component_parts += new /obj/item/weapon/circuitboard/cash_parcel(null)
- component_parts += new /obj/item/weapon/stock_parts/scanning_module(null)
- component_parts += new /obj/item/weapon/stock_parts/manipulator(null)
- component_parts += new /obj/item/weapon/stock_parts/manipulator(null)
- component_parts += new /obj/item/weapon/stock_parts/console_screen(null)
- RefreshParts()
- //obj/machinery/cash_parcel/RefreshParts()
- //obj/machinery/cash_parcel/process()
- /obj/machinery/cash_parcel/attackby(var/obj/item/weapon/W, var/mob/user, params)
- //exceptions
- if(istype(W,/obj/item/weapon/card/id))
- user << "<span class='notice'>This doesn't seem like a good idea.</span>"
- return
- if(istype(W,/obj/item/weapon/disk/nuclear))
- user << "<span class='notice'>This is a TERRIBLE idea.</span>"
- return
- //allow tools and construction/deconstruction
- if(exchange_parts(user, W))
- return
- if(default_pry_open(W))
- return
- if(default_unfasten_wrench(user, W))
- return
- if(default_deconstruction_screwdriver(user, "cash_parcel-open", "cash_parcel", W))
- updateUsrDialog()
- return
- if(panel_open)
- if(istype(W, /obj/item/weapon/crowbar))
- default_deconstruction_crowbar(W)
- return 1
- //0 value items
- var/worth = calculate_worth(W)
- if(worth <1)
- user << "<span class='notice'>That item is worthless.</span>"
- return
- //accept item, destroy it and add points to the machine
- if(parcel_points+worth > 100)
- user << "<span class='notice'>The Export Parcel Packager has too much merchandise, remove a parcel first.</span>"
- return
- parcel_points += worth
- user << "<span class='notice'>You add merchandise to the machine an are paid [worth] for it.</span>"
- W.Destroy()
- var/obj/item/weapon/spacecash/profit = new src.type( user, worth)
- user.put_in_hands(profit)
- return
- /obj/machinery/cash_parcel/proc/calculate_worth(var/obj/item/I)
- var/value = 0
- //intrinsic value
- value += I.spacecash_value
- //check contents (if it's a container)
- for(var/obj/item/S in I)
- value += S.spacecash_value
- return value
- /obj/machinery/cash_parcel/attack_hand(user as mob)
- if(..())
- return
- interact(user)
- /obj/machinery/cash_parcel/interact(mob/user)
- var/dat
- dat += text("Welcome to the Export Parcel Packager assistant.<br><br>")
- dat += text("Current parcel points: [parcel_points]/100<br>")
- dat += text("A parcel will take a maximum of 50 points.<br>A parcel will take a minimum of 10 points.<br><br>")
- if(parcel_points<10)
- dat += text("You need [10 - parcel_points] to make a new parcel.<br>")
- else
- dat += text("Make parcel? <A href='?src=\ref[src];make=true'>([max(parcel_points,50)] points)</A><br>")
- dat += text("<br><br>")
- var/datum/browser/popup = new(user, "cash_parcel_machine", "Export Parcel Packager", 400, 500)
- popup.set_content(dat)
- popup.open()
- return
- /obj/machinery/cash_parcel/Topic(href, href_list)
- if(..())
- return
- if(href_list["make"])
- //if(TEST POSITION)test if there's already a parcel on the machine
- //play animation
- new /obj/structure/export_parcel(loc,max(parcel_points,50))
- parcel_points -= max(parcel_points,50)
- updateUsrDialog()
- return
- //////////////////////
- // VENDING MACHINES //
- //////////////////////
- //These might need a funny name that relates to money
- //They are locked by ID, so one machine = one salesman
- //Chemistry should get two, Robotics gest one and R&D another
- //Barman and Chef get a old-times register
- //All-Purpose-Market can be used by anyone to sell anything and it's put in Crew Quarters
- /obj/machinery/smartfridge/sale_machine
- name = "Electronic Merchant"
- desc = "This machine is down for maintenance every saturday."
- density = 1
- anchored = 1
- icon = 'icons/obj/chemical.dmi' //gonna need a new one
- icon_state = "dispenser"
- use_power = 1
- idle_power_usage = 50
- var/item_prices = list()
- var/starting_inventory = list()
- //spawn some initial goodies with a standard price
- /obj/machinery/smartfridge/sale_machine/New()
- ..()
- for(var/I in starting_inventory)
- I = new typepath(I)(src)
- contents += I
- if(item_quants[I.name])
- item_quants[I.name]++
- else
- item_quants[I.name] = 1
- item_prices[I.name] = price
- return
- /obj/machinery/smartfridge/sale_machine/accept_check(var/obj/item/O as obj)
- if(istype(O,/obj/item/weapon/coin))
- return 1
- else
- return 0
- /obj/machinery/smartfridge/sale_machine/load(var/obj/item/O as obj)
- if(istype(O.loc,/mob))
- var/mob/M = O.loc
- if(!M.unEquip(O))
- usr << "<span class='notice'>\the [O] is stuck to your hand, you cannot put it in \the [src]</span>"
- return
- else if(istype(O.loc,/obj/item/weapon/storage))
- var/obj/item/weapon/storage/S = O.loc
- S.remove_from_storage(O,src)
- var/n = O.name
- var/price = min(max(input(usr, "Put [O.name] up for sale.", "How much Spacecash do you want charge?") as num|null, 0), 9999)
- O.loc = src
- if(item_quants[n])
- item_quants[n]++
- else
- item_quants[n] = 1
- item_prices[n] = price
- sortList(item_quants)
- /obj/machinery/smartfridge/sale_machine/interact(mob/user as mob)
- if(stat)
- return 0
- var/dat = "<TT><b>Select an item:</b><br>"
- if (contents.len == 0)
- dat += "<font color = 'red'>No product loaded!</font>"
- else
- for (var/O in item_quants)
- if(item_quants[O] > 0)
- var/N = item_quants[O]
- var/itemName = encodeparams(sanitize(O))
- dat += "<FONT color = 'blue'><B>[capitalize(O)]</B>:"
- dat += " x [N] </font>"
- dat += ": [item_prices[O]] Spacecash"
- dat += "<a href='byond://?src=\ref[src];vend=[itemName];amount=1'>Vend</A> "
- if(N > 1)
- dat += "(<a href='?src=\ref[src];vend=[itemName];amount=[N]'>All</A>)"
- dat += "<br>"
- dat += "</TT>"
- user << browse("<HEAD><TITLE>[src] supplies</TITLE></HEAD><TT>[dat]</TT>", "window=smartfridge")
- onclose(user, "smartfridge")
- return dat
- /obj/machinery/smartfridge/sale_machine/Topic(var/href, var/list/href_list)
- if(..())
- return
- usr.set_machine(src)
- var/N = href_list["vend"]
- var/amount = text2num(href_list["amount"])
- if(item_quants[N] <= 0) // Sanity check, there are probably ways to press the button when it shouldn't be possible.
- return
- //attempt to make a sale
- var/obj/item/weapon/spacecash/wad_money
- if(istype(usr.get_active_hand(), /obj/item/weapon/spacecash))
- wad_money = usr.get_active_hand()
- if(wad_money)
- if(wad_money.amount >= item_prices[N])
- wad_money.pay(item_prices[N])
- item_quants[N] = max(item_quants[N] - amount, 0)
- var/i = amount
- for(var/obj/O in contents)
- if(O.name == N)
- O.loc = src.loc
- i--
- if(i <= 0)
- break
- src.updateUsrDialog()
- return
- ////////////////////////
- //Chem Vending machine//
- ////////////////////////
- /obj/machinery/smartfridge/sale_machine/chems
- name = "Vend-a-Cure"
- desc = "Afordable healthcare for the one's who act. Get it now, before it's repealed!"
- icon = 'icons/obj/chemical.dmi' //gonna need a new one
- icon_state = "dispenser"
- starting_inventory = (/obj/item/weapon/reagent_containers/glass/bottle/inaprovaline = 2)
- /obj/machinery/smartfridge/sale_machine/chems/accept_check(var/obj/item/O as obj)
- if(istype(O,/obj/item/weapon/storage/pill_bottle) || istype(O,/obj/item/weapon/reagent_containers/pill) || istype(O,/obj/item/weapon/reagent_containers/syringe))
- return 1
- else
- return 0
- ///////////////////////////////////////////////
- //Stock Parts and Electronics Vending machine//
- ///////////////////////////////////////////////
- /obj/machinery/smartfridge/sale_machine
- name = "Volts & Bolts"
- desc = "With 10 easily affordable payments, you can make any broken machine whirr and bleep again!"
- //spawn some initial goodies with a standard price
- /obj/machinery/smartfridge/sale_machine/accept_check(var/obj/item/O as obj)
- if(istype(O,/obj/item/weapon/stock_parts) || istype(O,/obj/item/weapon/circuitboard))
- return 1
- else
- return 0
- /////////////
- // PARCELS //
- /////////////
- //these are objects that cargo can export. they also credit the department that produced them with some points
- /obj/structure/export_parcel
- name = "Export Parcel"
- desc = "Cargo to be offloaded and traded all across the universe."
- icon = 'icons/obj/objects.dmi' //needs new icon
- icon_state = "watertank"
- density = 1
- anchored = 0
- var/points = 0 //how many points this parcel is worth
- /obj/structure/export_parcel/New(var/loc, var/worth=null)
- ..()
- if (worth)
- src.points = worth
- desc += " The label reads: '[points] credits'."
- return
- /obj/structure/export_parcel/chem
- name = "Export Chemical Container"
- desc = "A container filled with chemicals to be offloaded and traded all acrss the universe."
- icon = 'icons/obj/objects.dmi' //needs new icon
- icon_state = "watertank"
- /obj/structure/export_parcel/power
- name = "Export Power Supply Battery"
- desc = "Charged battery to be offloaded and traded all across the universe."
- icon = 'icons/obj/objects.dmi' //needs new icon
- icon_state = "watertank"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement