Example #1
0
        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;
                }
                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;
        }
			protected override void OnTarget( Mobile from, object s )
			{
				Container bank = from.FindBankNoCreate();
				
				if ( s == from )
				{
					from.SendMessage( "You cannot room yourself." );
				}
				else if ( s is PlayerMobile )
				{
					from.SendMessage( "That is not a Squire." );
				}
				else if ( !(s is Squire) )
				{
					from.SendMessage( "That is not a Squire." );
				}
				else
				{
					BaseCreature squi = ( BaseCreature )s;
					
					if ( squi.Mounted == true )
					{
						from.SendMessage( "Please dismount the Squire first, use [Dismount" );
					}
					else if ( squi.Summoned )
					{
						from.SendMessage( "How did you summon a squire with magic?" );
					}
					else if ( !squi.Alive )
					{
						from.SendMessage( "Please resurrect the Squire first." );
					}
					else
					{
						RoomCommandFunctions.Room( from, squi, true );
					}
				}
			}
Example #3
0
		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;
		}
		public void EndStable( Mobile from, BaseBlue pet )
		{
			if ( Deleted || !from.CheckAlive() )
				return;

			if ( !pet.Controlled )
			{
				SayTo( from, "That cannot stay here!" ); // You can't stable that!
			}
			else if ( pet.ControlMaster != from )
			{
				SayTo( from, "He doesn't follow your orders!" ); // You do not own that pet!
			}
			else if ( pet.IsDeadPet )
			{
				SayTo( from, "A ghost!!!!" ); // Living pets only, please.
			}
			else if ( pet.Summoned )
			{
				SayTo( from, 502673 ); // I can not stable summoned creatures.
			}
			#region Mondain's Legacy
			else if ( pet.Allured )
			{
				SayTo( from, 1048053 ); // You can't stable that!
			}
			#endregion
			else if ( (pet is PackLlama || pet is PackHorse || pet is Beetle) && (pet.Backpack != null && pet.Backpack.Items.Count > 0) )
			{
				SayTo( from, 1042563 ); // You need to unload your pet.
			}
			else if ( pet.Combatant != null && pet.InRange( pet.Combatant, 12 ) && pet.Map == pet.Combatant.Map )
			{
				SayTo( from, "That person is at war right now!" ); // I'm sorry.  Your pet seems to be busy.
			}
			else if ( from.Stabled.Count >= GetMaxStabled( from ) )
			{
				SayTo( from, "Sorry, our Inn is full!" ); // You have too many pets in the stables!
			}
			else
			{
				Container bank = from.FindBankNoCreate();

				if ( ( from.Backpack != null && from.Backpack.ConsumeTotal( typeof( Gold ), 500 ) ) || ( bank != null && bank.ConsumeTotal( typeof( Gold ), 500 ) ) )
				{
					pet.ControlTarget = null;
					pet.ControlOrder = OrderType.Stay;
					pet.Internalize();

					pet.SetControlMaster( null );
					pet.SummonMaster = null;

					pet.IsStabled = true;

					from.Stabled.Add( pet );

					SayTo( from, "Enjoy your stay!" ); // [AOS: Your pet has been stabled.] Very well, thy pet is stabled. Thou mayst recover it by saying 'claim' to me. In one real world week, I shall sell it off if it is not claimed!
				}
				else
				{
					SayTo( from, 502677 ); // But thou hast not the funds in thy bank account!
				}
			}
		}
		public void BeginStable( Mobile from )
		{
			if ( Deleted || !from.CheckAlive() )
				return;

			Container bank = from.FindBankNoCreate();

			if ( ( from.Backpack == null || from.Backpack.GetAmount( typeof( Gold ) ) < 500 ) && ( bank == null || bank.GetAmount( typeof( Gold ) ) < 500 ) )
			{
				SayTo( from, "But who will pay for his stay?" ); // Thou dost not have enough gold, not even in thy bank account.
			}
			else
			{
				/* I charge 30 gold per pet for a real week's stable time.
										 * I will withdraw it from thy bank account.
										 * Which animal wouldst thou like to stable here?
										 */
				SayTo( from, "We charge 500 gold per day for a room at our fine establishment, who wishes to stay here?");

				from.Target = new StableTarget( this );
			}
		}
