Advertisement
Guest User

Untitled

a guest
Aug 4th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.95 KB | None | 0 0
  1.  
  2. //////////////////////
  3. // Parcel Packagers //
  4. //////////////////////
  5.  
  6. //These are the machines that package things into parcels
  7. //They immediately pay out some spacecash to the user
  8. //Produced parcels have to be delivered to cargo
  9. //It's important to keep track of what department owns the machine
  10.  
  11. //Export Parcel Packager: used to export physical goods
  12. //Export Chemical Bottler: used to export reagents
  13. //Export Power Supply: used to export large batteries with power produced in the engine
  14.  
  15. /obj/machinery/cash_parcel
  16. name = "Export Parcel Packager"
  17. desc = "Prepares export parcels and pays out space cash for them."
  18. density = 1
  19. anchored = 1
  20. icon = 'icons/obj/chemical.dmi' //gonna need a new one
  21. icon_state = "dispenser"
  22. use_power = 1
  23. idle_power_usage = 50
  24.  
  25. var/parcel_points = 0 //ammount of points currently stored. Maxes out at 100, costs 50 to remove an export parcel
  26. var/department = null //what department owns this machine. At null, no department will earn cash from it
  27.  
  28. /obj/machinery/cash_parcel/New()
  29. ..()
  30. component_parts = list()
  31. component_parts += new /obj/item/weapon/circuitboard/cash_parcel(null)
  32. component_parts += new /obj/item/weapon/stock_parts/scanning_module(null)
  33. component_parts += new /obj/item/weapon/stock_parts/manipulator(null)
  34. component_parts += new /obj/item/weapon/stock_parts/manipulator(null)
  35. component_parts += new /obj/item/weapon/stock_parts/console_screen(null)
  36. RefreshParts()
  37.  
  38. //obj/machinery/cash_parcel/RefreshParts()
  39.  
  40.  
  41. //obj/machinery/cash_parcel/process()
  42.  
  43.  
  44. /obj/machinery/cash_parcel/attackby(var/obj/item/weapon/W, var/mob/user, params)
  45. //exceptions
  46. if(istype(W,/obj/item/weapon/card/id))
  47. user << "<span class='notice'>This doesn't seem like a good idea.</span>"
  48. return
  49. if(istype(W,/obj/item/weapon/disk/nuclear))
  50. user << "<span class='notice'>This is a TERRIBLE idea.</span>"
  51. return
  52. //allow tools and construction/deconstruction
  53. if(exchange_parts(user, W))
  54. return
  55.  
  56. if(default_pry_open(W))
  57. return
  58.  
  59. if(default_unfasten_wrench(user, W))
  60. return
  61. if(default_deconstruction_screwdriver(user, "cash_parcel-open", "cash_parcel", W))
  62. updateUsrDialog()
  63. return
  64. if(panel_open)
  65. if(istype(W, /obj/item/weapon/crowbar))
  66. default_deconstruction_crowbar(W)
  67. return 1
  68.  
  69. //0 value items
  70. var/worth = calculate_worth(W)
  71. if(worth <1)
  72. user << "<span class='notice'>That item is worthless.</span>"
  73. return
  74.  
  75. //accept item, destroy it and add points to the machine
  76. if(parcel_points+worth > 100)
  77. user << "<span class='notice'>The Export Parcel Packager has too much merchandise, remove a parcel first.</span>"
  78. return
  79. parcel_points += worth
  80. user << "<span class='notice'>You add merchandise to the machine an are paid [worth] for it.</span>"
  81. W.Destroy()
  82. var/obj/item/weapon/spacecash/profit = new src.type( user, worth)
  83. user.put_in_hands(profit)
  84. return
  85.  
  86. /obj/machinery/cash_parcel/proc/calculate_worth(var/obj/item/I)
  87. var/value = 0
  88. //intrinsic value
  89. value += I.spacecash_value
  90. //check contents (if it's a container)
  91. for(var/obj/item/S in I)
  92. value += S.spacecash_value
  93. return value
  94.  
  95. /obj/machinery/cash_parcel/attack_hand(user as mob)
  96. if(..())
  97. return
  98. interact(user)
  99.  
  100. /obj/machinery/cash_parcel/interact(mob/user)
  101. var/dat
  102.  
  103. dat += text("Welcome to the Export Parcel Packager assistant.<br><br>")
  104. dat += text("Current parcel points: [parcel_points]/100<br>")
  105. dat += text("A parcel will take a maximum of 50 points.<br>A parcel will take a minimum of 10 points.<br><br>")
  106.  
  107. if(parcel_points<10)
  108. dat += text("You need [10 - parcel_points] to make a new parcel.<br>")
  109. else
  110. dat += text("Make parcel? <A href='?src=\ref[src];make=true'>([max(parcel_points,50)] points)</A><br>")
  111. dat += text("<br><br>")
  112.  
  113. var/datum/browser/popup = new(user, "cash_parcel_machine", "Export Parcel Packager", 400, 500)
  114. popup.set_content(dat)
  115. popup.open()
  116. return
  117.  
  118. /obj/machinery/cash_parcel/Topic(href, href_list)
  119. if(..())
  120. return
  121. if(href_list["make"])
  122. //if(TEST POSITION)test if there's already a parcel on the machine
  123. //play animation
  124. new /obj/structure/export_parcel(loc,max(parcel_points,50))
  125. parcel_points -= max(parcel_points,50)
  126.  
  127. updateUsrDialog()
  128. return
  129.  
  130.  
  131.  
  132. //////////////////////
  133. // VENDING MACHINES //
  134. //////////////////////
  135.  
  136. //These might need a funny name that relates to money
  137. //They are locked by ID, so one machine = one salesman
  138. //Chemistry should get two, Robotics gest one and R&D another
  139. //Barman and Chef get a old-times register
  140. //All-Purpose-Market can be used by anyone to sell anything and it's put in Crew Quarters
  141.  
  142. /obj/machinery/smartfridge/sale_machine
  143. name = "Electronic Merchant"
  144. desc = "This machine is down for maintenance every saturday."
  145. density = 1
  146. anchored = 1
  147. icon = 'icons/obj/chemical.dmi' //gonna need a new one
  148. icon_state = "dispenser"
  149. use_power = 1
  150. idle_power_usage = 50
  151. var/item_prices = list()
  152. var/starting_inventory = list()
  153.  
  154. //spawn some initial goodies with a standard price
  155. /obj/machinery/smartfridge/sale_machine/New()
  156. ..()
  157. for(var/I in starting_inventory)
  158. I = new typepath(I)(src)
  159. contents += I
  160. if(item_quants[I.name])
  161. item_quants[I.name]++
  162. else
  163. item_quants[I.name] = 1
  164. item_prices[I.name] = price
  165. return
  166.  
  167. /obj/machinery/smartfridge/sale_machine/accept_check(var/obj/item/O as obj)
  168. if(istype(O,/obj/item/weapon/coin))
  169. return 1
  170. else
  171. return 0
  172.  
  173. /obj/machinery/smartfridge/sale_machine/load(var/obj/item/O as obj)
  174. if(istype(O.loc,/mob))
  175. var/mob/M = O.loc
  176. if(!M.unEquip(O))
  177. usr << "<span class='notice'>\the [O] is stuck to your hand, you cannot put it in \the [src]</span>"
  178. return
  179. else if(istype(O.loc,/obj/item/weapon/storage))
  180. var/obj/item/weapon/storage/S = O.loc
  181. S.remove_from_storage(O,src)
  182.  
  183. var/n = O.name
  184. var/price = min(max(input(usr, "Put [O.name] up for sale.", "How much Spacecash do you want charge?") as num|null, 0), 9999)
  185.  
  186. O.loc = src
  187. if(item_quants[n])
  188. item_quants[n]++
  189. else
  190. item_quants[n] = 1
  191. item_prices[n] = price
  192. sortList(item_quants)
  193.  
  194. /obj/machinery/smartfridge/sale_machine/interact(mob/user as mob)
  195. if(stat)
  196. return 0
  197.  
  198. var/dat = "<TT><b>Select an item:</b><br>"
  199.  
  200. if (contents.len == 0)
  201. dat += "<font color = 'red'>No product loaded!</font>"
  202. else
  203. for (var/O in item_quants)
  204. if(item_quants[O] > 0)
  205. var/N = item_quants[O]
  206. var/itemName = encodeparams(sanitize(O))
  207. dat += "<FONT color = 'blue'><B>[capitalize(O)]</B>:"
  208. dat += " x [N] </font>"
  209. dat += ": [item_prices[O]] Spacecash"
  210. dat += "<a href='byond://?src=\ref[src];vend=[itemName];amount=1'>Vend</A> "
  211. if(N > 1)
  212. dat += "(<a href='?src=\ref[src];vend=[itemName];amount=[N]'>All</A>)"
  213.  
  214. dat += "<br>"
  215.  
  216. dat += "</TT>"
  217. user << browse("<HEAD><TITLE>[src] supplies</TITLE></HEAD><TT>[dat]</TT>", "window=smartfridge")
  218. onclose(user, "smartfridge")
  219. return dat
  220.  
  221. /obj/machinery/smartfridge/sale_machine/Topic(var/href, var/list/href_list)
  222. if(..())
  223. return
  224. usr.set_machine(src)
  225.  
  226. var/N = href_list["vend"]
  227. var/amount = text2num(href_list["amount"])
  228.  
  229. if(item_quants[N] <= 0) // Sanity check, there are probably ways to press the button when it shouldn't be possible.
  230. return
  231.  
  232. //attempt to make a sale
  233. var/obj/item/weapon/spacecash/wad_money
  234. if(istype(usr.get_active_hand(), /obj/item/weapon/spacecash))
  235. wad_money = usr.get_active_hand()
  236.  
  237. if(wad_money)
  238. if(wad_money.amount >= item_prices[N])
  239. wad_money.pay(item_prices[N])
  240. item_quants[N] = max(item_quants[N] - amount, 0)
  241.  
  242. var/i = amount
  243. for(var/obj/O in contents)
  244. if(O.name == N)
  245. O.loc = src.loc
  246. i--
  247. if(i <= 0)
  248. break
  249.  
  250. src.updateUsrDialog()
  251. return
  252.  
  253. ////////////////////////
  254. //Chem Vending machine//
  255. ////////////////////////
  256.  
  257. /obj/machinery/smartfridge/sale_machine/chems
  258. name = "Vend-a-Cure"
  259. desc = "Afordable healthcare for the one's who act. Get it now, before it's repealed!"
  260. icon = 'icons/obj/chemical.dmi' //gonna need a new one
  261. icon_state = "dispenser"
  262. starting_inventory = (/obj/item/weapon/reagent_containers/glass/bottle/inaprovaline = 2)
  263.  
  264. /obj/machinery/smartfridge/sale_machine/chems/accept_check(var/obj/item/O as obj)
  265. 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))
  266. return 1
  267. else
  268. return 0
  269.  
  270. ///////////////////////////////////////////////
  271. //Stock Parts and Electronics Vending machine//
  272. ///////////////////////////////////////////////
  273.  
  274. /obj/machinery/smartfridge/sale_machine
  275. name = "Volts & Bolts"
  276. desc = "With 10 easily affordable payments, you can make any broken machine whirr and bleep again!"
  277.  
  278. //spawn some initial goodies with a standard price
  279.  
  280.  
  281.  
  282. /obj/machinery/smartfridge/sale_machine/accept_check(var/obj/item/O as obj)
  283. if(istype(O,/obj/item/weapon/stock_parts) || istype(O,/obj/item/weapon/circuitboard))
  284. return 1
  285. else
  286. return 0
  287.  
  288. /////////////
  289. // PARCELS //
  290. /////////////
  291.  
  292. //these are objects that cargo can export. they also credit the department that produced them with some points
  293.  
  294. /obj/structure/export_parcel
  295. name = "Export Parcel"
  296. desc = "Cargo to be offloaded and traded all across the universe."
  297. icon = 'icons/obj/objects.dmi' //needs new icon
  298. icon_state = "watertank"
  299. density = 1
  300. anchored = 0
  301. var/points = 0 //how many points this parcel is worth
  302.  
  303. /obj/structure/export_parcel/New(var/loc, var/worth=null)
  304. ..()
  305. if (worth)
  306. src.points = worth
  307. desc += " The label reads: '[points] credits'."
  308. return
  309.  
  310. /obj/structure/export_parcel/chem
  311. name = "Export Chemical Container"
  312. desc = "A container filled with chemicals to be offloaded and traded all acrss the universe."
  313. icon = 'icons/obj/objects.dmi' //needs new icon
  314. icon_state = "watertank"
  315.  
  316. /obj/structure/export_parcel/power
  317. name = "Export Power Supply Battery"
  318. desc = "Charged battery to be offloaded and traded all across the universe."
  319. icon = 'icons/obj/objects.dmi' //needs new icon
  320. icon_state = "watertank"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement