public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 1 && info.IsSwitched(1) && sender.Mobile is PlayerMobile player) { QuestSystem qs = player.Quest; if (qs is CollectorQuest && qs.FindObjective(typeof(FindSheetMusicObjective)) is FindSheetMusicObjective obj && !obj.Completed) { if (player.Backpack != null && player.Backpack.ConsumeTotal(typeof(Gold), 10)) { obj.Complete(); } else { BankBox bank = player.FindBankNoCreate(); if (bank != null && bank.ConsumeTotal(typeof(Gold), 10)) { obj.Complete(); } else { player.SendLocalizedMessage(1055108); // You don't have enough gold to buy the sheet music. } } } } }
protected override void OnTarget(Mobile from, object targeted) { if (targeted is Mobile) { Mobile m = (Mobile)targeted; BankBox box = (m.Player ? m.BankBox : m.FindBankNoCreate()); if (box != null) { CommandLogging.WriteLine(from, "{0} {1} opening bank box of {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targeted)); if (from == targeted) { box.Open(); } else { box.DisplayTo(from); } } else { from.SendMessage("They have no bank box."); } } }
public void OnAuctionFinish() { this.Say(String.Format("The auction has finished.")); PlayerMobile pm = World.FindMobile(m_HighBidMobile) as PlayerMobile; if (CheckID() && pm != null) { this.Say(String.Format("The winning bid was placed by {0} for {1} gold.", pm.Name, m_HighBid)); this.Say("Congratulations!"); BankBox box = pm.BankBox; if (Misc.Diagnostics.Assert(box != null, "box == null")) { Item item = GetAuctionItem(); if (item != null) { LogEvent(String.Format("OnAuctionFinish() : winner: {0}, amount: {1} gold.", pm, m_HighBid)); Backpack.RemoveItem(item); box.AddItem(item); m_GoldDeleted += m_HighBid; } } } else { LogEvent(String.Format("OnAuctionFinish() : There were no bidders in this auction.")); this.Say("There were no bidders in this auction."); } // reset auction state ResetAuctionState(); }
public CreateBountyGump(Mobile from, Mobile killer) : base(100, 100) { m_From = from; m_Killer = killer; int balance = 0; BankBox box = from.BankBox; if (box != null) { balance = box.TotalGold; } Closable = false; Disposable = false; Dragable = false; Resizable = false; AddPage(0); AddBackground(28, 22, 346, 139, 9200); AddHtml(33, 31, 334, 55, @"<BASEFONT COLOR=WHITE><CENTER>Would you like to place a bounty on your killers head?</CENTER></BASEFONT>", (bool)false, (bool)false); AddLabel(33, 89, 1149, @"Current Bank Balance: " + balance.ToString()); AddImageTiled(33, 130, 130, 20, 2524); AddLabel(33, 108, 1149, @"Amount Of Bounty"); AddTextEntry(37, 130, 122, 20, 0, 1, @"1000"); AddButton(190, 128, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(270, 128, 241, 242, 2, GumpButtonType.Reply, 0); }
public static bool Deposit(Mobile from, int amount, bool message = false) { // If for whatever reason the TOL checks fail, we should still try old methods for depositing currency. if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount)) { if (message) from.SendLocalizedMessage(1042763, amount.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("en-US"))); // ~1_AMOUNT~ gold was deposited in your account. return true; } BankBox box = from.Player ? from.BankBox : from.FindBankNoCreate(); if (box == null) { return false; } List<Item> items = new List<Item>(); while (amount > 0) { Item item; if (amount < 5000) { item = new Gold(amount); amount = 0; } else if (amount <= 1000000) { item = new BankCheck(amount); amount = 0; } else { item = new BankCheck(1000000); amount -= 1000000; } if (box.TryDropItem(from, item, false)) { items.Add(item); } else { item.Delete(); foreach (Item curItem in items) { curItem.Delete(); } return false; } } if (message) from.SendLocalizedMessage(1042763, amount.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("en-US"))); // ~1_AMOUNT~ gold was deposited in your account. return true; }
public void SetBuyIn(PlayerMobile pm, int amount) { Item i = CheckForGoldSources(pm, amount); if (i is Gold) { i.Amount -= amount; Handeling.BuyIn += amount; } else { BankCheck check = (BankCheck)i; check.Worth -= amount; Handeling.BuyIn += amount; } if (i.Amount <= 0) { i.Delete(); return; } if (i is BankCheck) { BankCheck check = (BankCheck)i; if (check.Worth > 0) { if (check.Worth < 5000) { if (check.Parent is BankBox) { BankBox box = (BankBox)check.Parent; Gold g = new Gold(check.Worth); box.DropItem(g); check.Delete(); } if (check.Parent is Backpack) { Backpack pack = (Backpack)check.Parent; Gold g = new Gold(check.Worth); pack.DropItem(g); check.Delete(); } } } else { check.Delete(); } } pm.SendMessage("The funds have been gathered."); }
private static void EventSink_Login(LoginEventArgs args) { Mobile from = args.Mobile; if (from.Backpack != null) { List <PlantItem> plants = from.Backpack.FindItemsByType <PlantItem>(); foreach (PlantItem plant in plants) { if (plant.IsGrowable) { plant.PlantSystem.DoGrowthCheck(); } } } BankBox bank = from.FindBankNoCreate(); if (bank != null) { List <PlantItem> plants = bank.FindItemsByType <PlantItem>(); foreach (PlantItem plant in plants) { if (plant.IsGrowable) { plant.PlantSystem.DoGrowthCheck(); } } } }
public override bool AllowHousing(Mobile from, Point3D p) { if (m_Stone == null) { return(false); } if (m_Stone.IsExpired) { return(true); } if (m_Stone.Deed == null) { return(false); } Container pack = from.Backpack; if (pack != null && ContainsDeed(pack)) { return(true); } BankBox bank = from.FindBankNoCreate(); if (bank != null && ContainsDeed(bank)) { return(true); } return(false); }
private static void EventSink_Login(LoginEventArgs args) { Mobile from = args.Mobile; if (from.Backpack != null) { Item[] plants = from.Backpack.FindItemsByType(typeof(PlantItem)); foreach (PlantItem plant in plants) { if (plant.IsGrowable) { plant.PlantSystem.DoGrowthCheck(); } } } BankBox bank = from.FindBankNoCreate(); if (bank != null) { Item[] plants = bank.FindItemsByType(typeof(PlantItem)); foreach (PlantItem plant in plants) { if (plant.IsGrowable) { plant.PlantSystem.DoGrowthCheck(); } } } //Taran: Check for plants in houses the character owns ArrayList houses = new ArrayList(2); houses.AddRange(BaseHouse.GetHouses(from)); for (int i = 0; i < houses.Count; ++i) { BaseHouse house = (BaseHouse)houses[i]; foreach (IEntity entity in house.GetHouseEntities()) { if (entity is Item && !((Item)entity).Deleted) { Item item = (Item)entity; if (item is PlantItem && item.IsLockedDown) { PlantItem plant = (PlantItem)entity; if (plant.IsGrowable) { plant.PlantSystem.DoGrowthCheck(); } } } } } }
private static void FillBankbox(Mobile m) { BankBox bank = m.BankBox; if (bank == null) { return; } }
public static int DepositUpTo(Mobile from, int amount, bool message = false) { // If for whatever reason the TOL checks fail, we should still try old methods for depositing currency. if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount)) { if (message) { from.SendLocalizedMessage(1042763, amount.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("en-US"))); // ~1_AMOUNT~ gold was deposited in your account. } return(amount); } BankBox box = from.Player ? from.BankBox : from.FindBankNoCreate(); if (box == null) { return(0); } int amountLeft = amount; while (amountLeft > 0) { Item item; int amountGiven; if (amountLeft < 5000) { item = new Gold(amountLeft); amountGiven = amountLeft; } else if (amountLeft <= 1000000) { item = new BankCheck(amountLeft); amountGiven = amountLeft; } else { item = new BankCheck(1000000); amountGiven = 1000000; } if (box.TryDropItem(from, item, false)) { amountLeft -= amountGiven; } else { item.Delete(); break; } } return(amount - amountLeft); }
public Item CheckForGoldSources(PlayerMobile pm, int amount) { List <Gold> gold_piles = new List <Gold>(); List <BankCheck> checks = new List <BankCheck>(); Backpack pack = (Backpack)pm.Backpack; BankBox bank = (BankBox)pm.BankBox; foreach (Item i in pack.Items) { if (i is Gold) { gold_piles.Add((Gold)i); } else if (i is BankCheck) { checks.Add((BankCheck)i); } } foreach (Item i in bank.Items) { if (i is Gold) { gold_piles.Add((Gold)i); } else if (i is BankCheck) { checks.Add((BankCheck)i); } } for (int i = 0; i < gold_piles.Count; ++i) { Gold gold = (Gold)gold_piles[i]; if (gold.Amount >= amount) { return(gold); } } for (int i = 0; i < checks.Count; ++i) { BankCheck check = (BankCheck)checks[i]; if (check.Worth >= amount) { return(check); } } return(null); }
private static void AddPowerScrolls(BankBox bank) { Bag bag = new Bag(); for (int i = 0; i < PowerScroll.Skills.Length; ++i) { bag.DropItem(new PowerScroll(PowerScroll.Skills[i], 120.0)); } bag.DropItem(new StatCapScroll(250)); bank.DropItem(bag); }
public Mobile() { Backpack = new List <ContainerItem>(); Mail = new List <MailMessage>(); Spells = new List <LearnedSpell>(); Skills = new Skill[33]; BankBox bank = new BankBox(); bank.Items = new List <ContainerItem>(); this.Bank = bank; }
public static SavingsAccount GetAccountForMobile(Mobile mobile) { BankBox bank = mobile.BankBox; if (null == bank) { return(null); } else { return((SavingsAccount)bank.FindItemByType(typeof(SavingsAccount))); } }
public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; if (!m_Vendor.CanInteractWith(from, false)) { return; } if (m_Vendor.IsOwner(from)) { m_Vendor.SayTo(from, 503212); // You own this shop, just take what you want. return; } if (info.ButtonID == 1) { m_Vendor.Say(from.Name); if (!m_VI.Valid || !m_VI.Item.IsChildOf(m_Vendor.Backpack)) { m_Vendor.SayTo(from, 503216); // You can't buy that. } else if (!Banker.WithdrawPackAndBank(from, m_Vendor.TypeOfCurrency, m_VI.Price)) { m_Vendor.SayTo(from, 503205); // You cannot afford this item. } else if (!from.PlaceInBackpack(m_VI.Item)) { m_Vendor.SayTo(from, 503204); // You do not have room in your backpack for this. BankBox box = from.FindBank(m_Vendor.Expansion) ?? from.BankBox; box.Credit += (ulong)m_VI.Price; m_Vendor.SayTo(from, "I credited your bank account. Please come back when you have room for this item."); } else { from.SendLocalizedMessage(503201); // You take the item. m_Vendor.HoldCurrency += m_VI.Price; m_Vendor.LastActivity = DateTime.UtcNow; m_Vendor.NameMod = null; m_Vendor.NameHue = -1; } } else { from.SendLocalizedMessage(503207); // Cancelled purchase. } }
public static bool Deposit(Mobile from, int amount) { BankBox box = from.BankBox; Item item = (amount >= 1000 ? (Item) new BankCheck(amount) : (Item) new Gold(amount)); if (box != null && box.TryDropItem(from, item, false)) { return(true); } item.Delete(); return(false); }
public static int DepositUpTo(Mobile from, Type currencyType, int amount) { BankBox box = from.FindBankNoCreate(); if (box != null) { int amountLeft = amount; while (amountLeft > 0) { Item item; int amountGiven; if (amountLeft < 5000) { item = currencyType.CreateInstanceSafe <Item>(); item.Stackable = true; item.Amount = amountLeft; amountGiven = amountLeft; } else if (amountLeft <= 1000000) { item = new BankCheck(amountLeft); amountGiven = amountLeft; } else { item = new BankCheck(1000000); amountGiven = 1000000; } if (box.TryDropItem(from, item, false)) { amountLeft -= amountGiven; } else { item.Delete(); break; } } return(amount - amountLeft); } return(0); }
public static void CashCheck(Mobile from, BankCheck check) { BankBox box = from.BankBox; if (box != null) { int deposited = 0; int toAdd = check.Worth; check.Delete(); Gold gold; while (toAdd > 60000) { gold = new Gold(60000); if (box.TryDropItem(from, gold, false)) { toAdd -= 60000; deposited += 60000; } else { gold.Delete(); from.AddToBackpack(new BankCheck(toAdd)); toAdd = 0; break; } } if (toAdd > 0) { gold = new Gold(toAdd); if (box.TryDropItem(from, gold, false)) { deposited += toAdd; } else { gold.Delete(); from.AddToBackpack(new BankCheck(toAdd)); } } } }
public override void OnEnter(Mobile m) { if (m is PlayerMobile && m.AccessLevel < AccessLevel.Counselor) { PlayerMobile pm = (PlayerMobile)m; if (!m.Alive) { return; } Container bp = pm.Backpack; Container bankbag = new Bag(); bankbag.Hue = 38; BankBox bank = pm.BankBox; Item oncurs = pm.Holding; Item[] items = bp.FindItemsByType(typeof(Item)); if (oncurs != null) { bp.DropItem(oncurs); } foreach (Layer layer in EquipmentLayers) { Item item = pm.FindItemOnLayer(layer); if (item != null) { if (item.LootType == LootType.Newbied) { pm.DuelItems.Add(item); } } } foreach (Item i in items) { if (i.LootType == LootType.Newbied) { pm.DuelItems.Add(i); } } foreach (Item i in pm.DuelItems) { i.LootType = LootType.Blessed; } } }
public static bool Deposit(Mobile from, int amount) { BankBox box = from.FindBankNoCreate(); if (box == null) { return(false); } List <Item> items = new List <Item>(); while (amount > 0) { Item item; /*if ( amount < 5000 ) * { * item = new Gold( amount ); * amount = 0; * }*/ if (amount <= 60000) { item = new Gold(amount); amount = 0; } else { item = new Gold(60000); amount -= 60000; } if (box.TryDropItem(from, item, false)) { items.Add(item); } else { item.Delete(); foreach (Item curItem in items) { curItem.Delete(); } return(false); } } return(true); }
public void PayBuyIn(PlayerMobile pm, int teamid) { if (Handeling.BuyIn <= 0) { return; } int playercount = 0; int sharecount = 0; IEnumerator key = Handeling.Teams.Keys.GetEnumerator(); for (int i = 0; i < Handeling.Teams.Count; ++i) { key.MoveNext(); Field_Team d_team = (Field_Team)Handeling.Teams[(int)key.Current]; for (int i2 = 0; i2 < d_team.Players.Count; ++i2) { object o = (object)d_team.Players[i2]; if (o != "@null") { playercount += 1; } if ((int)key.Current == teamid && o != "@null") { sharecount += 1; } } } int goldshare = (playercount * Handeling.BuyIn) / sharecount; BankBox box = (BankBox)pm.BankBox; if (goldshare >= 5000) { BankCheck check = new BankCheck(goldshare); box.DropItem(check); } else { Gold gold = new Gold(goldshare); box.DropItem(gold); } pm.SendMessage(String.Format("Congragulations! you have won {0}gp.", goldshare.ToString())); }
/// <summary> /// Moves all of the given Mobile's items to their bank. /// </summary> public virtual void PackToBank(Mobile m) { if (m == null || !m.Player) { return; } BankBox bank = m.FindBankNoCreate(); Backpack pack = new Backpack(); pack.Hue = 1157; List <Item> items = new List <Item>(); for (int i = 0; i < m.Items.Count; i++) { if (m.Items[i] is BankBox || (m.Backpack != null && m.Items[i].Serial == m.Backpack.Serial)) { continue; } items.Add(m.Items[i]); } if (m.Backpack != null) { for (int i = 0; i < m.Backpack.Items.Count; i++) { items.Add(m.Backpack.Items[i]); } } items.ForEach( delegate(Item i) { pack.AddItem(i); }); items.Clear(); if (bank == null) { pack.MoveToWorld(m.Location, m.Map); } else { bank.AddItem(pack); } }
public static int DepositUpTo(Mobile from, int amount) { BankBox box = from.FindBankNoCreate(); if (box == null) { return(0); } int amountLeft = amount; while (amountLeft > 0) { Item item; int amountGiven; if (amountLeft < 5000) { item = new Gold(amountLeft); amountGiven = amountLeft; } else if (amountLeft <= 1000000) { item = new BankCheck(amountLeft); amountGiven = amountLeft; } else { item = new BankCheck(1000000); amountGiven = 1000000; } if (box.TryDropItem(from, item, false)) { amountLeft -= amountGiven; } else { item.Delete(); break; } } return(amount - amountLeft); }
public static bool Deposit(Mobile from, int amount) { BankBox box = from.BankBox; if (box == null) { return(false); } ArrayList items = new ArrayList(); while (amount > 0) { Item item; if (amount < 5000) { item = new Gold(amount); amount = 0; } else if (amount <= 1000000) { item = new BankCheck(amount); amount = 0; } else { item = new BankCheck(1000000); amount -= 1000000; } if (box.TryDropItem(from, item, false)) { items.Add(item); } else { item.Delete(); foreach (Item curItem in items) { curItem.Delete(); } return(false); } } return(true); }
private void RefundBid() { Mobile m = World.FindMobile(m_HighBidMobile); if (CheckID() && m != null) { // deposit the refund BankBox box = m.BankBox; //Item item = (m_HighBid >= 1000 ? (Item)new BankCheck(m_HighBid) : (Item)new Gold(m_HighBid)); if (Misc.Diagnostics.Assert(box != null, "box == null")) { //box.AddItem(item); Banker.Deposit(box, m_HighBid); LogEvent(String.Format("RefundBid() : player: {0}, amount: {1} gold", m, m_HighBid)); } } }
/// <summary> /// Moves all the players items to thier bank. /// Notifies the player that thier belongings have been placed in thier bank. /// </summary> /// <param name="m"> The mobile to be have items moved</param> public static void ItemsToBank(Mobile m) { try { if (m.Backpack != null && m.BankBox != null) { Container bp = m.Backpack; BankBox bank = m.BankBox; Container pack = new Backpack(); List <Item> list = new List <Item>(); Item addItem; foreach (Item item in m.Items) { if (item != bp && item != bank) { list.Add(item); } } foreach (Item item in bp.Items) { list.Add(item); } for (int i = 0; i < list.Count; i++) { addItem = list[i]; pack.AddItem(addItem); } if (pack.Items.Count > 0) { bank.AddItem(pack); } } m.SendMessage("All of your items have been sent to your bankbox via a backpack."); return; } catch (Exception e) { Console.WriteLine("Error : " + e.Message); Console.WriteLine("Location : " + e.InnerException); } }
protected override void OnTick() { if (DateTime.Now >= m_Expire) { if (m_vendor == null || !CheckVendorExist(m_vendor)) { Stop(); } else { Container pack = m_vendor.Backpack; if (pack != null && pack.Items.Count > 0) { BankBox box = m_owner.BankBox; List <Item> list = new List <Item>(); list = pack.Items; int number = pack.Items.Count; for (int i = 0; i < number; i++) { /*if ( (Item)list[i] is Container ) * { * * }*/ if (box.TryDropItem(m_owner, (Item)list[i], false)) { continue; } else { //list.Remove( list[i] ); continue; } } m_vendor.Dismiss(m_owner); Stop(); } else { m_vendor.Dismiss(m_owner); Stop(); } } } }
public SavingsGump(Mobile from) : base(400, 300) { from.CloseGump(typeof(SavingsGump)); m_Bank = from.BankBox; m_Pack = from.Backpack; m_Account = (SavingsAccount)m_Bank.FindItemByType(typeof(SavingsAccount)); String gold = m_Account.Gold.ToString("#,0") + " Gold"; String tokens = m_Account.Tokens.ToString("#,0") + " Tokens"; m_MaximumCheckValue = AuctionConfig.MaximumCheckValue.ToString("#,0"); Closable = true; Disposable = true; Dragable = true; Resizable = false; AddPage(0); AddBackground(0, 0, 240, 268, 9200); AddAlphaRegion(10, 9, 220, 100); AddAlphaRegion(10, 115, 220, 145); AddLabel(50, 15, 4, @"Savings Account Ledger"); AddLabel(50, 35, 4, @"-----------------------"); AddLabel(25, 55, 53, gold); if (Arya.Savings.SavingsAccount.EnableTokens) { AddLabel(25, 80, 18, tokens); } AddLabel(40, 130, 4, @"Withdraw 1 to " + m_MaximumCheckValue); AddBackground(75, 155, 95, 25, 0x2486); AddTextEntry(85, 155, 90, 20, 0, m_AmountID, ""); AddButton(25, 180, 4005, 4007, 1, GumpButtonType.Reply, 0); AddLabel(65, 180, 53, @"Make this gold check."); if (Arya.Savings.SavingsAccount.EnableTokens) { AddButton(25, 205, 4005, 4007, 2, GumpButtonType.Reply, 0); AddLabel(65, 205, 18, @"Make this token check."); } AddButton(25, 230, 4017, 4019, 0, GumpButtonType.Reply, 0); AddLabel(65, 230, 4, @"Done."); }
public static void ClaimAllDonationItems_OnCommand(CommandEventArgs e) { PlayerMobile pm = (PlayerMobile)e.Mobile; BankBox box = pm.FindBankNoCreate(); ArrayList itemList = GetDonationGiftList(pm.Account.Username); for (int i = 0; i < itemList.Count; i++) { DonationGift giftInfo = (DonationGift)itemList[i]; Item gift = RedeemGift(giftInfo.Id, pm.Account.Username) as Item; if (!box.TryDropItem(pm, gift, false)) { pm.AddToBackpack(gift); } } pm.SendMessage("{0} items has been placed in your bank box. Thank you for your donation!", itemList.Count); }