Example #1
0
		public override void OnDoubleClick( Mobile from )
		{
			ArrayList list = new ArrayList();

			foreach ( Item m in from.GetItemsInRange( 2 ) )
			{
				if ( m is FlourMillEastAddon )
					list.Add( m );

				else if ( m is FlourMillSouthAddon )
					list.Add( m );
			}

			if( IsChildOf( from.Backpack ) && Amount >= 4 && list.Count <= 0 )
			{
				from.SendLocalizedMessage( 1044491 ); // You must be near a flour mill to do that.
			}

			else if( IsChildOf( from.Backpack ) && Amount >= 4 )
			{
				from.SendMessage( "You got a sack of flour." );
				from.AddToBackpack( new SackFlour() );
				this.Consume( 4 );
			}

			else if( IsChildOf( from.Backpack ) && Amount < 4 )
			{
				from.SendMessage( "You need more wheat sheaves." );
			}

			else
			{
				from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
			}
		}
Example #2
0
        public override void OnDoubleClick( Mobile from )
        {
            if ( !IsChildOf( from.Backpack ) )
            {
                from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
            }
            else if ( from.Guild != null )
            {
                from.SendLocalizedMessage( 501137 ); // You must resign from your current guild before founding another!
            }
            else
            {
                BaseHouse house = BaseHouse.FindHouseAt( from );

                if ( house == null || house is Tent )
                {
                    from.SendLocalizedMessage( 501138 ); // You can only place a guildstone in a house.
                }
                else if ( house.FindGuildstone() != null )
                {
                    from.SendLocalizedMessage( 501142 );//Only one guildstone may reside in a given house.
                }
                else if ( !house.IsOwner( from ) )
                {
                    from.SendLocalizedMessage( 501141 ); // You can only place a guildstone in a house you own!
                }
                else
                {
                    IPooledEnumerable eable = from.GetItemsInRange( 1 );
                    foreach ( Item item in eable )
                    {
                        if ( item is BaseDoor && ( item.X == from.X || item.Y == from.Y ) && item.Z - 5 < from.Z && item.Z + 5 > from.Z )
                        {
                            from.SendAsciiMessage( "You cannot place this in front of a door." );
                            eable.Free();
                            return;
                        }
                    }
                    eable.Free();

                    from.SendLocalizedMessage( 1013060 ); // Enter new guild name (40 characters max):
                    from.Prompt = new InternalPrompt( this );
                }
            }
        }
Example #3
0
        public static bool IsNearType(Mobile mob, Type type, int range)
        {
            bool mobs = type.IsSubclassOf(typeof(Mobile));
            bool items = type.IsSubclassOf(typeof(Item));

            IPooledEnumerable eable;

            if (mobs)
                eable = mob.GetMobilesInRange(range);
            else if (items)
                eable = mob.GetItemsInRange(range);
            else
                return false;

            foreach (object obj in eable)
            {
                if (type.IsAssignableFrom(obj.GetType()))
                {
                    eable.Free();
                    return true;
                }
            }

            eable.Free();
            return false;
        }