Example #6
0
		public void EndStable( Mobile from, BaseCreature pet )
		{
			if ( Deleted || !from.CheckAlive() )
				return;

			if ( pet.Body.IsHuman )
			{
				SayTo( from, 502672 ); // HA HA HA! Sorry, I am not an inn.
			}
			else if ( !pet.Controlled )
			{
				SayTo( from, 1048053 ); // You can't stable that!
			}
			else if ( pet.ControlMaster != from )
			{
				SayTo( from, 1042562 ); // You do not own that pet!
			}
			else if ( pet.IsDeadPet )
			{
				SayTo( from, 1049668 ); // Living pets only, please.
			}
			else if ( pet.Summoned )
			{
				SayTo( from, 502673 ); // I can not stable summoned creatures.
			}
            /*
			else if ( pet.Allured )
			{
				SayTo( from, 1048053 ); // You can't stable that!
			}
*/
			else if ( (pet is PackLlama || pet is PackHorse || pet is Beetle) && (pet.Backpack != null && pet.Backpack.Items.Count > 0) )
			{
				SayTo( from, 1042563 ); // You need to unload your pet.
			}
			else if ( pet.Combatant != null && pet.InRange( pet.Combatant, 12 ) && pet.Map == pet.Combatant.Map )
			{
				SayTo( from, 1042564 ); // I'm sorry.  Your pet seems to be busy.
			}
			else if ( from.Stabled.Count >= GetMaxStabled( from ) )
			{
				SayTo( from, 1042565 ); // You have too many pets in the stables!
			}
			else
			{
				Container bank = from.FindBankNoCreate();

				if ( ( from.Backpack != null && from.Backpack.ConsumeTotal( typeof( Gold ), 30 ) ) || ( bank != null && bank.ConsumeTotal( typeof( Gold ), 30 ) ) )
				{
					pet.ControlTarget = null;
					pet.ControlOrder = OrderType.Stay;
					pet.Internalize();

					pet.SetControlMaster( null );
					pet.SummonMaster = null;

					pet.IsStabled = true;
                    pet.StabledBy = from;

					if ( Core.SE )	
						pet.Loyalty = BaseCreature.MaxLoyalty; // Wonderfully happy

					from.Stabled.Add( pet );

					SayTo( from, Core.AOS ? 1049677 : 502679 ); // [AOS: Your pet has been stabled.] Very well, thy pet is stabled. Thou mayst recover it by saying 'claim' to me. In one real world week, I shall sell it off if it is not claimed!
				}
				else
				{
					SayTo( from, 502677 ); // But thou hast not the funds in thy bank account!
				}
			}
		}
		public bool IsUsableBy( Mobile from )
		{
			Item root = RootParent as Item;
			return IsChildOf( from.Backpack ) || IsChildOf( from.FindBankNoCreate() ) || IsLockedDown && IsAccessibleTo( from ) || root != null && root.IsSecure && root.IsAccessibleTo( from );
		}
Example #8
0
        public int GetBalance(Mobile from)
        {
            int balance = 0;

            Container bank = from.FindBankNoCreate();
            Container backpack = from.Backpack;
            Item[] DonatorDeeds;

            if (bank != null)
            {
                DonatorDeeds = bank.FindItemsByType(typeof(DonatorDeed));

                for (int i = 0; i < DonatorDeeds.Length; i++)
                    balance += DonatorDeeds[i].Amount;
            }

            if (backpack != null)
            {
                DonatorDeeds = backpack.FindItemsByType(typeof(DonatorDeed));

                for (int i = 0; i < DonatorDeeds.Length; i++)
                    balance += DonatorDeeds[i].Amount;
            }

            return balance;
        }
