Ejemplo n.º 1
0
            protected override void OnTarget( Mobile from, object targeted )
            {
                if ( targeted is Spellbook )
                {
                    if ( from.CheckAlive() && !m_Scroll.Deleted && m_Scroll.Movable && m_Scroll.Amount >= 1 )
                    {
                        Spellbook book = (Spellbook)targeted;

                        SpellbookType type = Spellbook.GetTypeForSpell( m_Scroll.SpellID );

                        if ( type != book.SpellbookType )
                        {
                        }
                        else if ( book.HasSpell( m_Scroll.SpellID ) )
                        {
                            from.SendAsciiMessage( "That spell is already present in that spellbook." ); // That spell is already present in that spellbook.
                        }
                        else
                        {
                            int val = m_Scroll.SpellID - book.BookOffset;

                            if ( val >= 0 && val < book.BookCount )
                            {
                                book.Content |= (ulong)1 << val;

                                m_Scroll.Consume();

                                from.Send( new Network.PlaySound( 0x249, book.GetWorldLocation() ) );
                            }
                        }
                    }
                }
            }
Ejemplo n.º 2
0
 public virtual void BeginRelease(Mobile from)
 {
     if (!Deleted && Controlled && from == ControlMaster && from.CheckAlive())
     {
         EndRelease(from);
     }
 }
Ejemplo n.º 3
0
		public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
		{
			base.GetContextMenuEntries(from, list);

			if (from.CheckAlive() && IsChildOf(from.Backpack))
			{
				list.Add(new NameBookEntry(from, this));
			}
		}
Ejemplo n.º 4
0
 public virtual void EndRelease(Mobile from)
 {
     if (from?.CheckAlive() != false && !Deleted && Controlled && from == ControlMaster)
     {
         Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3728, 1, 13,
                                       2100, 3, 5042, 0);
         PlaySound(0x201);
         Delete();
     }
 }
		public override void OnDoubleClick( Mobile from )
		{
			if ( !Movable )
				return;

			if( from.InRange( this.GetWorldLocation(), 2 ) == false )
			{
				from.SendLocalizedMessage( 500486 );	//That is too far away.
				return;
			}
			else if ( squire == null || squire.Deleted )
			{
				from.SendMessage( "Your squire has been sold into slavery." );
				return;
			}
			else if( !from.CheckAlive() )
			{
				from.SendLocalizedMessage( 1060190 );	//You cannot do that while dead!
			}
			else if ( from.Followers + squire.ControlSlots > from.FollowersMax )
			{
				from.SendMessage( "You have too many followers to call your squire." );
				return;
			}
			else
			{
				bool alreadyOwned = squire.Owners.Contains( from );
				if (!alreadyOwned)
				{
					squire.Owners.Add( from );
				}

				//Make the Squire belong to their master again.
				squire.SetControlMaster( from );
				m_KillTheSquire = false;

				//Bring the Squire to their master.
				squire.Location = from.Location;
				squire.Map = from.Map;

				//Set the Squire to follow their master.
				squire.ControlTarget = from;
				squire.ControlOrder = OrderType.Follow;
				
				//Just in case someone messed with the system.
				if ( squire.Summoned )
					squire.SummonMaster = from;

				this.Delete();
			}



		}
Ejemplo n.º 6
0
		public bool VerifyPlacement( Mobile from, Rectangle2D area )
		{
			if( !from.CheckAlive() )
				return false;

			foreach( Item i in from.GetItemsInRange( 12 ) )
			{
				if( (i is TravelTent || i is TentAddon) && area.Contains( i ) )
					return false;
			}

			Region region = Region.Find( from.Location, from.Map );

			if( from.AccessLevel >= AccessLevel.GameMaster || region.AllowHousing( from, from.Location ) )
				return true;
			else if( !from.Map.CanFit( from.Location, 16 ) )
				return false;
			else if( region is TreasureRegion )
				return false;

			return (from.AccessLevel >= AccessLevel.GameMaster || region.AllowHousing( from, from.Location ));
		}
Ejemplo n.º 7
0
		public void EndClaimList(Mobile from, BaseCreature pet)
		{
			if (pet == null || pet.Deleted || from.Map != Map || !from.Stabled.Contains(pet) || !from.CheckAlive())
			{
				return;
			}

			if (!from.InRange(this, 14))
			{
				from.SendLocalizedMessage(500446); // That is too far away.
			}
			else if (CanClaim(from, pet))
			{
				int totalClaim = StablePrice * ((DateTime.UtcNow - pet.StabledDate).Days / ChargeFrequency);

				if (totalClaim <= 0 || from.AccessLevel >= AccessLevel.GameMaster ||
					Banker.WithdrawPackAndBank(from, TypeOfCurrency, totalClaim))
				{
					DoClaim(from, pet);
					from.Stabled.Remove(pet);

					if (from is PlayerMobile)
					{
						((PlayerMobile)from).AutoStabled.Remove(pet);
					}
				}
				else
				{
					SayTo(from, "Thou requires {0} {1} to claim thy pet.", totalClaim, TypeOfCurrency.Name);
				}
			}
			else
			{
				SayTo(from, 1049612, pet.Name); // ~1_NAME~ remained in the stables because you have too many followers.
			}
		}
Ejemplo n.º 8
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            if (info.ButtonID == 0 || !this.m_House.IsActive || !this.m_House.IsInside(from) || !this.m_House.IsOwner(from) || !from.CheckAlive())
            {
                return;
            }

            int index = info.ButtonID - 1;

            if (index < 0 || index >= this.m_Vendors.Count)
            {
                return;
            }

            Mobile mob = (Mobile)this.m_Vendors[index];

            if (!this.m_House.InternalizedVendors.Contains(mob))
            {
                return;
            }

            if (mob.Deleted)
            {
                this.m_House.InternalizedVendors.Remove(mob);
            }
            else
            {
                bool vendor, contract;
                BaseHouse.IsThereVendor(from.Location, from.Map, out vendor, out contract);

                if (vendor)
                {
                    from.SendLocalizedMessage(1062677); // You cannot place a vendor or barkeep at this location.
                }
                else if (contract)
                {
                    from.SendLocalizedMessage(1062678); // You cannot place a vendor or barkeep on top of a rental contract!
                }
                else
                {
                    this.m_House.InternalizedVendors.Remove(mob);
                    mob.MoveToWorld(from.Location, from.Map);
                }
            }
        }
Ejemplo n.º 9
0
		public virtual void VendorBuy( Mobile from )
		{
			if ( !IsActiveSeller )
				return;

			if ( !from.CheckAlive() )
				return;

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

			if ( DateTime.UtcNow - m_LastRestock > RestockDelay )
				Restock();

			UpdateBuyInfo();

			int count = 0;
			List<BuyItemState> list;
			IBuyItemInfo[] buyInfo = this.GetBuyInfo();
			IShopSellInfo[] sellInfo = this.GetSellInfo();

			list = new List<BuyItemState>( buyInfo.Length );
			Container cont = this.BuyPack;

			List<ObjectPropertyList> opls = null;

			for ( int idx = 0; idx < buyInfo.Length; idx++ )
			{
				IBuyItemInfo buyItem = (IBuyItemInfo)buyInfo[idx];

				if ( buyItem.Amount <= 0 || list.Count >= 250 )
					continue;

				// NOTE: Only GBI supported; if you use another implementation of IBuyItemInfo, this will crash
				GenericBuyInfo gbi = (GenericBuyInfo)buyItem;
				IEntity disp = gbi.GetDisplayEntity();

				list.Add( new BuyItemState( buyItem.Name, cont.Serial, disp == null ? (Serial)0x7FC0FFEE : disp.Serial, buyItem.Price, buyItem.Amount, buyItem.ItemID, buyItem.Hue ) );
				count++;

				if ( opls == null ) {
					opls = new List<ObjectPropertyList>();
				}

				if ( disp is Item ) {
					opls.Add( ( ( Item ) disp ).PropertyList );
				} else if ( disp is Mobile ) {
					opls.Add( ( ( Mobile ) disp ).PropertyList );
				}
			}

			List<Item> playerItems = cont.Items;

			for ( int i = playerItems.Count - 1; i >= 0; --i )
			{
				if ( i >= playerItems.Count )
					continue;

				Item item = playerItems[i];

				if ( ( item.LastMoved + InventoryDecayTime ) <= DateTime.UtcNow )
					item.Delete();
			}

			for ( int i = 0; i < playerItems.Count; ++i )
			{
				Item item = playerItems[i];

				int price = 0;
				string name = null;

				foreach ( IShopSellInfo ssi in sellInfo )
				{
					if ( ssi.IsSellable( item ) )
					{
						price = ssi.GetBuyPriceFor( item );
						name = ssi.GetNameFor( item );
						break;
					}
				}

				if ( name != null && list.Count < 250 )
				{
					list.Add( new BuyItemState( name, cont.Serial, item.Serial, price, item.Amount, item.ItemID, item.Hue ) );
					count++;

					if ( opls == null ) {
						opls = new List<ObjectPropertyList>();
					}

					opls.Add( item.PropertyList );
				}
			}

			//one (not all) of the packets uses a byte to describe number of items in the list.  Osi = dumb.
			//if ( list.Count > 255 )
			//	Console.WriteLine( "Vendor Warning: Vendor {0} has more than 255 buy items, may cause client errors!", this );

			if ( list.Count > 0 )
			{
				list.Sort( new BuyItemStateComparer() );

				SendPacksTo( from );

				NetState ns = from.NetState;

				if ( ns == null )
					return;

				if ( ns.ContainerGridLines )
					from.Send( new VendorBuyContent6017( list ) );
				else
					from.Send( new VendorBuyContent( list ) );

				from.Send( new VendorBuyList( this, list ) );

				if ( ns.HighSeas )
					from.Send( new DisplayBuyListHS( this ) );
				else
					from.Send( new DisplayBuyList( this ) );

				from.Send( new MobileStatusExtended( from ) );//make sure their gold amount is sent

				if ( opls != null ) {
					for ( int i = 0; i < opls.Count; ++i ) {
						from.Send( opls[i] );
					}
				}

				SayTo( from, 500186 ); // Greetings.  Have a look around.
			}
		}
Ejemplo n.º 10
0
			public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted)
			{
				if (!base.AllowSecureTrade(from, to, newOwner, accepted))
				{
					return false;
				}

				if (Deleted || m_Creature == null || m_Creature.Deleted || m_Creature.ControlMaster != from || !from.CheckAlive() ||
					!to.CheckAlive())
				{
					return false;
				}

				if (from.Map != m_Creature.Map || !from.InRange(m_Creature, 14))
				{
					return false;
				}

				bool youngFrom = from is PlayerMobile ? ((PlayerMobile)from).Young : false;
				bool youngTo = to is PlayerMobile ? ((PlayerMobile)to).Young : false;

				if (accepted && youngFrom && !youngTo)
				{
					from.SendLocalizedMessage(502051); // As a young player, you may not transfer pets to older players.
				}
				else if (accepted && !youngFrom && youngTo)
				{
					from.SendLocalizedMessage(502052); // As an older player, you may not transfer pets to young players.
				}
				else if (accepted && !m_Creature.CanBeControlledBy(to))
				{
					string args = String.Format("{0}\t{1}\t ", to.Name, from.Name);

					from.SendLocalizedMessage(1043248, args);
					// The pet refuses to be transferred because it will not obey ~1_NAME~.~3_BLANK~
					to.SendLocalizedMessage(1043249, args);
					// The pet will not accept you as a master because it does not trust you.~3_BLANK~

					return false;
				}
				else if (accepted && !m_Creature.CanBeControlledBy(from))
				{
					string args = String.Format("{0}\t{1}\t ", to.Name, from.Name);

					from.SendLocalizedMessage(1043250, args);
					// The pet refuses to be transferred because it will not obey you sufficiently.~3_BLANK~
					to.SendLocalizedMessage(1043251, args);
					// The pet will not accept you as a master because it does not trust ~2_NAME~.~3_BLANK~
				}
				else if (accepted && (to.Followers + m_Creature.ControlSlots) > to.FollowersMax)
				{
					to.SendLocalizedMessage(1049607); // You have too many followers to control that creature.

					return false;
				}
				else if (accepted && IsInCombat(m_Creature))
				{
					from.SendMessage("You may not transfer a pet that has recently been in combat.");
					to.SendMessage("The pet may not be transfered to you because it has recently been in combat.");

					return false;
				}

				return true;
			}
