Beispiel #1
0
		public static bool FindEntity( Type type, Point3D p, Map map, bool mob )
		{
			IPooledEnumerable loc;
			Rectangle2D rect = new Rectangle2D( p.X, p.Y, 1, 1 );
			if( mob )
				loc = map.GetMobilesInBounds( rect );
			else
				loc = map.GetItemsInBounds( rect );

			bool found = false;

			try
			{
				foreach( object o in loc )
					if( o != null && o.GetType() == type || o.GetType().IsSubclassOf( type ) )
					{
						found = true;
						break;
					}
			}
			catch
			{
			}

			loc.Free();

			return found;
		}
        public void OnTarget( Mobile from, Map map, Point3D start, Point3D end, object state )
        {
            try
            {
                object[] states = (object[]) state;
                BaseCommand command = (BaseCommand) states[0];
                string[] args = (string[]) states[1];

                ObjectConditional cond = ObjectConditional.Parse( from, ref args );

                Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );

                bool items, mobiles;

                if ( !CheckObjectTypes( command, cond, out items, out mobiles ) )
                {
                    return;
                }

                IEnumerable<object> eable;

                if ( items && mobiles )
                {
                    eable = map.GetObjectsInBounds( rect );
                }
                else if ( items )
                {
                    eable = map.GetItemsInBounds( rect );
                }
                else if ( mobiles )
                {
                    eable = map.GetMobilesInBounds( rect );
                }
                else
                {
                    return;
                }

                ArrayList objs = new ArrayList();

                foreach ( object obj in eable )
                {
                    if ( mobiles && obj is Mobile && !BaseCommand.IsAccessible( from, obj ) )
                    {
                        continue;
                    }

                    if ( cond.CheckCondition( obj ) )
                    {
                        objs.Add( obj );
                    }
                }

                RunCommand( from, objs, command, args );
            }
            catch ( Exception ex )
            {
                from.SendMessage( ex.Message );
            }
        }
