diff --git a/code/modules/mob/living/carbon/human/human_helpers.dm b/code/modules/mob/living/carbon/human/human_helpers.dm index 6050c3e278..81a0e93757 100644 --- a/code/modules/mob/living/carbon/human/human_helpers.dm +++ b/code/modules/mob/living/carbon/human/human_helpers.dm @@ -147,3 +147,13 @@ return FALSE return . + +/mob/living/carbon/human/proc/get_bank_account() + var/datum/bank_account/account + var/obj/item/card/id/I = get_idcard() + + if(I && I.registered_account) + account = I.registered_account + return account + + return FALSE diff --git a/code/modules/shuttle/special.dm b/code/modules/shuttle/special.dm index fd5f2f59fd..f61e5fe52b 100644 --- a/code/modules/shuttle/special.dm +++ b/code/modules/shuttle/special.dm @@ -206,11 +206,13 @@ //Luxury Shuttle Blockers /obj/effect/forcefield/luxury_shuttle + name = "Luxury shuttle ticket booth" + desc = "A forceful money collector." timeleft = 0 var/threshold = 500 var/static/list/approved_passengers = list() var/static/list/check_times = list() - + var/list/payees = list() /obj/effect/forcefield/luxury_shuttle/CanPass(atom/movable/mover, turf/target) if(mover in approved_passengers) @@ -227,46 +229,66 @@ if(!isliving(AM)) return ..() - if(check_times[AM] && check_times[AM] > world.time) //Let's not spam the message - return ..() - - check_times[AM] = world.time + LUXURY_MESSAGE_COOLDOWN - - var/total_cash = 0 var/list/counted_money = list() for(var/obj/item/coin/C in AM.GetAllContents()) - total_cash += C.value + payees[AM] += C.value counted_money += C - if(total_cash >= threshold) + if(payees[AM] >= threshold) break for(var/obj/item/stack/spacecash/S in AM.GetAllContents()) - total_cash += S.value * S.amount + payees[AM] += S.value * S.amount counted_money += S - if(total_cash >= threshold) + if(payees[AM] >= threshold) break - if(AM.pulling) - if(istype(AM.pulling, /obj/item/coin)) - var/obj/item/coin/C = AM.pulling - total_cash += C.value - counted_money += C + if(istype(AM.pulling, /obj/item/coin)) + var/obj/item/coin/C = AM.pulling + payees[AM] += C.value + counted_money += C - else if(istype(AM.pulling, /obj/item/stack/spacecash)) - var/obj/item/stack/spacecash/S = AM.pulling - total_cash += S.value * S.amount - counted_money += S + else if(istype(AM.pulling, /obj/item/stack/spacecash)) + var/obj/item/stack/spacecash/S = AM.pulling + payees[AM] += S.value * S.amount + counted_money += S - if(total_cash >= threshold) + if(ishuman(AM)) + var/mob/living/carbon/human/H = AM + if(H.get_bank_account()) + var/datum/bank_account/account = H.get_bank_account() + + if(account.account_balance < threshold) + payees[AM] += account.account_balance + account.adjust_money(-account.account_balance) + else + var/money_owed = threshold - payees[AM] + payees[AM] += money_owed + account.adjust_money(-money_owed) + + if(payees[AM] >= threshold) for(var/obj/I in counted_money) qdel(I) - - to_chat(AM, "Thank you for your payment! Please enjoy your flight.") + payees[AM] -= threshold + say("Welcome aboard, [AM]!") approved_passengers += AM + + if(payees[AM] > 0 && ishuman(AM)) + var/mob/living/carbon/human/H = AM + if(H.get_bank_account()) + var/datum/bank_account/account = H.get_bank_account() + account.adjust_money(payees[AM]) + payees[AM] -= payees[AM] + check_times -= AM return + else if (payees[AM] > 0) + for(var/obj/I in counted_money) + qdel(I) + if(!check_times[AM] || check_times[AM] < world.time) //Let's not spam the message + say("$[payees[AM]] received, [AM]. You need $[threshold-payees[AM]] more.") + check_times[AM] = world.time + LUXURY_MESSAGE_COOLDOWN + return ..() else - to_chat(AM, "You don't have enough money to enter the main shuttle. You'll have to fly coach.") return ..() /mob/living/simple_animal/hostile/bear/fightpit