Ejemplo n.º 11
0
		public virtual TeachResult CheckTeachSkills( SkillName skill, Mobile m, int maxPointsToLearn, ref int pointsToLearn, bool doTeach )
		{
			if ( !CheckTeach( skill, m ) || !m.CheckAlive() )
				return TeachResult.Failure;

			Skill ourSkill = Skills[skill];
			Skill theirSkill = m.Skills[skill];

			if ( ourSkill == null || theirSkill == null )
				return TeachResult.Failure;

			int baseToSet = ourSkill.BaseFixedPoint / 3;

			if ( baseToSet > 420 )
				baseToSet = 420;
			else if ( baseToSet < 200 )
				return TeachResult.Failure;

			if ( baseToSet > theirSkill.CapFixedPoint )
				baseToSet = theirSkill.CapFixedPoint;

			pointsToLearn = baseToSet - theirSkill.BaseFixedPoint;

			if ( maxPointsToLearn > 0 && pointsToLearn > maxPointsToLearn )
			{
				pointsToLearn = maxPointsToLearn;
				baseToSet = theirSkill.BaseFixedPoint + pointsToLearn;
			}

			if ( pointsToLearn < 0 )
				return TeachResult.KnowsMoreThanMe;

			if ( pointsToLearn == 0 )
				return TeachResult.KnowsWhatIKnow;

			if ( theirSkill.Lock != SkillLock.Up )
				return TeachResult.SkillNotRaisable;

			int freePoints = m.Skills.Cap - m.Skills.Total;
			int freeablePoints = 0;

			if ( freePoints < 0 )
				freePoints = 0;

			for ( int i = 0; (freePoints + freeablePoints) < pointsToLearn && i < m.Skills.Length; ++i )
			{
				Skill sk = m.Skills[i];

				if ( sk == theirSkill || sk.Lock != SkillLock.Down )
					continue;

				freeablePoints += sk.BaseFixedPoint;
			}

			if ( (freePoints + freeablePoints) == 0 )
				return TeachResult.NotEnoughFreePoints;

			if ( (freePoints + freeablePoints) < pointsToLearn )
			{
				pointsToLearn = freePoints + freeablePoints;
				baseToSet = theirSkill.BaseFixedPoint + pointsToLearn;
			}

			if ( doTeach )
			{
				int need = pointsToLearn - freePoints;

				for ( int i = 0; need > 0 && i < m.Skills.Length; ++i )
				{
					Skill sk = m.Skills[i];

					if ( sk == theirSkill || sk.Lock != SkillLock.Down )
						continue;

					if ( sk.BaseFixedPoint < need )
					{
						need -= sk.BaseFixedPoint;
						sk.BaseFixedPoint = 0;
					}
					else
					{
						sk.BaseFixedPoint -= need;
						need = 0;
					}
				}

				/* Sanity check */
				if ( baseToSet > theirSkill.CapFixedPoint || (m.Skills.Total - theirSkill.BaseFixedPoint + baseToSet) > m.Skills.Cap )
					return TeachResult.NotEnoughFreePoints;

				theirSkill.BaseFixedPoint = baseToSet;
			}

			return TeachResult.Success;
		}
Ejemplo n.º 12
0
        public virtual bool OnSellItems(Mobile seller, List<SellItemResponse> list)
        {
            if ( !IsActiveBuyer )
                return false;

            if ( !seller.CheckAlive() )
                return false;

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

            seller.PlaySound( 0x32 );

            IShopSellInfo[] info = GetSellInfo();
            IBuyItemInfo[] buyInfo = this.GetBuyInfo();
            int GiveGold = 0;
            int Sold = 0;
            int Count = 0;
            Container cont;
            ArrayList delete = new ArrayList();
            ArrayList drop = new ArrayList();

            foreach ( SellItemResponse resp in list )
            {
                if ( resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable || (resp.Item is Container && ((Container)resp.Item).Items.Count != 0) )
                    continue;

                foreach( IShopSellInfo ssi in info )
                {
                    if ( ssi.IsSellable( resp.Item ) )
                    {
                        Sold += resp.Amount-1;
                        Sold++;
                        break;
                    }
                }
            }

            if ( Sold > MaxSell )
            {
                SayTo( seller, true, "You may only sell {0} items at a time!", MaxSell );
                return false;
            }
            else if ( Sold == 0 )
            {
                return true;
            }

            //wallet

            /*foreach (SellItemResponse resp in list)
            {
                if (resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable || (resp.Item is Container && ((Container)resp.Item).Items.Count != 0))
                    continue;

                foreach (IShopSellInfo ssi in info)
                {
                    if (ssi.IsSellable(resp.Item))
                    {
                        int amount = resp.Amount;

                        if (amount > resp.Item.Amount)
                            amount = resp.Item.Amount;

                        if (ssi.IsResellable(resp.Item))
                        {

                            GiveGold += ssi.GetSellPriceFor(resp.Item) * amount;
                            break;
                        }
                    }
                }
            }

            if (Wallet < MaxWallet && ((LastWallet + WalletDelay) < DateTime.Now))
            {
                Wallet = MaxWallet;
            }

            if (Wallet < GiveGold)
            {
                Say(true, "I'm sorry but I cannot afford to buy this right now. Please come back again later.");
                //seller.NetState.Send(new EndVendorSell(this));
                return false;
            }
            else if (Wallet > GiveGold)
            {
                LastWallet = DateTime.Now;
                Wallet -= GiveGold;
            }*/

            GiveGold = 0;

            Item LastResp = null;

            foreach (SellItemResponse resp in list)
            {
                if (LastResp != null && resp.Item.GetType() == LastResp.GetType())
                    continue;

                foreach (Item item in BuyPack.Items)
                {
                    LastResp = resp.Item;
                    if (resp.Item.GetType() == item.GetType())
                        Count += item.Amount;
                }
            }

            if ((Sold + Count) > MaxSellAmount)
            {
                Say(true, "I can't afford any more of that right now. You might try other adventurers.");
                return false;
            }

            foreach ( SellItemResponse resp in list )
            {
                if ( resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable || (resp.Item is Container && ((Container)resp.Item).Items.Count != 0) )
                    continue;

                foreach( IShopSellInfo ssi in info )
                {
                    if ( ssi.IsSellable( resp.Item ) )
                    {
                        int amount = resp.Amount;

                        if ( amount > resp.Item.Amount )
                            amount = resp.Item.Amount;

                        if ( ssi.IsResellable( resp.Item ) )
                        {
                            bool found = false;

                            foreach ( IBuyItemInfo bii in buyInfo )
                            {
                                if ( bii.Restock( resp.Item, amount ) )
                                {
                                    resp.Item.Consume( amount );
                                    found = true;

                                    break;
                                }
                            }

                            if ( !found )
                            {
                                cont = this.BuyPack;

                                if ( amount < resp.Item.Amount )
                                {
                                    Item item = Mobile.LiftItemDupe( resp.Item, resp.Item.Amount - amount );

                                    if ( item != null )
                                    {
                                        item.SetLastMoved();
                                        cont.DropItem( item );
                                    }
                                    else
                                    {
                                        resp.Item.SetLastMoved();
                                        cont.DropItem( resp.Item );
                                    }
                                }
                                else
                                {
                                    resp.Item.SetLastMoved();
                                    cont.DropItem( resp.Item );
                                }
                            }
                        }
                        else
                        {
                            if ( amount < resp.Item.Amount )
                                resp.Item.Amount -= amount;
                            else
                                resp.Item.Delete();
                        }

                        GiveGold += ssi.GetSellPriceFor( resp.Item )*amount;
                        break;
                    }
                }
            }

            if ( GiveGold > 0 )
            {
                while ( GiveGold > 60000 )
                {
                    seller.AddToBackpack( new Gold( 60000 ) );
                    GiveGold -= 60000;
                }

                seller.AddToBackpack( new Gold( GiveGold ) );

                seller.PlaySound( 0x0037 );//Gold dropping sound

                if ( SupportsBulkOrders( seller ) )
                {
                    Item bulkOrder = CreateBulkOrder( seller, false );

                    if ( bulkOrder is LargeBOD )
                        seller.SendGump( new LargeBODAcceptGump( seller, (LargeBOD)bulkOrder ) );
                    else if ( bulkOrder is SmallBOD )
                        seller.SendGump( new SmallBODAcceptGump( seller, (SmallBOD)bulkOrder ) );
                }
            }
            //no cliloc for this?
            //SayTo( seller, true, "Thank you! I bought {0} item{1}. Here is your {2}gp.", Sold, (Sold > 1 ? "s" : ""), GiveGold );

            return true;
        }
Ejemplo n.º 13
0
        public void EndClaimList(Mobile from, BaseCreature pet)
        {
            if (pet == null || pet.Deleted || from.Map != this.Map || !from.InRange(this, 14) || !from.Stabled.Contains(pet) || !from.CheckAlive())
                return;

            if ((from.Followers + pet.ControlSlots) <= from.FollowersMax)
            {
                pet.SetControlMaster(from);

                if (pet.Summoned)
                    pet.SummonMaster = from;

                pet.ControlTarget = from;
                pet.ControlOrder = OrderType.Follow;

                pet.MoveToWorld(from.Location, from.Map);

                pet.IsStabled = false;
                from.Stabled.Remove(pet);

                from.SendLocalizedMessage(1042559); // Here you go... and good day to you!
            }
            else
            {
                from.SendLocalizedMessage(1049612, pet.Name); // ~1_NAME~ remained in the stables because you have too many followers.
            }
        }
Ejemplo n.º 14
0
            public override void OnResponse(NetState sender, RelayInfo info)
            {
                if (m_Chest.Deleted || info.ButtonID == 0 || !m_From.CheckAlive())
                {
                    return;
                }

                if (m_From.IsPlayer() && (m_From.Map != m_Chest.Map || !m_From.InRange(m_Chest.GetWorldLocation(), 2)))
                {
                    m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500446); // That is too far away.
                    return;
                }

                if (info.ButtonID == 1)
                {
                    m_Chest.SubmitSolution(m_From, m_Solution);
                }
                else
                {
                    if (info.Switches.Length == 0)
                    {
                        return;
                    }

                    int pedestal = info.Switches[0];
                    if (pedestal < 0 || pedestal >= m_Solution.Cylinders.Length)
                    {
                        return;
                    }

                    PuzzleChestCylinder cylinder;
                    switch (info.ButtonID)
                    {
                    case 10:
                        cylinder = PuzzleChestCylinder.LightBlue;
                        break;

                    case 11:
                        cylinder = PuzzleChestCylinder.Blue;
                        break;

                    case 12:
                        cylinder = PuzzleChestCylinder.Green;
                        break;

                    case 13:
                        cylinder = PuzzleChestCylinder.Orange;
                        break;

                    case 14:
                        cylinder = PuzzleChestCylinder.Purple;
                        break;

                    case 15:
                        cylinder = PuzzleChestCylinder.Red;
                        break;

                    case 16:
                        cylinder = PuzzleChestCylinder.DarkBlue;
                        break;

                    case 17:
                        cylinder = PuzzleChestCylinder.Yellow;
                        break;

                    default:
                        return;
                    }

                    m_Solution.Cylinders[pedestal] = cylinder;

                    m_From.SendGump(new PuzzleGump(m_From, m_Chest, m_Solution, pedestal));
                }
            }