Example #9
0
        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 void PlacementWarning_Callback( Mobile from, bool okay, object state )
		{
			if( !from.CheckAlive() || from.Backpack == null || from.Backpack.FindItemByType( typeof( HousePlacementTool ) ) == null )
				return;

			PreviewHouse prevHouse = (PreviewHouse)state;

			if( !okay )
			{
				prevHouse.Delete();
				return;
			}

			if( prevHouse.Deleted )
			{
				/* Too much time has passed and the test house you created has been deleted.
				 * Please try again!
				 */
				from.SendGump( new NoticeGump( 1060637, 30720, 1060647, 32512, 320, 180, null, null ) );

				return;
			}

			Point3D center = prevHouse.Location;
			Map map = prevHouse.Map;

			prevHouse.Delete();

			ArrayList toMove;
			//Point3D center = new Point3D( p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z );
			HousePlacementResult res = HousePlacement.Check( from, m_MultiID, center, out toMove );

			switch( res )
			{
				case HousePlacementResult.Valid:
					{
						if( from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse( from ) )
						{
							from.SendLocalizedMessage( 501271 ); // You already own a house, you may not place another!
						}
						else
						{
							BaseHouse house = ConstructHouse( from );

							if( house == null )
								return;

							house.Price = m_Cost;

							//if( Banker.Withdraw( from, m_Cost ) )
							//{
							//    from.SendLocalizedMessage( 1060398, m_Cost.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
							//}

							if( CurrencySystem.Consume( from.FindBankNoCreate(), CurrencySystem.typeofCopper, m_Cost ) )
							{
								from.SendMessage( "{0} copper has been withdrawn from your bank box.", m_Cost.ToString() );
							}
							else
							{
								house.RemoveKeys( from );
								house.Delete();
								from.SendLocalizedMessage( 1060646 ); // You do not have the funds available in your bank box to purchase this house.  Try placing a smaller house, or adding gold or checks to your bank box.
								return;
							}

							house.MoveToWorld( center, from.Map );

							for( int i = 0; i < toMove.Count; ++i )
							{
								object o = toMove[i];

								if( o is Mobile )
									((Mobile)o).Location = house.BanLocation;
								else if( o is Item )
									((Item)o).Location = house.BanLocation;
							}
						}

						break;
					}
				case HousePlacementResult.BadItem:
				case HousePlacementResult.BadLand:
				case HousePlacementResult.BadStatic:
				case HousePlacementResult.BadRegionHidden:
				case HousePlacementResult.NoSurface:
					{
						from.SendLocalizedMessage( 1043287 ); // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
						break;
					}
				case HousePlacementResult.BadRegion:
					{
						from.SendLocalizedMessage( 501265 ); // Housing cannot be created in this area.
						break;
					}
			}
		}
		//code to finish adding an item - accessed by the add item target
		public void AddItem( Mobile from, object targeted )
		{
			if( from != null && !CanUse( from ) )
			{
				from.SendMessage( "You no longer can use that" );
				return;
			}
			
			//keep track of the item
			Item item = null;
			
			//keep track of the deed if it's a commodity deeds
			Item deed = null;
			
			int entryindex;
			
			if( !( targeted is Item ) )
			{
				if( from != null )
				{
					from.SendMessage( "this only works on items." );
				}
				return;
			}
			
			item = (Item)targeted;
			
			if( from != null && !item.IsChildOf( from.Backpack ) )
			{
				BankBox box = from.FindBankNoCreate();
				
				if( box == null || !item.IsChildOf( box ) )
				{
					from.SendMessage( "you can only add items from your backpack or bank box" );
					return;
				}
			}

			
			//Handle commodity deed insertion
			if( item is CommodityDeed )
			{
				if( ((CommodityDeed)item).Commodity == null )
				{
					if( from != null )
					{
						from.SendMessage( "there is nothing to add in that commodity deed." );
					}
					return;
				}
				//store the deed reference
				deed = item;
				
				//reference the commodity within the deed
				item = ((CommodityDeed)item).Commodity;
			}
			
			//this uses the overloadable comparison for the appropriate store entries, so that custom store entries
			//can provide custom comparisons with items through their Match() methods
			entryindex = StoreEntry.IndexOfItem( _StoreEntries, item, true );
			
			if( entryindex == -1 )
			{
				if( from != null )
				{
					from.SendMessage( "that cannot be stored in this." );
				}
				return;
				
			}
			
			//reference the item store entry
			StoreEntry entry = _StoreEntries[ entryindex ];
			
			if( !entry.Add( item ) )
			{
				if( from != null )
				{
					from.SendMessage( "that quantity cannot fit in this." );
				}
				return;
			}
			
			//don't delete items that are stuck in a stash list
			if( !( entry is StashEntry ) )
			{
				//delete the item after
				if( deed != null )
				{
					deed.Delete();
				}
				else
				{
					entry.AbsorbItem( item );
				}
			}
			
			
			
			//start next add and give another cursor
			if( from != null )
			{
				AddItem( from );
				
				//resend the gump after it's all done
				if( !ItemStoreGump.RefreshGump( from ) )
				{
					//send a new gump if there's no existing one up
					from.SendGump( new ItemStoreGump( from, this ) );
				}
				
				
			}
			
		}
Example #12
0
		public override void OnDoubleClick( Mobile from )
		{
			BankBox box = from.FindBankNoCreate();

			if ( box != null && IsChildOf( box ) )
			{
				Delete();

				int deposited = 0;

				int toAdd = m_Worth;

				Copper copper;

				while ( toAdd > 60000 )
				{
					copper = new Copper( 60000 );

					if ( box.TryDropItem( from, copper, false ) )
					{
						toAdd -= 60000;
						deposited += 60000;
					}
					else
					{
						copper.Delete();

						from.AddToBackpack( new BankCheck( toAdd ) );
						toAdd = 0;

						break;
					}
				}

				if ( toAdd > 0 )
				{
					copper = new Copper( toAdd );

					if ( box.TryDropItem( from, copper, false ) )
					{
						deposited += toAdd;
					}
					else
					{
						copper.Delete();

						from.AddToBackpack( new BankCheck( toAdd ) );
					}
				}

				// Gold was deposited in your account:
				from.SendLocalizedMessage( 1042672, true, " " + deposited.ToString() );
			}
			else
			{
				from.SendLocalizedMessage( 1047026 ); // That must be in your bank box to use it.
			}
		}
