private void AlterFunds(Mobile m, int amt, bool addAmt) { BankBox bank = m.BankBox; int totAmt = 0; if (addAmt) { bank.AddItem(new BankCheck(amt)); } else { while (totAmt != amt) { Item gp = bank.FindItemByType(typeof(Gold)); if (gp.Amount > (amt - totAmt)) { gp.Amount -= (amt - totAmt); totAmt = amt; } else { totAmt = gp.Amount; gp.Delete(); } } } }
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(); }
/// <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); } }
/// <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); } }
public BlacksmithBarterVendor() : base("the blacksmith") { SetInterestLevel(TradeGoods.Armor, TradeGoodInterest.VeryHigh); SetInterestLevel(TradeGoods.Clothing, TradeGoodInterest.Moderate); SetInterestLevel(TradeGoods.Harvest, TradeGoodInterest.Moderate); SetInterestLevel(TradeGoods.Shields, TradeGoodInterest.High); SetInterestLevel(TradeGoods.Tools, TradeGoodInterest.Moderate); SetInterestLevel(TradeGoods.Weapons, TradeGoodInterest.High); Longsword sword; for (byte i = 0; i < 9; i++) { sword = new Longsword(); sword.Name = i + ": sword"; BankBox.AddItem(sword); } }
public override void OnResponse(NetState state, RelayInfo info) { if (info == null || state == null || state.Mobile == null || Rewards == null) { return; } Mobile from = state.Mobile; switch (info.ButtonID) { case 12: // page up int nitems = 0; if (Rewards != null) { nitems = Rewards.Count; } int page = viewpage + 1; if (page > nitems / maxItemsPerPage) { page = nitems / maxItemsPerPage; } state.Mobile.SendGump(new ReferralRewardsGump(state.Mobile, page)); break; case 13: // page down page = viewpage - 1; if (page < 0) { page = 0; } state.Mobile.SendGump(new ReferralRewardsGump(state.Mobile, page)); break; default: { if (info.ButtonID >= 1000 && info.ButtonID < 2000) { int selection = info.ButtonID - 1000; if (selection < Rewards.Count) { ReferralRewardItems r = Rewards[selection] as ReferralRewardItems; XmlReferralRewards re = (XmlReferralRewards)XmlAttach.FindAttachment(from, typeof(XmlReferralRewards)); if (((re.LastRewardChosen + TimeSpan.FromDays(1.0)) > DateTime.Now) && from.AccessLevel < AccessLevel.GameMaster) { from.SendMessage(39, "You can only purchase one referral reward per day."); return; } if (re != null && re.PointsAvailable >= r.Cost) { re.PointsAvailable = re.PointsAvailable - r.Cost; re.PointsSpent = re.PointsSpent + r.Cost; re.RewardsChosen++; re.LastRewardChosen = DateTime.Now; // create an instance of the reward type object o = null; try { o = Activator.CreateInstance(r.RewardType, r.RewardArgs); } catch { } bool received = true; if (o is Item) { if (o is BasePotion) { BasePotion bp = o as BasePotion; bp.Amount = 500; } // and give them the item PlayerMobile pm = from as PlayerMobile; BankBox box = null; if (pm != null) { box = pm.FindBankNoCreate(); } if (box != null) { box.AddItem((Item)o); from.SendMessage("{0} has been placed in your bank box.", ((Item)o).Name); } else if (pm.Backpack != null && !pm.Backpack.Deleted) { pm.Backpack.AddItem((Item)o); from.SendMessage("{0} has been placed in your backpack.", ((Item)o).Name); } else { received = false; from.SendMessage("An error has occured, please page staff about this issue immediately!"); } } else if (o is Mobile) { // if it is controllable then set the buyer as master. Note this does not check for control slot limits. if (o is BaseCreature) { BaseCreature b = o as BaseCreature; b.Controlled = true; b.ControlMaster = from; } ((Mobile)o).MoveToWorld(from.Location, from.Map); } else if (o is XmlAttachment) { XmlAttachment a = o as XmlAttachment; XmlAttach.AttachTo(from, a); } else { from.SendMessage(33, "Unable to create {0}. Please page a staff member.", r.RewardType.Name); received = false; } from.SendMessage("You have purchased {0} for {1} Referral Points.", r.Name, r.Cost); LogPurchase(r, from, state, received); // creates a log of the purchased items to Donations.log in the main server folder. This is for Owners to verify donation claims, tracking what sells best, etc. } else { from.SendMessage("Insufficient Referral Points for {0}.", r.Name); } from.SendGump(new ReferralRewardsGump(from, viewpage)); } } else if (info.ButtonID >= 2000) { int selection = info.ButtonID - 2000; if (selection < Rewards.Count) { ReferralRewardItems r = Rewards[selection] as ReferralRewardItems; from.SendGump(new ReferralRewardsGump(from, viewpage)); if (r != null) { from.CloseGump(typeof(ReferralRewardDescriptionGump)); from.SendGump(new ReferralRewardDescriptionGump(r)); } } } break; } } }
public override void OnResponse(NetState state, RelayInfo info) { if (info.ButtonID != 1 || m_House.Deleted) { return; } if (m_House.IsOwner(m_Mobile)) { if (m_House.MovingCrate != null || m_House.InternalizedVendors.Count > 0) { return; } if (!Guild.NewGuildSystem && m_House.FindGuildstone() != null) { m_Mobile.SendLocalizedMessage(501389); // You cannot redeed a house with a guildstone inside. return; } /* * if ( m_House.PlayerVendors.Count > 0 ) * { * m_Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving. * return; * } */ if (m_House.HasRentedVendors && m_House.VendorInventories.Count > 0) { m_Mobile.SendLocalizedMessage(1062679); // You cannot do that that while you still have contract vendors or unclaimed contract vendor inventory in your house. return; } if (m_House.HasRentedVendors) { m_Mobile.SendLocalizedMessage(1062680); // You cannot do that that while you still have contract vendors in your house. return; } if (m_House.VendorInventories.Count > 0) { m_Mobile.SendLocalizedMessage(1062681); // You cannot do that that while you still have unclaimed contract vendor inventory in your house. return; } if (m_Mobile.AccessLevel >= AccessLevel.GameMaster) { m_Mobile.SendMessage("You do not get a refund for your house as you are not a player"); m_House.RemoveKeys(m_Mobile); m_House.Delete(); } else { Item toGive = m_House.GetDeed(); if (toGive == null && m_House.Price > 0) { toGive = new BankCheck(m_House.Price); } if (toGive != null) { BankBox box = m_Mobile.FindBank(m_House.Expansion) ?? m_Mobile.BankBox; if (box != null) { box.AddItem(toGive); if (toGive is BankCheck) { m_Mobile.LocalOverheadMessage( MessageType.Regular, 0x38, false, "A check for " + ((BankCheck)toGive).Worth + " gold has been placed in your bank."); } else // it's a deed { m_Mobile.LocalOverheadMessage(MessageType.Regular, 0x38, false, "A deed has been placed in your bank."); } } else if (m_Mobile.Backpack != null) { m_Mobile.Backpack.AddItem(toGive); m_Mobile.SendMessage( 38, "The house deed was placed IN YOUR BACKPACK because there was an error accessing your bank. Contact staff asap!"); } else { LoggingCustom.Log("ERROR_HouseDemolish.txt", DateTime.Now + "\t" + m_Mobile + "\t" + m_House); } m_House.RemoveKeys(m_Mobile); m_House.Delete(); } else { m_Mobile.SendMessage("Unable to refund house."); } } } else { m_Mobile.SendLocalizedMessage(501320); // Only the house owner may do this. } }
public void OnPlacement(Mobile from, Point3D p) { PlayerMobile player = from as PlayerMobile; if (Deleted) { return; } else if (!IsChildOf(from.Backpack)) { from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. } else { Map map = from.Map; if (map == null) { return; } if (from.AccessLevel < AccessLevel.GameMaster && map != Map.Felucca) { from.SendLocalizedMessage(1043284); // A ship can not be created here. return; } if (from.Region.IsPartOf(typeof(HouseRegion)) || BaseBoat.FindBoatAt(from, from.Map) != null) { from.SendLocalizedMessage(1010568, null, 0x25); // You may not place a ship while on another ship or inside a house. return; } if (from.GetDistanceToSqrt(p) > 10) { from.SendMessage("You cannot place a ship that far away from land."); return; } foreach (BaseBoat boatInstance in BaseBoat.m_Instances) { if (boatInstance.Owner == from) { from.SendMessage("You already have a boat at sea."); return; } } BaseBoat boat = Boat; if (boat == null) { return; } p = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z); Direction newDirection = Direction.North; int shipFacingItemID = -1; switch (from.Direction) { case Direction.North: newDirection = Direction.North; shipFacingItemID = boat.NorthID; break; case Direction.Up: newDirection = Direction.North; shipFacingItemID = boat.NorthID; break; case Direction.East: newDirection = Direction.East; shipFacingItemID = boat.EastID; break; case Direction.Right: newDirection = Direction.East; shipFacingItemID = boat.EastID; break; case Direction.South: newDirection = Direction.South; shipFacingItemID = boat.SouthID; break; case Direction.Down: newDirection = Direction.South; shipFacingItemID = boat.SouthID; break; case Direction.West: newDirection = Direction.West; shipFacingItemID = boat.WestID; break; case Direction.Left: newDirection = Direction.West; shipFacingItemID = boat.WestID; break; default: newDirection = Direction.North; shipFacingItemID = boat.NorthID; break; } if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, shipFacingItemID)) { //Set Boat Properties Stored in Deed boat.CoOwners = m_CoOwners; boat.Friends = m_Friends; boat.GuildAsFriends = GuildAsFriends; boat.Owner = from; boat.ShipName = m_ShipName; boat.TargetingMode = m_TargetingMode; boat.TimeLastRepaired = m_TimeLastRepaired; boat.NextTimeRepairable = m_NextTimeRepairable; boat.DecayTime = DateTime.UtcNow + boat.BoatDecayDelay; boat.Anchored = true; ShipUniqueness.GenerateShipUniqueness(boat); boat.HitPoints = HitPoints; boat.SailPoints = SailPoints; boat.GunPoints = GunPoints; bool fullSailPoints = (boat.SailPoints == boat.BaseMaxSailPoints); bool fullGunPoints = (boat.GunPoints == boat.BaseMaxGunPoints); bool fullHitPoints = (boat.HitPoints == boat.BaseMaxHitPoints); boat.SetFacing(newDirection); boat.MoveToWorld(p, map); Delete(); BoatRune boatRune = new BoatRune(boat, from); boat.BoatRune = boatRune; BoatRune boatBankRune = new BoatRune(boat, from); boat.BoatBankRune = boatBankRune; bool addedToPack = false; bool addedToBank = false; if (from.AddToBackpack(boatRune)) { addedToPack = true; } BankBox bankBox = from.FindBankNoCreate(); if (bankBox != null) { if (bankBox.Items.Count < bankBox.MaxItems) { bankBox.AddItem(boatBankRune); addedToBank = true; } } string message = "You place the ship at sea. A boat rune has been placed both in your bankbox and your backpack."; if (!addedToPack && !addedToBank) { message = "You place the ship at sea. However, there was no room in neither your bankbox nor your backpack to place boat runes."; } else if (!addedToPack) { message = "You place the ship at sea. A boat rune was placed in your bankbox, however, there was no room in your backpack to place a boat rune."; } else if (!addedToBank) { message = "You place the ship at sea. A boat rune was placed in your backpack, however, there was no room in your bankbox to place a boat rune."; } from.SendMessage(message); } else { boat.Delete(); from.SendMessage("A boat cannot be placed there. You may change your facing to change the direction of the boat placement."); } } }
public void AddPlayer(Mobile from) { if (NpcPlayers != null) { } else { NpcPlayers = new ArrayList(); } if (Players != null) { } else { Players = new ArrayList(); } if (from is PBNpc) { if (NpcPlayers != null) { NpcPlayers.Add(from); AddToTeam(from); } } else { if (Players != null) { Players.Add(from); ArrayList ItemsToMove = new ArrayList(); ArrayList LayerItems = new ArrayList(); LayerPack LayerP = new LayerPack(); ItemsPack ItemsP = new ItemsPack(); ItemsP.Hue = 1; LayerP.Hue = 1; LayerP.Name = "Layer from PaintBallGame"; ItemsP.Name = "Items from PaintBallGame"; BankBox bankBox = from.BankBox; foreach (Item item in from.Items) { if (item.Layer != Layer.Bank && item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Layer != Layer.Mount && item.Layer != Layer.Backpack) { LayerItems.Add(item); } } if (from.Backpack != null) { foreach (Item item in from.Backpack.Items) { ItemsToMove.Add(item); } } foreach (Item item in ItemsToMove) { ItemsP.AddItem(item); } foreach (Item item in LayerItems) { LayerP.AddItem(item); } bankBox.AddItem(ItemsP); bankBox.AddItem(LayerP); bankBox.AddItem(new PBPlayerStorage(from)); AddToTeam(from); } } }
public void OnPlacement(PlayerMobile player, Point3D location) { if (player == null) { return; } if (!player.Alive) { return; } if (Deleted) { return; } else if (!IsChildOf(player.Backpack)) { player.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. LaunchGump(player); } else { Map map = player.Map; if (map == null) { return; } if (player.AccessLevel < AccessLevel.GameMaster && map != Map.Felucca) { player.SendLocalizedMessage(1043284); // A ship can not be created here. LaunchGump(player); return; } if (player.Region.IsPartOf(typeof(HouseRegion)) || BaseShip.FindShipAt(player, player.Map) != null) { player.SendLocalizedMessage(1010568, null, 0x25); // You may not place a ship while on another ship or inside a house. LaunchGump(player); return; } Region region = Region.Find(location, map); if (region.IsPartOf(typeof(DungeonRegion))) { player.SendLocalizedMessage(502488); // You can not place a ship inside a dungeon. LaunchGump(player); return; } if (region.IsPartOf(typeof(HouseRegion))) { player.SendLocalizedMessage(1042549); // A ship may not be placed in this area. LaunchGump(player); return; } if (player.GetDistanceToSqrt(location) > 10) { player.SendMessage("You cannot place a ship that far away from land."); LaunchGump(player); return; } foreach (BaseShip shipInstance in BaseShip.m_Instances) { if (shipInstance.Owner == player) { player.SendMessage("You already have a ship at sea."); LaunchGump(player); return; } } BaseShip ship = (BaseShip)Activator.CreateInstance(ShipType); if (ship == null) { LaunchGump(player); return; } location = new Point3D(location.X - m_Offset.X, location.Y - m_Offset.Y, location.Z - m_Offset.Z); Direction newDirection = Direction.North; int shipFacingItemID = -1; switch (player.Direction) { case Direction.North: newDirection = Direction.North; shipFacingItemID = ship.NorthID; break; case Direction.Up: newDirection = Direction.North; shipFacingItemID = ship.NorthID; break; case Direction.East: newDirection = Direction.East; shipFacingItemID = ship.EastID; break; case Direction.Right: newDirection = Direction.East; shipFacingItemID = ship.EastID; break; case Direction.South: newDirection = Direction.South; shipFacingItemID = ship.SouthID; break; case Direction.Down: newDirection = Direction.South; shipFacingItemID = ship.SouthID; break; case Direction.West: newDirection = Direction.West; shipFacingItemID = ship.WestID; break; case Direction.Left: newDirection = Direction.West; shipFacingItemID = ship.WestID; break; default: newDirection = Direction.North; shipFacingItemID = ship.NorthID; break; } if (BaseShip.IsValidLocation(location, map) && ship.CanFit(location, map, shipFacingItemID)) { ship.Owner = player; BaseShip.PushDeedStoredPropertiesToShip(this, ship); ship.DecayTime = DateTime.UtcNow + ship.ShipDecayDelay; ship.Anchored = true; ship.SetFacing(newDirection); ship.MoveToWorld(location, map); Delete(); ShipRune shipRune = new ShipRune(ship, player); ship.m_ShipRune = shipRune; ShipRune shipBankRune = new ShipRune(ship, player); ship.m_ShipBankRune = shipBankRune; bool addedToPack = false; bool addedToBank = false; if (player.AddToBackpack(shipRune)) { addedToPack = true; } BankBox bankBox = player.FindBankNoCreate(); if (bankBox != null) { if (bankBox.Items.Count < bankBox.MaxItems) { bankBox.AddItem(shipBankRune); addedToBank = true; } } string message = "You place the ship at sea. A ship rune has been placed both in your bankbox and your backpack."; if (!addedToPack && !addedToBank) { message = "You place the ship at sea. However, there was no room in neither your bankbox nor your backpack to place ship runes."; } else if (!addedToPack) { message = "You place the ship at sea. A ship rune was placed in your bankbox, however, there was no room in your backpack to place a ship rune."; } else if (!addedToBank) { message = "You place the ship at sea. A ship rune was placed in your backpack, however, there was no room in your bankbox to place a ship rune."; } player.SendMessage(message); ShipGumpObject shipGumpObject = new ShipGumpObject(player, ship, null); player.CloseGump(typeof(ShipGump)); player.SendGump(new ShipGump(player, shipGumpObject)); } else { ship.Delete(); player.SendMessage("A ship cannot be placed there. You may change your facing to change the direction of the ship placement."); LaunchGump(player); } } }
public void EndInvasion(InvasionEventSink.InvasionEndedEventArgs.InvasionEndedReason Reason) { m_InvasionStarted = false; List <InvasionSpawn> ToDelete = new List <InvasionSpawn>(); for (int i = 0; i < m_SpawnList.Count; ++i) { ToDelete.Add((InvasionSpawn)m_SpawnList[i]); } foreach (Mobile m in World.Mobiles.Values) { if (m is InvasionSpawn) { if (((InvasionSpawn)m).Controller == this) { ToDelete.Add((InvasionSpawn)m); } } } for (int i = 0; i < ToDelete.Count; ++i) { InvasionSpawn deleting = (InvasionSpawn)ToDelete[i]; deleting.Delete(); } if (Reason == InvasionEventSink.InvasionEndedEventArgs.InvasionEndedReason.KillCountReached) { Console.WriteLine("Player Count:" + m_Players.Count.ToString()); IEnumerator key = m_Players.Keys.GetEnumerator(); for (int i = 0; i < m_Players.Count; ++i) { key.MoveNext(); int kills = (int)m_Players[(PlayerMobile)key.Current]; int percent = (kills / m_RequiredKillCount) * 100; if (percent > 100) { percent = 100; } int reward = (percent * m_Reward) / 100; if (reward < 1) { reward = 1; } if (reward > 60000) { reward = 60000; } Console.WriteLine("Kills:" + kills.ToString()); Console.WriteLine("Percent:" + percent.ToString()); Item givenreward; if (reward >= 5000) { givenreward = new BankCheck(reward); } else { givenreward = new Gold(reward); } BankBox bank = (BankBox)((PlayerMobile)key.Current).BankBox; bank.AddItem(givenreward); ((PlayerMobile)key.Current).SendMessage(String.Format("The invasion has ended! You have been rewarded {0}gp!", reward.ToString())); } } m_SpawnList.Clear(); m_SpawnList = null; m_Players.Clear(); m_Players = null; m_Kills = 0; InvasionEventSink.OnInvasionEnded(new InvasionEventSink.InvasionEndedEventArgs(this, Reason)); }
public override void OnDoubleClick(Mobile from) { if (from.AccessLevel >= AccessLevel.Counselor) { from.SendGump(new PBGMGump(this)); } else if (this.m_Active) { from.SendMessage("The game has already started"); } else if (from is Mobile && from.AccessLevel == AccessLevel.Player) { if (!from.InRange(GetWorldLocation(), 3)) { from.SendLocalizedMessage(500446); } else if (CheckAlreadyPlayer(from)) { from.SendMessage("You are already on a team"); } else { Players.Add(from); ArrayList ItemsToMove = new ArrayList(); Backpack itemsPack = new Backpack(); itemsPack.Hue = 1; itemsPack.Name = "Items from PaintBallGame"; BankBox bankBox = from.BankBox; foreach (Item item in from.Items) { if (item.Layer != Layer.Bank && item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Layer != Layer.Mount && item.Layer != Layer.Backpack) { ItemsToMove.Add(item); } } foreach (Item item in from.Backpack.Items) { ItemsToMove.Add(item); } foreach (Item item in ItemsToMove) { itemsPack.AddItem(item); } bankBox.AddItem(itemsPack); bankBox.AddItem(new PBPlayerStorage(from)); AddToTeam(from); } } else { from.SendMessage("You could not access that item for some reason. Please page a GM."); } }
// Disabled until further understood. // see rule #7 in public void Annex(BaseHouse house) { // because we were annexed, the owner of the new house cannot Demolish it for 7 days if (house != null) { house.SetFlag(ImplFlags.ManagedDemolishion, true); if (house.Owner != null) { house.Owner.SendMessage("Annexation of another property requires that you keep this house here for at least 7 days."); } } if (m_TentPack != null && this.Owner != null) { Backpack pack = new Backpack(); // give them back their tent pack.AddItem(new TentBag()); // Adam: Tents don't follow the rules :\ their regions don't list the mobiles (vendors) // so we'll have to find them via enumeration in the rects of the region if (Region.Coords != null && Region.Coords.Count > 0) { System.Collections.ArrayList c = Region.Coords; System.Collections.ArrayList toDelete = new System.Collections.ArrayList(); for (int i = 0; i < c.Count; i++) { Rectangle2D rect; rect = (Rectangle2D)c[i]; IPooledEnumerable eable; eable = this.Map.GetMobilesInBounds(rect); foreach (object obj in eable) { if (obj is PlayerVendor && (obj as PlayerVendor).Deleted == false && toDelete.Contains(obj) == false) { PlayerVendor pv = obj as PlayerVendor; // give them back the vendor contract pack.AddItem(new ContractOfEmployment()); // now give them the gold int hold = pv.HoldGold; pack.AddItem(new Gold(hold)); // now give them the loot if (pv.Backpack != null && pv.Backpack.Items.Count > 0) { for (int ix = 0; ix < pv.Backpack.Items.Count; ix++) { Item item = pv.Backpack.Items[0] as Item; pv.Backpack.RemoveItem(item); pack.AddItem(item); } } toDelete.Add(obj); } } eable.Free(); } // delete the vendors for (int mx = 0; mx < toDelete.Count; mx++) { if ((toDelete[mx] as PlayerVendor).Deleted == false) { (toDelete[mx] as PlayerVendor).Delete(); } } } // copy the items from the tentpack to the new pack if (m_TentPack.Items != null && m_TentPack.Items.Count > 0) { while (m_TentPack.Items.Count > 0) { Item item = m_TentPack.Items[0] as Item; m_TentPack.RemoveItem(item); pack.AddItem(item); } } // save the pack in a safe place pack.MoveItemToIntStorage(); BankBox box = this.Owner.BankBox; if (box == null) { return; } box.AddItem(new TentReimbursementDeed(pack)); this.Owner.SendMessage("By decree of Lord British, your tent has been annexed."); this.Owner.SendMessage("You may recover your belongings by redeeming the deed in your bankbox."); this.Delete(); } }
public override bool OnDragDrop(Mobile from, Item dropped) { BankBox box = from.BankBox; if (box == null) { return(false); } if (dropped is HolidayDeed) { if (message != null) { SayTo(from, message); } Item random = null; int randomitem = Utility.RandomMinMax(0, 3); if (randomitem == 0) { random = new Snowman(); random.Name = "snowman"; } if (randomitem == 1) { random = new SnowPile(); } if (randomitem == 2) { random = new EternalEmbers(); } if (randomitem == 3) { if (Utility.RandomBool()) { random = new RedPoinsettia(); } else { random = new WhitePoinsettia(); } random.Name = "poinsettia"; } Item roast = new RoastPig(); roast.Name = "roast pig"; Item candle = new CandleLong(); candle.Name = "candle"; candle.Hue = Utility.RandomList(0, 3343, 72, 7, 1274, 53); Item cookie = new Cookies(); cookie.Name = "Christmas cookies"; GiftBox Giftbox = new GiftBox(); string year = DateTime.Now.Year.ToString(); string Signature = "Christmas " + year; Giftbox.Name = Signature; roast.Name += " - " + Signature; Giftbox.DropItem(roast); candle.Name += " - " + Signature; Giftbox.DropItem(candle); random.Name += " - " + Signature; Giftbox.DropItem(random); cookie.Name += " - " + Signature; Giftbox.DropItem(cookie); //drop it all to bank // Adam: This method fails if the bank is full! // box.TryDropItem( from, Giftbox, false ); // this one won't box.AddItem(Giftbox); //delete deed. dropped.Delete(); return(true); } else //if not a holiday deed dont accept anything { return(false); } }
public override void OnResponse(NetState state, RelayInfo info) { if (info.ButtonID == 1 && !m_House.Deleted) { if (m_House.IsOwner(m_Mobile)) { if (m_House.FindGuildstone() != null) { m_Mobile.SendLocalizedMessage(501389); // You cannot redeed a house with a guildstone inside. return; } //Pix: 7/13/2008 - Removing the requirement of a townshipstone to be in a house. // else if (m_House.FindTownshipStone() != null) // { // m_Mobile.SendMessage("You can't demolish a house which holds a Township stone."); // return; // } //It was decided that we should just auto-dismiss the township NPC if the house is demolished //else if (m_House.FindTownshipNPC() != null) //{ // m_Mobile.SendMessage("You need to dismiss your Township NPC before moving."); // return; //} else if (m_House.FindPlayerVendor() != null) { m_Mobile.SendLocalizedMessage(503236); // You need to collect your vendor's belongings before moving. return; } else if (m_House.FindPlayer() != null) { m_Mobile.SendMessage("It is not safe to demolish this house with someone still inside."); // You need to collect your vendor's belongings before moving. //Tell staff that an exploit is in progress //Server.Scripts.Commands.CommandHandlers.BroadcastMessage( AccessLevel.Counselor, //0x482, //String.Format( "Exploit in progress at {0}. Stay hidden, Jail involved players, get acct name, ban.", m_House.Location.ToString() ) ); return; } Item toGive = null; Item Refund = null; // for various home upgrades if (m_House.IsAosRules) { if (m_House.Price > 0) { toGive = new BankCheck(m_House.Price); } else { toGive = m_House.GetDeed(); } } else { toGive = m_House.GetDeed(); if (toGive == null && m_House.Price > 0) { toGive = new BankCheck(m_House.Price); } if (m_House.UpgradeCosts > 0) { Refund = new BankCheck((int)m_House.UpgradeCosts); } } if (toGive != null) { BankBox box = m_Mobile.BankBox; // Adam: TryDropItem() fails if trhe bank is full, and this isn't the time to be // failing .. just overload their bank. if (box != null /*&& box.TryDropItem( m_Mobile, toGive, false )*/) { box.AddItem(toGive); if (toGive is BankCheck) { m_Mobile.SendLocalizedMessage(1060397, ((BankCheck)toGive).Worth.ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box. } if (Refund != null) { box.AddItem(Refund); if (Refund is BankCheck) { m_Mobile.SendLocalizedMessage(1060397, ((BankCheck)Refund).Worth.ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box. } } m_House.RemoveKeys(m_Mobile); m_House.Delete(); } else { toGive.Delete(); m_Mobile.SendLocalizedMessage(500390); // Your bank box is full. } } else { m_Mobile.SendMessage("Unable to refund house."); } } else { m_Mobile.SendLocalizedMessage(501320); // Only the house owner may do this. } } }
public override void OnSpeech(SpeechEventArgs e) { if (!e.Handled && e.Mobile.InRange(this.Location, 12)) { for (int i = 0; i < e.Keywords.Length; ++i) { int keyword = e.Keywords[i]; switch (keyword) { case 0x0000: // *withdraw* { //e.Handled = true; //if( e.Mobile.Criminal ) //{ // this.Say( 500389 ); // I will not do business with a criminal! // break; //} //string[] split = e.Speech.Split( ' ' ); //if( split.Length >= 2 ) //{ // int amount; // try // { // amount = Convert.ToInt32( split[1] ); // } // catch // { // break; // } // if( amount > 5000 ) // { // this.Say( 500381 ); // Thou canst not withdraw so much at one time! // } // else if( amount > 0 ) // { // BankBox box = e.Mobile.FindBankNoCreate(); // if( box == null || !box.ConsumeTotal( typeof( Gold ), amount ) ) // { // this.Say( 500384 ); // Ah, art thou trying to fool me? Thou hast not so much gold! // } // else // { // e.Mobile.AddToBackpack( new Gold( amount ) ); // this.Say( 1010005 ); // Thou hast withdrawn gold from thy account. // } // } //} break; } case 0x0001: // *balance* { e.Handled = true; if (e.Mobile.Criminal) { this.Say(500389); // I will not do business with a criminal! break; } BankBox box = e.Mobile.FindBankNoCreate(); //if( box != null ) // this.Say( 1042759, box.TotalGold.ToString() ); // Thy current bank balance is ~1_AMOUNT~ gold. //else // this.Say( 1042759, "0" ); // Thy current bank balance is ~1_AMOUNT~ gold. if (box != null) { Item[] coins = box.FindItemsByType(new Type[] { CurrencySystem.typeofGold, CurrencySystem.typeofVerite, CurrencySystem.typeofValorite }); int valorite = 0, verite = 0, gold = 0; for (int c = 0; c < coins.Length; c++) { if (coins[c].GetType() == CurrencySystem.typeofGold) { gold += coins[c].Amount; } else if (coins[c].GetType() == CurrencySystem.typeofVerite) { verite += coins[c].Amount; } else if (coins[c].GetType() == CurrencySystem.typeofValorite) { valorite += coins[c].Amount; } } Say(String.Format("Thy current bank balance is {0} valorite, {1} verite, and {2} gold.", valorite, verite, gold)); } else { Say("Thy bank box doth not have any coins."); } break; } case 0x0002: // *bank* { e.Handled = true; if (e.Mobile.Criminal) { this.Say(500378); // Thou art a criminal and cannot access thy bank box. break; } e.Mobile.BankBox.Open(); break; } case 0x0003: // *check* { //e.Handled = true; //if( e.Mobile.Criminal ) //{ // this.Say( 500389 ); // I will not do business with a criminal! // break; //} //string[] split = e.Speech.Split( ' ' ); //if( split.Length >= 2 ) //{ // int amount; // try // { // amount = Convert.ToInt32( split[1] ); // } // catch // { // break; // } // if( amount < 5000 ) // { // this.Say( 1010006 ); // We cannot create checks for such a paltry amount of gold! // } // else if( amount > 1000000 ) // { // this.Say( 1010007 ); // Our policies prevent us from creating checks worth that much! // } // else // { // BankCheck check = new BankCheck( amount ); // BankBox box = e.Mobile.BankBox; // if( !box.TryDropItem( e.Mobile, check, false ) ) // { // this.Say( 500386 ); // There's not enough room in your bankbox for the check! // check.Delete(); // } // else if( !box.ConsumeTotal( typeof( Gold ), amount ) ) // { // this.Say( 500384 ); // Ah, art thou trying to fool me? Thou hast not so much gold! // check.Delete(); // } // else // { // this.Say( 1042673, AffixType.Append, amount.ToString(), "" ); // Into your bank box I have placed a check in the amount of: // } // } //} break; } } } if (e.Speech.ToLower().IndexOf("exchange") > -1) { BankBox box = e.Mobile.FindBankNoCreate(); if (box != null) { int cc = 0, sc = 0, gc = 0; Point3D ccLoc = Point3D.Zero, scLoc = Point3D.Zero, gcLoc = Point3D.Zero; List <BaseCoin> coins = box.FindItemsByType <BaseCoin>(); coins.ForEach( delegate(BaseCoin coin) { if (coin.GetType() == CurrencySystem.typeofGold) { cc += coin.Amount; ccLoc = coin.Location; } else if (coin.GetType() == CurrencySystem.typeofVerite) { sc += coin.Amount; scLoc = coin.Location; } else if (coin.GetType() == CurrencySystem.typeofValorite) { gc += coin.Amount; gcLoc = coin.Location; } coin.Delete(); }); int[] newAmts = CurrencySystem.Compress(cc, sc, gc); if (newAmts[0] > 0) { Gold gold = new Gold(newAmts[0]); box.AddItem(gold); gold.Location = ccLoc; } if (newAmts[1] > 0) { Verite silver = new Verite(newAmts[1]); box.DropItem(silver); silver.Location = scLoc; } if (newAmts[2] > 0) { Valorite gold = new Valorite(newAmts[2]); box.DropItem(gold); gold.Location = gcLoc; } } } } base.OnSpeech(e); }