Example #4
0
        public virtual bool CheckFeed( Mobile from, Item dropped )
        {
            if ( !IsDeadPet && Controlled && ( ControlMaster == from || IsPetFriend( from ) ) && ( dropped is Food || dropped is Gold || dropped is CookableFood || dropped is Head || dropped is LeftArm || dropped is LeftLeg || dropped is Torso || dropped is RightArm || dropped is RightLeg || dropped is IPetBooster ) )
            {
                Item f = dropped;

                if ( dropped is IPetBooster )
                {
                    IPetBooster pb = dropped as IPetBooster;

                    return pb.OnUsed( from, this );
                }
                else if ( CheckFoodPreference( f ) )
                {
                    int amount = f.Amount;

                    if ( amount > 0 )
                    {
                        bool happier = false;

                        int stamGain;

                        if ( f is Gold )
                            stamGain = amount - 50;
                        else
                            stamGain = ( amount * 15 ) - 50;

                        if ( stamGain > 0 )
                            Stam += stamGain;

                        if ( m_Loyalty != PetLoyalty.WonderfullyHappy )
                        {
                            m_Loyalty = PetLoyalty.WonderfullyHappy;
                            happier = true;
                        }

                        #region PetBondingGate
                        if ( TestCenter.Enabled )
                        {
                            if ( !IsBonded )
                            {
                                var overPetBondingGate = from.GetItemsInRange( 5 ).OfType<PetBondingGate>()
                                    .Any( pbg => pbg.Location == from.Location && pbg.Location == Location );

                                if ( overPetBondingGate )
                                {
                                    IsBonded = true;
                                    BondingBegin = DateTime.MinValue;
                                    from.SendLocalizedMessage( 1049666 ); // Your pet has bonded with you!
                                }
                            }
                        }
                        #endregion

                        if ( happier )
                            SayTo( from, 502060 ); // Your pet looks happier.

                        if ( Body.IsAnimal )
                            Animate( 3, 5, 1, true, false, 0 );
                        else if ( Body.IsMonster )
                            Animate( 17, 5, 1, true, false, 0 );

                        if ( IsBondable && !IsBonded )
                        {
                            Mobile master = m_ControlMaster;

                            if ( master != null && master == from )	//So friends can't start the bonding process
                            {
                                if ( m_dMinTameSkill <= 29.1 || master.Skills[SkillName.AnimalTaming].Base >= m_dMinTameSkill || this is SwampDragon || this is Ridgeback || this is SavageRidgeback || this is FireBeetle || this is LesserHiryu || this is IronBeetle )
                                {
                                    if ( BondingBegin == DateTime.MinValue )
                                    {
                                        BondingBegin = DateTime.Now;
                                    }
                                    else if ( ( BondingBegin + BondingDelay ) <= DateTime.Now )
                                    {
                                        IsBonded = true;
                                        BondingBegin = DateTime.MinValue;
                                        from.SendLocalizedMessage( 1049666 ); // Your pet has bonded with you!
                                    }
                                }
                                else
                                {
                                    from.SendLocalizedMessage( 1075268 ); // Your pet cannot form a bond with you until your animal taming ability has risen.
                                }
                            }
                        }

                        dropped.Delete();
                        return true;
                    }
                }
                else if ( !( dropped is Gold ) )
                {
                    SayTo( from, 1043257 ); // The animal shies away.
                }
            }

            return false;
        }