Example #13
0
        public void BeginDryDock( Mobile from, Mobile master )
        {
            if ( CheckDecay() )
                return;

            /*FIND GOLD*/
            int balance = 0;
            Item[] gold;

            Container bank = from.FindBankNoCreate();

            if (bank != null)
            {
                gold = bank.FindItemsByType(typeof(Gold));

                for (int i = 0; i < gold.Length; ++i)
                    balance += gold[i].Amount;
            }

            if (balance < 25)
            {
                master.Say(true, "Thou dost not have 25 gold in thy bank account.");
                return;
            }
            else
            {
                EndDryDock(from, master, bank);
            }

            /*DryDockResult result = CheckDryDock( from );

            if ( result == DryDockResult.Dead )
                from.SendAsciiMessage( "You appear to be dead." ); // You appear to be dead.
            else if ( result == DryDockResult.NoKey )
                from.SendAsciiMessage("You must have a key to the ship to dock the boat."); // You must have a key to the ship to dock the boat.
            else if ( result == DryDockResult.NotAnchored )
                from.SendAsciiMessage("You must lower the anchor to dock the boat."); // You must lower the anchor to dock the boat.
            else if ( result == DryDockResult.Mobiles )
                from.SendAsciiMessage("You cannot dock the ship with beings on board!"); // You cannot dock the ship with beings on board!
            else if ( result == DryDockResult.Items )
                from.SendAsciiMessage("You cannot dock the ship with a cluttered deck."); // You cannot dock the ship with a cluttered deck.
            else if ( result == DryDockResult.Hold )
                from.SendAsciiMessage("Make sure your hold is empty, and try again!"); // Make sure your hold is empty, and try again!
            else if ( result == DryDockResult.Valid )
                from.SendGump( new ConfirmDryDockGump( from, this ) );*/
        }
Example #14
0
        public void EndStable(Mobile from, BaseCreature pet)
        {
            if (Deleted || !from.CheckAlive())
                return;

            else if (!pet.Controlled || pet.ControlMaster != from)
            {
                from.SendLocalizedMessage(1042562); // You do not own that pet!
            }
            else if (pet.IsDeadPet)
            {
                from.SendLocalizedMessage(1049668); // Living pets only, please.
            }
            else if (pet.Summoned)
            {
                from.SendLocalizedMessage(502673); // I can not stable summoned creatures.
            }
            #region Mondain's Legacy
            else if (pet.Allured)
            {
                from.SendLocalizedMessage(1048053); // You can't stable that!
            }
            #endregion
            else if (pet.Body.IsHuman)
            {
                from.SendLocalizedMessage(502672); // HA HA HA! Sorry, I am not an inn.
            }
            else if (pet.Combatant != null && pet.InRange(pet.Combatant, 12) && pet.Map == pet.Combatant.Map)
            {
                from.SendLocalizedMessage(1042564); // I'm sorry.  Your pet seems to be busy.
            }
            else if (from.Stabled.Count >= GetMaxStabled(from))
            {
                from.SendLocalizedMessage(1114325); // There is no more room in your chicken coop!
            }
            else
            {
                Container bank = from.FindBankNoCreate();

                if (bank != null && bank.ConsumeTotal(typeof(Gold), 30))
                {
                    pet.ControlTarget = null;
                    pet.ControlOrder = OrderType.Stay;
                    pet.Internalize();

                    pet.SetControlMaster(null);
                    pet.SummonMaster = null;

                    pet.IsStabled = true;

                    if (Core.SE)
                        pet.Loyalty = BaseCreature.MaxLoyalty; // Wonderfully happy

                    from.Stabled.Add(pet);

                    from.SendLocalizedMessage(502679); // Very well, thy pet is stabled. Thou mayst recover it by saying 'claim' to me. In one real world week, I shall sell it off if it is not claimed!
                }
                else
                {
                    from.SendLocalizedMessage(502677); // But thou hast not the funds in thy bank account!
                }
            }
        }