Ejemplo n.º 15
0
        private static void EventSink_OpenDoorMacroUsed(OpenDoorMacroEventArgs args)
        {
            Mobile m = args.Mobile;

            if (m.Map != null)
            {
                int x = m.X, y = m.Y;

                switch (m.Direction & Direction.Mask)
                {
                case Direction.North:
                    --y;
                    break;

                case Direction.Right:
                    ++x;
                    --y;
                    break;

                case Direction.East:
                    ++x;
                    break;

                case Direction.Down:
                    ++x;
                    ++y;
                    break;

                case Direction.South:
                    ++y;
                    break;

                case Direction.Left:
                    --x;
                    ++y;
                    break;

                case Direction.West:
                    --x;
                    break;

                case Direction.Up:
                    --x;
                    --y;
                    break;
                }

                Sector sector = m.Map.GetSector(x, y);

                foreach (Item item in sector.Items)
                {
                    if (item.Location.X == x && item.Location.Y == y && (item.Z + item.ItemData.Height) > m.Z && (m.Z + 16) > item.Z && item is BaseDoor && m.CanSee(item) && m.InLOS(item))
                    {
                        if (m.CheckAlive())
                        {
                            m.SendLocalizedMessage(500024); // Opening door...
                            item.OnDoubleClick(m);
                        }

                        break;
                    }
                }
            }
        }
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            if (ArenaGroupController.GetArenaGroupRegionAtLocation(m_From.Location, m_From.Map) != null)
            {
                m_From.SendMessage("Followers may not be released in that area.");
                return;
            }

            if (m_From.Region is NewbieDungeonRegion)
            {
                m_From.SendMessage("Followers may not be released in that area.");
                return;
            }

            if (info.ButtonID == 2)
            {
                if (!m_Pet.Deleted && m_Pet.Controlled && m_From == m_Pet.ControlMaster && m_From.CheckAlive() /*&& m_Pet.CheckControlChance( m_From )*/)
                {
                    if (m_Pet.Map == m_From.Map && m_Pet.InRange(m_From, 14))
                    {
                        m_Pet.ControlTarget = null;
                        m_Pet.ControlOrder  = OrderType.Release;
                    }
                }
            }
        }
Ejemplo n.º 17
0
 public override void OnClick()
 {
     if (!m_Familiar.Deleted && m_Familiar.Controlled && m_From == m_Familiar.ControlMaster && m_From.CheckAlive())
     {
         m_Familiar.BeginRelease(m_From);
     }
 }
Ejemplo n.º 18
0
                protected override void OnTick()
                {
                    m_Count++;

                    DamageEntry de           = m_Creature.FindMostRecentDamageEntry(false);
                    bool        alreadyOwned = m_Creature.Owners.Contains(m_Tamer);

                    if (!m_Tamer.InRange(m_Creature, 6))
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502795, m_Tamer.NetState);                           // You are too far away to continue taming.
                        Stop();
                    }
                    else if (!m_Tamer.CheckAlive())
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502796, m_Tamer.NetState);                           // You are dead, and cannot continue taming.
                        Stop();
                    }
                    else if (!m_Tamer.CanSee(m_Creature) || !m_Tamer.InLOS(m_Creature))
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049654, m_Tamer.NetState);                           // You do not have a clear path to the animal you are taming, and must cease your attempt.
                        Stop();
                    }
                    else if (!m_Creature.Tamable)
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049655, m_Tamer.NetState);                           // That creature cannot be tamed.
                        Stop();
                    }
                    else if (m_Creature.Controlled)
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502804, m_Tamer.NetState);                           // That animal looks tame already.
                        Stop();
                    }
                    else if (m_Creature.Owners.Count >= BaseCreature.MaxOwners && !m_Creature.Owners.Contains(m_Tamer))
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1005615, m_Tamer.NetState);                           // This animal has had too many owners and is too upset for you to tame.
                        Stop();
                    }
                    else if (MustBeSubdued(m_Creature))
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1054025, m_Tamer.NetState);                           // You must subdue this creature before you can tame it!
                        Stop();
                    }
                    else if (de != null && de.LastDamage > m_StartTime)
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502794, m_Tamer.NetState);                           // The animal is too angry to continue taming.
                        Stop();
                    }
                    else if (m_Count < m_MaxCount)
                    {
                        m_Tamer.RevealingAction();

                        switch (Utility.Random(3))
                        {
                        case 0:
                            m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(502790, 4));
                            break;

                        case 1:
                            m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1005608, 6));
                            break;

                        case 2:
                            m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1010593, 4));
                            break;
                        }

                        if (!alreadyOwned)                           // Passively check animal lore for gain
                        {
                            m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0);
                        }

                        if (m_Creature.Paralyzed)
                        {
                            m_Paralyzed = true;
                        }
                    }
                    else
                    {
                        m_Tamer.RevealingAction();
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_BeingTamed.Remove(m_Creature);

                        if (m_Creature.Paralyzed)
                        {
                            m_Paralyzed = true;
                        }

                        if (!alreadyOwned)                           // Passively check animal lore for gain
                        {
                            m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0);
                        }

                        double minSkill = m_Creature.MinTameSkill + (m_Creature.Owners.Count * 6.0);

                        if (minSkill > -24.9 && CheckMastery(m_Tamer, m_Creature))
                        {
                            minSkill = -24.9;                             // 50% at 0.0?
                        }
                        minSkill += 24.9;

                        if (alreadyOwned || m_Tamer.CheckTargetSkill(SkillName.AnimalTaming, m_Creature, minSkill - 25.0, minSkill + 25.0))
                        {
                            if (m_Creature.Owners.Count == 0)                               // First tame
                            {
                                if (m_Paralyzed)
                                {
                                    ScaleSkills(m_Creature, 0.86);                                       // 86% of original skills if they were paralyzed during the taming
                                }
                                else
                                {
                                    ScaleSkills(m_Creature, 0.90);                                       // 90% of original skills
                                }
                                if (m_Creature.StatLossAfterTame)
                                {
                                    ScaleStats(m_Creature, 0.50);
                                }

                                AdjustSkillCaps(m_Creature);
                            }

                            if (alreadyOwned)
                            {
                                m_Tamer.SendLocalizedMessage(502797);                                   // That wasn't even challenging.
                            }
                            else
                            {
                                m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502799, m_Tamer.NetState);                                   // It seems to accept you as master.
                                m_Creature.Owners.Add(m_Tamer);
                            }

                            m_Creature.SetControlMaster(m_Tamer);
                            m_Creature.IsBonded = false;

                            m_Creature.RemoveOnSave = false;

                            m_Creature.Skills.Cap = 15000;

                            m_Creature.OnTamed(m_Tamer);
                        }
                        else
                        {
                            m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502798, m_Tamer.NetState);                               // You fail to tame the creature.
                        }
                    }
                }
Ejemplo n.º 19
0
 protected override bool IsValidResponse(Mobile from) =>
 m_Contract.IsUsableBy(m_Landlord, true, false, false, false) && from.CheckAlive() && m_Contract.Offeree == from;
Ejemplo n.º 20
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 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.AccessLevel >= AccessLevel.GameMaster || Banker.WithdrawPackAndBank(from, TypeOfCurrency, StablePrice))
				{
					if (from is PlayerMobile)
					{
						((PlayerMobile)from).StablePet(pet, true);
					}

					SayTo(
						from,
						"Very well, thy pet is stabled.  Thou mayst recover it by saying 'claim' to me.  " +
						"Thou mayst pay outstanding charges when thy pet is claimed.");
				}
				else
				{
					SayTo(from, 502677); // But thou hast not the funds in thy bank account!
				}
			}
		}
Ejemplo n.º 21
0
		public virtual void EndRelease( Mobile from )
		{
			if ( from == null || (!Deleted && Controlled && from == ControlMaster && from.CheckAlive()) )
			{
				Effects.SendLocationParticles( EffectItem.Create( Location, Map, EffectItem.DefaultDuration ), 0x3728, 1, 13, 2100, 3, 5042, 0 );
				PlaySound( 0x201 );
				Delete();
			}
		}
Ejemplo n.º 22
0
            public override void OnResponse(NetState sender, RelayInfo info)
            {
                if (m_Panel.Deleted || info.ButtonID == 0 || !m_From.CheckAlive())
                {
                    m_Panel.m_User = null;
                    return;
                }

                if (m_From.Map != m_Panel.Map || !m_From.InRange(m_Panel, 3))
                {
                    m_From.SendLocalizedMessage(500446);                       // That is too far away.
                    m_Panel.m_User = null;
                    return;
                }

                Node nextNode = m_Panel.Path[m_Step + 1];

                if (info.ButtonID == 5)                   // Attempt to Decipher
                {
                    double lockpicking = m_From.Skills.Lockpicking.Value;

                    if (lockpicking < 65.0)
                    {
                        return;
                    }

                    m_From.PlaySound(0x241);

                    if (40.0 + Utility.RandomDouble() * 80.0 < lockpicking)
                    {
                        m_From.SendGump(new GameGump(m_Panel, m_From, m_Step, true));
                        m_Panel.m_LastUse = DateTime.Now;
                    }
                    else
                    {
                        m_Panel.DoDamage(m_From);
                        m_Panel.m_User = null;
                    }
                }
                else
                {
                    Node curNode = m_Panel.Path[m_Step];

                    int newX, newY;
                    switch (info.ButtonID)
                    {
                    case 1:                             // Left
                        newX = curNode.X - 1;
                        newY = curNode.Y;
                        break;

                    case 2:                             // Up
                        newX = curNode.X;
                        newY = curNode.Y - 1;
                        break;

                    case 3:                             // Right
                        newX = curNode.X + 1;
                        newY = curNode.Y;
                        break;

                    case 4:                             // Down
                        newX = curNode.X;
                        newY = curNode.Y + 1;
                        break;

                    default:
                        return;
                    }

                    if (nextNode.X == newX && nextNode.Y == newY)
                    {
                        if (m_Step + 1 == m_Panel.Path.Length - 1)
                        {
                            m_Panel.Solve(m_From);
                            m_Panel.m_User = null;
                        }
                        else
                        {
                            m_From.PlaySound(0x1F4);
                            m_From.SendGump(new GameGump(m_Panel, m_From, m_Step + 1, false));
                            m_Panel.m_LastUse = DateTime.Now;
                        }
                    }
                    else
                    {
                        m_Panel.DoDamage(m_From);
                        m_Panel.m_User = null;
                    }
                }
            }
Ejemplo n.º 23
0
        public void EndStable(Mobile from, BaseCreature pet)
        {
            if (this.Deleted || !from.CheckAlive())
                return;

            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 is PackLlama || pet is PackHorse || pet is Beetle) && (pet.Backpack != null && pet.Backpack.Items.Count > 0))
            {
                from.SendLocalizedMessage(1042563); // You need to unload your pet.
            }
            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(1042565); // You have too many pets in the stables!
            }
            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);

                    this.UsesRemaining -= 1;

                    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!
                }
            }
        }
