From 300d85be1c52574bea570377c7f65b584c29e0d4 Mon Sep 17 00:00:00 2001 From: Tastyfish Date: Tue, 16 Feb 2016 19:30:48 -0500 Subject: [PATCH 1/2] EngiVend has camera assemblies, can be used by borgs --- code/game/machinery/vending.dm | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/code/game/machinery/vending.dm b/code/game/machinery/vending.dm index 0939b189eb1..4468a42fb64 100644 --- a/code/game/machinery/vending.dm +++ b/code/game/machinery/vending.dm @@ -494,15 +494,9 @@ 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 @@ -1096,7 +1090,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) From 50d0d0c5e0b45bd578f2d68a06d6c927ac09be77 Mon Sep 17 00:00:00 2001 From: Tastyfish Date: Wed, 17 Feb 2016 18:07:23 -0500 Subject: [PATCH 2/2] Paid vending machines usable by borgs too --- code/game/machinery/vending.dm | 72 ++++++++++++++-------------------- code/modules/economy/utils.dm | 6 ++- 2 files changed, 35 insertions(+), 43 deletions(-) diff --git a/code/game/machinery/vending.dm b/code/game/machinery/vending.dm index 4468a42fb64..aa66773b16b 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,25 +463,21 @@ 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)) diff --git a/code/modules/economy/utils.dm b/code/modules/economy/utils.dm index 44b5ebdd036..a23308b9219 100644 --- a/code/modules/economy/utils.dm +++ b/code/modules/economy/utils.dm @@ -47,6 +47,10 @@ return "$[num2septext(money)]" /datum/money_account/proc/charge(var/transaction_amount,var/datum/money_account/dest,var/transaction_purpose, var/terminal_name="", var/terminal_id=0, var/dest_name = "UNKNOWN") + if(suspended) + usr << "Unable to access source account: account suspended." + return 0 + if(transaction_amount <= money) //transfer the money money -= transaction_amount @@ -84,5 +88,5 @@ transaction_log.Add(T) return 1 else - usr << "\icon[src]You don't have that much money!" + usr << "Insufficient funds in account." return 0 \ No newline at end of file