Example #5
0
		public void SmeltOre( Mobile from )
		{
			object forge = null;

			IPooledEnumerable eable = from.GetItemsInRange( 2 );

			foreach ( Item item in eable )
			{
				if ( IsForge( item ) )
				{
					forge = item;
					break;
				}
			}

			eable.Free();

			eable = from.GetMobilesInRange( 2 );

			foreach ( Mobile mob in eable )
			{
				if ( IsForge( mob ) )
				{
					forge = mob;
					break;
				}
			}

			eable.Free();

			if ( forge == null )
			{
				for ( int x = from.X-2;forge == null && x < from.X+2; x++ )
				{
					for ( int y = from.Y-2;forge == null &&  y < from.Y+2; y++ )
					{
						StaticTile[] tiles = from.Map.Tiles.GetStaticTiles( x, y, true );
						for ( int j = 0;forge == null && j < tiles.Length; j++ )
						{
							StaticTarget st = new StaticTarget( tiles[j], tiles[j].ID );
							if ( IsForge( st ) )
								forge = st;
						}
					}
				}
			}

			if ( forge != null )
			{
				double difficulty;

				switch ( Resource )
				{
					default: difficulty = 50.0; break;
					case CraftResource.DullCopper: difficulty = 65.0; break;
					case CraftResource.ShadowIron: difficulty = 70.0; break;
					case CraftResource.Copper: difficulty = 75.0; break;
					case CraftResource.Bronze: difficulty = 80.0; break;
					case CraftResource.Gold: difficulty = 85.0; break;
					case CraftResource.Agapite: difficulty = 90.0; break;
					case CraftResource.Verite: difficulty = 95.0; break;
					case CraftResource.Valorite: difficulty = 99.0; break;
				}

				double minSkill = difficulty - 25.0;
				double maxSkill = difficulty + 25.0;

				if ( difficulty > 50.0 && difficulty > from.Skills[SkillName.Mining].Value )
					from.SendLocalizedMessage( 501986 ); // You have no idea how to smelt this strange ore!
				//else if ( Amount <= 1 )
				//	from.SendLocalizedMessage( 501987 ); // There is not enough metal-bearing ore in this pile to make an ingot.
				else
				{
					/*
					int successes = 0;
					int count = Amount / 2;

					for ( int i = 0;i < count; i++ )
						if ( from.CheckTargetSkill( SkillName.Mining, forge, minSkill, maxSkill ) )
							successes++;

					Consume( count * 2 );

					if ( successes > 0 )
					{
						string[] locals = new string[3];

						BaseIngot ingot = GetIngot();
						ingot.Amount = successes;

						if ( Parent != from.Backpack && Parent is Container && RootParent == from && ((Container)Parent).TryDropItem( from, ingot, false ) ) //Its in a container, on the player
						{
							if ( locals[0] == null )
								locals[0] = "back in the same container";
						}
						else if ( from.AddToBackpack( ingot ) )
						{
							if ( locals[1] == null )
								locals[1] = "in your backpack";
						}
						else	if ( locals[2] == null )
								locals[2] = "on the floor";

						string localText = String.Empty;
						//Trimmed list
						List<string> localslist = new List<string>();
						for ( int i = 0;i < locals.Length; i++ )
							if ( locals[i] != null )
								localslist.Add( locals[i] );

						//We know there is at least ONE location
						localText = localslist[0];

						for ( int i = 1;i < localslist.Count; i++ )
							localText = String.Format( "{0},{1}{2}", localText, (i+1 < localslist.Count) ? " and" : " ", localslist[i] );

						from.SendMessage( "You smelt the ore removing the impurities and put the metal {0}.", localText );
					}
					else
						from.SendLocalizedMessage( 501990 ); // You burn away the impurities but are left with less useable metal.

					from.PlaySound( 0x2B ); // Smelting/Bellow noise
*/
					bool atcap = from.Skills[SkillName.Mining].Value > from.Skills[SkillName.Mining].Cap || from.Skills[SkillName.Mining].Value >= maxSkill;
					//int amountIngot = atcap ? (Amount / 2) : 1;
					//int amountOre = amountIngot * 2;
					int amountIngot = atcap ? Amount : 1;
					from.PlaySound( 0x2B ); // Smelting/Bellow noise

					if ( from.CheckTargetSkill( SkillName.Mining, forge, minSkill, maxSkill ) )
					{
						string[] locals = new string[3];

						BaseIngot ingot = GetIngot();
                        double chanceOfDoublingIronSmelt = from.Skills[SkillName.Mining].Value / 200.0; // 50% chance at 100
                        if (ingot.Resource == CraftResource.Iron && chanceOfDoublingIronSmelt > Utility.RandomDouble()) // per 10 skill, 5% chance of 2 ingots
                        {
                            ingot.Amount = amountIngot * 2;
                            from.SendMessage("You skillfully extract extra metal out of the ore pile.");
                        }
                        else
                        {
                            ingot.Amount = amountIngot;
                        }

						if ( Parent != from.Backpack && Parent is Container && RootParent == from && ((Container)Parent).TryDropItem( from, ingot, false ) ) //Its in a container, on the player
						{
							if ( locals[0] == null )
								locals[0] = "back in the same container";
						}
						else if ( from.AddToBackpack( ingot ) )
						{
							if ( locals[1] == null )
								locals[1] = "in your backpack";
						}
						else	if ( locals[2] == null )
								locals[2] = "on the floor";

						string localText = String.Empty;
						//Trimmed list
						List<string> localslist = new List<string>();
						for ( int i = 0;i < locals.Length; i++ )
							if ( locals[i] != null )
								localslist.Add( locals[i] );

						//We know there is at least ONE location
						localText = localslist[0];

						for ( int i = 1;i < localslist.Count; i++ )
							localText = String.Format( "{0},{1}{2}", localText, (i+1 < localslist.Count) ? " and" : " ", localslist[i] );

						from.SendMessage( "You smelt the ore removing the impurities and put the metal {0}.", localText );
						Consume( amountIngot );
					}
					else
					{
						Consume( Math.Max(amountIngot / 2, 1) );
						from.SendLocalizedMessage( 501990 ); // You burn away the impurities but are left with less useable metal.
					}
				}
			}
			else
				from.SendLocalizedMessage( 500420 ); // You are not near a forge.
		}