Beispiel #3
0
        public static void DoWipe( Mobile from, Map map, Point3D start, Point3D end, WipeType type )
        {
            CommandLogging.WriteLine( from, "{0} {1} wiping from {2} to {3} in {5} ({4})", from.AccessLevel, CommandLogging.Format( from ), start, end, type, map );

            bool mobiles = ( ( type & WipeType.Mobiles ) != 0 );
            bool multis = ( ( type & WipeType.Multis ) != 0 );
            bool items = ( ( type & WipeType.Items ) != 0 );

            ArrayList toDelete = new ArrayList();

            Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );

            IEnumerable<object> eable;

            if ( ( items || multis ) && mobiles )
            {
                eable = map.GetObjectsInBounds( rect );
            }
            else if ( items || multis )
            {
                eable = map.GetItemsInBounds( rect );
            }
            else if ( mobiles )
            {
                eable = map.GetMobilesInBounds( rect );
            }
            else
            {
                return;
            }

            foreach ( object obj in eable )
            {
                if ( items && ( obj is Item ) && !( ( obj is BaseMulti ) || ( obj is HouseSign ) ) )
                {
                    toDelete.Add( obj );
                }
                else if ( multis && ( obj is BaseMulti ) )
                {
                    toDelete.Add( obj );
                }
                else if ( mobiles && ( obj is Mobile ) && !( (Mobile) obj ).IsPlayer )
                {
                    toDelete.Add( obj );
                }
            }

            for ( int i = 0; i < toDelete.Count; ++i )
            {
                if ( toDelete[i] is Item )
                {
                    ( (Item) toDelete[i] ).Delete();
                }
                else if ( toDelete[i] is Mobile )
                {
                    ( (Mobile) toDelete[i] ).Delete();
                }
            }
        }
		private void BoundingBox_Callback( Mobile from, Map map, Point3D start, Point3D end, object state )
		{
			Utility.FixPoints( ref start, ref end );
			Rectangle2D rect = new Rectangle2D(start, end);

			#region MobileSaver
			from.SendMessage( "Extracting Mobiles" );

			foreach ( Mobile m in map.GetMobilesInBounds( rect ) )
			{
				if ( m != null && m is BaseCreature )
				{
					int saveflag = MobileSaver.GetSaveFlag( m );

					if ( saveflag > 0 )
					{
						DesignItem designItem = new DesignItem();
						designItem.ItemID = (short)0x1;
						designItem.X = m.X;
						designItem.Y = m.Y;
						designItem.Z = m.Z + saveflag;
						designItem.Hue = (short)m.Hue;
					}
				}
			}
			#endregion

			for ( int x = 0; x <= rect.Width; ++x )
			{
				for ( int y = 0; y <= rect.Height; ++y )
				{
					int tileX = rect.Start.X + x;
					int tileY = rect.Start.Y + y;

					Sector sector = map.GetSector( tileX, tileY );

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

						if(_args.UseMinZ && item.Z < _args.MinZ)
							continue;
						else if(_args.UseMaxZ && item.Z > _args.MaxZ)
							continue;

						if ( item.Visible && item.X == tileX && item.Y == tileY && !((item is BaseMulti) || (item is HouseSign)) )
						{
							_itemSerials.Add(item.Serial.Value);
						}
					}
				}
			}

			if(_itemSerials.Count > 0)
				SendResponse(new SelectItemsResponse((int[])_itemSerials.ToArray(typeof(int))));
			else
				SendResponse(null);
		}
		public void OnTarget( Mobile from, Map map, Point3D start, Point3D end, object state )
		{
			try
			{
                if ( from.AccessLevel < MaxLengthOverride && Math.Max(end.X - start.X, end.Y - start.Y) > MaxLength )
                {
                    from.SendMessage("Maximum bounding box size exceeded.");
                    return;
                }

                object[] states = (object[])state;
				BaseCommand command = (BaseCommand)states[0];
				string[] args = (string[])states[1];

				Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );

				Extensions ext = Extensions.Parse( from, ref args );

				bool items, mobiles;

				if ( !CheckObjectTypes( from, command, ext, out items, out mobiles ) )
					return;

				IPooledEnumerable eable;

				if ( items && mobiles )
					eable = map.GetObjectsInBounds( rect );
				else if ( items )
					eable = map.GetItemsInBounds( rect );
				else if ( mobiles )
					eable = map.GetMobilesInBounds( rect );
				else
					return;

				ArrayList objs = new ArrayList();

				foreach ( object obj in eable )
				{
					if ( mobiles && obj is Mobile && !BaseCommand.IsAccessible( from, obj ) )
						continue;

					if ( ext.IsValid( obj ) )
						objs.Add( obj );
				}

				eable.Free();

				ext.Filter( objs );

				RunCommand( from, objs, command, args );
			}
			catch ( Exception ex )
			{
				from.SendMessage( ex.Message );
			}
		}
		public void OnTarget( Mobile from, Map map, Point3D start, Point3D end, object state )
		{
			try
			{
                if (from.AccessLevel < MIN_MAX_EDGE_OVERRIDE_ACCESS_LEVEL &&
                    Math.Max(end.X - start.X, end.Y - start.Y) > MAX_EDGE_LENGTH)
                {
                    from.SendMessage("Maximum bounding box size exceeded.");
                    return;
                }

                object[] states = (object[])state;
				BaseCommand command = (BaseCommand)states[0];
				string[] args = (string[])states[1];

				ObjectConditional cond = ObjectConditional.Parse( from, ref args );

				Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );

				bool items, mobiles;

				if ( !CheckObjectTypes( command, cond, out items, out mobiles ) )
					return;

				IPooledEnumerable eable;

				if ( items && mobiles )
					eable = map.GetObjectsInBounds( rect );
				else if ( items )
					eable = map.GetItemsInBounds( rect );
				else if ( mobiles )
					eable = map.GetMobilesInBounds( rect );
				else
					return;

				ArrayList objs = new ArrayList();

				foreach ( object obj in eable )
				{
					if ( mobiles && obj is Mobile && !BaseCommand.IsAccessible( from, obj ) )
						continue;

					if ( cond.CheckCondition( obj ) )
						objs.Add( obj );
				}

				eable.Free();

				RunCommand( from, objs, command, args );
			}
			catch ( Exception ex )
			{
				from.SendMessage( ex.Message );
			}
		}
Beispiel #7
0
		public static void DoWipe( Mobile from, Map map, Point3D start, Point3D end, WipeType type )
		{
			CommandLogging.WriteLine( from, "{0} {1} wiping from {2} to {3} in {5} ({4})", from.AccessLevel, CommandLogging.Format( from ), start, end, type, map );

			bool mobiles = ( (type & WipeType.Mobiles) != 0 );
			bool multis = ( (type & WipeType.Multis) != 0 );
			bool items = ( (type & WipeType.Items) != 0 );

			List<IEntity> toDelete = new List<IEntity>();

			Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );

			IPooledEnumerable eable;

			if ( (items || multis) && mobiles )
				eable = map.GetObjectsInBounds( rect );
			else if ( items || multis )
				eable = map.GetItemsInBounds( rect );
			else if ( mobiles )
				eable = map.GetMobilesInBounds( rect );
			else
				return;

			foreach ( IEntity obj in eable )
			{
				if ( items && (obj is Item) && ((Item)obj).CommandDelete && !((obj is BaseMulti) || (obj is HouseSign)) )
					toDelete.Add( obj );
				else if ( multis && (obj is BaseMulti) )
					toDelete.Add( obj );
				else if ( mobiles && (obj is Mobile) && !((Mobile)obj).Player )
					toDelete.Add( obj );
			}

			eable.Free();

			foreach (IEntity d in toDelete)
				d.Delete();
		}