Ejemplo n.º 24
0
        public void EndStable(Mobile from, BaseCreature pet)
        {
            if (Deleted || !from.CheckAlive() || !CanUse() || !CheckAccess(from))
            {
                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 (GetCount() >= MaxStables)
            {
                from.SendLocalizedMessage(1114325); // There is no more room in your chicken coop!
            }
            else
            {
                pet.ControlTarget = null;
                pet.ControlOrder  = OrderType.Stay;
                pet.Internalize();

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

                pet.IsStabled = true;

                pet.Loyalty = BaseCreature.MaxLoyalty; // Wonderfully happy

                if (!m_Stored.ContainsKey(from))
                {
                    m_Stored.Add(from, new List <BaseCreature>());
                }

                if (!m_Stored[from].Contains(pet))
                {
                    m_Stored[from].Add(pet);
                }

                from.SendMessage("Your chicken has been stabled.");
            }
        }
Ejemplo n.º 25
0
        public void Claim(Mobile from, string petName)
        {
            if (Deleted || !from.CheckAlive())
            {
                return;
            }

            var claimed = false;
            var stabled = 0;

            var claimByName = (petName != null);

            for (var i = 0; i < from.Stabled.Count; ++i)
            {
                var pet = from.Stabled[i] as BaseCreature;

                if (pet == null || pet.Deleted)
                {
                    if (pet != null)
                    {
                        pet.IsStabled = false;
                        pet.StabledBy = null;
                    }

                    from.Stabled.RemoveAt(i--);
                    continue;
                }

                ++stabled;

                if (claimByName && !Insensitive.Equals(pet.Name, petName))
                {
                    continue;
                }

                if (CanClaim(from, pet))
                {
                    DoClaim(from, pet);

                    from.Stabled.RemoveAt(i);

                    if (from is PlayerMobile)
                    {
                        ((PlayerMobile)from).AutoStabled.Remove(pet);
                    }

                    --i;

                    claimed = true;
                }
                else
                {
                    SayTo(from, 1049612, pet.Name);                     // ~1_NAME~ remained in the stables because you have too many followers.
                }
            }

            if (claimed)
            {
                SayTo(from, 1042559);                 // Here you go... and good day to you!
            }
            else if (stabled == 0)
            {
                SayTo(from, 502671);                 // But I have no animals stabled with me at the moment!
            }
            else if (claimByName)
            {
                BeginClaimList(from);
            }
        }
Ejemplo n.º 26
0
        public void Claim(Mobile from)
        {
            if (Deleted || !from.CheckAlive() || !m_Stored.ContainsKey(from))
            {
                return;
            }

            bool claimed      = false;
            int  stabledCount = 0;

            List <BaseCreature> stabled = m_Stored[from];

            for (int i = 0; i < stabled.Count; ++i)
            {
                BaseCreature pet = stabled[i] as BaseCreature;

                if (pet == null || pet.Deleted)
                {
                    pet.IsStabled = false;
                    stabled.RemoveAt(i);
                    --i;
                    continue;
                }

                ++stabledCount;

                if ((from.Followers + pet.ControlSlots) <= from.FollowersMax)
                {
                    pet.SetControlMaster(from);

                    if (pet.Summoned)
                    {
                        pet.SummonMaster = from;
                    }

                    pet.ControlTarget = from;
                    pet.ControlOrder  = OrderType.Follow;

                    pet.MoveToWorld(from.Location, from.Map);

                    pet.IsStabled = false;

                    pet.Loyalty = BaseCreature.MaxLoyalty; // Wonderfully Happy

                    stabled.RemoveAt(i);
                    --i;

                    claimed = true;
                }
                else
                {
                    from.SendLocalizedMessage(1049612, pet.Name); // ~1_NAME~ remained in the stables because you have too many followers.
                }
            }

            if (claimed)
            {
                from.SendLocalizedMessage(1042559); // Here you go... and good day to you!
            }

            else if (stabledCount == 0)
            {
                from.SendLocalizedMessage(502671); // But I have no animals stabled with me at the moment!
            }
        }
Ejemplo n.º 27
0
        public virtual void VendorSell(Mobile from)
        {
            if (!IsActiveBuyer)
                return;

            if (!from.CheckAlive())
                return;

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

			Container cont = this.BuyPack;
			ArrayList playerItems = cont.Items;
			ArrayList deleteItems = new ArrayList();

            for (int i = playerItems.Count - 1; i >= 0; --i)
            {
                Item item = (Item)playerItems[i];

                if ((item.LastMoved + InventoryDecayTime) <= DateTime.Now)
                    deleteItems.Add( playerItems[i] );
            }

            for (int i = deleteItems.Count - 1; i >= 0; --i)
            {
				Item item = (Item)deleteItems[i];
				item.Delete();
			}

            if (DateTime.Now - m_LastRestock > RestockDelay)
                Restock();

			if ( playerItems.Count > InventoryBuyPackLimit )
			{
				Say( true, "I cannot purchase more at this time." );
				return;
			}

            Container pack = from.Backpack;

            if (pack != null)
            {
                IShopSellInfo[] info = GetSellInfo();

                Hashtable table = new Hashtable();

                foreach (IShopSellInfo ssi in info)
                {
                    Item[] items = pack.FindItemsByType(ssi.Types);

                    foreach (Item item in items)
                    {
                        if (item is Container && ((Container)item).Items.Count != 0)
                            continue;

                        if (item.IsStandardLoot() && item.Movable && ssi.IsSellable(item))
                            table[item] = new SellItemState(item, ssi.GetSellPriceFor(item), ssi.GetNameFor(item));
                    }
                }

                if (table.Count > 0)
                {
                    SendPacksTo(from);

                    from.Send(new VendorSellList(this, table));
                }
                else
                {
                    Say(true, "You have nothing I would be interested in.");
                }
            }
        }
Ejemplo n.º 28
0
        public void Claim(Mobile from, String petName)
        {
            if (Deleted || !from.CheckAlive())
            {
                return;
            }

            bool claimed = false;
            int  stabled = 0;

            bool claimByName = (petName != null);

            for (int i = 0; i < from.Stabled.Count; ++i)
            {
                BaseCreature pet = from.Stabled[i] as BaseCreature;

                if (pet == null || pet.Deleted)
                {
                    pet.IsStabled = false;
                    from.Stabled.RemoveAt(i);
                    --i;
                    continue;
                }

                ++stabled;

                if (claimByName && !Insensitive.Equals(pet.Name, petName))
                {
                    continue;
                }

                if ((from.Followers + pet.ControlSlots) <= from.FollowersMax)
                {
                    pet.SetControlMaster(from);

                    if (pet.Summoned)
                    {
                        pet.SummonMaster = from;
                    }

                    pet.ControlTarget = from;
                    pet.ControlOrder  = OrderType.Follow;

                    pet.MoveToWorld(from.Location, from.Map);

                    pet.IsStabled = false;

                    if (Core.SE)
                    {
                        pet.Loyalty = BaseCreature.MaxLoyalty;                         // Wonderfully Happy
                    }
                    from.Stabled.RemoveAt(i);
                    --i;

                    claimed = true;
                }
                else
                {
                    SayTo(from, 1049612, pet.Name);                       // ~1_NAME~ remained in the stables because you have too many followers.
                }
            }

            if (claimed)
            {
                SayTo(from, true, "Here you go... and good day to you!"); // Here you go... and good day to you!
            }
            else if (stabled == 0)
            {
                SayTo(from, true, "But I have no animals stabled with me at the moment!"); // But I have no animals stabled with me at the moment!
            }
            else if (claimByName)
            {
                BeginClaimList(from);
            }
        }
Ejemplo n.º 29
0
		public virtual void EndPickTarget(Mobile from, Mobile target, OrderType order)
		{
			if (m_Mobile.Deleted || !m_Mobile.Controlled || !from.InRange(m_Mobile, 14) || from.Map != m_Mobile.Map ||
				!from.CheckAlive())
			{
				return;
			}

			bool isOwner = (from == m_Mobile.ControlMaster);
			bool isFriend = (!isOwner && m_Mobile.IsPetFriend(from));

			if (!isOwner && !isFriend)
			{
				return;
			}
			else if (isFriend && order != OrderType.Follow && order != OrderType.Stay && order != OrderType.Stop)
			{
				return;
			}

			if (order == OrderType.Attack)
			{
				if (target is BaseCreature && ((BaseCreature)target).IsScaryToPets && m_Mobile.IsScaredOfScaryThings)
				{
					m_Mobile.SayTo(from, "Your pet refuses to attack this creature!");
					return;
				}

				if ((SolenHelper.CheckRedFriendship(from) &&
					 (target is RedSolenInfiltratorQueen || target is RedSolenInfiltratorWarrior || target is RedSolenQueen ||
					  target is RedSolenWarrior || target is RedSolenWorker)) ||
					(SolenHelper.CheckBlackFriendship(from) &&
					 (target is BlackSolenInfiltratorQueen || target is BlackSolenInfiltratorWarrior || target is BlackSolenQueen ||
					  target is BlackSolenWarrior || target is BlackSolenWorker)))
				{
					from.SendAsciiMessage("You can not force your pet to attack a creature you are protected from.");
					return;
				}

				if (target is BaseFactionGuard)
				{
					m_Mobile.SayTo(from, "Your pet refuses to attack the guard.");
					return;
				}
			}

			if (m_Mobile.CheckControlChance(from))
			{
				m_Mobile.ControlTarget = target;
				m_Mobile.ControlOrder = order;
			}
		}
Ejemplo n.º 30
0
        public void EndClaimList(Mobile from, BaseCreature pet)
        {
            if (pet == null || pet.Deleted || from.Map != this.Map || !from.InRange(this, 14) || !from.Stabled.Contains(pet) || !from.CheckAlive())
            {
                return;
            }

            if ((from.Followers + pet.ControlSlots) <= from.FollowersMax)
            {
                pet.SetControlMaster(from);

                if (pet.Summoned)
                {
                    pet.SummonMaster = from;
                }

                pet.ControlTarget = from;
                pet.ControlOrder  = OrderType.Follow;

                pet.MoveToWorld(from.Location, from.Map);

                pet.IsStabled = false;
                from.Stabled.Remove(pet);

                from.SendLocalizedMessage(1042559);                   // Here you go... and good day to you!
            }
            else
            {
                from.SendLocalizedMessage(1049612, pet.Name);                   // ~1_NAME~ remained in the stables because you have too many followers.
            }
        }
Ejemplo n.º 31
0
		public virtual bool OnBuyItems( Mobile buyer, List<BuyItemResponse> list )
		{
			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();

			IBuyItemInfo[] buyInfo = this.GetBuyInfo();
			IShopSellInfo[] info = GetSellInfo();
			int totalCost = 0;
			List<BuyItemResponse> validBuy = new List<BuyItemResponse>( list.Count );
			Container cont;
			bool bought = false;
			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 != this.BuyPack && item.IsChildOf( this.BuyPack ) )
					{
						if ( amount > item.Amount )
							amount = item.Amount;

						if ( amount <= 0 )
							continue;

						foreach ( IShopSellInfo ssi in info )
						{
							if ( ssi.IsSellable( item ) )
							{
								if ( 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 );
				}
			}//foreach

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

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

			bought = ( buyer.AccessLevel >= AccessLevel.GameMaster );

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

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

			if ( !bought )
				return false;
			else
				buyer.PlaySound( 0x32 );

			cont = buyer.Backpack;
			if ( cont == null )
				cont = 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;

						foreach ( IShopSellInfo ssi in info )
						{
							if ( ssi.IsSellable( item ) )
							{
								if ( ssi.IsResellable( item ) )
								{
									Item buyItem;
									if ( amount >= item.Amount )
									{
										buyItem = item;
									}
									else
									{
										buyItem = Mobile.LiftItemDupe( item, item.Amount - amount );

										if ( buyItem == null )
											buyItem = item;
									}

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

									break;
								}
							}
						}
					}
				}
				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 );
				}
			}//foreach

			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} gold, which has been withdrawn from your bank account.  My thanks for the patronage.", totalCost );
				else
					SayTo( buyer, true, "The total of thy purchase is {0} gold.  My thanks for the patronage.", totalCost );
			}
			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} gold, 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 );
				else
					SayTo( buyer, true, "The total of thy purchase is {0} gold.  My thanks for the patronage.  Unfortunately, I could not sell you all the goods you requested.", totalCost );
			}

			return true;
		}
