Files
kiwistation/code/modules/modular_computers/laptop_vendor.dm
T
Cyberboss 9e1ef0ffe2 Global variable wrappers (#25325)
* Add the system for managed global variables

* Travis ban old globals

* So you CAN inline proccall, that's neat

* Fix that

* master.dm

* Remove the hack procs

* Move InitGlobals to the proper spot

* configuration.dm

* Fix the missing pre-slash

* clockcult.dm

* This is probably for the best

* Doy

* Fix shit

* Rest of the DEFINES tree

* Fix

* Use global. for access

* Update find_references_in_globals

Always hated that proc

Whoever made it must've bee a r e a l idiot...

* __HELPERS tree

* Move global initialization to master.

Fix the declaration

* database.dm

* Dat newline

* I said DECLARATIVE order!

* Here's something you can chew on @Iamgoofball

* game_modes.dm

* Fix this

* genetics.dm

* flavor_misc.dm

* More stuff

* Do it mso's way. Keep the controllers as global

* Make master actually see it

* Fix

* Finish _globalvars/lists

* Finish the rest of the _globalvars tree

* This is weird

* Migrate the controllers

* SLOTH -> GLOB

* Lighting globals

* round_start_time -> ticker

* PAI card list -> pai SS

* record_id_num -> static

* Diseases list -> SSdisease

* More disease globals to the SS

* More disease stuff

* Emote list

* Better and better

* Bluh

* So much stuff

* Ahh

* Wires

* dview

* station_areas

* Teleportlocs

* blood_splatter_icons

* Stuff and such

* More stuff

* RAD IO

* More stuff and such

* Blob shit

* Changeling stuff

* Add "Balance" to changelogs

* Balance for changelog compiler + Auto Tagging

* Update the PR template

* hivemind_bank

* Bip

* sacrificed

* Good shit

* Better define

* More cult shit

* Devil shit

* Gang shit

* > borers

Fix shit

* Rename the define

* Nuke

* Objectives

* Sandbox

* Multiverse sword

* Announce systems

* Stuff and such

* TC con

* Airlock

* doppllllerrrrrr

* holopads

* Shut up byond you inconsistent fuck

* Sneaky fuck

* Burp

* Bip

* Fixnshit

* Port without regard

* askdlfjs;

* asdfjasoidojfi

* Protected globals and more

* SO MANY

* ajsimkvahsaoisd

* akfdsiaopwimfeoiwafaw

* gsdfigjosidjfgiosdg

* AHHHHHHHHHHHHHHHHHHHHHHH!!!!!

* facerolll

* ASDFASDFASDF

* Removes the unused parts of dmm_suite

* WIP

* Fix quote

* asdfjauwfnkjs

* afwlunhskjfda

* asfjlaiwuefhaf

* SO CLOSE

* wwwweeeeeewwwww

* agdgmoewranwg

* HOLY MOTHER OF FUCK AND THATS JUST HALF THE JOB?!?

* Fix syntax errors

* 100 errors

* Another 100

* So many...

* Ugh

* More shit

* kilme

* Stuuuuuufffff

* ajrgmrlshio;djfa;sdkl

* jkbhkhjbmjvjmh

* soi soi soi

* butt

* TODAY WE LEARNED THAT GLOBAL AND STATIC ARE THE EXACT SAME FUCKING THING

* lllllllllllllllllllllllllllllllllllllllllll

* afsdijfiawhnflnjhnwsdfs

* yugykihlugk,kj

* time to go

* STUFFF!!!

* AAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!!!!!!!!

* ngoaijdjlfkamsdlkf

* Break time

* aufjsdklfalsjfi

* CONTROL KAY AND PRAY

* IT COMPILEELEELELAKLJFKLDAFJLKFDJLADKJHFLJKAJGAHIEJALDFJ!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

* Goteem

* Fix testing mode

* This does not belong in this PR

* Convert it to a controller

* Eh, fuck this option

* Revert controllerization Ill do it some other time

* Fix

* Working controllerization

* FOR THE LOVE OF CHRIST PROTECT THE LOGS

* Protect admins and deadmins

* Use the inbuilt proc
2017-04-06 23:26:13 -06:00

300 lines
9.5 KiB
Plaintext

// A vendor machine for modular computer portable devices - Laptops and Tablets
/obj/machinery/lapvend
name = "computer vendor"
desc = "A vending machine with microfabricator capable of dispensing various NT-branded computers."
icon = 'icons/obj/vending.dmi'
icon_state = "robotics"
layer = 2.9
anchored = 1
density = 1
// The actual laptop/tablet
var/obj/item/device/modular_computer/laptop/fabricated_laptop = null
var/obj/item/device/modular_computer/tablet/fabricated_tablet = null
// Utility vars
var/state = 0 // 0: Select device type, 1: Select loadout, 2: Payment, 3: Thankyou screen
var/devtype = 0 // 0: None(unselected), 1: Laptop, 2: Tablet
var/total_price = 0 // Price of currently vended device.
var/credits = 0
// Device loadout
var/dev_cpu = 1 // 1: Default, 2: Upgraded
var/dev_battery = 1 // 1: Default, 2: Upgraded, 3: Advanced
var/dev_disk = 1 // 1: Default, 2: Upgraded, 3: Advanced
var/dev_netcard = 0 // 0: None, 1: Basic, 2: Long-Range
var/dev_apc_recharger = 0 // 0: None, 1: Standard (LAPTOP ONLY)
var/dev_printer = 0 // 0: None, 1: Standard
var/dev_card = 0 // 0: None, 1: Standard
// Removes all traces of old order and allows you to begin configuration from scratch.
/obj/machinery/lapvend/proc/reset_order()
state = 0
devtype = 0
if(fabricated_laptop)
qdel(fabricated_laptop)
fabricated_laptop = null
if(fabricated_tablet)
qdel(fabricated_tablet)
fabricated_tablet = null
dev_cpu = 1
dev_battery = 1
dev_disk = 1
dev_netcard = 0
dev_apc_recharger = 0
dev_printer = 0
dev_card = 0
// Recalculates the price and optionally even fabricates the device.
/obj/machinery/lapvend/proc/fabricate_and_recalc_price(fabricate = 0)
total_price = 0
if(devtype == 1) // Laptop, generally cheaper to make it accessible for most station roles
var/obj/item/weapon/computer_hardware/battery/battery_module = null
if(fabricate)
fabricated_laptop = new /obj/item/device/modular_computer/laptop/buildable(src)
fabricated_laptop.install_component(new /obj/item/weapon/computer_hardware/battery)
battery_module = fabricated_laptop.all_components[MC_CELL]
total_price = 99
switch(dev_cpu)
if(1)
if(fabricate)
fabricated_laptop.install_component(new /obj/item/weapon/computer_hardware/processor_unit/small)
if(2)
if(fabricate)
fabricated_laptop.install_component(new /obj/item/weapon/computer_hardware/processor_unit)
total_price += 299
switch(dev_battery)
if(1) // Basic(750C)
if(fabricate)
battery_module.try_insert(new /obj/item/weapon/stock_parts/cell/computer)
if(2) // Upgraded(1100C)
if(fabricate)
battery_module.try_insert(new /obj/item/weapon/stock_parts/cell/computer/advanced)
total_price += 199
if(3) // Advanced(1500C)
if(fabricate)
battery_module.try_insert(new /obj/item/weapon/stock_parts/cell/computer/super)
total_price += 499
switch(dev_disk)
if(1) // Basic(128GQ)
if(fabricate)
fabricated_laptop.install_component(new /obj/item/weapon/computer_hardware/hard_drive)
if(2) // Upgraded(256GQ)
if(fabricate)
fabricated_laptop.install_component(new /obj/item/weapon/computer_hardware/hard_drive/advanced)
total_price += 99
if(3) // Advanced(512GQ)
if(fabricate)
fabricated_laptop.install_component(new /obj/item/weapon/computer_hardware/hard_drive/super)
total_price += 299
switch(dev_netcard)
if(1) // Basic(Short-Range)
if(fabricate)
fabricated_laptop.install_component(new /obj/item/weapon/computer_hardware/network_card)
total_price += 99
if(2) // Advanced (Long Range)
if(fabricate)
fabricated_laptop.install_component(new /obj/item/weapon/computer_hardware/network_card/advanced)
total_price += 299
if(dev_apc_recharger)
total_price += 399
if(fabricate)
fabricated_laptop.install_component(new /obj/item/weapon/computer_hardware/recharger/APC)
if(dev_printer)
total_price += 99
if(fabricate)
fabricated_laptop.install_component(new /obj/item/weapon/computer_hardware/printer/mini)
if(dev_card)
total_price += 199
if(fabricate)
fabricated_laptop.install_component(new /obj/item/weapon/computer_hardware/card_slot)
return total_price
else if(devtype == 2) // Tablet, more expensive, not everyone could probably afford this.
var/obj/item/weapon/computer_hardware/battery/battery_module = null
if(fabricate)
fabricated_tablet = new(src)
fabricated_tablet.install_component(new /obj/item/weapon/computer_hardware/battery)
fabricated_tablet.install_component(new /obj/item/weapon/computer_hardware/processor_unit/small)
battery_module = fabricated_tablet.all_components[MC_CELL]
total_price = 199
switch(dev_battery)
if(1) // Basic(300C)
if(fabricate)
battery_module.try_insert(new /obj/item/weapon/stock_parts/cell/computer/nano)
if(2) // Upgraded(500C)
if(fabricate)
battery_module.try_insert(new /obj/item/weapon/stock_parts/cell/computer/micro)
total_price += 199
if(3) // Advanced(750C)
if(fabricate)
battery_module.try_insert(new /obj/item/weapon/stock_parts/cell/computer)
total_price += 499
switch(dev_disk)
if(1) // Basic(32GQ)
if(fabricate)
fabricated_tablet.install_component(new /obj/item/weapon/computer_hardware/hard_drive/micro)
if(2) // Upgraded(64GQ)
if(fabricate)
fabricated_tablet.install_component(new /obj/item/weapon/computer_hardware/hard_drive/small)
total_price += 99
if(3) // Advanced(128GQ)
if(fabricate)
fabricated_tablet.install_component(new /obj/item/weapon/computer_hardware/hard_drive)
total_price += 299
switch(dev_netcard)
if(1) // Basic(Short-Range)
if(fabricate)
fabricated_tablet.install_component(new/obj/item/weapon/computer_hardware/network_card)
total_price += 99
if(2) // Advanced (Long Range)
if(fabricate)
fabricated_tablet.install_component(new/obj/item/weapon/computer_hardware/network_card/advanced)
total_price += 299
if(dev_printer)
total_price += 99
if(fabricate)
fabricated_tablet.install_component(new/obj/item/weapon/computer_hardware/printer)
if(dev_card)
total_price += 199
if(fabricate)
fabricated_tablet.install_component(new/obj/item/weapon/computer_hardware/card_slot)
return total_price
return 0
/obj/machinery/lapvend/ui_act(action, params)
if(..())
return 1
switch(action)
if("pick_device")
if(state) // We've already picked a device type
return 0
devtype = text2num(params["pick"])
state = 1
fabricate_and_recalc_price(0)
return 1
if("clean_order")
reset_order()
return 1
if("purchase")
try_purchase()
return 1
if((state != 1) && devtype) // Following IFs should only be usable when in the Select Loadout mode
return 0
switch(action)
if("confirm_order")
state = 2 // Wait for ID swipe for payment processing
fabricate_and_recalc_price(0)
return 1
if("hw_cpu")
dev_cpu = text2num(params["cpu"])
fabricate_and_recalc_price(0)
return 1
if("hw_battery")
dev_battery = text2num(params["battery"])
fabricate_and_recalc_price(0)
return 1
if("hw_disk")
dev_disk = text2num(params["disk"])
fabricate_and_recalc_price(0)
return 1
if("hw_netcard")
dev_netcard = text2num(params["netcard"])
fabricate_and_recalc_price(0)
return 1
if("hw_tesla")
dev_apc_recharger = text2num(params["tesla"])
fabricate_and_recalc_price(0)
return 1
if("hw_nanoprint")
dev_printer = text2num(params["print"])
fabricate_and_recalc_price(0)
return 1
if("hw_card")
dev_card = text2num(params["card"])
fabricate_and_recalc_price(0)
return 1
return 0
/obj/machinery/lapvend/attack_hand(mob/user)
ui_interact(user)
/obj/machinery/lapvend/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
if(stat & (BROKEN | NOPOWER | MAINT))
if(ui)
ui.close()
return 0
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if (!ui)
ui = new(user, src, ui_key, "computer_fabricator", "Personal Computer Vendor", 500, 400, state = state)
ui.open()
ui.set_autoupdate(state = 1)
/obj/machinery/lapvend/attackby(obj/item/I as obj, mob/user as mob)
if(istype(I,/obj/item/stack/spacecash))
var/obj/item/stack/spacecash/c = I
if(!user.drop_item(c))
return
credits += c.value
visible_message("<span class='info'><span class='name'>[usr]</span> inserts [c.value] credits into the [src].</span>")
qdel(c)
return
return ..()
// Simplified payment processing, returns 1 on success.
/obj/machinery/lapvend/proc/process_payment()
if(total_price > credits)
say("Insufficient credits.")
return 0
else
return 1
/obj/machinery/lapvend/ui_data(mob/user)
var/list/data = list()
data["state"] = state
if(state == 1)
data["devtype"] = devtype
data["hw_battery"] = dev_battery
data["hw_disk"] = dev_disk
data["hw_netcard"] = dev_netcard
data["hw_tesla"] = dev_apc_recharger
data["hw_nanoprint"] = dev_printer
data["hw_card"] = dev_card
data["hw_cpu"] = dev_cpu
if(state == 1 || state == 2)
data["totalprice"] = total_price
data["credits"] = credits
return data
/obj/machinery/lapvend/proc/try_purchase()
// Awaiting payment state
if(state == 2)
if(process_payment())
fabricate_and_recalc_price(1)
if((devtype == 1) && fabricated_laptop)
fabricated_laptop.forceMove(src.loc)
fabricated_laptop = null
else if((devtype == 2) && fabricated_tablet)
fabricated_tablet.forceMove(src.loc)
fabricated_tablet = null
credits -= total_price
say("Enjoy your new product!")
state = 3
return 1
return 0