Example #15
0
		public override bool OnBuyItems(Mobile buyer, List<BuyItemResponse> list)
		{
			if (!Trading || TokenType == null || !TokenType.IsNotNull)
			{
				return false;
			}

			if (!IsActiveSeller)
			{
				return false;
			}

			if (!buyer.CheckAlive())
			{
				return false;
			}

			if (!CheckVendorAccess(buyer))
			{
				Say(501522); // I shall not treat with scum like thee!
				return false;
			}

			UpdateBuyInfo();

			var info = GetSellInfo();
			int totalCost = 0;
			var validBuy = new List<BuyItemResponse>(list.Count);
			bool fromBank = false;
			bool fullPurchase = true;
			int controlSlots = buyer.FollowersMax - buyer.Followers;

			foreach (BuyItemResponse buy in list)
			{
				Serial ser = buy.Serial;
				int amount = buy.Amount;

				if (ser.IsItem)
				{
					Item item = World.FindItem(ser);

					if (item == null)
					{
						continue;
					}

					GenericBuyInfo gbi = LookupDisplayObject(item);

					if (gbi != null)
					{
						ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost);
					}
					else if (item != BuyPack && item.IsChildOf(BuyPack))
					{
						if (amount > item.Amount)
						{
							amount = item.Amount;
						}

						if (amount <= 0)
						{
							continue;
						}

						foreach (IShopSellInfo ssi in
							info.Where(ssi => ssi.IsSellable(item)).Where(ssi => ssi.IsResellable(item)))
						{
							totalCost += ssi.GetBuyPriceFor(item) * amount;
							validBuy.Add(buy);
							break;
						}
					}
				}
				else if (ser.IsMobile)
				{
					Mobile mob = World.FindMobile(ser);

					if (mob == null)
					{
						continue;
					}

					GenericBuyInfo gbi = LookupDisplayObject(mob);

					if (gbi != null)
					{
						ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost);
					}
				}
			}

			if (fullPurchase && validBuy.Count == 0)
			{
				// Thou hast bought nothing!
				SayTo(buyer, 500190);
			}
			else if (validBuy.Count == 0)
			{
				// Your order cannot be fulfilled, please try again.
				SayTo(buyer, 500187);
			}

			if (validBuy.Count == 0)
			{
				return false;
			}

			bool bought = (buyer.AccessLevel >= AccessLevel.GameMaster);
			Container cont = buyer.Backpack;

			if (!bought && cont != null)
			{
				if (cont.ConsumeTotal(TokenType, totalCost))
				{
					bought = true;
				}
				else if (totalCost < 2000)
				{
					// Begging thy pardon, but thou casnt afford that.
					SayTo(buyer, 500192);
				}
			}

			if (!bought && totalCost >= 2000)
			{
				cont = buyer.FindBankNoCreate();

				if (cont != null && cont.ConsumeTotal(TokenType, totalCost))
				{
					bought = true;
					fromBank = true;
				}
				else
				{
					// Begging thy pardon, but thy bank account lacks these funds.
					SayTo(buyer, 500191);
				}
			}

			if (!bought)
			{
				return false;
			}

			buyer.PlaySound(0x32);

			cont = buyer.Backpack ?? buyer.BankBox;

			foreach (BuyItemResponse buy in validBuy)
			{
				Serial ser = buy.Serial;
				int amount = buy.Amount;

				if (amount < 1)
				{
					continue;
				}

				if (ser.IsItem)
				{
					Item item = World.FindItem(ser);

					if (item == null)
					{
						continue;
					}

					GenericBuyInfo gbi = LookupDisplayObject(item);

					if (gbi != null)
					{
						ProcessValidPurchase(amount, gbi, buyer, cont);
					}
					else
					{
						if (amount > item.Amount)
						{
							amount = item.Amount;
						}

						if (info.Where(ssi => ssi.IsSellable(item)).Any(ssi => ssi.IsResellable(item)))
						{
							Item buyItem;

							if (amount >= item.Amount)
							{
								buyItem = item;
							}
							else
							{
								buyItem = LiftItemDupe(item, item.Amount - amount) ?? item;
							}

							if (cont == null || !cont.TryDropItem(buyer, buyItem, false))
							{
								buyItem.MoveToWorld(buyer.Location, buyer.Map);
							}
						}
					}
				}
				else if (ser.IsMobile)
				{
					Mobile mob = World.FindMobile(ser);

					if (mob == null)
					{
						continue;
					}

					GenericBuyInfo gbi = LookupDisplayObject(mob);

					if (gbi != null)
					{
						ProcessValidPurchase(amount, gbi, buyer, cont);
					}
				}
			}

			if (fullPurchase)
			{
				if (buyer.AccessLevel >= AccessLevel.GameMaster)
				{
					SayTo(buyer, true, "I would not presume to charge thee anything.  Here are the goods you requested.");
				}
				else if (fromBank)
				{
					SayTo(
						buyer,
						true,
						"The total of thy purchase is {0} {1}, which has been withdrawn from your bank account.  My thanks for the patronage.",
						totalCost,
						TokenName);
				}
				else
				{
					SayTo(buyer, true, "The total of thy purchase is {0} {1}.  My thanks for the patronage.", totalCost, TokenName);
				}
			}
			else
			{
				if (buyer.AccessLevel >= AccessLevel.GameMaster)
				{
					SayTo(
						buyer,
						true,
						"I would not presume to charge thee anything.  Unfortunately, I could not sell you all the goods you requested.");
				}
				else if (fromBank)
				{
					SayTo(
						buyer,
						true,
						"The total of thy purchase is {0} {1}, which has been withdrawn from your bank account.  My thanks for the patronage.  Unfortunately, I could not sell you all the goods you requested.",
						totalCost,
						TokenName);
				}
				else
				{
					SayTo(
						buyer,
						true,
						"The total of thy purchase is {0} {1}.  My thanks for the patronage.  Unfortunately, I could not sell you all the goods you requested.",
						totalCost,
						TokenName);
				}
			}

			return true;
		}