Ejemplo n.º 32
0
        public void Claim(Mobile from)
        {
            if (m_UsesRemaining <= 0)
            {
                from.SendLocalizedMessage(1071151);                   // Hitching rope is insufficient. You have to supply it.
            }
            else
            {
                if (Deleted || !from.CheckAlive())
                {
                    return;
                }

                bool claimed = false;
                int  stabled = 0;

                for (int i = 0; i < from.Stabled.Count; ++i)
                {
                    BaseCreature pet = from.Stabled[i] as BaseCreature;

                    if (pet == null || pet.Deleted)
                    {
                        pet.IsStabled = false;
                        from.Stabled.RemoveAt(i);
                        --i;
                        continue;
                    }

                    ++stabled;

                    if ((from.Followers + pet.ControlSlots) <= from.FollowersMax)
                    {
                        pet.SetControlMaster(from);

                        if (pet.Summoned)
                        {
                            pet.SummonMaster = from;
                        }

                        pet.ControlTarget = from;
                        pet.ControlOrder  = OrderType.Follow;

                        pet.MoveToWorld(from.Location, from.Map);

                        pet.IsStabled = false;
                        pet.Loyalty   = PetLoyalty.WonderfullyHappy;                       // Wonderfully Happy

                        from.Stabled.RemoveAt(i);
                        --i;

                        claimed = true;
                    }
                    else
                    {
                        from.SendLocalizedMessage(1049612, pet.Name);                           // ~1_NAME~ remained in the stables because you have too many followers.
                    }
                }

                if (claimed)
                {
                    from.SendLocalizedMessage(1042559);                       // Here you go... and good day to you!
                    UsesRemaining -= 1;
                }

                else if (stabled == 0)
                {
                    from.SendLocalizedMessage(502671);                       // But I have no animals stabled with me at the moment!
                }
            }
        }
Ejemplo n.º 33
0
		public void BeginClaimList(Mobile from)
		{
			if (Deleted || !from.CheckAlive())
			{
				return;
			}

			var list = new List<BaseCreature>();

			for (int i = 0; i < from.Stabled.Count; ++i)
			{
				var pet = from.Stabled[i] as BaseCreature;

				if (pet == null || pet.Deleted)
				{
					if (pet != null)
					{
						pet.IsStabled = false;
					}

					from.Stabled.RemoveAt(i);
					--i;
					continue;
				}

				list.Add(pet);
			}

			if (list.Count > 0)
			{
				from.SendGump(new ClaimListGump(this, from, list));
			}
			else
			{
				SayTo(from, 502671); // But I have no animals stabled with me at the moment!
			}
		}
Ejemplo n.º 34
0
                protected override void OnTick()
                {
                    m_Count++;

                    DamageEntry de           = m_Creature.FindMostRecentDamageEntry(false);
                    bool        alreadyOwned = m_Creature.Owners.Contains(m_Tamer);

                    if (!m_Tamer.InRange(m_Creature, Core.AOS ? 7 : 6))
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502795, m_Tamer.NetState);
                        // You are too far away to continue taming.
                        Stop();
                    }
                    else if (!m_Tamer.CheckAlive())
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502796, m_Tamer.NetState);
                        // You are dead, and cannot continue taming.
                        Stop();
                    }
                    else if (!m_Tamer.CanSee(m_Creature) || !m_Tamer.InLOS(m_Creature) || !CanPath())
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Tamer.SendLocalizedMessage(1049654);
                        // You do not have a clear path to the animal you are taming, and must cease your attempt.
                        Stop();
                    }
                    else if (!m_Creature.Tamable)
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049655, m_Tamer.NetState);
                        // That creature cannot be tamed.
                        Stop();
                    }
                    else if (m_Creature.Controlled)
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502804, m_Tamer.NetState);
                        // That animal looks tame already.
                        Stop();
                    }
                    else if (m_Creature.Owners.Count >= BaseCreature.MaxOwners && !m_Creature.Owners.Contains(m_Tamer))
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1005615, m_Tamer.NetState);
                        // This animal has had too many owners and is too upset for you to tame.
                        Stop();
                    }
                    else if (MustBeSubdued(m_Creature))
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1054025, m_Tamer.NetState);
                        // You must subdue this creature before you can tame it!
                        Stop();
                    }
                    else if (de != null && de.LastDamage > m_StartTime)
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502794, m_Tamer.NetState);
                        // The animal is too angry to continue taming.
                        Stop();
                    }
                    else if (m_Count < m_MaxCount)
                    {
                        m_Tamer.RevealingAction();

                        switch (Utility.Random(3))
                        {
                        case 0:
                            m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(502790, 4));
                            break;

                        case 1:
                            m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1005608, 6));
                            break;

                        case 2:
                            m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1010593, 4));
                            break;
                        }

                        if (!alreadyOwned) // Passively check animal lore for gain
                        {
                            m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0);
                        }

                        if (m_Creature.Paralyzed)
                        {
                            m_Paralyzed = true;
                        }
                    }
                    else
                    {
                        m_Tamer.RevealingAction();
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_BeingTamed.Remove(m_Creature);

                        if (m_Creature.Paralyzed)
                        {
                            m_Paralyzed = true;
                        }

                        if (!alreadyOwned) // Passively check animal lore for gain
                        {
                            m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0);
                        }

                        double minSkill     = m_Creature.CurrentTameSkill + (m_Creature.Owners.Count * 6.0);
                        bool   necroMastery = DarkWolfFamiliar.CheckMastery(m_Tamer, m_Creature);

                        if (minSkill > -24.9 && necroMastery)
                        {
                            minSkill = -24.9; // 50% at 0.0?
                        }

                        minSkill += 24.9;

                        if (necroMastery || alreadyOwned ||
                            m_Tamer.CheckTargetSkill(SkillName.AnimalTaming, m_Creature, minSkill - 25.0, minSkill + 25.0))
                        {
                            if (m_Creature.Owners.Count == 0) // First tame
                            {
                                if (m_Creature is GreaterDragon)
                                {
                                    ScaleSkills(m_Creature, 0.72, 0.90, true); // 72% of original skills trainable to 90%
                                    m_Creature.Skills[SkillName.Magery].Base = m_Creature.Skills[SkillName.Magery].Cap;
                                    // Greater dragons have a 90% cap reduction and 90% skill reduction on magery
                                }
                                else if (m_Paralyzed)
                                {
                                    ScaleSkills(m_Creature, 0.86, true); // 86% of original skills if they were paralyzed during the taming
                                }
                                else
                                {
                                    ScaleSkills(m_Creature, 0.90, true); // 90% of original skills
                                }
                            }
                            else
                            {
                                ScaleSkills(m_Creature, 0.90, false); // 90% of original skills
                            }

                            if (alreadyOwned)
                            {
                                m_Tamer.SendLocalizedMessage(502797); // That wasn't even challenging.
                            }
                            else
                            {
                                m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502799, m_Tamer.NetState);
                                // It seems to accept you as master.
                            }

                            m_Creature.SetControlMaster(m_Tamer);
                            m_Creature.IsBonded = false;

                            m_Creature.OnAfterTame(m_Tamer);

                            if (!m_Creature.Owners.Contains(m_Tamer))
                            {
                                m_Creature.Owners.Add(m_Tamer);
                            }

                            PetTrainingHelper.GetAbilityProfile(m_Creature, true).OnTame();

                            EventSink.InvokeTameCreature(new TameCreatureEventArgs(m_Tamer, m_Creature));
                        }
                        else
                        {
                            m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502798, m_Tamer.NetState);
                            // You fail to tame the creature.
                        }
                    }
                }
Ejemplo n.º 35
0
		public void BeginStable(Mobile from)
		{
			if (Deleted || !from.CheckAlive())
			{
				return;
			}

			Item[] currency;
			BankCheck[] checks;
			ulong credit;

			if ((from.Backpack == null || from.Backpack.GetAmount(TypeOfCurrency, true) < StablePrice) &&
				Banker.GetBalance(from, TypeOfCurrency, out currency, out checks, out credit) < (ulong)StablePrice)
			{
				SayTo(from, "Thou dost not have enough {0}, not even in thy bank account.", TypeOfCurrency.Name);
			}
			else
			{
				if (from.AccessLevel >= AccessLevel.GameMaster)
				{
					from.SendMessage("Which animal wouldst thou like to stable here?");
				}
				else
				{
					SayTo(
						from,
						"I charge {0} {1} per pet for up to a real week's stable time. " +
						"Thou mayst pay outstanding charges upon claim. Which animal wouldst thou like to stable here?",
						StablePrice,
						TypeOfCurrency.Name);
				}

				from.Target = new StableTarget(this);
			}
		}
Ejemplo n.º 36
0
            public override void OnClick()
            {
                Mobile from = Owner.From;

                if (!m_Obsidian.Deleted && m_Obsidian.Quantity >= Obsidian.m_Partial && m_Obsidian.Quantity < Obsidian.m_Completed && m_Obsidian.IsChildOf(from.Backpack) && from.CheckAlive())
                {
                    for (int i = 0; i < m_Obsidian.Quantity - 1; i++)
                    {
                        from.AddToBackpack(new Obsidian());
                    }

                    m_Obsidian.Quantity = 1;
                }
            }
Ejemplo n.º 37
0
		public void Claim(Mobile from, string petName)
		{
			if (Deleted || !from.CheckAlive())
			{
				return;
			}

			bool claimed = false;
			int stabled = 0;

			bool claimByName = petName != null;

			for (int i = 0; i < from.Stabled.Count; ++i)
			{
				var pet = from.Stabled[i] as BaseCreature;

				if (pet == null || pet.Deleted)
				{
					if (pet != null)
					{
						pet.IsStabled = false;
					}

					from.Stabled.RemoveAt(i);
					--i;
					continue;
				}

				++stabled;

				if (claimByName && !Insensitive.Equals(pet.Name, petName))
				{
					continue;
				}

				if (CanClaim(from, pet))
				{
					int totalClaim = StablePrice * ((DateTime.UtcNow - pet.StabledDate).Days / ChargeFrequency);

					if (totalClaim <= 0 || from.AccessLevel >= AccessLevel.GameMaster ||
						Banker.WithdrawPackAndBank(from, TypeOfCurrency, totalClaim))
					{
						DoClaim(from, pet);
						from.Stabled.RemoveAt(i--);

						if (from is PlayerMobile)
						{
							((PlayerMobile)from).AutoStabled.Remove(pet);
						}

						claimed = true;
					}
					else
					{
						SayTo(from, "{0} remained in the stables because you require {0} {1}.", pet.Name, totalClaim, TypeOfCurrency.Name);
					}
				}
				else
				{
					SayTo(from, 1049612, pet.Name); // ~1_NAME~ remained in the stables because you have too many followers.
				}
			}

			if (claimed)
			{
				SayTo(from, 1042559); // Here you go... and good day to you!
			}
			else if (stabled == 0)
			{
				SayTo(from, 502671); // But I have no animals stabled with me at the moment!
			}
			else if (claimByName)
			{
				BeginClaimList(from);
			}
		}
Ejemplo n.º 38
0
            public override void OnClick()
            {
                Mobile from = this.Owner.From;

                if (m_Sign.Deleted || m_Sign.Owner == null || m_Sign.Owner.VendorInventories.Count == 0 || !from.CheckAlive())
                {
                    return;
                }

                if (from.Map != m_Sign.Map || !from.InRange(m_Sign, 5))
                {
                    from.SendLocalizedMessage(1062429);                       // You must be within five paces of the house sign to use this option.
                }
                else
                {
                    from.CloseGump(typeof(VendorInventoryGump));
                    from.SendGump(new VendorInventoryGump(m_Sign.Owner, from));
                }
            }
