diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index c590c844eb9..0655e8f53e8 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -494,6 +494,15 @@ if(!C || (!C.prefs.windowflashing && !ignorepref)) return winset(C, "mainwindow", "flash=5") + +//Recursively checks if an item is inside a given type, even through layers of storage. Returns the atom if it finds it. +/proc/recursive_loc_check(atom/movable/target, type) + var/atom/A = target + while(!istype(A.loc, type)) + if(!A.loc) + return + A = A.loc + return A /proc/AnnounceArrival(var/mob/living/carbon/human/character, var/rank) if(!SSticker.IsRoundInProgress() || QDELETED(character)) diff --git a/code/modules/economy/account.dm b/code/modules/economy/account.dm index f7718c072c2..d66caeb2464 100644 --- a/code/modules/economy/account.dm +++ b/code/modules/economy/account.dm @@ -54,12 +54,24 @@ bank_card_talk("ERROR: Payday aborted, unable to contact departmental account.") return FALSE -/datum/bank_account/proc/bank_card_talk(fuck) - if(!fuck || !bank_cards.len) +/datum/bank_account/proc/bank_card_talk(message) + if(!message || !bank_cards.len) return for(var/obj/A in bank_cards) - for(var/mob/M in hearers(1,get_turf(A))) - to_chat(M, fuck) + var/mob/card_holder = recursive_loc_check(A, /mob) + if(card_holder) //If on a mob + card_holder.playsound_local(get_turf(card_holder), 'sound/machines/twobeep.ogg', 50, 1) + if(card_holder.can_hear()) + to_chat(card_holder, "[icon2html(A, card_holder)] *[message]*") + else if(isturf(A.loc)) //If on the ground + for(var/mob/M in hearers(1,get_turf(A))) + playsound(get_turf(card_holder), 'sound/machines/twobeep.ogg', 50, 1) + A.audible_message("[icon2html(A, hearers(A))] *[message]*", null, 1) + else + for(var/mob/M in A.loc) //If inside a container with other mobs (e.g. locker) + M.playsound_local(get_turf(M), 'sound/machines/twobeep.ogg', 50, 1) + if(M.can_hear()) + to_chat(M, "[icon2html(A, M)] *[message]*") /datum/bank_account/department account_holder = "Guild Credit Agency"