Example #16
0
        public override void OnDoubleClick( Mobile from )
        {
            BankBox box = from.FindBankNoCreate();

            if ( box != null && IsChildOf( box ) )
            {
                Delete();

                int deposited = 0;

                int toAdd = m_Worth;

                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 ) );
                    }
                }

                // Gold was deposited in your account:
                from.SendLocalizedMessage( 1042672, true, " " + deposited.ToString() );

                PlayerMobile pm = from as PlayerMobile;

                /*if ( pm != null )
                {
                    QuestSystem qs = pm.Quest;

                    if ( qs is Necro.DarkTidesQuest )
                    {
                        QuestObjective obj = qs.FindObjective( typeof( Necro.CashBankCheckObjective ) );

                        if ( obj != null && !obj.Completed )
                            obj.Complete();
                    }

                    if ( qs is Haven.UzeraanTurmoilQuest )
                    {
                        QuestObjective obj = qs.FindObjective( typeof( Haven.CashBankCheckObjective ) );

                        if ( obj != null && !obj.Completed )
                            obj.Complete();
                    }
                }*/
            }
            else
            {
                from.SendLocalizedMessage( 1047026 ); // That must be in your bank box to use it.
            }
        }
Example #17
0
        public static bool BuyItem( Mobile buyer, MarketEntry entry )
        {
            if( buyer == null || !buyer.Alive )
            {
                buyer.SendMessage("You cannot purchase a market order while knocked out.");
            }
            else if( buyer == entry.Seller )
            {
                buyer.SendMessage("You cannot purchase something from yourself.");
            }
            else
            {
                IEntity entity = World.FindEntity(entry.ObjectSerial);

                if( entity == null || IsSold(entry) )
                {
                    buyer.SendMessage("The order has expired.");
                }
                else
                {
                    Type[] coinTypes = new Type[] { Curr.typeofCopper, Curr.typeofSilver, Curr.typeofGold };
                    int[] compressedCost = Curr.Compress(entry.Cost, 0, 0);
                    Container cont = buyer.FindBankNoCreate();

                    if( cont != null && cont.ConsumeTotal(coinTypes, compressedCost) == -1 )
                    {
                        if( entity is Item )
                        {
                            Item item = (Item)entity;
                            cont = buyer.Backpack;

                            if( cont != null && !cont.TryDropItem(buyer, item, false) )
                                item.MoveToWorld(buyer.Location, buyer.Map);

                            CloseOrder(entry);

                            if( buyer.HasGump(typeof(MarketGump)) )
                            {
                                buyer.CloseGump(typeof(MarketGump));
                                buyer.SendGump(new MarketGump(entry.Category, 0));
                            }

                            return true;
                        }
                        else if( entity is Mobile )
                        {
                            Mobile mob = (Mobile)entity;
                            mob.Direction = (Direction)Utility.Random(8);
                            mob.MoveToWorld(buyer.Location, buyer.Map);
                            mob.PlaySound(mob.GetIdleSound());

                            if( mob is BaseCreature )
                                ((BaseCreature)mob).SetControlMaster(buyer);

                            CloseOrder(entry);

                            if( buyer.HasGump(typeof(MarketGump)) )
                            {
                                buyer.CloseGump(typeof(MarketGump));
                                buyer.SendGump(new MarketGump(entry.Category, 0));
                            }

                            return true;
                        }
                    }
                    else
                    {
                        buyer.SendMessage("You cannot afford that item.");
                    }
                }
            }

            return false;
        }
Example #18
0
        public static int GetBalance( Mobile from, out Item[] gold, out Item[] checks )
        {
            int balance = 0;

            Container bank = from.FindBankNoCreate();

            if ( bank != null )
            {
                gold = bank.FindItemsByType( typeof( Gold ) );
                checks = bank.FindItemsByType( typeof( BankCheck ) );

                for ( int i = 0; i < gold.Length; ++i )
                    balance += gold[i].Amount;

                for ( int i = 0; i < checks.Length; ++i )
                    balance += ((BankCheck)checks[i]).Worth;
            }
            else
            {
                gold = checks = new Item[0];
            }

            return balance;
        }
Example #19
0
        public void Purchase_Callback( Mobile from, bool okay, object state )
        {
            if ( Deleted || !from.CheckAlive() || HasEntered( from ) || IsAtIPLimit( from ) )
                return;

            Account acc = from.Account as Account;

            if ( acc == null )
                return;

            if ( okay )
            {
                Container bank = from.FindBankNoCreate();

                if ( m_TicketPrice == 0 || ( from.Backpack != null && from.Backpack.ConsumeTotal( typeof( Gold ), m_TicketPrice ) ) || ( bank != null && bank.ConsumeTotal( typeof( Gold ), m_TicketPrice ) ) )
                {
                    m_Entries.Add( new RaffleEntry( from ) );

                    from.SendMessage( MessageHue, "You have successfully entered the plot's raffle." );
                }
                else
                {
                    from.SendMessage( MessageHue, "You do not have the {0} required to enter the raffle.", FormatPrice() );
                }
            }
            else
            {
                from.SendMessage( MessageHue, "You have chosen not to enter the raffle." );
            }
        }
