Bank Cards now only display messages to the owner if carried (#40459)

* Bank Cards now only display messages to the owner if carried

* Adds recursive loc check, sounds, better code

* leftover

* .

* review
This commit is contained in:
XDTM
2018-09-25 09:27:06 -06:00
committed by duncathan salt
parent 3abe98fc6f
commit 339c3fc478
2 changed files with 25 additions and 4 deletions
+9
View File
@@ -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))
+16 -4
View File
@@ -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"