Ejemplo n.º 39
0
        public void BeginClaimList(Mobile from)
        {
            if (this.Deleted || !from.CheckAlive())
                return;

            if (this.UsesRemaining <= 0 && this.Charges >= 1)
                from.SendLocalizedMessage(1071151); //Hitching rope is insufficient. You have to supply it.
            else if (this.UsesRemaining <= 0 && this.Charges == 0)
                from.SendLocalizedMessage(1071157); //This hitching post is damaged. You can't use it any longer.
            else
            {
                List<BaseCreature> list = new List<BaseCreature>();

                for (int i = 0; i < from.Stabled.Count; ++i)
                {
                    BaseCreature pet = from.Stabled[i] as BaseCreature;

                    if (pet == null || pet.Deleted)
                    {
                        pet.IsStabled = false;
                        from.Stabled.RemoveAt(i);
                        --i;
                        continue;
                    }

                    list.Add(pet);
                }

                if (list.Count > 0)
                    from.SendGump(new ClaimListGump(this, from, list));
                else
                    from.SendLocalizedMessage(502671); // But I have no animals stabled with me at the moment!
            }
        }
Ejemplo n.º 40
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 is PackHorse || pet is Scarabee) && (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;

                    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!
                }
            }
        }
Ejemplo n.º 41
0
        public void BeginStable(Mobile from)
        {
            if (this.Deleted || !from.CheckAlive())
                return;

            if (this.UsesRemaining <= 0 && this.Charges >= 1)
                from.SendLocalizedMessage(1071151); //Hitching rope is insufficient. You have to supply it.
            else if (this.UsesRemaining <= 0 && this.Charges == 0)
                from.SendLocalizedMessage(1071157); //This hitching post is damaged. You can't use it any longer.
            else if (from.Stabled.Count >= GetMaxStabled(from))
            {
                from.SendLocalizedMessage(1042565); // You have too many pets in the stables!
            }
            else
            {
                from.SendLocalizedMessage(1042558); /* 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.Target = new StableTarget(this);
            }
        }
Ejemplo n.º 42
0
        public virtual bool OnSellItems(Mobile seller, ArrayList list)
        {
            if (!IsActiveBuyer)
            {
                return(false);
            }

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

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

            seller.PlaySound(0x32);

            IShopSellInfo[] info     = GetSellInfo();
            IBuyItemInfo[]  buyInfo  = this.GetBuyInfo();
            int             GiveGold = 0;
            int             Sold     = 0;
            Container       cont;
            ArrayList       delete = new ArrayList();
            ArrayList       drop   = new ArrayList();

            foreach (SellItemResponse resp in list)
            {
                if (resp.Item.RootParent != seller || resp.Amount <= 0)
                {
                    continue;
                }

                foreach (IShopSellInfo ssi in info)
                {
                    if (ssi.IsSellable(resp.Item))
                    {
                        Sold++;
                        break;
                    }
                }
            }

            if (Sold > MaxSell)
            {
                SayTo(seller, true, "You may only sell {0} items at a time!", MaxSell);
                return(false);
            }
            else if (Sold == 0)
            {
                return(true);
            }

            foreach (SellItemResponse resp in list)
            {
                if (resp.Item.RootParent != seller || resp.Amount <= 0)
                {
                    continue;
                }

                foreach (IShopSellInfo ssi in info)
                {
                    if (ssi.IsSellable(resp.Item))
                    {
                        int amount = resp.Amount;

                        if (amount > resp.Item.Amount)
                        {
                            amount = resp.Item.Amount;
                        }

                        if (ssi.IsResellable(resp.Item))
                        {
                            bool found = false;

                            foreach (IBuyItemInfo bii in buyInfo)
                            {
                                if (bii.Restock(resp.Item, amount))
                                {
                                    resp.Item.Consume(amount);
                                    found = true;

                                    break;
                                }
                            }

                            if (!found)
                            {
                                cont = this.BuyPack;

                                if (amount < resp.Item.Amount)
                                {
                                    resp.Item.Amount -= amount;
                                    Item item = resp.Item.Dupe(amount);
                                    item.SetLastMoved();
                                    cont.DropItem(item);
                                }
                                else
                                {
                                    resp.Item.SetLastMoved();
                                    cont.DropItem(resp.Item);
                                }
                            }
                        }
                        else
                        {
                            if (amount < resp.Item.Amount)
                            {
                                resp.Item.Amount -= amount;
                            }
                            else
                            {
                                resp.Item.Delete();
                            }
                        }

                        GiveGold += ssi.GetSellPriceFor(resp.Item) * amount;
                        break;
                    }
                }
            }

            if (GiveGold > 0)
            {
                while (GiveGold > 60000)
                {
                    seller.AddToBackpack(new Gold(60000));
                    GiveGold -= 60000;
                }

                seller.AddToBackpack(new Gold(GiveGold));

                seller.PlaySound(0x0037);                  //Gold dropping sound

                if (SupportsBulkOrders(seller))
                {
                    Item bulkOrder = CreateBulkOrder(seller, false);

                    if (bulkOrder is LargeBOD)
                    {
                        seller.SendGump(new LargeBODAcceptGump(seller, (LargeBOD)bulkOrder));
                    }
                    else if (bulkOrder is SmallBOD)
                    {
                        seller.SendGump(new SmallBODAcceptGump(seller, (SmallBOD)bulkOrder));
                    }
                }
            }
            //no cliloc for this?
            //SayTo( seller, true, "Thank you! I bought {0} item{1}. Here is your {2}gp.", Sold, (Sold > 1 ? "s" : ""), GiveGold );

            return(true);
        }
Ejemplo n.º 43
0
        public void Claim(Mobile from)
        {
            if (this.m_UsesRemaining <= 0 && this.m_Charges >= 1)
                from.SendLocalizedMessage(1071151); //Hitching rope is insufficient. You have to supply it.
            else if (this.m_UsesRemaining <= 0 && this.m_Charges == 0)
                from.SendLocalizedMessage(1071157); //This hitching post is damaged. You can't use it any longer.
            else
            {
                if (this.Deleted || !from.CheckAlive())
                    return;

                bool claimed = false;
                int stabled = 0;

                for (int i = 0; i < from.Stabled.Count; ++i)
                {
                    BaseCreature pet = from.Stabled[i] as BaseCreature;

                    if (pet == null || pet.Deleted)
                    {
                        pet.IsStabled = false;
                        from.Stabled.RemoveAt(i);
                        --i;
                        continue;
                    }

                    ++stabled;

                    if ((from.Followers + pet.ControlSlots) <= from.FollowersMax)
                    {
                        pet.SetControlMaster(from);

                        if (pet.Summoned)
                            pet.SummonMaster = from;

                        pet.ControlTarget = from;
                        pet.ControlOrder = OrderType.Follow;

                        pet.MoveToWorld(from.Location, from.Map);

                        pet.IsStabled = false;

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

                        from.Stabled.RemoveAt(i);
                        --i;

                        claimed = true;
                    }
                    else
                    {
                        from.SendLocalizedMessage(1049612, pet.Name); // ~1_NAME~ remained in the stables because you have too many followers.
                    }
                }

                if (claimed)
                {
                    from.SendLocalizedMessage(1042559); // Here you go... and good day to you!
                    this.UsesRemaining -= 1;
                }
                else if (stabled == 0)
                    from.SendLocalizedMessage(502671); // But I have no animals stabled with me at the moment!
            }
        }
Ejemplo n.º 44
0
        public virtual void VendorBuy(Mobile from)
        {
            if (!IsActiveSeller)
            {
                return;
            }

            if (!from.CheckAlive())
            {
                return;
            }

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

            if (DateTime.Now - m_LastRestock > RestockDelay)
            {
                Restock();
            }

            UpdateBuyInfo();

            int       count = 0;
            ArrayList list;

            IBuyItemInfo[]  buyInfo  = this.GetBuyInfo();
            IShopSellInfo[] sellInfo = this.GetSellInfo();

            list = new ArrayList(buyInfo.Length);
            Container cont = this.BuyPack;

            ArrayList opls = new ArrayList();

            for (int idx = 0; idx < buyInfo.Length; idx++)
            {
                IBuyItemInfo buyItem = (IBuyItemInfo)buyInfo[idx];

                if (buyItem.Amount <= 0 || list.Count >= 250)
                {
                    continue;
                }

                // NOTE: Only GBI supported; if you use another implementation of IBuyItemInfo, this will crash
                GenericBuyInfo gbi  = (GenericBuyInfo)buyItem;
                IEntity        disp = gbi.GetDisplayObject() as IEntity;

                list.Add(new BuyItemState(buyItem.Name, cont.Serial, disp == null ? (Serial)0x7FC0FFEE : disp.Serial, buyItem.Price, buyItem.Amount, buyItem.ItemID, buyItem.Hue));
                count++;

                if (disp is Item)
                {
                    opls.Add((disp as Item).PropertyList);
                }
                else if (disp is Mobile)
                {
                    opls.Add((disp as Mobile).PropertyList);
                }
            }

            ArrayList playerItems = cont.Items;

            for (int i = playerItems.Count - 1; i >= 0; --i)
            {
                if (i >= playerItems.Count)
                {
                    continue;
                }

                Item item = (Item)playerItems[i];

                if ((item.LastMoved + InventoryDecayTime) <= DateTime.Now)
                {
                    item.Delete();
                }
            }

            for (int i = 0; i < playerItems.Count; ++i)
            {
                Item item = (Item)playerItems[i];

                int    price = 0;
                string name  = null;

                foreach (IShopSellInfo ssi in sellInfo)
                {
                    if (ssi.IsSellable(item))
                    {
                        price = ssi.GetBuyPriceFor(item);
                        name  = ssi.GetNameFor(item);
                        break;
                    }
                }

                if (name != null && list.Count < 250)
                {
                    list.Add(new BuyItemState(name, cont.Serial, item.Serial, price, item.Amount, item.ItemID, item.Hue));
                    count++;

                    opls.Add(item.PropertyList);
                }
            }

            //one (not all) of the packets uses a byte to describe number of items in the list.  Osi = dumb.
            //if ( list.Count > 255 )
            //	Console.WriteLine( "Vendor Warning: Vendor {0} has more than 255 buy items, may cause client errors!", this );

            if (list.Count > 0)
            {
                list.Sort(new BuyItemStateComparer());

                SendPacksTo(from);

                from.Send(new VendorBuyContent(list));
                from.Send(new VendorBuyList(this, list));
                from.Send(new DisplayBuyList(this));
                from.Send(new MobileStatusExtended(from));                    //make sure their gold amount is sent

                for (int i = 0; i < opls.Count; ++i)
                {
                    from.Send(opls[i] as Packet);
                }

                SayTo(from, 500186);                   // Greetings.  Have a look around.
            }
        }
Ejemplo n.º 45
0
			public override void OnResponse(Mobile from, string text)
			{
				if (text.Length > 40)
				{
					text = text.Substring(0, 40);
				}

				if (!from.CheckAlive() || !m_Book.IsChildOf(from.Backpack))
				{
					return;
				}

				m_Book.Name = Utility.FixHtml(text.Trim());

				from.SendMessage("This TMap Book name has been changed");
			}
Ejemplo n.º 46
0
        public virtual bool OnBuyItems(Mobile buyer, ArrayList list)
        {
            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();

            IBuyItemInfo[]  buyInfo   = this.GetBuyInfo();
            IShopSellInfo[] info      = GetSellInfo();
            int             totalCost = 0;
            ArrayList       validBuy  = new ArrayList(list.Count);
            Container       cont;
            bool            bought       = false;
            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.RootParent == this)
                    {
                        if (amount > item.Amount)
                        {
                            amount = item.Amount;
                        }

                        if (amount <= 0)
                        {
                            continue;
                        }

                        foreach (IShopSellInfo ssi in info)
                        {
                            if (ssi.IsSellable(item))
                            {
                                if (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);
                    }
                }
            }            //foreach

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

            bought = (buyer.AccessLevel >= AccessLevel.GameMaster);

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

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

            if (!bought)
            {
                return(false);
            }
            else
            {
                buyer.PlaySound(0x32);
            }

            cont = buyer.Backpack;
            if (cont == null)
            {
                cont = 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;
                        }

                        foreach (IShopSellInfo ssi in info)
                        {
                            if (ssi.IsSellable(item))
                            {
                                if (ssi.IsResellable(item))
                                {
                                    Item buyItem;
                                    if (amount >= item.Amount)
                                    {
                                        buyItem = item;
                                    }
                                    else
                                    {
                                        buyItem      = item.Dupe(amount);
                                        item.Amount -= amount;
                                    }

                                    if (cont == null || !cont.TryDropItem(buyer, buyItem, false))
                                    {
                                        buyItem.MoveToWorld(buyer.Location, buyer.Map);
                                    }

                                    break;
                                }
                            }
                        }
                    }
                }
                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 ( ser >= 0 && ser <= buyInfo.Length )
                 * {
                 *      IBuyItemInfo bii = buyInfo[ser];
                 *
                 * }
                 * else
                 * {
                 *      Item item = World.FindItem( buy.Serial );
                 *
                 *      if ( item == null )
                 *              continue;
                 *
                 *      if ( amount > item.Amount )
                 *              amount = item.Amount;
                 *
                 *      foreach( IShopSellInfo ssi in info )
                 *      {
                 *              if ( ssi.IsSellable( item ) )
                 *              {
                 *                      if ( ssi.IsResellable( item ) )
                 *                      {
                 *                              Item buyItem;
                 *                              if ( amount >= item.Amount )
                 *                              {
                 *                                      buyItem = item;
                 *                              }
                 *                              else
                 *                              {
                 *                                      buyItem = item.Dupe( amount );
                 *                                      item.Amount -= amount;
                 *                              }
                 *
                 *                              if ( cont == null || !cont.TryDropItem( buyer, buyItem, false ) )
                 *                                      buyItem.MoveToWorld( buyer.Location, buyer.Map );
                 *
                 *                              break;
                 *                      }
                 *              }
                 *      }
                 * }*/
            }            //foreach

            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} gold, which has been withdrawn from your bank account.  My thanks for the patronage.", totalCost);
                }
                else
                {
                    SayTo(buyer, true, "The total of thy purchase is {0} gold.  My thanks for the patronage.", totalCost);
                }
            }
            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} gold, 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);
                }
                else
                {
                    SayTo(buyer, true, "The total of thy purchase is {0} gold.  My thanks for the patronage.  Unfortunately, I could not sell you all the goods you requested.", totalCost);
                }
            }

            return(true);
        }