Example #6
0
        public virtual bool Give(Mobile m, Item item, bool placeAtFeet)
        {
            if (m.PlaceInBackpack(item))
                return true;

            if (!placeAtFeet)
                return false;

            Map map = m.Map;

            if (map == null)
                return false;

            List<Item> atFeet = new List<Item>();

            foreach (Item obj in m.GetItemsInRange(0))
                atFeet.Add(obj);

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

                if (check.StackWith(m, item, false))
                    return true;
            }

            item.MoveToWorld(m.Location, map);
            return true;
        }
        public override void OnDoubleClick( Mobile from )
        {
            Guildstone stone = m_Stone as Guildstone;

            if ( !IsChildOf( from.Backpack ) )
            {
                from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
            }
            else if ( stone == null || stone.Deleted || stone.Guild == null || stone.Guild.Teleporter != this )
            {
                from.SendLocalizedMessage( 501197 ); // This teleporting object can not determine what guildstone to teleport
            }
            else
            {
                BaseHouse house = BaseHouse.FindHouseAt( from );

                if ( house == null || house is Tent )
                {
                    from.SendLocalizedMessage( 501138 ); // You can only place a guildstone in a house.
                }
                else if ( !house.IsOwner( from ) )
                {
                    from.SendLocalizedMessage( 501141 ); // You can only place a guildstone in a house you own!
                }
                else
                {
                    IPooledEnumerable eable = from.GetItemsInRange( 1 );
                    foreach ( Item item in eable )
                    {
                        if ( item is BaseDoor && ( item.X == from.X || item.Y == from.Y ) && item.Z - 5 < from.Z && item.Z + 5 > from.Z )
                        {
                            from.SendAsciiMessage( "You cannot place this in front of a door." );
                            eable.Free();
                            return;
                        }
                    }
                    eable.Free();
                    m_Stone.MoveToWorld( from.Location, from.Map );
                    Delete();
                    stone.Guild.Teleporter = null;
                }
            }
        }
Example #8
0
		public static bool IsNearType(Mobile mob, Type type, int range)
		{
			bool mobs = type.IsSubclassOf(typeof(Mobile));
			bool items = type.IsSubclassOf(typeof(Item));

			IPooledEnumerable eable;

			if (mobs)
			{
				eable = mob.GetMobilesInRange(range);
			}
			else if (items)
			{
				eable = mob.GetItemsInRange(range);
			}
			else
			{
				return false;
			}

			if (eable.OfType<IEntity>().Any(e => e.TypeEquals(type)))
			{
				eable.Free();
				return true;
			}

			eable.Free();
			return false;
		}
        public override void OnDoubleClick( Mobile from )
        {
            if( from == null || !from.InRange( this.Location, 2 ) || !from.InLOS( this.Location ) || !from.Alive || from.Paralyzed )
            {
                from.SendMessage( "You are too far away." );
                return;
            }

            if( m_Owner == null )
            {
                bool haschest = false;

                foreach( Item item in from.GetItemsInRange( 10 ) )
                {
                    if( item is BaseStorageContainer )
                    {
                        BaseStorageContainer cont = item as BaseStorageContainer;

                        if( cont.Owner == from )
                            haschest = true;
                    }
                }

                if( haschest )
                {
                    from.SendMessage( "You already have a storage box in this area." );
                    return;
                }

                Container pack = from.Backpack;

                if ( !pack.ConsumeTotal( typeof( Copper ), m_Price ) )
                {
                    from.SendMessage( "You need to be carrying " + m_Price + " copper coins in order to purchase this storage box." );
                }

                else
                {
                    m_Owner = from;
                    m_OwnersName = from.Name;

                    if( m_OwnersName.EndsWith( "s" ) )
                        m_OwnersName = m_OwnersName + "'";

                    else
                        m_OwnersName = m_OwnersName + "'s";

                    this.Name = "" + m_OwnersName + " Storage Box";

                    Key key = new Key();

                    uint newlock = Key.RandomValue();
                    this.KeyValue = newlock;
                    this.Locked = true;
                    key.KeyValue = newlock;
                    pack.DropItem( key );
                    this.LastRent = DateTime.Now;
                    from.SendMessage( "A key to the storage box has been placed in your backpack and " + m_Price + " copper coins have been charged from you." );

                    Copper copper = new Copper( m_Price );

                    if( this.Nation != Nation.None && this.AssignTreasury() )
                    {
                        if( this.Treasury is BaseContainer )
                            ( (BaseContainer)this.Treasury ).DropAndStack( copper );
                    }
                }
            }

            else
                base.OnDoubleClick( from );
        }
Example #10
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 ));
		}
Example #11
0
		public virtual bool Give(Mobile m, Item item, bool placeAtFeet)
		{
			if (m.PlaceInBackpack(item))
			{
				return true;
			}

			if (!placeAtFeet)
			{
				return false;
			}

			Map map = m.Map;

			if (map == null)
			{
				return false;
			}

			var list = m.GetItemsInRange(0);
			var atFeet = list.OfType<Item>().ToList();

			list.Free();

			if (atFeet.Any(check => check.StackWith(m, item, false)))
			{
				return true;
			}

			item.MoveToWorld(m.Location, map);
			return true;
		}