Example #20
0
        public virtual void Pour_OnTarget( Mobile from, object targ )
        {
            if ( IsEmpty || !Pourable || !ValidateUse( from, false ) )
                return;

            if ((targ is SackFlourOpen) && (this.Quantity > 0))
            {
                this.Quantity -= 1;
                ((SackFlourOpen)targ).Quantity--;

                from.AddToBackpack(new Dough());
                from.SendAsciiMessage("You make some dough and put it in your backpack.");
                return;
            }

            if ( targ is BaseBeverage )
            {
                BaseBeverage bev = (BaseBeverage)targ;

                if ( !bev.ValidateUse( from, true ) )
                    return;

                if ( bev.IsFull && bev.Content == this.Content )
                {
                    from.SendAsciiMessage( "Couldn't pour it there.  It was already full." ); // Couldn't pour it there.  It was already full.
                }
                else if ( !bev.IsEmpty )
                {
                    from.SendAsciiMessage( "Can't pour it there." ); // Can't pour it there.
                }
                else
                {
                    bev.Content = this.Content;
                    bev.Poison = this.Poison;
                    bev.Poisoner = this.Poisoner;

                    if ( this.Quantity > bev.MaxQuantity )
                    {
                        bev.Quantity = bev.MaxQuantity;
                        this.Quantity -= bev.MaxQuantity;
                    }
                    else
                    {
                        bev.Quantity += this.Quantity;
                        this.Quantity = 0;
                    }

                    from.PlaySound( 0x4E );
                }
            }
            else if ( targ is Item && this.Content == BeverageType.Water )
            {
                Item item = ( (Item)targ );

                //empty barrel
                if ( item.ItemID == 3703 && this.Quantity == this.MaxQuantity )
                {
                    Static barrel = new Static( 5453 );
                    barrel.Name = "a water barrel";

                    if ( item.Parent != null && from.Backpack != null && from.Backpack == item.Parent )
                    {
                        barrel.MoveToWorld( from.Location );
                        barrel.Map = from.Map;
                    }
                    else if ( item.Parent != null && from.FindBankNoCreate() != null && from.BankBox == item.Parent )
                    {
                        barrel.MoveToWorld( from.Location );
                        barrel.Map = from.Map;
                    }
                    else if ( item.Parent != null && item.Parent is Item)
                    {
                        Item parent = ((Item)item.Parent);
                        barrel.MoveToWorld( parent.Location );
                        barrel.Map = parent.Map;
                    }
                    else
                    {
                        barrel.MoveToWorld( item.Location );
                        barrel.Map = item.Map;
                    }

                    this.Quantity = 0;

                    item.Delete();
                }
            }
            else if ( from == targ )
            {
                if ( from.Thirst < 20 )
                    from.Thirst += 1;

                if ( ContainsAlchohol )
                {
                    int bac = 0;

                    switch ( this.Content )
                    {
                        case BeverageType.Ale: bac = 1; break;
                        case BeverageType.Wine: bac = 2; break;
                        case BeverageType.Cider: bac = 3; break;
                        case BeverageType.Liquor: bac = 4; break;
                    }

                    from.BAC += bac;

                    if ( from.BAC > 60 )
                        from.BAC = 60;

                    CheckHeaveTimer( from );
                }

                from.PlaySound( Utility.RandomList( 0x30, 0x2D6 ) );

                if ( m_Poison != null )
                    from.ApplyPoison( m_Poisoner, m_Poison );

                --Quantity;
            }
            else if ( targ is PlantItem )
            {
                ((PlantItem)targ).Pour( from, this );
            }
            else if ( targ is AddonComponent &&
                ( ((AddonComponent)targ).Addon is WaterVatEast || ((AddonComponent)targ).Addon is WaterVatSouth ) &&
                this.Content == BeverageType.Water )
            {
                PlayerMobile player = from as PlayerMobile;

                if ( player != null )
                {
                    SolenMatriarchQuest qs = player.Quest as SolenMatriarchQuest;

                    if ( qs != null )
                    {
                        QuestObjective obj = qs.FindObjective( typeof( GatherWaterObjective ) );

                        if ( obj != null && !obj.Completed )
                        {
                            BaseAddon vat = ((AddonComponent)targ).Addon;

                            if ( vat.X > 5784 && vat.X < 5814 && vat.Y > 1903 && vat.Y < 1934 &&
                                ( (qs.RedSolen && vat.Map == Map.Trammel) || (!qs.RedSolen && vat.Map == Map.Felucca) ) )
                            {
                                if ( obj.CurProgress + Quantity > obj.MaxProgress )
                                {
                                    int delta = obj.MaxProgress - obj.CurProgress;

                                    Quantity -= delta;
                                    obj.CurProgress = obj.MaxProgress;
                                }
                                else
                                {
                                    obj.CurProgress += Quantity;
                                    Quantity = 0;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                from.SendAsciiMessage( "Can't pour it there." ); // Can't pour it there.
            }
        }
Example #21
0
		public void BeginStable( Mobile from )
		{
			if ( Deleted || !from.CheckAlive() )
				return;

			Container bank = from.FindBankNoCreate();
			
			if ( ( from.Backpack == null || from.Backpack.GetAmount( typeof( Gold ) ) < 30 ) && ( bank == null || bank.GetAmount( typeof( Gold ) ) < 30 ) )
			{
				SayTo( from, 1042556 ); // Thou dost not have enough gold, not even in thy bank account.
			}
			else
			{
				/* I charge 30 gold per pet for a real week's stable time.
				 * I will withdraw it from thy bank account.
				 * Which animal wouldst thou like to stable here?
				 */
				from.SendLocalizedMessage(1042558);

				from.Target = new StableTarget( this );
			}
		}
			protected override void OnTarget( Mobile from, object s )
			{
				Container bank = from.FindBankNoCreate();
				
				if ( s == from )
				{
					m_InnKeeper.Say( "Haha! Sorry! I thought we were rooming someone else... You may sleep here for free." );
				}
				else if ( s is PlayerMobile )
				{
					m_InnKeeper.Say( "Haha! Sorry! I think the sir or madam may speak for themselves." );
				}
				else if ( !(s is Squire) )
				{
					m_InnKeeper.Say( "That... Doesn't look like a squire to me." );
				}
				else
				{
					BaseCreature squi = ( BaseCreature )s;
					
					if ( squi.Combatant != null && squi.InRange( squi.Combatant, 12 ) && squi.Map == squi.Combatant.Map )
					{
						m_InnKeeper.Say( "Your squire seems to be distracted..." );
					}
					else if ( !( squi.Controlled && squi.ControlMaster == from ) )
					{
						m_InnKeeper.Say( "That is not your squire to room." );
					}
					//Uncomment this section if you don't want them to have items in their backpacks before storing them.
					/*else if ( squi is Squire && squi.Backpack != null && squi.Backpack.Items.Count > 0 )
					{
						m_InnKeeper.Say( "Please unload your squire before sending them to a room." );
					}*/
					else if ( squi.Mounted == true )
					{
						m_InnKeeper.Say( "This is not a stable, please have your squire dismount before I rent them a room." );
					}
					else if ( squi.Summoned )
					{
						m_InnKeeper.Say( "How did you summon a squire with magic?" );
					}
					else if ( !squi.Alive )
					{
						m_InnKeeper.Say( "I do not provide rooms for ghosts." );
					}
					else if ( squi is Squire && squi.Controlled == true && from == squi.ControlMaster && from.Backpack.ConsumeTotal( typeof( Gold ), 300 ) || bank != null && bank.ConsumeTotal( typeof( Gold ), 300 ) )
					{
						RoomFunctions.Room( from, squi, true );
					}
					else
					{
						m_InnKeeper.Say( "I will not room... That." ); // You can't stable that!
					}
				}
			}
		//this checks for money, and withdraws it if necessary
		public bool CheckCost( Mobile from, bool withdraw )
		{
			if( CostToPlay == 0 )
			{
				return true;
			}
			
			Gold gold = (Gold)from.Backpack.FindItemByType( typeof( Gold ) );
			
			if( gold == null || gold.Amount < CostToPlay )
			{
				Container bankbox = from.FindBankNoCreate();
				
				if( bankbox != null )
				{
					gold = (Gold)bankbox.FindItemByType( typeof( Gold ) );
					
					if( gold != null && gold.Amount >= CostToPlay )
					{
						if( withdraw )
						{
							bankbox.ConsumeTotal( typeof( Gold ), CostToPlay );
						}
						return true;
					}
				}
				return false;
			}
			
			if( withdraw )
			{
				from.Backpack.ConsumeTotal( typeof( Gold ), CostToPlay );
			}
			
			return true;
		}
Example #24
0
		public override void OnDoubleClick(Mobile from)
		{
			// This probably isn't OSI accurate, but we can't just make the quests redundant.
			// Double-clicking the BankCheck in your pack will now credit your account.

			var box = AccountGold.Enabled ? from.Backpack : from.FindBankNoCreate();

			if (box == null || !IsChildOf(box))
			{
				from.SendLocalizedMessage(AccountGold.Enabled ? 1080058 : 1047026);
				// This must be in your backpack to use it. : That must be in your bank box to use it.
				return;
			}

			Delete();

			var deposited = 0;
			var toAdd = m_Worth;

			if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(toAdd))
			{
				deposited = toAdd;
				toAdd = 0;
			}

			if (toAdd > 0)
			{
				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));
					}
				}
			}

			// Gold was deposited in your account:
			from.SendLocalizedMessage(1042672, true, deposited.ToString("#,0"));

			var pm = from as PlayerMobile;

			if (pm != null)
			{
				var qs = pm.Quest;

				if (qs is Necro.DarkTidesQuest)
				{
					var obj = qs.FindObjective(typeof(Necro.CashBankCheckObjective));

					if (obj != null && !obj.Completed)
					{
						obj.Complete();
					}
				}

				if (qs is Haven.UzeraanTurmoilQuest)
				{
					var obj = qs.FindObjective(typeof(Engines.Quests.Haven.CashBankCheckObjective));

					if (obj != null && !obj.Completed)
					{
						obj.Complete();
					}
				}
			}
		}