diff --git a/code/game/machinery/vending.dm b/code/game/machinery/vending.dm index 51af34bfb8c..b97007d627b 100644 --- a/code/game/machinery/vending.dm +++ b/code/game/machinery/vending.dm @@ -323,7 +323,9 @@ */ /obj/machinery/vending/proc/pay_with_card(var/obj/item/weapon/card/id/I) visible_message("[usr] swipes a card through [src].") - var/datum/money_account/customer_account = attempt_account_access_nosec(I.associated_account_number) + return pay_with_account(get_card_account(I)) + +/obj/machinery/vending/proc/pay_with_account(var/datum/money_account/customer_account) if (!customer_account) src.status_message = "Error: Unable to access account. Please contact technical support if problem persists." src.status_error = 1 @@ -338,7 +340,7 @@ // empty at high security levels if(customer_account.security_level != 0) //If card requires pin authentication (ie seclevel 1 or 2) var/attempt_pin = input("Enter pin code", "Vendor transaction") as num - customer_account = attempt_account_access(I.associated_account_number, attempt_pin, 2) + customer_account = attempt_account_access(customer_account, attempt_pin, 2) if(!customer_account) src.status_message = "Unable to access account: incorrect credentials." @@ -351,28 +353,18 @@ return 0 else // Okay to move the money at this point + var/paid = customer_account.charge(currently_vending.price, + transaction_purpose = "Purchase of [currently_vending.product_name]", + terminal_name = name, + terminal_id = name, + dest_name = vendor_account.owner_name) - // debit money from the purchaser's account - customer_account.money -= currently_vending.price - - // create entry in the purchaser's account log - var/datum/transaction/T = new() - T.target_name = "[vendor_account.owner_name] (via [src.name])" - T.purpose = "Purchase of [currently_vending.product_name]" - if(currently_vending.price > 0) - T.amount = "([currently_vending.price])" - else - T.amount = "[currently_vending.price]" - T.source_terminal = src.name - T.date = current_date_string - T.time = worldtime2text() - customer_account.transaction_log.Add(T) - - // Give the vendor the money. We use the account owner name, which means - // that purchases made with stolen/borrowed card will look like the card - // owner made them - credit_purchase(customer_account.owner_name) - return 1 + if(paid) + // Give the vendor the money. We use the account owner name, which means + // that purchases made with stolen/borrowed card will look like the card + // owner made them + credit_purchase(customer_account.owner_name) + return paid /** * Add money for current purchase to the vendor account. @@ -471,38 +463,28 @@ if (href_list["pay"]) if(currently_vending && vendor_account && !vendor_account.suspended) - if(istype(usr, /mob/living/carbon/human)) - var/paid = 0 - var/handled = 0 - var/mob/living/carbon/human/H = usr - var/obj/item/weapon/card/card = null - if(istype(H.wear_id,/obj/item/weapon/card)) - card = H.wear_id - paid = pay_with_card(card) - handled = 1 - else if(istype(H.get_active_hand(), /obj/item/weapon/card)) - card = H.get_active_hand() - paid = pay_with_card(card) - handled = 1 - if(paid) - src.vend(currently_vending, usr) - return - else if(handled) - nanomanager.update_uis(src) - return // don't smack that machine with your 2 credits + var/paid = 0 + var/handled = 0 + var/datum/money_account/A = usr.get_worn_id_account() + if(A) + paid = pay_with_account(A) + handled = 1 + else if(istype(usr.get_active_hand(), /obj/item/weapon/card)) + paid = pay_with_card(usr.get_active_hand()) + handled = 1 + if(paid) + src.vend(currently_vending, usr) + return + else if(handled) + nanomanager.update_uis(src) + return // don't smack that machine with your 2 credits if ((usr.contents.Find(src) || (in_range(src, usr) && istype(src.loc, /turf)))) if ((href_list["vend"]) && (src.vend_ready) && (!currently_vending)) - if(istype(usr,/mob/living/silicon)) - if(istype(usr,/mob/living/silicon/robot)) - var/mob/living/silicon/robot/R = usr - if(!(R.module && istype(R.module,/obj/item/weapon/robot_module/butler) )) - usr << "\red The vending machine refuses to interface with you, as you are not in its target demographic!" - return - else - usr << "\red The vending machine refuses to interface with you, as you are not in its target demographic!" - return + if(issilicon(usr) && !isrobot(usr)) + usr << "The vending machine refuses to interface with you, as you are not in its target demographic!" + return if((!allowed(usr)) && !emagged && scan_id) //For SECURE VENDING MACHINES YEAH usr << "Access denied." //Unless emagged of course @@ -847,11 +829,11 @@ icon_deny = "cart-deny" products = list(/obj/item/device/pda =10,/obj/item/weapon/cartridge/medical = 10,/obj/item/weapon/cartridge/chemistry = 10, /obj/item/weapon/cartridge/engineering = 10,/obj/item/weapon/cartridge/atmos = 10,/obj/item/weapon/cartridge/janitor = 10, - /obj/item/weapon/cartridge/signal/toxins = 10,/obj/item/weapon/cartridge/signal = 10,/obj/item/weapon/cartridge = 10) + /obj/item/weapon/cartridge/signal/toxins = 10,/obj/item/weapon/cartridge/signal = 10) contraband = list(/obj/item/weapon/cartridge/clown = 1,/obj/item/weapon/cartridge/mime = 1) prices = list(/obj/item/device/pda =300,/obj/item/weapon/cartridge/medical = 200,/obj/item/weapon/cartridge/chemistry = 150,/obj/item/weapon/cartridge/engineering = 100, /obj/item/weapon/cartridge/atmos = 75,/obj/item/weapon/cartridge/janitor = 100,/obj/item/weapon/cartridge/signal/toxins = 150, - /obj/item/weapon/cartridge/signal = 75,/obj/item/weapon/cartridge = 50) + /obj/item/weapon/cartridge/signal = 75) /obj/machinery/vending/liberationstation @@ -1107,7 +1089,7 @@ icon_state = "engivend" icon_deny = "engivend-deny" req_access_txt = "11" //Engineering Equipment access - products = list(/obj/item/clothing/glasses/meson = 2,/obj/item/device/multitool = 4,/obj/item/weapon/airlock_electronics = 10,/obj/item/weapon/firealarm_electronics = 10,/obj/item/weapon/apc_electronics = 10,/obj/item/weapon/airalarm_electronics = 10,/obj/item/weapon/stock_parts/cell/high = 10) + products = list(/obj/item/clothing/glasses/meson = 2,/obj/item/device/multitool = 4,/obj/item/weapon/airlock_electronics = 10,/obj/item/weapon/firealarm_electronics = 10,/obj/item/weapon/apc_electronics = 10,/obj/item/weapon/airalarm_electronics = 10,/obj/item/weapon/stock_parts/cell/high = 10,/obj/item/weapon/camera_assembly = 10) contraband = list(/obj/item/weapon/stock_parts/cell/potato = 3) premium = list(/obj/item/weapon/storage/belt/utility = 3)