From c9f09661566b7d3a573e59d8f4ef26644d5b6f56 Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Tue, 27 Oct 2020 15:59:28 +0100 Subject: [PATCH] Non-human mobs can now benefit from held id cards and economy. --- code/game/machinery/_machinery.dm | 39 +++-- code/game/machinery/roulette_machine.dm | 15 +- code/game/objects/items/crab17.dm | 7 +- code/game/objects/items/wayfinding.dm | 8 +- .../antagonists/traitor/syndicate_contract.dm | 6 +- code/modules/cargo/orderconsole.dm | 5 +- code/modules/mining/machine_vending.dm | 24 ++- .../mob/living/carbon/human/human_helpers.dm | 47 +----- .../mob/living/simple_animal/simple_animal.dm | 3 +- code/modules/mob/mob.dm | 7 - code/modules/mob/mob_helpers.dm | 29 ++++ .../file_system/programs/budgetordering.dm | 2 +- code/modules/projectiles/pins.dm | 54 ++++--- code/modules/shuttle/special.dm | 7 +- code/modules/vending/_vending.dm | 141 ++++++++---------- 15 files changed, 171 insertions(+), 223 deletions(-) diff --git a/code/game/machinery/_machinery.dm b/code/game/machinery/_machinery.dm index f734b081096..f59c94f0f7f 100644 --- a/code/game/machinery/_machinery.dm +++ b/code/game/machinery/_machinery.dm @@ -371,27 +371,26 @@ Class Procs: if(!SSeconomy.full_ancap) return TRUE if(occupant && !state_open) - if(ishuman(occupant)) - var/mob/living/carbon/human/H = occupant - var/obj/item/card/id/I = H.get_idcard(TRUE) - if(I) - var/datum/bank_account/insurance = I.registered_account - if(!insurance) - say("[market_verb] NAP Violation: No bank account found.") - nap_violation(H) - return FALSE - else - if(!insurance.adjust_money(-fair_market_price)) - say("[market_verb] NAP Violation: Unable to pay.") - nap_violation(H) - return FALSE - var/datum/bank_account/D = SSeconomy.get_dep_account(payment_department) - if(D) - D.adjust_money(fair_market_price) - else - say("[market_verb] NAP Violation: No ID card found.") - nap_violation(H) + var/mob/living/L = occupant + var/obj/item/card/id/I = L.get_idcard(TRUE) + if(I) + var/datum/bank_account/insurance = I.registered_account + if(!insurance) + say("[market_verb] NAP Violation: No bank account found.") + nap_violation(L) return FALSE + else + if(!insurance.adjust_money(-fair_market_price)) + say("[market_verb] NAP Violation: Unable to pay.") + nap_violation(L) + return FALSE + var/datum/bank_account/D = SSeconomy.get_dep_account(payment_department) + if(D) + D.adjust_money(fair_market_price) + else + say("[market_verb] NAP Violation: No ID card found.") + nap_violation(L) + return FALSE return TRUE /obj/machinery/proc/nap_violation(mob/violator) diff --git a/code/game/machinery/roulette_machine.dm b/code/game/machinery/roulette_machine.dm index 212a1b4e57c..379a1e55d39 100644 --- a/code/game/machinery/roulette_machine.dm +++ b/code/game/machinery/roulette_machine.dm @@ -74,14 +74,13 @@ data["HouseBalance"] = my_card?.registered_account.account_balance data["LastSpin"] = last_spin data["Spinning"] = playing - if(ishuman(user)) - var/mob/living/carbon/human/H = user - var/obj/item/card/id/C = H.get_idcard(TRUE) - if(C) - data["AccountBalance"] = C.registered_account.account_balance - else - data["AccountBalance"] = 0 - data["CanUnbolt"] = (H.get_idcard() == my_card) + var/mob/living/carbon/human/H = user + var/obj/item/card/id/C = H.get_idcard(TRUE) + if(C) + data["AccountBalance"] = C.registered_account.account_balance + else + data["AccountBalance"] = 0 + data["CanUnbolt"] = (C == my_card) return data diff --git a/code/game/objects/items/crab17.dm b/code/game/objects/items/crab17.dm index 5ccfe8ee854..05905494047 100644 --- a/code/game/objects/items/crab17.dm +++ b/code/game/objects/items/crab17.dm @@ -9,7 +9,7 @@ var/dumped = FALSE /obj/item/suspiciousphone/attack_self(mob/user) - if(!ishuman(user)) + if(!user.IsAdvancedToolUser()) to_chat(user, "This device is too advanced for you!") return if(dumped) @@ -22,8 +22,7 @@ if (!targetturf) return FALSE var/list/accounts_to_rob = flatten_list(SSeconomy.bank_accounts_by_id) - var/mob/living/carbon/human/H = user - accounts_to_rob -= H.get_bank_account() + accounts_to_rob -= user.get_bank_account() for(var/i in accounts_to_rob) var/datum/bank_account/B = i B.being_dumped = TRUE @@ -41,7 +40,7 @@ pixel_z = -8 max_integrity = 5000 var/list/accounts_to_rob - var/mob/living/carbon/human/bogdanoff + var/mob/bogdanoff var/canwalk = FALSE /obj/structure/checkoutmachine/examine(mob/living/user) diff --git a/code/game/objects/items/wayfinding.dm b/code/game/objects/items/wayfinding.dm index 0090fd0819b..6fdfcda0deb 100644 --- a/code/game/objects/items/wayfinding.dm +++ b/code/game/objects/items/wayfinding.dm @@ -27,7 +27,7 @@ set_expression("neutral") -/obj/machinery/pinpointer_dispenser/attack_hand(mob/living/carbon/user) +/obj/machinery/pinpointer_dispenser/attack_hand(mob/living/user) if(world.time < user_interact_cooldowns[user.real_name]) to_chat(user, "It doesn't respond.") return @@ -59,11 +59,7 @@ msg += "to wait another [secsleft/60 > 1 ? "[round(secsleft/60,1)] minute\s" : "[round(secsleft)] second\s"]" dispense = FALSE - var/datum/bank_account/cust_acc = null - if(ishuman(user)) - var/mob/living/carbon/human/H = user - if(H.get_bank_account()) - cust_acc = H.get_bank_account() + var/datum/bank_account/cust_acc = user.get_bank_account() if(cust_acc) if(!cust_acc.has_money(ppt_cost)) diff --git a/code/modules/antagonists/traitor/syndicate_contract.dm b/code/modules/antagonists/traitor/syndicate_contract.dm index 64c45c0414d..480c6772a72 100644 --- a/code/modules/antagonists/traitor/syndicate_contract.dm +++ b/code/modules/antagonists/traitor/syndicate_contract.dm @@ -140,11 +140,7 @@ // Pay contractor their portion of ransom if (status == CONTRACT_STATUS_COMPLETE) - var/mob/living/carbon/human/H - var/obj/item/card/id/C - if(ishuman(contract.owner.current)) - H = contract.owner.current - C = H.get_idcard(TRUE) + var/obj/item/card/id/C = contract.owner.current?.get_idcard(TRUE) if(C?.registered_account) C.registered_account.adjust_money(ransom * 0.35) diff --git a/code/modules/cargo/orderconsole.dm b/code/modules/cargo/orderconsole.dm index 9197dce0e96..e9880e4bd53 100644 --- a/code/modules/cargo/orderconsole.dm +++ b/code/modules/cargo/orderconsole.dm @@ -199,9 +199,8 @@ rank = "Silicon" var/datum/bank_account/account - if(self_paid && ishuman(usr)) - var/mob/living/carbon/human/H = usr - var/obj/item/card/id/id_card = H.get_idcard(TRUE) + if(self_paid) + var/obj/item/card/id/id_card = usr.get_idcard(TRUE) if(!istype(id_card)) say("No ID card detected.") return diff --git a/code/modules/mining/machine_vending.dm b/code/modules/mining/machine_vending.dm index 739c447a3f6..06ae6512b36 100644 --- a/code/modules/mining/machine_vending.dm +++ b/code/modules/mining/machine_vending.dm @@ -113,20 +113,16 @@ /obj/machinery/mineral/equipment_vendor/ui_data(mob/user) . = list() - var/mob/living/carbon/human/H - var/obj/item/card/id/C - if(ishuman(user)) - H = user - C = H.get_idcard(TRUE) - if(C) - .["user"] = list() - .["user"]["points"] = C.mining_points - if(C.registered_account) - .["user"]["name"] = C.registered_account.account_holder - if(C.registered_account.account_job) - .["user"]["job"] = C.registered_account.account_job.title - else - .["user"]["job"] = "No Job" + var/obj/item/card/id/C = user.get_idcard(TRUE) + if(C) + .["user"] = list() + .["user"]["points"] = C.mining_points + if(C.registered_account) + .["user"]["name"] = C.registered_account.account_holder + if(C.registered_account.account_job) + .["user"]["job"] = C.registered_account.account_job.title + else + .["user"]["job"] = "No Job" /obj/machinery/mineral/equipment_vendor/ui_act(action, params) . = ..() diff --git a/code/modules/mob/living/carbon/human/human_helpers.dm b/code/modules/mob/living/carbon/human/human_helpers.dm index 30254dc6e88..330eed9a1d7 100644 --- a/code/modules/mob/living/carbon/human/human_helpers.dm +++ b/code/modules/mob/living/carbon/human/human_helpers.dm @@ -77,40 +77,12 @@ . = if_no_id //to prevent null-names making the mob unclickable return -//Gets ID card from a human. If hand_first is false the one in the id slot is prioritized, otherwise inventory slots go first. /mob/living/carbon/human/get_idcard(hand_first = TRUE) - //Check hands - var/obj/item/card/id/id_card - var/obj/item/held_item - held_item = get_active_held_item() - if(held_item) //Check active hand - id_card = held_item.GetID() - if(!id_card) //If there is no id, check the other hand - held_item = get_inactive_held_item() - if(held_item) - id_card = held_item.GetID() - - if(id_card) - if(hand_first) - return id_card - else - . = id_card - - //Check inventory slots - if(wear_id) - id_card = wear_id.GetID() - if(id_card) - return id_card - else if(belt) - id_card = belt.GetID() - if(id_card) - return id_card - -/mob/living/carbon/human/get_id_in_hand() - var/obj/item/held_item = get_active_held_item() - if(!held_item) + . = ..() + if(. && hand_first) return - return held_item.GetID() + //Check inventory slots + return (wear_id?.GetID() || belt?.GetID()) /mob/living/carbon/human/IsAdvancedToolUser() if(HAS_TRAIT(src, TRAIT_MONKEYLIKE)) @@ -142,17 +114,6 @@ to_chat(src, "You can't bring yourself to use a ranged weapon!") return FALSE -/mob/living/carbon/human/proc/get_bank_account() - RETURN_TYPE(/datum/bank_account) - var/datum/bank_account/account - var/obj/item/card/id/I = get_idcard() - - if(I?.registered_account) - account = I.registered_account - return account - - return FALSE - /mob/living/carbon/human/get_policy_keywords() . = ..() . += "[dna.species.type]" diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index 276a18fb293..e0faab6af91 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -588,8 +588,9 @@ return sync_lighting_plane_alpha() +//Will always check hands first, because access_card is internal to the mob and can't be removed or swapped. /mob/living/simple_animal/get_idcard(hand_first) - return access_card + return (..() || access_card) /mob/living/simple_animal/can_hold_items() return dextrous diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index a4285d7f396..e4f1c7518f6 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1197,13 +1197,6 @@ /mob/proc/can_hold_items() return FALSE -///Get the id card on this mob -/mob/proc/get_idcard(hand_first) - return - -/mob/proc/get_id_in_hand() - return - /** * Get the mob VV dropdown extras */ diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 0f8021d2733..5a8d62bbab1 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -531,3 +531,32 @@ ///Can the mob see reagents inside of containers? /mob/proc/can_see_reagents() return stat == DEAD || has_unlimited_silicon_privilege //Dead guys and silicons can always see reagents + +//Gets ID card from a mob. If hand_firsts is TRUE hands are checked first, otherwise other slots are prioritized (for subtypes at least). +/mob/proc/get_idcard(hand_first) + if(!length(held_items)) //Early return for mobs without hands. + return + //Check hands + var/obj/item/held_item = get_active_held_item() + if(held_item) //Check active hand + . = held_item.GetID() + if(!.) //If there is no id, check the other hand + held_item = get_inactive_held_item() + if(held_item) + . = held_item.GetID() + +/mob/proc/get_id_in_hand() + var/obj/item/held_item = get_active_held_item() + if(!held_item) + return + return held_item.GetID() + +//Returns the bank account of an ID the user may be holding. +/mob/proc/get_bank_account() + RETURN_TYPE(/datum/bank_account) + var/datum/bank_account/account + var/obj/item/card/id/I = get_idcard() + + if(I?.registered_account) + account = I.registered_account + return account diff --git a/code/modules/modular_computers/file_system/programs/budgetordering.dm b/code/modules/modular_computers/file_system/programs/budgetordering.dm index c2f9f015078..30b25a810f8 100644 --- a/code/modules/modular_computers/file_system/programs/budgetordering.dm +++ b/code/modules/modular_computers/file_system/programs/budgetordering.dm @@ -193,7 +193,7 @@ rank = "Silicon" var/datum/bank_account/account - if(self_paid && ishuman(usr)) + if(self_paid) var/mob/living/carbon/human/H = usr var/obj/item/card/id/id_card = H.get_idcard(TRUE) if(!istype(id_card)) diff --git a/code/modules/projectiles/pins.dm b/code/modules/projectiles/pins.dm index a794c5c851f..9bccd89d488 100644 --- a/code/modules/projectiles/pins.dm +++ b/code/modules/projectiles/pins.dm @@ -276,40 +276,36 @@ /obj/item/firing_pin/paywall/pin_auth(mob/living/user) if(!istype(user))//nice try commie return FALSE - if(ishuman(user)) - var/datum/bank_account/credit_card_details - var/mob/living/carbon/human/H = user - if(H.get_bank_account()) - credit_card_details = H.get_bank_account() - if(H in gun_owners) - if(multi_payment && credit_card_details) + var/datum/bank_account/credit_card_details = user.get_bank_account() + if(user in gun_owners) + if(multi_payment && credit_card_details) + if(credit_card_details.adjust_money(-payment_amount)) + pin_owner.registered_account.adjust_money(payment_amount) + return TRUE + to_chat(user, "ERROR: User balance insufficent for successful transaction!") + return FALSE + return TRUE + if(credit_card_details && !active_prompt) + var/license_request = alert(user, "Do you wish to pay [payment_amount] credit[( payment_amount > 1 ) ? "s" : ""] for [( multi_payment ) ? "each shot of [gun.name]" : "usage license of [gun.name]"]?", "Weapon Purchase", "Yes", "No") + active_prompt = TRUE + if(!user.canUseTopic(src, BE_CLOSE)) + active_prompt = FALSE + return FALSE + switch(license_request) + if("Yes") if(credit_card_details.adjust_money(-payment_amount)) pin_owner.registered_account.adjust_money(payment_amount) - return TRUE + gun_owners += user + to_chat(user, "Gun license purchased, have a secure day!") + active_prompt = FALSE + return FALSE //we return false here so you don't click initially to fire, get the prompt, accept the prompt, and THEN the gun to_chat(user, "ERROR: User balance insufficent for successful transaction!") return FALSE - return TRUE - if(credit_card_details && !active_prompt) - var/license_request = alert(usr, "Do you wish to pay [payment_amount] credit[( payment_amount > 1 ) ? "s" : ""] for [( multi_payment ) ? "each shot of [gun.name]" : "usage license of [gun.name]"]?", "Weapon Purchase", "Yes", "No") - active_prompt = TRUE - if(!user.canUseTopic(src, BE_CLOSE)) - active_prompt = FALSE + if("No") + to_chat(user, "ERROR: User has declined to purchase gun license!") return FALSE - switch(license_request) - if("Yes") - if(credit_card_details.adjust_money(-payment_amount)) - pin_owner.registered_account.adjust_money(payment_amount) - gun_owners += H - to_chat(user, "Gun license purchased, have a secure day!") - active_prompt = FALSE - return FALSE //we return false here so you don't click initially to fire, get the prompt, accept the prompt, and THEN the gun - to_chat(user, "ERROR: User balance insufficent for successful transaction!") - return FALSE - if("No") - to_chat(user, "ERROR: User has declined to purchase gun license!") - return FALSE - to_chat(user, "ERROR: User has no valid bank account to substract neccesary funds from!") - return FALSE + to_chat(user, "ERROR: User has no valid bank account to substract neccesary funds from!") + return FALSE // Explorer Firing Pin- Prevents use on station Z-Level, so it's justifiable to give Explorers guns that don't suck. /obj/item/firing_pin/explorer diff --git a/code/modules/shuttle/special.dm b/code/modules/shuttle/special.dm index f2798dfe909..9cb8a34e155 100644 --- a/code/modules/shuttle/special.dm +++ b/code/modules/shuttle/special.dm @@ -258,10 +258,9 @@ else if(!check_times[AM] || check_times[AM] < world.time) //Let's not spam the message to_chat(AM, "This ID card doesn't have an owner associated with it!") check_times[AM] = world.time + LUXURY_MESSAGE_COOLDOWN - else if(ishuman(AM)) - var/mob/living/carbon/human/H = AM - if(H.get_bank_account()) - account = H.get_bank_account() + else + var/mob/living/L = AM + account = L.get_bank_account() if(account) if(account.account_balance < threshold - payees[AM]) diff --git a/code/modules/vending/_vending.dm b/code/modules/vending/_vending.dm index 0600c7f110f..2643e0828b6 100644 --- a/code/modules/vending/_vending.dm +++ b/code/modules/vending/_vending.dm @@ -764,21 +764,17 @@ GLOBAL_LIST_EMPTY(vending_products) /obj/machinery/vending/ui_data(mob/user) . = list() - var/mob/living/carbon/human/H - var/obj/item/card/id/C - if(ishuman(user)) - H = user - C = H.get_idcard(TRUE) - if(C?.registered_account) - .["user"] = list() - .["user"]["name"] = C.registered_account.account_holder - .["user"]["cash"] = C.registered_account.account_balance - if(C.registered_account.account_job) - .["user"]["job"] = C.registered_account.account_job.title - .["user"]["department"] = C.registered_account.account_job.paycheck_department - else - .["user"]["job"] = "No Job" - .["user"]["department"] = "No Department" + var/obj/item/card/id/C = user.get_idcard(TRUE) + if(C?.registered_account) + .["user"] = list() + .["user"]["name"] = C.registered_account.account_holder + .["user"]["cash"] = C.registered_account.account_balance + if(C.registered_account.account_job) + .["user"]["job"] = C.registered_account.account_job.title + .["user"]["department"] = C.registered_account.account_job.paycheck_department + else + .["user"]["job"] = "No Job" + .["user"]["department"] = "No Department" .["stock"] = list() for (var/datum/data/vending_product/R in product_records + coin_records + hidden_records) .["stock"][R.name] = R.amount @@ -820,9 +816,8 @@ GLOBAL_LIST_EMPTY(vending_products) flick(icon_deny,src) vend_ready = TRUE return - if(onstation && ishuman(usr)) - var/mob/living/carbon/human/H = usr - var/obj/item/card/id/C = H.get_idcard(TRUE) + if(onstation) + var/obj/item/card/id/C = usr.get_idcard(TRUE) if(!C) say("No card found.") @@ -838,8 +833,8 @@ GLOBAL_LIST_EMPTY(vending_products) say("You are not of legal age to purchase [R.name].") if(!(usr in GLOB.narcd_underages)) Radio.set_frequency(FREQ_SECURITY) - Radio.talk_into(src, "SECURITY ALERT: Underaged crewmember [H] recorded attempting to purchase [R.name] in [get_area(src)]. Please watch for substance abuse.", FREQ_SECURITY) - GLOB.narcd_underages += H + Radio.talk_into(src, "SECURITY ALERT: Underaged crewmember [usr] recorded attempting to purchase [R.name] in [get_area(src)]. Please watch for substance abuse.", FREQ_SECURITY) + GLOB.narcd_underages += usr flick(icon_deny,src) vend_ready = TRUE return @@ -1012,13 +1007,9 @@ GLOBAL_LIST_EMPTY(vending_products) /obj/machinery/vending/custom/compartmentLoadAccessCheck(mob/user) . = FALSE - var/mob/living/carbon/human/H - var/obj/item/card/id/C - if(ishuman(user)) - H = user - C = H.get_idcard(FALSE) - if(C?.registered_account && C.registered_account == private_a) - return TRUE + var/obj/item/card/id/C = user.get_idcard(FALSE) + if(C?.registered_account && C.registered_account == private_a) + return TRUE /obj/machinery/vending/custom/canLoadItem(obj/item/I, mob/user) . = FALSE @@ -1068,66 +1059,60 @@ GLOBAL_LIST_EMPTY(vending_products) var/N = params["item"] var/obj/S vend_ready = FALSE - if(ishuman(usr)) - var/mob/living/carbon/human/H = usr - var/obj/item/card/id/C = H.get_idcard(TRUE) + var/obj/item/card/id/C = usr.get_idcard(TRUE) - if(!C) - say("No card found.") - flick(icon_deny,src) + if(!C) + say("No card found.") + flick(icon_deny,src) + vend_ready = TRUE + return + else if (!C.registered_account) + say("No account found.") + flick(icon_deny,src) + vend_ready = TRUE + return + var/datum/bank_account/account = C.registered_account + for(var/obj/O in contents) + if(O.name == N) + S = O + break + if(S) + if(compartmentLoadAccessCheck(usr)) + vending_machine_input[N] = max(vending_machine_input[N] - 1, 0) + S.forceMove(drop_location()) + loaded_items-- + use_power(5) vend_ready = TRUE + updateUsrDialog() return - else if (!C.registered_account) - say("No account found.") - flick(icon_deny,src) + if(account.has_money(S.custom_price)) + account.adjust_money(-S.custom_price) + var/datum/bank_account/owner = private_a + if(owner) + owner.adjust_money(S.custom_price) + SSblackbox.record_feedback("amount", "vending_spent", S.custom_price) + log_econ("[S.custom_price] credits were spent on [src] buying a [S] by [owner.account_holder], owned by [private_a.account_holder].") + vending_machine_input[N] = max(vending_machine_input[N] - 1, 0) + S.forceMove(drop_location()) + loaded_items-- + use_power(5) + if(last_shopper != usr || purchase_message_cooldown < world.time) + say("Thank you for buying local and purchasing [S]!") + purchase_message_cooldown = world.time + 5 SECONDS + last_shopper = usr vend_ready = TRUE + updateUsrDialog() return - var/datum/bank_account/account = C.registered_account - for(var/obj/O in contents) - if(O.name == N) - S = O - break - if(S) - if(compartmentLoadAccessCheck(usr)) - vending_machine_input[N] = max(vending_machine_input[N] - 1, 0) - S.forceMove(drop_location()) - loaded_items-- - use_power(5) - vend_ready = TRUE - updateUsrDialog() - return - if(account.has_money(S.custom_price)) - account.adjust_money(-S.custom_price) - var/datum/bank_account/owner = private_a - if(owner) - owner.adjust_money(S.custom_price) - SSblackbox.record_feedback("amount", "vending_spent", S.custom_price) - log_econ("[S.custom_price] credits were spent on [src] buying a [S] by [owner.account_holder], owned by [private_a.account_holder].") - vending_machine_input[N] = max(vending_machine_input[N] - 1, 0) - S.forceMove(drop_location()) - loaded_items-- - use_power(5) - if(last_shopper != usr || purchase_message_cooldown < world.time) - say("Thank you for buying local and purchasing [S]!") - purchase_message_cooldown = world.time + 5 SECONDS - last_shopper = usr - vend_ready = TRUE - updateUsrDialog() - return - else - say("You do not possess the funds to purchase this.") + else + say("You do not possess the funds to purchase this.") vend_ready = TRUE /obj/machinery/vending/custom/attackby(obj/item/I, mob/user, params) if(!private_a) - var/mob/living/carbon/human/H - var/obj/item/card/id/C - if(ishuman(user)) - H = user - C = H.get_idcard(TRUE) - if(C?.registered_account) - private_a = C.registered_account - say("\The [src] has been linked to [C].") + var/obj/item/card/id/C = user.get_idcard(TRUE) + if(C?.registered_account) + private_a = C.registered_account + say("\The [src] has been linked to [C].") if(compartmentLoadAccessCheck(user)) if(istype(I, /obj/item/pen))