Ejemplo n.º 47
0
			public override void OnResponse( Mobile from, string text )
			{
				if ( text.Length > 40 )
					text = text.Substring( 0, 40 );

				if ( from.CheckAlive() && m_Book.IsChildOf( from.Backpack ) )
				{
					m_Book.BookName = Utility.FixHtml( text.Trim() );

					from.SendLocalizedMessage( 1062480 ); // The bulk order book's name has been changed.
				}
			}
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 0)
            {
                return;
            }

            Mobile    from = sender.Mobile;
            HouseSign sign = m_House.Sign;

            if (m_House.Deleted || sign == null || sign.Deleted || !from.CheckAlive())
            {
                return;
            }

            if (from.Map != sign.Map || !from.InRange(sign, 5))
            {
                from.SendLocalizedMessage(1062429);                   // You must be within five paces of the house sign to use this option.
                return;
            }

            int index = info.ButtonID - 1;

            if (index < 0 || index >= m_Inventories.Count)
            {
                return;
            }

            VendorInventory inventory = (VendorInventory)m_Inventories[index];

            if (inventory.Owner != from || !m_House.VendorInventories.Contains(inventory))
            {
                return;
            }

            int totalItems      = 0;
            int givenToBackpack = 0;
            int givenToBankBox  = 0;

            for (int i = inventory.Items.Count - 1; i >= 0; i--)
            {
                Item item = (Item)inventory.Items[i];

                if (item.Deleted)
                {
                    inventory.Items.RemoveAt(i);
                    continue;
                }

                totalItems += 1 + item.TotalItems;

                if (from.PlaceInBackpack(item))
                {
                    inventory.Items.RemoveAt(i);
                    givenToBackpack += 1 + item.TotalItems;
                }
                else if (from.BankBox != null && from.BankBox.TryDropItem(from, item, false))
                {
                    inventory.Items.RemoveAt(i);
                    givenToBankBox += 1 + item.TotalItems;
                }
            }

            from.SendLocalizedMessage(1062436, totalItems.ToString() + "\t" + inventory.Gold.ToString());               // The vendor you selected had ~1_COUNT~ items in its inventory, and ~2_AMOUNT~ gold in its account.

            int givenGold = Banker.DepositUpTo(from, inventory.Gold);

            inventory.Gold -= givenGold;

            from.SendLocalizedMessage(1060397, givenGold.ToString());                                          // ~1_AMOUNT~ gold has been deposited into your bank box.
            from.SendLocalizedMessage(1062437, givenToBackpack.ToString() + "\t" + givenToBankBox.ToString()); // ~1_COUNT~ items have been removed from the shop inventory and placed in your backpack.  ~2_BANKCOUNT~ items were removed from the shop inventory and placed in your bank box.

            if (inventory.Gold > 0 || inventory.Items.Count > 0)
            {
                from.SendLocalizedMessage(1062440);                   // Some of the shop inventory would not fit in your backpack or bank box.  Please free up some room and try again.
            }
            else
            {
                inventory.Delete();
                from.SendLocalizedMessage(1062438);                   // The shop is now empty of inventory and funds, so it has been deleted.
            }
        }
Ejemplo n.º 49
0
        public virtual bool OnSellItems(Mobile seller, ArrayList list)
        {
            if (!IsActiveBuyer)
                return false;

            if (!seller.CheckAlive())
                return false;

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

            seller.PlaySound(0x32);

            IShopSellInfo[] info = GetSellInfo();
            IBuyItemInfo[] buyInfo = this.GetBuyInfo();
            int GiveGold = 0;
            int Sold = 0;
            Container cont;
            ArrayList delete = new ArrayList();
            ArrayList drop = new ArrayList();

            foreach (SellItemResponse resp in list)
            {
                if (resp.Item.RootParent != seller || resp.Amount <= 0)
                    continue;

                foreach (IShopSellInfo ssi in info)
                {
                    if (ssi.IsSellable(resp.Item))
                    {
                        Sold++;
                        GiveGold += ssi.GetSellPriceFor(resp.Item) * resp.Amount;
                        break;
                    }
                }
            }

            if (Sold > MaxSell)
            {
                SayTo(seller, true, "You may only sell {0} items at a time!", MaxSell);
                return false;
            }
            else if (Sold == 0)
            {
                return true;
            }
            else if (GiveGold > m_cash)
            {
                SayTo(seller, true, "Unfortunately I can't afford any more items. Please come back later.", MaxSell);
                return false;
            }
            GiveGold = 0;

            foreach (SellItemResponse resp in list)
            {
                if (resp.Item.RootParent != seller || resp.Amount <= 0)
                    continue;

                foreach (IShopSellInfo ssi in info)
                {
                    if (ssi.IsSellable(resp.Item))
                    {
                        int amount = resp.Amount;

                        if (amount > resp.Item.Amount)
                            amount = resp.Item.Amount;

                        if (ssi.IsResellable(resp.Item))
                        {
                            bool found = false;

                            foreach (IBuyItemInfo bii in buyInfo)
                            {
                                if (bii.Restock(resp.Item, amount))
                                {
                                    resp.Item.Consume(amount);
                                    found = true;

                                    break;
                                }
                            }

                            if (!found)
                            {
                                cont = this.BuyPack;

                                if (amount < resp.Item.Amount)
                                {
                                    resp.Item.Amount -= amount;
                                    Item item = resp.Item.Dupe(amount);
                                    item.SetLastMoved();
                                    cont.DropItem(item);
                                }
                                else
                                {
                                    resp.Item.SetLastMoved();
                                    cont.DropItem(resp.Item);
                                }
                            }
                        }
                        else
                        {
                            if (amount < resp.Item.Amount)
                                resp.Item.Amount -= amount;
                            else
                                resp.Item.Delete();
                        }

                        // with the following lines, all sellings from a staffchar to a vendor will get loged.  by dev minkio
                        int pfo = ssi.GetSellPriceFor(resp.Item) * amount;
                        GiveGold += pfo;

                        // if staffmembers sell items, this will be logged. by dev minkio
                        if (seller.AccessLevel > AccessLevel.Player)
                            CommandLogging.WriteLine(seller, String.Format("sold {0} for {1} gold.", resp.Item, pfo));
                        // ---

                        break;
                    }
                }
            }

            m_cash = GiveGold > m_cash ? 0 : m_cash - GiveGold;
            //SayTo(seller, true, "DEBUG: cash: {0}", m_cash);

            if (GiveGold > 0)
            {
                while (GiveGold > 60000)
                {
                    seller.AddToBackpack(new Gold(60000));
                    GiveGold -= 60000;
                }

                seller.AddToBackpack(new Gold(GiveGold));

                seller.PlaySound(0x0037);//Gold dropping sound

                if (SupportsBulkOrders(seller))
                {
                    Item bulkOrder = CreateBulkOrder(seller, false);

                    if (bulkOrder is LargeBOD)
                        seller.SendGump(new LargeBODAcceptGump(seller, (LargeBOD)bulkOrder));
                    else if (bulkOrder is SmallBOD)
                        seller.SendGump(new SmallBODAcceptGump(seller, (SmallBOD)bulkOrder));
                }
            }
            //no cliloc for this?
            //SayTo( seller, true, "Thank you! I bought {0} item{1}. Here is your {2}gp.", Sold, (Sold > 1 ? "s" : ""), GiveGold );

            return true;
        }
Ejemplo n.º 50
0
        public void EndClaimList(Mobile from, BaseCreature pet)
        {
            if (pet == null || pet.Deleted || from.Map != Map || !from.Stabled.Contains(pet) || !from.CheckAlive())
            {
                return;
            }

            if (!from.InRange(this, 14))
            {
                from.SendLocalizedMessage(500446); // That is too far away.
                return;
            }

            if (CanClaim(from, pet))
            {
                DoClaim(from, pet);

                from.Stabled.Remove(pet);

                if (from is PlayerMobile)
                {
                    ((PlayerMobile)from).AutoStabled.Remove(pet);
                }
            }
            else
            {
                SayTo(from, 1049612, pet.Name); // ~1_NAME~ remained in the stables because you have too many followers.
            }
        }
Ejemplo n.º 51
0
		public void BeginCustomize( Mobile m )
		{
			if( !m.CheckAlive() ) {
				return;
			} else if ( SpellHelper.CheckCombat( m ) ) {
				m.SendLocalizedMessage( 1005564, "", 0x22 ); // Wouldst thou flee during the heat of battle??
				return;
			}

			RelocateEntities();

			foreach( Item item in GetItems() )
			{
				item.Location = BanLocation;
			}

			foreach( Mobile mobile in GetMobiles() )
			{
				if( mobile != m )
					mobile.Location = BanLocation;
			}

			DesignContext.Add( m, this );
			m.Send( new BeginHouseCustomization( this ) );

			NetState ns = m.NetState;
			if( ns != null )
				SendInfoTo( ns );

			DesignState.SendDetailedInfoTo( ns );
		}
Ejemplo n.º 52
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 if ((from.Backpack != null && from.Backpack.ConsumeTotal(typeof(Gold), 30)) || Banker.Withdraw(from, 30))
            {
                pet.ControlTarget = null;
                pet.ControlOrder  = OrderType.Stay;
                pet.Internalize();

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

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

                pet.Loyalty = MaxLoyalty; // Wonderfully happy

                from.Stabled.Add(pet);

                SayTo(from, 1049677); // Your pet has been stabled.
            }
            else
            {
                SayTo(from, 502677); // But thou hast not the funds in thy bank account!
            }
        }
