From 3dc406624ec8895bb26fe179dac2b183459366f6 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Mon, 2 Aug 2021 19:23:25 -0700 Subject: [PATCH] fix: Fixes bank box withdraw using account gold (#671) Fixes various locations where account gold is not used. --- .../Engines/Quests/Collector/Mobiles/Impresario.cs | 14 +++----------- .../Items/Special/House Raffle/HouseRaffleStone.cs | 3 ++- Projects/UOContent/Mobiles/Townfolk/Banker.cs | 14 +++----------- Projects/UOContent/Mobiles/Vendors/BaseVendor.cs | 3 +-- .../UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs | 5 ++--- 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/Projects/UOContent/Engines/Quests/Collector/Mobiles/Impresario.cs b/Projects/UOContent/Engines/Quests/Collector/Mobiles/Impresario.cs index 0183a0beb..561bfadfc 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Mobiles/Impresario.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Mobiles/Impresario.cs @@ -161,22 +161,14 @@ namespace Server.Engines.Quests.Collector return; } - if (player.Backpack?.ConsumeTotal(typeof(Gold), 10) == true) + if (player.Backpack?.ConsumeTotal(typeof(Gold), 10) == true || Banker.Withdraw(player, 10)) { obj.Complete(); } else { - if (player.FindBankNoCreate()?.ConsumeTotal(typeof(Gold), 10) == true) - { - obj.Complete(); - } - else - { - player.SendLocalizedMessage( - 1055108 - ); // You don't have enough gold to buy the sheet music. - } + // You don't have enough gold to buy the sheet music. + player.SendLocalizedMessage(1055108); } } } diff --git a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs index 61be90d6d..8e6f99915 100644 --- a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs +++ b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs @@ -5,6 +5,7 @@ using System.Text; using Server.Accounting; using Server.ContextMenus; using Server.Gumps; +using Server.Mobiles; using Server.Network; using Server.Regions; @@ -518,7 +519,7 @@ namespace Server.Items Container bank = from.FindBankNoCreate(); if (m_TicketPrice == 0 || from.Backpack?.ConsumeTotal(typeof(Gold), m_TicketPrice) == true || - bank?.ConsumeTotal(typeof(Gold), m_TicketPrice) == true) + Banker.Withdraw(from, m_TicketPrice)) { Entries.Add(new RaffleEntry(from)); diff --git a/Projects/UOContent/Mobiles/Townfolk/Banker.cs b/Projects/UOContent/Mobiles/Townfolk/Banker.cs index 73db97375..25248dd74 100644 --- a/Projects/UOContent/Mobiles/Townfolk/Banker.cs +++ b/Projects/UOContent/Mobiles/Townfolk/Banker.cs @@ -280,15 +280,7 @@ namespace Server.Mobiles } } - public override bool HandlesOnSpeech(Mobile from) - { - if (from.InRange(Location, 12)) - { - return true; - } - - return base.HandlesOnSpeech(from); - } + public override bool HandlesOnSpeech(Mobile from) => from.InRange(Location, 12) || base.HandlesOnSpeech(from); public override void OnSpeech(SpeechEventArgs e) { @@ -441,11 +433,11 @@ namespace Server.Mobiles else { Say( - 1042673, + 1042673, // Into your bank box I have placed a check in the amount of: AffixType.Append, amount.ToString(), "" - ); // Into your bank box I have placed a check in the amount of: + ); } } } diff --git a/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs b/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs index 0310c7f2b..8c7e98cf6 100644 --- a/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs +++ b/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs @@ -230,8 +230,7 @@ namespace Server.Mobiles if (!bought && totalCost >= 2000) { - cont = buyer.FindBankNoCreate(); - if (cont?.ConsumeTotal(typeof(Gold), totalCost) == true) + if (Banker.Withdraw(buyer, totalCost)) { bought = true; fromBank = true; diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs b/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs index 7e203c696..844645099 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs @@ -181,7 +181,7 @@ namespace Server.Mobiles Container bank = from.FindBankNoCreate(); if (!(from.Backpack?.GetAmount(typeof(Gold)) >= 30) && - !(bank?.GetAmount(typeof(Gold)) >= 30)) + !(Banker.GetBalance(from) >= 30)) { SayTo(from, 1042556); // Thou dost not have enough gold, not even in thy bank account. } @@ -246,8 +246,7 @@ namespace Server.Mobiles { Container bank = from.FindBankNoCreate(); - if (from.Backpack?.ConsumeTotal(typeof(Gold), 30) == true || - bank?.ConsumeTotal(typeof(Gold), 30) == true) + if (from.Backpack?.ConsumeTotal(typeof(Gold), 30) == true || Banker.Withdraw(from, 30)) { pet.ControlTarget = null; pet.ControlOrder = OrderType.Stay;