Beispiel #8
0
        public bool CanFit(Point3D p, Map map, int itemID)
        {
            if (map == null || map == Map.Internal || Deleted || CheckDecay())
                return false;

            MultiComponentList newComponents = MultiData.GetComponents(itemID);

            for (int x = 0; x < newComponents.Width; ++x)
            {
                for (int y = 0; y < newComponents.Height; ++y)
                {
                    int tx = p.X + newComponents.Min.X + x;
                    int ty = p.Y + newComponents.Min.Y + y;
                    
                    if (newComponents.Tiles[x][y].Length == 0 || Contains(tx, ty) || IsExcludedTile(newComponents.Tiles[x][y]))
                        continue;

                    LandTile landTile = map.Tiles.GetLandTile(tx, ty);
                    StaticTile[] tiles = map.Tiles.GetStaticTiles(tx, ty, true);

                    //if (tiles.Length > 0 && IsExcludedTile(tiles) && !Contains(tiles[0].X, tiles[0].Y))
                    //    continue;

                    bool hasWater = false;

                    if (landTile.Z == p.Z && ((landTile.ID >= 168 && landTile.ID <= 171) || (landTile.ID >= 310 && landTile.ID <= 311)))
                        hasWater = true;

                    int z = p.Z;

                    //int landZ = 0, landAvg = 0, landTop = 0;

                    //map.GetAverageZ( tx, ty, ref landZ, ref landAvg, ref landTop );

                    //if ( !landTile.Ignored && top > landZ && landTop > z )
                    //	return false;

                    for (int i = 0; i < tiles.Length; ++i)
                    {
                        StaticTile tile = tiles[i];

                        if (IsExcludedTile(tile))
                            continue;

                        bool isWater = (tile.ID >= 0x1796 && tile.ID <= 0x17B2);

                        if (tile.Z == p.Z && isWater)
                            hasWater = true;
                        else if (tile.Z >= p.Z && !isWater)
                            return false;
                    }

                    if (!hasWater)
                        return false;
                }
            }

            IPooledEnumerable eable = map.GetItemsInBounds(new Rectangle2D(p.X + newComponents.Min.X, p.Y + newComponents.Min.Y, newComponents.Width, newComponents.Height));

            foreach (Item item in eable)
            {
                if (CheckItem(itemID, item, p) || CanMoveOver(item) || item.Z < p.Z || ExemptOverheadComponent(p, itemID, item.X, item.Y, item.Z + item.ItemData.Height))
                    continue;

                int x = item.X - p.X + newComponents.Min.X;
                int y = item.Y - p.Y + newComponents.Min.Y;

                if (x >= 0 && x < newComponents.Width && y >= 0 && y < newComponents.Height && newComponents.Tiles[x][y].Length == 0)
                    continue;

                eable.Free();
                return false;
            }

            eable.Free();

            IPooledEnumerable mobiles = map.GetMobilesInBounds(new Rectangle2D(p.X + newComponents.Min.X, p.Y + newComponents.Min.Y, newComponents.Width, newComponents.Height));

            foreach (Mobile mobile in mobiles)
            {
                if (mobile is BaseSeaChampion)
                {
                    mobiles.Free();
                    return false;
                }
            }

            mobiles.Free();

            return true;
        }
Beispiel #9
0
        private void CheckHint(Map map)
        {
            IPooledEnumerable eable = map.GetMobilesInBounds(new Rectangle2D(735, 2135, 24, 24));

            foreach (Mobile m in eable)
            {
                if (m is BaseVendor)
                {
                    IPooledEnumerable players = map.GetMobilesInRange(m.Location, 3);

                    foreach (Mobile player in players)
                    {
                        if (player is PlayerMobile && ((PlayerMobile)player).NpcGuild == NpcGuild.RangersGuild && !player.Hidden)
                        {
                            GiveHint(player, m);
                            eable.Free();
                            players.Free();
                            return;
                        }
                    }

                    players.Free();
                }
            }

            eable.Free();
        }