Ejemplo n.º 53
0
			public override void OnSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted)
			{
				if (Deleted)
				{
					return;
				}

				Delete();

				if (m_Creature == null || m_Creature.Deleted || m_Creature.ControlMaster != from || !from.CheckAlive() ||
					!to.CheckAlive())
				{
					return;
				}

				if (from.Map != m_Creature.Map || !from.InRange(m_Creature, 14))
				{
					return;
				}

				if (accepted)
				{
					if (m_Creature.SetControlMaster(to))
					{
						if (m_Creature.Summoned)
						{
							m_Creature.SummonMaster = to;
						}

						m_Creature.ControlTarget = to;
						m_Creature.ControlOrder = OrderType.Follow;

						m_Creature.BondingBegin = DateTime.MinValue;
						m_Creature.OwnerAbandonTime = DateTime.MinValue;
						m_Creature.IsBonded = false;

						m_Creature.PlaySound(m_Creature.GetIdleSound());

						string args = String.Format("{0}\t{1}\t{2}", from.Name, m_Creature.Name, to.Name);

						from.SendLocalizedMessage(1043253, args); // You have transferred your pet to ~3_GETTER~.
						to.SendLocalizedMessage(1043252, args); // ~1_NAME~ has transferred the allegiance of ~2_PET_NAME~ to you.
					}
				}
			}
Ejemplo n.º 54
0
        public void EndStable(Mobile from, BaseCreature pet)
        {
            if (Deleted || !from.CheckAlive() || !CanUse() || !CheckAccess(from))
            {
                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 (GetCount() >= MaxStables)
            {
                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
                }
                if (!m_Stored.ContainsKey(from))
                {
                    m_Stored.Add(from, new List <BaseCreature>());
                }

                if (!m_Stored[from].Contains(pet))
                {
                    m_Stored[from].Add(pet);
                }

                from.SendMessage("Your chicken has been stabled.");
                //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!
                //}
            }
        }
Ejemplo n.º 55
0
		public virtual bool OnSellItems( Mobile seller, List<SellItemResponse> list )
		{
			if ( !IsActiveBuyer )
				return false;

			if ( !seller.CheckAlive() )
				return false;

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

			seller.PlaySound( 0x32 );

			IShopSellInfo[] info = GetSellInfo();
			IBuyItemInfo[] buyInfo = this.GetBuyInfo();
			int GiveGold = 0;
			int Sold = 0;
			Container cont;

			foreach ( SellItemResponse resp in list )
			{
				if ( resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable || ( resp.Item is Container && ( (Container)resp.Item ).Items.Count != 0 ) )
					continue;

				foreach ( IShopSellInfo ssi in info )
				{
					if ( ssi.IsSellable( resp.Item ) )
					{
						Sold++;
						break;
					}
				}
			}

			if ( Sold > MaxSell )
			{
				SayTo( seller, true, "You may only sell {0} items at a time!", MaxSell );
				return false;
			}
			else if ( Sold == 0 )
			{
				return true;
			}

			foreach ( SellItemResponse resp in list )
			{
				if ( resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable || ( resp.Item is Container && ( (Container)resp.Item ).Items.Count != 0 ) )
					continue;

				foreach ( IShopSellInfo ssi in info )
				{
					if ( ssi.IsSellable( resp.Item ) )
					{
						int amount = resp.Amount;

						if ( amount > resp.Item.Amount )
							amount = resp.Item.Amount;

						if ( ssi.IsResellable( resp.Item ) )
						{
							bool found = false;

							foreach ( IBuyItemInfo bii in buyInfo )
							{
								if ( bii.Restock( resp.Item, amount ) )
								{
									resp.Item.Consume( amount );
									found = true;

									break;
								}
							}

							if ( !found )
							{
								cont = this.BuyPack;

								if ( amount < resp.Item.Amount )
								{
									Item item = Mobile.LiftItemDupe( resp.Item, resp.Item.Amount - amount );

									if ( item != null )
									{
										item.SetLastMoved();
										cont.DropItem( item );
									}
									else
									{
										resp.Item.SetLastMoved();
										cont.DropItem( resp.Item );
									}
								}
								else
								{
									resp.Item.SetLastMoved();
									cont.DropItem( resp.Item );
								}
							}
						}
						else
						{
							if ( amount < resp.Item.Amount )
								resp.Item.Amount -= amount;
							else
								resp.Item.Delete();
						}

						GiveGold += ssi.GetSellPriceFor( resp.Item ) * amount;
						break;
					}
				}
			}

			if ( GiveGold > 0 )
			{
				while ( GiveGold > 60000 )
				{
					seller.AddToBackpack( new Gold( 60000 ) );
					GiveGold -= 60000;
				}

				seller.AddToBackpack( new Gold( GiveGold ) );

				seller.PlaySound( 0x0037 );//Gold dropping sound

				if ( SupportsBulkOrders( seller ) )
				{
					Item bulkOrder = CreateBulkOrder( seller, false );

					if ( bulkOrder is LargeBOD )
						seller.SendGump( new LargeBODAcceptGump( seller, (LargeBOD)bulkOrder ) );
					else if ( bulkOrder is SmallBOD )
						seller.SendGump( new SmallBODAcceptGump( seller, (SmallBOD)bulkOrder ) );
				}
			}
			//no cliloc for this?
			//SayTo( seller, true, "Thank you! I bought {0} item{1}. Here is your {2}gp.", Sold, (Sold > 1 ? "s" : ""), GiveGold );

			return true;
		}
Ejemplo n.º 56
0
        public bool OnPlacement(Mobile from, HouseSurveyTool tool, Point3D p)
        {
            if (!from.CheckAlive() || from.Backpack == null || tool == null || tool.UsesRemaining == 0 || !tool.IsChildOf(from.Backpack))
            {
                return(false);
            }

            if (SurveyPreviewHouse.PreviewHouseList.Contains(from))
            {
                from.SendMessage("You are already previewing a potential house location.");
                return(false);
            }

            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, false);

            switch (res)
            {
            case HousePlacementResult.Valid:
            {
                from.SendMessage("This is valid terrain to place a house.");                           // This is a valid location.

                SurveyPreviewHouse prev = new SurveyPreviewHouse(m_MultiID, from);

                MultiComponentList mcl = prev.Components;

                prev.MoveToWorld(center, from.Map);

                string message = "You have found valid terrain to place a house.  This preview will stay visible for 20 seconds.<BR><BR>Press OKAY to stop previewing this house.";

                from.SendGump(new NoticeGump(1060635, 30720, message, 0xFFC000, 420, 280, new NoticeGumpCallback(SurveyNotice_Callback), prev));

                return(true);
            }

            case HousePlacementResult.MobileBlocking:
            {
                from.SendMessage("There is somebody in the way, and you can't place on top of them!");
                break;
            }

            case HousePlacementResult.ItemBlocking:
            {
                from.SendMessage("There is an item in the way, and you can't place on top of them!");
                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;
            }

            case HousePlacementResult.BadRegionTemp:
            {
                from.SendLocalizedMessage(501270);                           //Lord British has decreed a 'no build' period, thus you cannot build this house at this time.
                break;
            }
            }

            return(false);
        }
Ejemplo n.º 57
0
		public virtual void VendorSell( Mobile from )
		{
			if ( !IsActiveBuyer )
				return;

			if ( !from.CheckAlive() )
				return;

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

			Container pack = from.Backpack;

			if ( pack != null )
			{
				IShopSellInfo[] info = GetSellInfo();

				Dictionary<Item, SellItemState> table = new Dictionary<Item, SellItemState>();

				foreach ( IShopSellInfo ssi in info )
				{
					Item[] items = pack.FindItemsByType( ssi.Types );

					foreach ( Item item in items )
					{
						if ( item is Container && ( (Container)item ).Items.Count != 0 )
							continue;

						if ( item.IsStandardLoot() && item.Movable && ssi.IsSellable( item ) )
							table[item] = new SellItemState( item, ssi.GetSellPriceFor( item ), ssi.GetNameFor( item ) );
					}
				}

				if ( table.Count > 0 )
				{
					SendPacksTo( from );

					from.Send( new VendorSellList( this, table.Values ) );
				}
				else
				{
					Say( true, "You have nothing I would be interested in." );
				}
			}
		}
Ejemplo n.º 58
0
        public virtual bool Cast()
        {
            m_StartCastTime = Core.TickCount;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).Peaced)
            {
                m_Caster.SendLocalizedMessage(1072060);                 // You cannot cast a spell while calmed.
            }
            else if (m_Scroll is BaseWand && m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            else if (SkillHandlers.SpiritSpeak.IsInSpiritSpeak(m_Caster) || (m_Caster.Spell != null && m_Caster.Spell.IsCasting))
            {
                m_Caster.SendLocalizedMessage(502642);                 // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)) ||
                     (BlockedByAnimalForm && AnimalForm.UnderTransformation(m_Caster)))
            {
                m_Caster.SendLocalizedMessage(1061091);                 // You cannot cast that spell in this form.
            }
            else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && Core.TickCount - m_Caster.NextSpellTime < 0)
            {
                m_Caster.SendLocalizedMessage(502644);                 // You have not yet recovered from casting a spell.
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.UtcNow)
            {
                m_Caster.SendLocalizedMessage(1072060);                 // You cannot cast a spell while calmed.
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                #region Stygian Abyss
                if (m_Caster.Race == Race.Gargoyle && m_Caster.Flying)
                {
                    if (BaseMount.OnFlightPath(m_Caster))
                    {
                        if (m_Caster.IsPlayer())
                        {
                            m_Caster.SendLocalizedMessage(1113750); // You may not cast spells while flying over such precarious terrain.
                            return(false);
                        }
                        else
                        {
                            m_Caster.SendMessage("Your staff level allows you to cast while flying over precarious terrain.");
                        }
                    }
                }
                #endregion

                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() &&
                    m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    Caster.Delta(MobileDelta.Flags);

                    if (!(m_Scroll is BaseWand) && RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = GetCastDelay();

                    if (ShowHandMovement && !(m_Scroll is SpellStone) && (m_Caster.Body.IsHuman || (m_Caster.Player && m_Caster.Body.IsMonster)))
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    if (Core.ML)
                    {
                        WeaponAbility.ClearCurrentAbility(m_Caster);
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    //m_CastTimer.Start();

                    OnBeginCast();

                    if (castDelay > TimeSpan.Zero)
                    {
                        m_CastTimer.Start();
                    }
                    else
                    {
                        m_CastTimer.Tick();
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625, ScaleMana(GetMana()).ToString()); // Insufficient mana. You must have at least ~1_MANA_REQUIREMENT~ Mana to use this spell.
            }

            return(false);
        }
Ejemplo n.º 59
0
        public void EndStable(Mobile from, BaseCreature pet)
        {
            if (Deleted || !from.CheckAlive())
            {
                return;
            }

            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 is PackLlama || pet is PackHorse || pet is Beetle) && (pet.Backpack != null && pet.Backpack.Items.Count > 0))
            {
                from.SendLocalizedMessage(1042563); // You need to unload your pet.
            }
            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 >= AnimalTrainer.GetMaxStabled(from))
            {
                from.SendLocalizedMessage(1042565); // You have too many pets in the stables!
            }
            else
            {
                Container bank = from.FindBankNoCreate();

                if ((bank != null && bank.ConsumeTotal(typeof(Gold), 30)) || Banker.Withdraw(from, 30, true))
                {
                    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);

                    if (m_Replica)
                    {
                        UsesRemaining -= 1;
                    }

                    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!
                }
            }
        }
Ejemplo n.º 60
0
 public override void OnResponse(Server.Network.GameClient sender, RelayInfo info)
 {
     if (info.ButtonID == 2)
     {
         if (!m_Pet.Deleted && m_Pet.Controlled && m_From == m_Pet.ControlMaster && m_From.CheckAlive())
         {
             if (m_Pet.Map == m_From.Map && m_Pet.InRange(m_From, 14))
             {
                 m_Pet.Delete();
             }
         }
     }
 }