Example #1
0
		public unsafe LandData(OldLandTileDataMul mulstruct)
		{
			m_TexID = mulstruct.texID;
			m_Flags = (TileFlag)mulstruct.flags;
			m_Unk1 = 0;
			m_Name = TileData.ReadNameString(mulstruct.name);
		}
Example #2
0
		private void SetFlag(TileFlag flag, bool set)
		{
			if (set)
				Flags |= flag;
			else
				Flags &= ~flag;
		}
Example #3
0
		public LandData(string name, int TexID, TileFlag flags, int unk1)
		{
			m_Name = name;
			m_TexID = (short)TexID;
			m_Flags = flags;
			m_Unk1 = unk1;
		}
Example #4
0
 public bool this[TileFlag flag]
 {
     get
     {
         return ((this.Value & flag) != 0);
     }
 }
Example #5
0
		public ItemData( string name, TileFlag flags, int weight, int quality, int quantity, int value, int height )
		{
			m_Name = name;
			m_Flags = flags;
			m_Weight = (byte)weight;
			m_Quality = (byte)quality;
			m_Quantity = (byte)quantity;
			m_Value = (byte)value;
			m_Height = (byte)height;
		}
Example #6
0
 public ItemData(string name, TileFlag flags, int weight, int quality, int quantity, int value, int height, int anim)
 {
     _name = name;
     _flags = flags;
     _weight = (byte)weight;
     _quality = (byte)quality;
     _quantity = (byte)quantity;
     _value = (byte)value;
     _height = (byte)height;
     _animation = (short)anim;
 }
 public ItemData(string name, TileFlag flags, int weight, int quality, int quantity, int value, int height, int anim)
 {
     this.m_Name = name;
     this.m_Flags = flags;
     this.m_Weight = (byte)weight;
     this.m_Quality = (byte)quality;
     this.m_Quantity = (byte)quantity;
     this.m_Value = (byte)value;
     this.m_Height = (byte)height;
     this.m_Animation = (short)anim;
 }
Example #8
0
        private bool Check(Map map, Mobile m, ArrayList items, int x, int y, int startTop, int startZ, bool canSwim, bool cantWalk, out int newZ)
        {
            newZ = 0;

            Tile[] tiles    = map.Tiles.GetStaticTiles(x, y, true);
            Tile   landTile = map.Tiles.GetLandTile(x, y);

            bool landBlocks   = (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) != 0;
            bool considerLand = !landTile.Ignored;

            if (landBlocks && canSwim && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) != 0)
            {
                landBlocks = false;
            }
            else if (cantWalk && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) == 0)
            {
                landBlocks = true;
            }

            int landZ = 0, landCenter = 0, landTop = 0;

            map.GetAverageZ(x, y, ref landZ, ref landCenter, ref landTop);

            bool moveIsOk = false;

            int stepTop  = startTop + StepHeight;
            int checkTop = startZ + PersonHeight;

            bool ignoreDoors = (m_AlwaysIgnoreDoors || !m.Alive || m.Body.BodyID == 0x3DB || m.IsDeadBondedPet);

            for (int i = 0; i < tiles.Length; ++i)
            {
                Tile     tile     = tiles[i];
                ItemData itemData = TileData.ItemTable[tile.ID & 0x3FFF];
                TileFlag flags    = itemData.Flags;

                if ((flags & ImpassableSurface) == TileFlag.Surface || (canSwim && (flags & TileFlag.Wet) != 0))                   // Surface && !Impassable
                {
                    if (cantWalk && (flags & TileFlag.Wet) == 0)
                    {
                        continue;
                    }

                    int itemZ   = tile.Z;
                    int itemTop = itemZ;
                    int ourZ    = itemZ + itemData.CalcHeight;
                    int testTop = checkTop;

                    if (moveIsOk)
                    {
                        int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z);

                        if (cmp > 0 || (cmp == 0 && ourZ > newZ))
                        {
                            continue;
                        }
                    }

                    if (ourZ + PersonHeight > testTop)
                    {
                        testTop = ourZ + PersonHeight;
                    }

                    if (!itemData.Bridge)
                    {
                        itemTop += itemData.Height;
                    }

                    if (stepTop >= itemTop)
                    {
                        int landCheck = itemZ;

                        if (itemData.Height >= StepHeight)
                        {
                            landCheck += StepHeight;
                        }
                        else
                        {
                            landCheck += itemData.Height;
                        }

                        if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ)
                        {
                            continue;
                        }

                        if (IsOk(ignoreDoors, ourZ, testTop, tiles, items))
                        {
                            newZ     = ourZ;
                            moveIsOk = true;
                        }
                    }
                }
            }

            for (int i = 0; i < items.Count; ++i)
            {
                Item     item     = (Item)items[i];
                ItemData itemData = item.ItemData;                //TileData.ItemTable[item.ItemID & 0x3FFF];
                TileFlag flags    = itemData.Flags;

                if ((flags & ImpassableSurface) == TileFlag.Surface || (m.CanSwim && (flags & TileFlag.Wet) != 0))                   // Surface && !Impassable
                {
                    if (cantWalk && (flags & TileFlag.Wet) == 0)
                    {
                        continue;
                    }

                    int itemZ   = item.Z;
                    int itemTop = itemZ;
                    int ourZ    = itemZ + itemData.CalcHeight;
                    int testTop = checkTop;

                    if (moveIsOk)
                    {
                        int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z);

                        if (cmp > 0 || (cmp == 0 && ourZ > newZ))
                        {
                            continue;
                        }
                    }

                    if (ourZ + PersonHeight > testTop)
                    {
                        testTop = ourZ + PersonHeight;
                    }

                    if (!itemData.Bridge)
                    {
                        itemTop += itemData.Height;
                    }

                    if (stepTop >= itemTop)
                    {
                        int landCheck = itemZ;

                        if (itemData.Height >= StepHeight)
                        {
                            landCheck += StepHeight;
                        }
                        else
                        {
                            landCheck += itemData.Height;
                        }

                        if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ)
                        {
                            continue;
                        }

                        if (IsOk(ignoreDoors, ourZ, testTop, tiles, items))
                        {
                            newZ     = ourZ;
                            moveIsOk = true;
                        }
                    }
                }
            }

            if (considerLand && !landBlocks && stepTop >= landZ)
            {
                int ourZ    = landCenter;
                int testTop = checkTop;

                if (ourZ + PersonHeight > testTop)
                {
                    testTop = ourZ + PersonHeight;
                }

                bool shouldCheck = true;

                if (moveIsOk)
                {
                    int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z);

                    if (cmp > 0 || (cmp == 0 && ourZ > newZ))
                    {
                        shouldCheck = false;
                    }
                }

                if (shouldCheck && IsOk(ignoreDoors, ourZ, testTop, tiles, items))
                {
                    newZ     = ourZ;
                    moveIsOk = true;
                }
            }

            return(moveIsOk);
        }
        private static bool check(Map map, Mobile m, List <Item> items, int x, int y, int startTop, int startZ, out int newZ)
        {
            newZ = 0;

            MapTile mapTile = map.GetMapTile(x, y);

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

            StaticItem[] tiles = mapTile.GetStatics().ToArray();

            bool landBlocks   = (mapTile.Ground.LandData.Flags & TileFlag.Impassable) != 0;
            bool considerLand = !mapTile.Ground.IsIgnored;

            //if (landBlocks && canSwim && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) != 0)	//Impassable, Can Swim, and Is water.  Don't block it.
            //    landBlocks = false;
            // else
            // if (cantWalk && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) == 0)	//Can't walk and it's not water
            //     landBlocks = true;

            int landLow = 0, landCenter = 0, landTop = 0;

            landCenter = map.GetAverageZ(x, y, ref landLow, ref landTop);

            bool moveIsOk = false;

            int stepTop  = startTop + StepHeight;
            int checkTop = startZ + PersonHeight;

            bool ignoreDoors = (!m.Alive || m.BodyID == 0x3DB);

            #region Tiles
            for (int i = 0; i < tiles.Length; ++i)
            {
                StaticItem tile = tiles[i];

                if ((tile.ItemData.Flags & ImpassableSurface) == TileFlag.Surface) //  || (canSwim && (flags & TileFlag.Wet) != 0) Surface && !Impassable
                {
                    // if (cantWalk && (flags & TileFlag.Wet) == 0)
                    //     continue;

                    int itemZ   = (int)tile.Z;
                    int itemTop = itemZ;
                    int ourZ    = itemZ + tile.ItemData.CalcHeight;
                    int ourTop  = ourZ + PersonHeight;
                    int testTop = checkTop;

                    if (moveIsOk)
                    {
                        int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z);

                        if (cmp > 0 || (cmp == 0 && ourZ > newZ))
                        {
                            continue;
                        }
                    }

                    if (ourZ + PersonHeight > testTop)
                    {
                        testTop = ourZ + PersonHeight;
                    }

                    if (!tile.ItemData.IsBridge)
                    {
                        itemTop += tile.ItemData.Height;
                    }

                    if (stepTop >= itemTop)
                    {
                        int landCheck = itemZ;

                        if (tile.ItemData.Height >= StepHeight)
                        {
                            landCheck += StepHeight;
                        }
                        else
                        {
                            landCheck += tile.ItemData.Height;
                        }

                        if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landLow)
                        {
                            continue;
                        }

                        if (IsOk(ignoreDoors, ourZ, testTop, tiles, items))
                        {
                            newZ     = ourZ;
                            moveIsOk = true;
                        }
                    }
                }
            }
            #endregion

            #region Items
            for (int i = 0; i < items.Count; ++i)
            {
                Item item = items[i];
                UltimaData.ItemData itemData = item.ItemData;
                TileFlag            flags    = itemData.Flags;

                if ((flags & ImpassableSurface) == TileFlag.Surface) // Surface && !Impassable && !Movable
                {
                    //  || (m.CanSwim && (flags & TileFlag.Wet) != 0))
                    // !item.Movable &&
                    // if (cantWalk && (flags & TileFlag.Wet) == 0)
                    //     continue;

                    int itemZ   = item.Z;
                    int itemTop = itemZ;
                    int ourZ    = itemZ + itemData.CalcHeight;
                    int ourTop  = ourZ + PersonHeight;
                    int testTop = checkTop;

                    if (moveIsOk)
                    {
                        int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z);

                        if (cmp > 0 || (cmp == 0 && ourZ > newZ))
                        {
                            continue;
                        }
                    }

                    if (ourZ + PersonHeight > testTop)
                    {
                        testTop = ourZ + PersonHeight;
                    }

                    if (!itemData.IsBridge)
                    {
                        itemTop += itemData.Height;
                    }

                    if (stepTop >= itemTop)
                    {
                        int landCheck = itemZ;

                        if (itemData.Height >= StepHeight)
                        {
                            landCheck += StepHeight;
                        }
                        else
                        {
                            landCheck += itemData.Height;
                        }

                        if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landLow)
                        {
                            continue;
                        }

                        if (IsOk(ignoreDoors, ourZ, testTop, tiles, items))
                        {
                            newZ     = ourZ;
                            moveIsOk = true;
                        }
                    }
                }
            }

            #endregion

            if (considerLand && !landBlocks && (stepTop) >= landLow)
            {
                int ourZ    = landCenter;
                int ourTop  = ourZ + PersonHeight;
                int testTop = checkTop;

                if (ourZ + PersonHeight > testTop)
                {
                    testTop = ourZ + PersonHeight;
                }

                bool shouldCheck = true;

                if (moveIsOk)
                {
                    int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z);

                    if (cmp > 0 || (cmp == 0 && ourZ > newZ))
                    {
                        shouldCheck = false;
                    }
                }

                if (shouldCheck && IsOk(ignoreDoors, ourZ, testTop, tiles, items))
                {
                    newZ     = ourZ;
                    moveIsOk = true;
                }
            }

            return(moveIsOk);
        }
Example #10
0
        public static HousePlacementResult Check(Mobile from, int multiID, Point3D center, out ArrayList toMove)
        {
            // If this spot is considered valid, every item and mobile in this list will be moved under the house sign
            toMove = new ArrayList();

            Map map = from.Map;

            if (map == null || map == Map.Internal)
            {
                return(HousePlacementResult.BadLand);                // A house cannot go here
            }
            if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                return(HousePlacementResult.Valid);                // Staff can place anywhere
            }
            if (map == Map.Ilshenar)
            {
                return(HousePlacementResult.BadRegion);                // No houses in Ilshenar
            }
            // This holds data describing the internal structure of the house
            MultiComponentList mcl = MultiData.GetComponents(multiID);

            if (multiID >= 0x13EC && multiID < 0x1D00)
            {
                HouseFoundation.AddStairsTo(ref mcl);                   // this is a AOS house, add the stairs
            }
            // Location of the nortwest-most corner of the house
            Point3D start = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z);

            // These are storage lists. They hold items and mobiles found in the map for further processing
            ArrayList items = new ArrayList(), mobiles = new ArrayList();

            // These are also storage lists. They hold location values indicating the yard and border locations.
            ArrayList yard = new ArrayList(), borders = new ArrayList();

            /* RULES:
             *
             * 1) All tiles which are around the -outside- of the foundation must not have anything impassable.
             * 2) No impassable object or land tile may come in direct contact with any part of the house.
             * 3) Five tiles from the front and back of the house must be completely clear of all house tiles.
             * 4) The foundation must rest flatly on a surface. Any bumps around the foundation are not allowed.
             * 5) No foundation tile may reside over terrain which is viewed as a road.
             */

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

                    Tile[] addTiles = mcl.Tiles[x][y];

                    if (addTiles.Length == 0)
                    {
                        continue;                         // There are no tiles here, continue checking somewhere else
                    }
                    Point3D testPoint = new Point3D(tileX, tileY, center.Z);

                    HousePlacementResult RegionCheck = HousePlacementRegionCheck(from, map, testPoint);
                    if (RegionCheck != HousePlacementResult.Valid)
                    {
                        return(RegionCheck);
                    }

                    Tile landTile = map.Tiles.GetLandTile(tileX, tileY);
                    int  landID   = landTile.ID & 0x3FFF;

                    Tile[] oldTiles = map.Tiles.GetStaticTiles(tileX, tileY, true);

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

                    items.Clear();

                    foreach (Item item in sector.Items.Values)
                    {
                        if (item == null)
                        {
                            continue;
                        }

                        if (item.Visible && item.X == tileX && item.Y == tileY)
                        {
                            items.Add(item);
                        }
                    }

                    mobiles.Clear();

                    foreach (Mobile m in sector.Mobiles.Values)
                    {
                        if (m == null)
                        {
                            continue;
                        }

                        if (m.X == tileX && m.Y == tileY)
                        {
                            mobiles.Add(m);
                        }
                    }

                    int landStartZ = 0, landAvgZ = 0, landTopZ = 0;

                    map.GetAverageZ(tileX, tileY, ref landStartZ, ref landAvgZ, ref landTopZ);

                    bool hasFoundation = false;

                    for (int i = 0; i < addTiles.Length; ++i)
                    {
                        Tile addTile = addTiles[i];

                        if (addTile.ID == 0x4001)                           // Nodraw
                        {
                            continue;
                        }

                        TileFlag addTileFlags = TileData.ItemTable[addTile.ID & 0x3FFF].Flags;

                        bool isFoundation = (addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0);
                        bool hasSurface   = false;

                        if (isFoundation)
                        {
                            hasFoundation = true;
                        }

                        int addTileZ   = center.Z + addTile.Z;
                        int addTileTop = addTileZ + addTile.Height;

                        if ((addTileFlags & TileFlag.Surface) != 0)
                        {
                            addTileTop += 16;
                        }

                        if (addTileTop > landStartZ && landAvgZ > addTileZ)
                        {
                            return(HousePlacementResult.BadLand);                            // Broke rule #2
                        }
                        if (isFoundation && ((TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) == 0) && landAvgZ == center.Z)
                        {
                            hasSurface = true;
                        }

                        for (int j = 0; j < oldTiles.Length; ++j)
                        {
                            Tile     oldTile = oldTiles[j];
                            ItemData id      = TileData.ItemTable[oldTile.ID & 0x3FFF];

                            if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)) && addTileTop > oldTile.Z && (oldTile.Z + id.CalcHeight) > addTileZ)
                            {
                                return(HousePlacementResult.BadStatic);                                // Broke rule #2
                            }
                            else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (oldTile.Z + id.CalcHeight) == center.Z)
                            {
                                hasSurface = true;
                            }
                        }

                        for (int j = 0; j < items.Count; ++j)
                        {
                            Item     item = (Item)items[j];
                            ItemData id   = item.ItemData;

                            if (addTileTop > item.Z && (item.Z + id.CalcHeight) > addTileZ)
                            {
                                if (item.Movable)
                                {
                                    toMove.Add(item);
                                }
                                else if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)))
                                {
                                    return(HousePlacementResult.BadItem);                                    // Broke rule #2
                                }
                            }
                            else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (item.Z + id.CalcHeight) == center.Z)
                            {
                                hasSurface = true;
                            }
                        }

                        if (isFoundation && !hasSurface)
                        {
                            return(HousePlacementResult.NoSurface);                            // Broke rule #4
                        }
                        for (int j = 0; j < mobiles.Count; ++j)
                        {
                            Mobile m = (Mobile)mobiles[j];

                            if (addTileTop > m.Z && (m.Z + 16) > addTileZ)
                            {
                                toMove.Add(m);
                            }
                        }
                    }

                    for (int i = 0; i < m_RoadIDs.Length; i += 2)
                    {
                        if ((landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1]) && (ExceptionTiles(landID) == false))
                        {
                            //Console.WriteLine(landID.ToString());
                            return(HousePlacementResult.BadLand);                            // Broke rule #5
                        }
                    }

                    if (hasFoundation)
                    {
                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -YardSize; yOffset <= YardSize; ++yOffset)
                            {
                                Point2D yardPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!yard.Contains(yardPoint))
                                {
                                    yard.Add(yardPoint);
                                }
                            }
                        }

                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -1; yOffset <= 1; ++yOffset)
                            {
                                if (xOffset == 0 && yOffset == 0)
                                {
                                    continue;
                                }

                                // To ease this rule, we will not add to the border list if the tile here is under a base floor (z<=8)

                                int vx = x + xOffset;
                                int vy = y + yOffset;

                                if (vx >= 0 && vx < mcl.Width && vy >= 0 && vy < mcl.Height)
                                {
                                    Tile[] breakTiles  = mcl.Tiles[vx][vy];
                                    bool   shouldBreak = false;

                                    for (int i = 0; !shouldBreak && i < breakTiles.Length; ++i)
                                    {
                                        Tile breakTile = breakTiles[i];

                                        if (breakTile.Height == 0 && breakTile.Z <= 8 && TileData.ItemTable[breakTile.ID & 0x3FFF].Surface)
                                        {
                                            shouldBreak = true;
                                        }
                                    }

                                    if (shouldBreak)
                                    {
                                        continue;
                                    }
                                }

                                Point2D borderPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!borders.Contains(borderPoint))
                                {
                                    borders.Add(borderPoint);
                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < borders.Count; ++i)
            {
                Point2D borderPoint = (Point2D)borders[i];

                Tile landTile = map.Tiles.GetLandTile(borderPoint.X, borderPoint.Y);
                int  landID   = landTile.ID & 0x3FFF;

                if ((TileData.LandTable[landID].Flags & TileFlag.Impassable) != 0)
                {
                    return(HousePlacementResult.BadLand);
                }

                for (int j = 0; j < m_RoadIDs.Length; j += 2)
                {
                    if ((landID >= m_RoadIDs[j] && landID <= m_RoadIDs[j + 1]) && (ExceptionTiles(landID) == false))
                    {
                        //Console.WriteLine(landID.ToString());
                        return(HousePlacementResult.BadLand);                        // Broke rule #5
                    }
                }

                Tile[] tiles = map.Tiles.GetStaticTiles(borderPoint.X, borderPoint.Y, true);

                for (int j = 0; j < tiles.Length; ++j)
                {
                    Tile     tile = tiles[j];
                    ItemData id   = TileData.ItemTable[tile.ID & 0x3FFF];

                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (tile.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        return(HousePlacementResult.BadStatic);                        // Broke rule #1
                    }
                }

                Sector sector = map.GetSector(borderPoint.X, borderPoint.Y);

                foreach (Item item in sector.Items.Values)
                {
                    if (item == null)
                    {
                        continue;
                    }

                    if (item.X != borderPoint.X || item.Y != borderPoint.Y || item.Movable)
                    {
                        continue;
                    }

                    ItemData id = item.ItemData;

                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (item.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        return(HousePlacementResult.BadItem);                        // Broke rule #1
                    }
                }
            }

            for (int i = 0; i < yard.Count; ++i)
            {
                Point2D yardPoint = (Point2D)yard[i];

                IPooledEnumerable eable = map.GetMultiTilesAt(yardPoint.X, yardPoint.Y);

                foreach (Tile[] tile in eable)
                {
                    for (int j = 0; j < tile.Length; ++j)
                    {
                        if ((TileData.ItemTable[tile[j].ID & 0x3FFF].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0)
                        {
                            eable.Free();
                            return(HousePlacementResult.BadStatic);                            // Broke rule #3
                        }
                    }
                }

                eable.Free();
            }

            return(HousePlacementResult.Valid);

            /*if ( blockedLand || blockedStatic || blockedItem )
             * {
             *      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.
             * }
             * else if ( !foundationHasSurface )
             * {
             *      from.SendMessage( "The house could not be created here.  Part of the foundation would not be on any surface." );
             * }
             * else
             * {
             *      BaseHouse house = GetHouse( from );
             *      house.MoveToWorld( center, from.Map );
             *      this.Delete();
             *
             *      for ( int i = 0; i < toMove.Count; ++i )
             *      {
             *              object o = toMove[i];
             *
             *              if ( o is Mobile )
             *                      ((Mobile)o).Location = house.BanLocation;
             *              else if ( o is Item )
             *                      ((Item)o).Location = house.BanLocation;
             *      }
             * }*/
        }
Example #11
0
        public bool CheckMovement(IPoint3D p, Map map, Point3D loc, Direction d, out int newZ)
        {
            if (!Enabled && _Successor != null)
            {
                return(_Successor.CheckMovement(p, map, loc, d, out newZ));
            }

            if (map == null || map == Map.Internal)
            {
                newZ = 0;
                return(false);
            }

            int xStart = loc.X;
            int yStart = loc.Y;

            int xForward = xStart, yForward = yStart;
            int xRight = xStart, yRight = yStart;
            int xLeft = xStart, yLeft = yStart;

            bool checkDiagonals = ((int)d & 0x1) == 0x1;

            Offset(d, ref xForward, ref yForward);
            Offset((Direction)(((int)d - 1) & 0x7), ref xLeft, ref yLeft);
            Offset((Direction)(((int)d + 1) & 0x7), ref xRight, ref yRight);

            if (xForward < 0 || yForward < 0 || xForward >= map.Width || yForward >= map.Height)
            {
                newZ = 0;
                return(false);
            }

            int startZ, startTop;

            IEnumerable <Item> itemsStart, itemsForward, itemsLeft, itemsRight;

            bool     ignoreMovableImpassables = MovementImpl.IgnoresMovableImpassables(p);
            TileFlag reqFlags = ImpassableSurface;

            if (p is Mobile mobile && mobile.CanSwim)
            {
                reqFlags |= TileFlag.Wet;
            }

            if (checkDiagonals)
            {
                Sector sStart   = map.GetSector(xStart, yStart);
                Sector sForward = map.GetSector(xForward, yForward);
                Sector sLeft    = map.GetSector(xLeft, yLeft);
                Sector sRight   = map.GetSector(xRight, yRight);

                itemsStart   = sStart.Items.Where(i => Verify(i, reqFlags, ignoreMovableImpassables, xStart, yStart));
                itemsForward = sForward.Items.Where(i => Verify(i, reqFlags, ignoreMovableImpassables, xForward, yForward));
                itemsLeft    = sLeft.Items.Where(i => Verify(i, reqFlags, ignoreMovableImpassables, xLeft, yLeft));
                itemsRight   = sRight.Items.Where(i => Verify(i, reqFlags, ignoreMovableImpassables, xRight, yRight));
            }
            else
            {
                Sector sStart   = map.GetSector(xStart, yStart);
                Sector sForward = map.GetSector(xForward, yForward);

                itemsStart   = sStart.Items.Where(i => Verify(i, reqFlags, ignoreMovableImpassables, xStart, yStart));
                itemsForward = sForward.Items.Where(i => Verify(i, reqFlags, ignoreMovableImpassables, xForward, yForward));
                itemsLeft    = Enumerable.Empty <Item>();
                itemsRight   = Enumerable.Empty <Item>();
            }

            GetStartZ(p, map, loc, itemsStart, out startZ, out startTop);

            List <Item> list = null;

            MovementPool.AcquireMoveCache(ref list, itemsForward);
            Mobile m = p as Mobile;

            bool moveIsOk = Check(map, p, list, xForward, yForward, startTop, startZ, m != null && m.CanSwim, m != null && m.CantWalk, out newZ);

            if (m != null && moveIsOk && checkDiagonals)
            {
                int hold;

                if (m.Player && m.AccessLevel < AccessLevel.GameMaster)
                {
                    MovementPool.AcquireMoveCache(ref list, itemsLeft);

                    if (!Check(map, m, list, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk, out hold))
                    {
                        moveIsOk = false;
                    }
                    else
                    {
                        MovementPool.AcquireMoveCache(ref list, itemsRight);

                        if (!Check(map, m, list, xRight, yRight, startTop, startZ, m.CanSwim, m.CantWalk, out hold))
                        {
                            moveIsOk = false;
                        }
                    }
                }
                else
                {
                    MovementPool.AcquireMoveCache(ref list, itemsLeft);

                    if (!Check(map, m, list, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk, out hold))
                    {
                        MovementPool.AcquireMoveCache(ref list, itemsRight);

                        if (!Check(map, m, list, xRight, yRight, startTop, startZ, m.CanSwim, m.CantWalk, out hold))
                        {
                            moveIsOk = false;
                        }
                    }
                }
            }

            MovementPool.ClearMoveCache(ref list, true);

            if (!moveIsOk)
            {
                newZ = startZ;
            }

            return(moveIsOk);
        }
Example #12
0
 public MultiTileEntry(ushort itemID, short xOffset, short yOffset, short zOffset, TileFlag flags)
 {
     ItemId  = itemID;
     OffsetX = xOffset;
     OffsetY = yOffset;
     OffsetZ = zOffset;
     Flags   = flags;
 }
Example #13
0
 public unsafe LandData(LandTileOldDataMul oldmulstruct)
 {
     m_TexID = oldmulstruct.texID;
     m_Flags = (TileFlag)oldmulstruct.flags;
     m_Name = TileData.ReadNameString(oldmulstruct.name);
 }
Example #14
0
 private static bool CheckImpassableSurfaceFlags(int id, TileFlag flag)
 {
     return(((flag & ImpassableSurface) != 0) && id != 2910);
 }
Example #15
0
 public IEnumerable <ModelLandData> GetLandTile(TileFlag flags = TileFlag.None, bool valid = true)
 {
     return(new ObservableCollection <ModelLandData>(_storageLand.Where(t => t.IsValid == valid && t.Flags.HasFlag(flags)).Select(t => new ModelLandData(t))));
 }
Example #16
0
 public LandData(string name, TileFlag flags, int id)
 {
     _name  = name;
     _flags = flags;
     _id    = id;
 }
Example #17
0
        // Issue 5 - End

        static TileData()
        {
            using (FileStream fileStream = FileManager.GetFile("tiledata.mul"))
            {
                BinaryReader binaryReader = new BinaryReader(fileStream);

                LandData landData;

                for (int i = 0; i < 0x4000; i++)
                {
                    landData = new LandData();

                    if ((i & 0x1F) == 0)
                    {
                        binaryReader.ReadInt32();
                    }

                    TileFlag flags = (TileFlag)binaryReader.ReadInt32();

                    int iTextureID = binaryReader.ReadInt16();

                    binaryReader.BaseStream.Seek(20, SeekOrigin.Current);

                    landData.Flags     = flags;
                    landData.TextureID = iTextureID;

                    LandData[i] = landData;
                }

                ItemData itemData;

                for (int i = 0; i < 0x4000; i++)
                {
                    itemData = new ItemData();

                    if ((i & 0x1F) == 0)
                    {
                        binaryReader.ReadInt32();
                    }

                    itemData.Flags   = (TileFlag)binaryReader.ReadInt32();
                    itemData.Weight  = binaryReader.ReadByte();
                    itemData.Quality = binaryReader.ReadByte();

                    binaryReader.BaseStream.Seek(3, SeekOrigin.Current);

                    itemData.Quantity = binaryReader.ReadByte();
                    itemData.AnimID   = binaryReader.ReadInt16();
                    binaryReader.BaseStream.Seek(3, SeekOrigin.Current);

                    itemData.Value  = binaryReader.ReadByte();
                    itemData.Height = binaryReader.ReadByte();

                    itemData.Name = System.Text.ASCIIEncoding.ASCII.GetString((binaryReader.ReadBytes(20)));
                    itemData.Name = itemData.Name.Trim('\0');
                    // binaryReader.BaseStream.Seek(20, SeekOrigin.Current);

                    // Issue 5 - Statics (bridge, stairs, etc) should be walkable - http://code.google.com/p/ultimaxna/issues/detail?id=5 - Smjert
                    if (i > 1005 && i < 7640)
                    {
                        itemData.IsStairs = !(Array.BinarySearch(m_StairsID, i) < 0);
                    }
                    // Issue 5 - End

                    ItemData[i] = itemData;
                }

                Metrics.ReportDataRead((int)binaryReader.BaseStream.Position);
            }
        }
Example #18
0
 public LandData(string name, TileFlag flags)
 {
     _name = name;
     _flags = flags;
 }
Example #19
0
 public MultiTileEntry(ushort itemID, short xOffset, short yOffset, short zOffset, TileFlag flags)
 {
     m_ItemID  = itemID;
     m_OffsetX = xOffset;
     m_OffsetY = yOffset;
     m_OffsetZ = zOffset;
     m_Flags   = flags;
 }
Example #20
0
        public static bool CanFit(int x, int y, int z, Map map, Mobile mob, int height = 16, bool checkMobiles = true, bool requireSurface = true)
        {
            if (map == null || map == Map.Internal)
            {
                return(false);
            }

            if (x < 0 || y < 0 || x >= map.Width || y >= map.Height)
            {
                return(false);
            }

            bool hasSurface = false;
            bool canswim    = mob.CanSwim;
            bool cantwalk   = mob.CantWalk;

            LandTile lt = map.Tiles.GetLandTile(x, y);
            int      lowZ = 0, avgZ = 0, topZ = 0;

            bool surface, impassable;

            map.GetAverageZ(x, y, ref lowZ, ref avgZ, ref topZ);
            TileFlag landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags;

            impassable = (landFlags & TileFlag.Impassable) != 0;

            bool wet = (landFlags & TileFlag.Wet) != 0;

            if (cantwalk && !wet)
            {
                impassable = true;
            }

            if (canswim && wet)
            {
                impassable = false;
            }

            if (impassable && avgZ > z && (z + height) > lowZ)
            {
                return(false);
            }
            else if (!impassable && z == avgZ && !lt.Ignored)
            {
                hasSurface = true;
            }

            StaticTile[] staticTiles = map.Tiles.GetStaticTiles(x, y, true);

            for (int i = 0; i < staticTiles.Length; ++i)
            {
                ItemData id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue];
                surface    = id.Surface;
                impassable = id.Impassable;

                wet = (id.Flags & TileFlag.Wet) != 0;

                if (cantwalk && !wet)
                {
                    impassable = true;
                }
                if (canswim && wet)
                {
                    surface    = true;
                    impassable = false;
                }

                if ((surface || impassable) && (staticTiles[i].Z + id.CalcHeight) > z && (z + height) > staticTiles[i].Z)
                {
                    return(false);
                }
                else if (surface && !impassable && z == (staticTiles[i].Z + id.CalcHeight))
                {
                    hasSurface = true;
                }
            }

            IPooledEnumerable eable = map.GetItemsInRange(new Point3D(x, y, z), 0);

            foreach (Item item in eable)
            {
                if (item.ItemID < 0x4000)
                {
                    ItemData id = item.ItemData;
                    surface    = id.Surface;
                    impassable = id.Impassable;

                    wet = (id.Flags & TileFlag.Wet) != 0;
                    if (cantwalk && !wet)
                    {
                        impassable = true;
                    }
                    if (canswim && wet)
                    {
                        surface    = true;
                        impassable = false;
                    }

                    if ((surface || impassable) && (item.Z + id.CalcHeight) > z && (z + height) > item.Z)
                    {
                        eable.Free();
                        return(false);
                    }
                    else if (surface && !impassable && !item.Movable && z == (item.Z + id.CalcHeight))
                    {
                        hasSurface = true;
                    }
                }
            }

            eable.Free();

            if (checkMobiles)
            {
                eable = map.GetMobilesInRange(new Point3D(x, y, z), 0);

                foreach (Mobile m in eable)
                {
                    if (m.AccessLevel == AccessLevel.Player || !m.Hidden)
                    {
                        if ((m.Z + 16) > z && (z + height) > m.Z)
                        {
                            eable.Free();
                            return(false);
                        }
                    }
                }

                eable.Free();
            }

            return(!requireSurface || hasSurface);
        }
Example #21
0
		private static bool Verify(Item item, TileFlag reqFlags, bool ignoreMovableImpassables, int x, int y)
		{
			return Verify(item, reqFlags, ignoreMovableImpassables) && Verify(item, x, y);
		}
Example #22
0
        public static void Configure()
        {
            string filePath = Environment.FindDataFile("TileData.mul");

            if (File.Exists(filePath))
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader bin = new BinaryReader(fs);

                    m_LandData = new LandData[0x4000];

                    for (int i = 0; i < 0x4000; ++i)
                    {
                        if ((i & 0x1F) == 0)
                        {
                            bin.ReadInt32();                             // header
                        }

                        TileFlag flags = (TileFlag)bin.ReadInt64();
                        bin.ReadInt16();                         // skip 2 bytes -- textureID

                        m_LandData[i] = new LandData(ReadNameString(bin), flags);
                    }

                    m_ItemData = new ItemData[0x10000];

                    for (int i = 0; i < 0x10000; ++i)
                    {
                        if ((i & 0x1F) == 0)
                        {
                            bin.ReadInt32();                             // header
                        }

                        TileFlag flags   = (TileFlag)bin.ReadInt64();
                        int      weight  = bin.ReadByte();
                        int      quality = bin.ReadByte();
                        bin.ReadInt16();
                        bin.ReadByte();
                        int quantity = bin.ReadByte();
                        bin.ReadInt32();
                        bin.ReadByte();
                        int value  = bin.ReadByte();
                        int height = bin.ReadByte();

                        m_ItemData[i] = new ItemData(ReadNameString(bin), flags, weight, quality, quantity, value, height);
                    }
                }

                m_MaxLandValue = m_LandData.Length - 1;
                m_MaxItemValue = m_ItemData.Length - 1;
            }
            else
            {
                Console.WriteLine("TileData.mul was not found");
                Console.WriteLine("Make sure your x-runuo.xml is properly configured");
                Console.WriteLine("After pressing return an exception will be thrown and the server will terminate");

                throw new Exception(String.Format("TileData: {0} not found", filePath));
            }
        }
Example #23
0
 public IEnumerable<ModelLandData> GetLandTile(TileFlag flags = TileFlag.None, bool valid = true)
 {
     return new ObservableCollection<ModelLandData>(StorageLand.Where(t => t.IsValid == valid && t.Flags.HasFlag(flags)).Select(t => new ModelLandData(t)));
 }
Example #24
0
        public Point3D RandomSpawnLocation(int spawnHeight, bool land, bool water, Point3D home, int range)
        {
            Map map = this.Map;

            if (map == Map.Internal)
            {
                return(Point3D.Zero);
            }

            InitRectangles();

            if (m_TotalWeight <= 0)
            {
                return(Point3D.Zero);
            }

            for (int i = 0; i < 10; i++)               // Try 10 times
            {
                int x, y, minZ, maxZ;

                if (home == Point3D.Zero)
                {
                    int rand = Utility.Random(m_TotalWeight);

                    x    = int.MinValue; y = int.MinValue;
                    minZ = int.MaxValue; maxZ = int.MinValue;
                    for (int j = 0; j < m_RectangleWeights.Length; j++)
                    {
                        int curWeight = m_RectangleWeights[j];

                        if (rand < curWeight)
                        {
                            Rectangle3D rect = m_Rectangles[j];

                            x = rect.Start.X + rand % rect.Width;
                            y = rect.Start.Y + rand / rect.Width;

                            minZ = rect.Start.Z;
                            maxZ = rect.End.Z;

                            break;
                        }

                        rand -= curWeight;
                    }
                }
                else
                {
                    x = Utility.RandomMinMax(home.X - range, home.X + range);
                    y = Utility.RandomMinMax(home.Y - range, home.Y + range);

                    minZ = int.MaxValue; maxZ = int.MinValue;
                    for (int j = 0; j < this.Area.Length; j++)
                    {
                        Rectangle3D rect = this.Area[j];

                        if (x >= rect.Start.X && x < rect.End.X && y >= rect.Start.Y && y < rect.End.Y)
                        {
                            minZ = rect.Start.Z;
                            maxZ = rect.End.Z;
                            break;
                        }
                    }

                    if (minZ == int.MaxValue)
                    {
                        continue;
                    }
                }

                if (x < 0 || y < 0 || x >= map.Width || y >= map.Height)
                {
                    continue;
                }

                LandTile lt = map.Tiles.GetLandTile(x, y);

                int ltLowZ = 0, ltAvgZ = 0, ltTopZ = 0;
                map.GetAverageZ(x, y, ref ltLowZ, ref ltAvgZ, ref ltTopZ);

                TileFlag ltFlags      = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags;
                bool     ltImpassable = (ltFlags & TileFlag.Impassable) != 0;

                if (!lt.Ignored && ltAvgZ >= minZ && ltAvgZ < maxZ)
                {
                    if ((ltFlags & TileFlag.Wet) != 0)
                    {
                        if (water)
                        {
                            m_SpawnBuffer1.Add(ltAvgZ);
                        }
                    }
                    else if (land && !ltImpassable)
                    {
                        m_SpawnBuffer1.Add(ltAvgZ);
                    }
                }

                StaticTile[] staticTiles = map.Tiles.GetStaticTiles(x, y, true);

                for (int j = 0; j < staticTiles.Length; j++)
                {
                    StaticTile tile  = staticTiles[j];
                    ItemData   id    = TileData.ItemTable[tile.ID & TileData.MaxItemValue];
                    int        tileZ = tile.Z + id.CalcHeight;

                    if (tileZ >= minZ && tileZ < maxZ)
                    {
                        if ((id.Flags & TileFlag.Wet) != 0)
                        {
                            if (water)
                            {
                                m_SpawnBuffer1.Add(tileZ);
                            }
                        }
                        else if (land && id.Surface && !id.Impassable)
                        {
                            m_SpawnBuffer1.Add(tileZ);
                        }
                    }
                }


                Sector sector = map.GetSector(x, y);

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

                    if (!(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(x, y))
                    {
                        m_SpawnBuffer2.Add(item);

                        if (!item.Movable)
                        {
                            ItemData id    = item.ItemData;
                            int      itemZ = item.Z + id.CalcHeight;

                            if (itemZ >= minZ && itemZ < maxZ)
                            {
                                if ((id.Flags & TileFlag.Wet) != 0)
                                {
                                    if (water)
                                    {
                                        m_SpawnBuffer1.Add(itemZ);
                                    }
                                }
                                else if (land && id.Surface && !id.Impassable)
                                {
                                    m_SpawnBuffer1.Add(itemZ);
                                }
                            }
                        }
                    }
                }


                if (m_SpawnBuffer1.Count == 0)
                {
                    m_SpawnBuffer1.Clear();
                    m_SpawnBuffer2.Clear();
                    continue;
                }

                int z;
                switch (m_SpawnZLevel)
                {
                case SpawnZLevel.Lowest:
                {
                    z = int.MaxValue;

                    for (int j = 0; j < m_SpawnBuffer1.Count; j++)
                    {
                        int l = m_SpawnBuffer1[j];

                        if (l < z)
                        {
                            z = l;
                        }
                    }

                    break;
                }

                case SpawnZLevel.Highest:
                {
                    z = int.MinValue;

                    for (int j = 0; j < m_SpawnBuffer1.Count; j++)
                    {
                        int l = m_SpawnBuffer1[j];

                        if (l > z)
                        {
                            z = l;
                        }
                    }

                    break;
                }

                default:                         // SpawnZLevel.Random
                {
                    int index = Utility.Random(m_SpawnBuffer1.Count);
                    z = m_SpawnBuffer1[index];

                    break;
                }
                }

                m_SpawnBuffer1.Clear();


                if (!Region.Find(new Point3D(x, y, z), map).AcceptsSpawnsFrom(this))
                {
                    m_SpawnBuffer2.Clear();
                    continue;
                }

                int top = z + spawnHeight;

                bool ok = true;
                for (int j = 0; j < m_SpawnBuffer2.Count; j++)
                {
                    Item     item = m_SpawnBuffer2[j];
                    ItemData id   = item.ItemData;

                    if ((id.Surface || id.Impassable) && item.Z + id.CalcHeight > z && item.Z < top)
                    {
                        ok = false;
                        break;
                    }
                }

                m_SpawnBuffer2.Clear();

                if (!ok)
                {
                    continue;
                }

                if (ltImpassable && ltAvgZ > z && ltLowZ < top)
                {
                    continue;
                }

                for (int j = 0; j < staticTiles.Length; j++)
                {
                    StaticTile tile = staticTiles[j];
                    ItemData   id   = TileData.ItemTable[tile.ID & TileData.MaxItemValue];

                    if ((id.Surface || id.Impassable) && tile.Z + id.CalcHeight > z && tile.Z < top)
                    {
                        ok = false;
                        break;
                    }
                }

                if (!ok)
                {
                    continue;
                }

                for (int j = 0; j < sector.Mobiles.Count; j++)
                {
                    Mobile m = sector.Mobiles[j];

                    if (m.X == x && m.Y == y && (m.AccessLevel == AccessLevel.Player || !m.Hidden))
                    {
                        if (m.Z + 16 > z && m.Z < top)
                        {
                            ok = false;
                            break;
                        }
                    }
                }

                if (ok)
                {
                    return(new Point3D(x, y, z));
                }
            }

            return(Point3D.Zero);
        }
Example #25
0
        public void ReadData(string[] split)
        {
            m_Name = String.IsNullOrEmpty(split[1]) ? m_Name : split[1];
            m_Weight = System.Convert.ToByte(split[2]);
            m_Quality = System.Convert.ToByte(split[3]);
            m_Animation = (short)TileData.ConvertStringToInt(split[4]);
            m_Height = System.Convert.ToByte(split[5]);
            m_Hue = System.Convert.ToByte(split[6]);
            m_Quantity = System.Convert.ToByte(split[7]);
            m_StackOffset = System.Convert.ToByte(split[8]);
            m_MiscData = System.Convert.ToInt16(split[9]);
            m_Unk2 = System.Convert.ToByte(split[10]);
            m_Unk3 = System.Convert.ToByte(split[11]);

            //m_Flags = 0;
            int temp = System.Convert.ToByte(split[12]);
            if (temp != 0)
                m_Flags |= TileFlag.Background;
            temp = System.Convert.ToByte(split[13]);
            if (temp != 0)
                m_Flags |= TileFlag.Weapon;
            temp = System.Convert.ToByte(split[14]);
            if (temp != 0)
                m_Flags |= TileFlag.Transparent;
            temp = System.Convert.ToByte(split[15]);
            if (temp != 0)
                m_Flags |= TileFlag.Translucent;
            temp = System.Convert.ToByte(split[16]);
            if (temp != 0)
                m_Flags |= TileFlag.Wall;
            temp = System.Convert.ToByte(split[17]);
            if (temp != 0)
                m_Flags |= TileFlag.Damaging;
            temp = System.Convert.ToByte(split[18]);
            if (temp != 0)
                m_Flags |= TileFlag.Impassable;
            temp = System.Convert.ToByte(split[19]);
            if (temp != 0)
                m_Flags |= TileFlag.Wet;
            temp = System.Convert.ToByte(split[20]);
            if (temp != 0)
                m_Flags |= TileFlag.Unknown1;
            temp = System.Convert.ToByte(split[21]);
            if (temp != 0)
                m_Flags |= TileFlag.Surface;
            temp = System.Convert.ToByte(split[22]);
            if (temp != 0)
                m_Flags |= TileFlag.Bridge;
            temp = System.Convert.ToByte(split[23]);
            if (temp != 0)
                m_Flags |= TileFlag.Generic;
            temp = System.Convert.ToByte(split[24]);
            if (temp != 0)
                m_Flags |= TileFlag.Window;
            temp = System.Convert.ToByte(split[25]);
            if (temp != 0)
                m_Flags |= TileFlag.NoShoot;
            temp = System.Convert.ToByte(split[26]);
            if (temp != 0)
                m_Flags |= TileFlag.ArticleA;
            temp = System.Convert.ToByte(split[27]);
            if (temp != 0)
                m_Flags |= TileFlag.ArticleAn;
            temp = System.Convert.ToByte(split[28]);
            if (temp != 0)
                m_Flags |= TileFlag.Internal;
            temp = System.Convert.ToByte(split[29]);
            if (temp != 0)
                m_Flags |= TileFlag.Foliage;
            temp = System.Convert.ToByte(split[30]);
            if (temp != 0)
                m_Flags |= TileFlag.PartialHue;
            temp = System.Convert.ToByte(split[31]);
            if (temp != 0)
                m_Flags |= TileFlag.Unknown2;
            temp = System.Convert.ToByte(split[32]);
            if (temp != 0)
                m_Flags |= TileFlag.Map;
            temp = System.Convert.ToByte(split[33]);
            if (temp != 0)
                m_Flags |= TileFlag.Container;
            temp = System.Convert.ToByte(split[34]);
            if (temp != 0)
                m_Flags |= TileFlag.Wearable;
            temp = System.Convert.ToByte(split[35]);
            if (temp != 0)
                m_Flags |= TileFlag.LightSource;
            temp = System.Convert.ToByte(split[36]);
            if (temp != 0)
                m_Flags |= TileFlag.Animation;
            temp = System.Convert.ToByte(split[37]);
            if (temp != 0)
                m_Flags |= TileFlag.HoverOver;
            temp = System.Convert.ToByte(split[38]);
            if (temp != 0)
                m_Flags |= TileFlag.Unknown3;
            temp = System.Convert.ToByte(split[39]);
            if (temp != 0)
                m_Flags |= TileFlag.Armor;
            temp = System.Convert.ToByte(split[40]);
            if (temp != 0)
                m_Flags |= TileFlag.Roof;
            temp = System.Convert.ToByte(split[41]);
            if (temp != 0)
                m_Flags |= TileFlag.Door;
            temp = System.Convert.ToByte(split[42]);
            if (temp != 0)
                m_Flags |= TileFlag.StairBack;
            temp = System.Convert.ToByte(split[43]);
            if (temp != 0)
                m_Flags |= TileFlag.StairRight;
        }
Example #26
0
 public void SetFlag(TileFlag flag)
 {
     Flags |= (byte)flag;
 }
Example #27
0
        public bool CheckMovement(Mobile m, Map map, Point3D loc, Direction d, out int newZ)
        {
            if (map == null || map == Map.Internal)
            {
                newZ = 0;
                return(false);
            }

            int xStart = loc.X;
            int yStart = loc.Y;
            int xForward = xStart, yForward = yStart;
            int xRight = xStart, yRight = yStart;
            int xLeft = xStart, yLeft = yStart;

            bool checkDiagonals = ((int)d & 0x1) == 0x1;

            Offset(d, ref xForward, ref yForward);
            Offset((Direction)(((int)d - 1) & 0x7), ref xLeft, ref yLeft);
            Offset((Direction)(((int)d + 1) & 0x7), ref xRight, ref yRight);

            if (xForward < 0 || yForward < 0 || xForward >= map.Width || yForward >= map.Height)
            {
                newZ = 0;
                return(false);
            }

            int startZ, startTop;

            ArrayList itemsStart   = m_Pools[0];
            ArrayList itemsForward = m_Pools[1];
            ArrayList itemsLeft    = m_Pools[2];
            ArrayList itemsRight   = m_Pools[3];
            ArrayList items;

            bool     ignoreMovableImpassables = m_IgnoreMovableImpassables;
            TileFlag reqFlags = ImpassableSurface;

            if (m.CanSwim)
            {
                reqFlags |= TileFlag.Wet;
            }

            if (checkDiagonals)
            {
                Sector sectorStart   = map.GetSector(xStart, yStart);
                Sector sectorForward = map.GetSector(xForward, yForward);
                Sector sectorLeft    = map.GetSector(xLeft, yLeft);
                Sector sectorRight   = map.GetSector(xRight, yRight);

                ArrayList sectors = m_Pools[4];

                sectors.Add(sectorStart);

                if (!sectors.Contains(sectorForward))
                {
                    sectors.Add(sectorForward);
                }

                if (!sectors.Contains(sectorLeft))
                {
                    sectors.Add(sectorLeft);
                }

                if (!sectors.Contains(sectorRight))
                {
                    sectors.Add(sectorRight);
                }

                for (int i = 0; i < sectors.Count; ++i)
                {
                    Sector sector = (Sector)sectors[i];

                    items = sector.Items;

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

                        if (ignoreMovableImpassables && item.Movable && item.ItemData.Impassable)
                        {
                            continue;
                        }

                        if ((item.ItemData.Flags & reqFlags) == 0)
                        {
                            continue;
                        }

                        if (sector == sectorStart && item.AtWorldPoint(xStart, yStart) && item.ItemID < 0x4000)
                        {
                            itemsStart.Add(item);
                        }
                        else if (sector == sectorForward && item.AtWorldPoint(xForward, yForward) && item.ItemID < 0x4000)
                        {
                            itemsForward.Add(item);
                        }
                        else if (sector == sectorLeft && item.AtWorldPoint(xLeft, yLeft) && item.ItemID < 0x4000)
                        {
                            itemsLeft.Add(item);
                        }
                        else if (sector == sectorRight && item.AtWorldPoint(xRight, yRight) && item.ItemID < 0x4000)
                        {
                            itemsRight.Add(item);
                        }
                    }
                }

                if (m_Pools[4].Count > 0)
                {
                    m_Pools[4].Clear();
                }
            }
            else
            {
                Sector sectorStart   = map.GetSector(xStart, yStart);
                Sector sectorForward = map.GetSector(xForward, yForward);

                if (sectorStart == sectorForward)
                {
                    items = sectorStart.Items;

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

                        if (ignoreMovableImpassables && item.Movable && item.ItemData.Impassable)
                        {
                            continue;
                        }

                        if ((item.ItemData.Flags & reqFlags) == 0)
                        {
                            continue;
                        }

                        if (item.AtWorldPoint(xStart, yStart) && item.ItemID < 0x4000)
                        {
                            itemsStart.Add(item);
                        }
                        else if (item.AtWorldPoint(xForward, yForward) && item.ItemID < 0x4000)
                        {
                            itemsForward.Add(item);
                        }
                    }
                }
                else
                {
                    items = sectorForward.Items;

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

                        if (ignoreMovableImpassables && item.Movable && item.ItemData.Impassable)
                        {
                            continue;
                        }

                        if ((item.ItemData.Flags & reqFlags) == 0)
                        {
                            continue;
                        }

                        if (item.AtWorldPoint(xForward, yForward) && item.ItemID < 0x4000)
                        {
                            itemsForward.Add(item);
                        }
                    }

                    items = sectorStart.Items;

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

                        if (ignoreMovableImpassables && item.Movable && item.ItemData.Impassable)
                        {
                            continue;
                        }

                        if ((item.ItemData.Flags & reqFlags) == 0)
                        {
                            continue;
                        }

                        if (item.AtWorldPoint(xStart, yStart) && item.ItemID < 0x4000)
                        {
                            itemsStart.Add(item);
                        }
                    }
                }
            }

            GetStartZ(m, map, loc, itemsStart, out startZ, out startTop);

            bool moveIsOk = Check(map, m, itemsForward, xForward, yForward, startTop, startZ, m.CanSwim, m.CantWalk, out newZ);

            if (moveIsOk && checkDiagonals)
            {
                int hold;

                if (!Check(map, m, itemsLeft, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk, out hold) && !Check(map, m, itemsRight, xRight, yRight, startTop, startZ, m.CanSwim, m.CantWalk, out hold))
                {
                    moveIsOk = false;
                }
            }

            for (int i = 0; i < (checkDiagonals ? 4 : 2); ++i)
            {
                if (m_Pools[i].Count > 0)
                {
                    m_Pools[i].Clear();
                }
            }

            if (!moveIsOk)
            {
                newZ = startZ;
            }

            return(moveIsOk);
        }
        public TileData(Engine engine)
        {
            _instance = this;

            IConfigurationService configurationService = engine.Services.GetService <IConfigurationService>();
            string ultimaOnlineDirectory = configurationService.GetValue <string>(ConfigSections.UltimaOnline, ConfigKeys.UltimaOnlineDirectory);

            string filePath = Path.Combine(ultimaOnlineDirectory, "tiledata.mul");

            if (filePath != null)
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader bin = new BinaryReader(fs);

                    m_LandData = new LandData[0x4000];

                    for (int i = 0; i < 0x4000; ++i)
                    {
                        if ((i & 0x1F) == 0)
                        {
                            bin.ReadInt32(); // header
                        }

                        TileFlag flags = (TileFlag)bin.ReadInt32();
                        bin.ReadInt16(); // skip 2 bytes -- textureID

                        m_LandData[i] = new LandData(ReadNameString(bin), flags);
                    }

                    m_ItemData    = new ItemData[0x4000];
                    m_HeightTable = new int[0x4000];

                    for (int i = 0; i < 0x4000; ++i)
                    {
                        if ((i & 0x1F) == 0)
                        {
                            bin.ReadInt32(); // header
                        }
                        TileFlag flags   = (TileFlag)bin.ReadInt32();
                        int      weight  = bin.ReadByte();
                        int      quality = bin.ReadByte();
                        bin.ReadInt16();
                        bin.ReadByte();
                        int quantity = bin.ReadByte();
                        int anim     = bin.ReadInt16();
                        bin.ReadInt16();
                        bin.ReadByte();
                        int value  = bin.ReadByte();
                        int height = bin.ReadByte();

                        m_ItemData[i]    = new ItemData(ReadNameString(bin), flags, weight, quality, quantity, value, height, anim);
                        m_HeightTable[i] = height;
                    }
                }
            }
            else
            {
                throw new FileNotFoundException();
            }
        }
Example #29
0
        public static HousePlacementResult Check(Mobile from, int multiID, Point3D center, out ArrayList toMove)
        {
            // If this spot is considered valid, every item and mobile in this list will be moved under the house sign
            toMove = new ArrayList();

            Map map = from.Map;

            if (map == null || map == Map.Internal)
            {
                return(HousePlacementResult.BadLand); // A house cannot go here
            }
            if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                return(HousePlacementResult.Valid); // Staff can place anywhere
            }
            if (map == Map.Ilshenar || SpellHelper.IsFeluccaT2A(map, center))
            {
                return(HousePlacementResult.BadRegion); // No houses in Ilshenar/T2A
            }
            if (map == Map.Malas && (multiID == 0x007C || multiID == 0x007E))
            {
                return(HousePlacementResult.InvalidCastleKeep);
            }

            #region SA
            if (map == Map.TerMur && !Server.Engines.Points.PointsSystem.QueensLoyalty.IsNoble(from))
            {
                return(HousePlacementResult.NoQueenLoyalty);
            }
            #endregion

            var noHousingRegion = (NoHousingRegion)Region.Find(center, map).GetRegion(typeof(NoHousingRegion));

            if (noHousingRegion != null)
            {
                return(HousePlacementResult.BadRegion);
            }

            // This holds data describing the internal structure of the house
            MultiComponentList mcl = MultiData.GetComponents(multiID);

            if (multiID >= 0x13EC && multiID < 0x1D00)
            {
                HouseFoundation.AddStairsTo(ref mcl); // this is a AOS house, add the stairs
            }
            // Location of the nortwest-most corner of the house
            Point3D start = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z);

            // These are storage lists. They hold items and mobiles found in the map for further processing
            List <Item>   items   = new List <Item>();
            List <Mobile> mobiles = new List <Mobile>();

            // These are also storage lists. They hold location values indicating the yard and border locations.
            List <Point2D> yard = new List <Point2D>(), borders = new List <Point2D>();

            /* RULES:
             *
             * 1) All tiles which are around the -outside- of the foundation must not have anything impassable.
             * 2) No impassable object or land tile may come in direct contact with any part of the house.
             * 3) Five tiles from the front and back of the house must be completely clear of all house tiles.
             * 4) The foundation must rest flatly on a surface. Any bumps around the foundation are not allowed.
             * 5) No foundation tile may reside over terrain which is viewed as a road.
             */

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

                    StaticTile[] addTiles = mcl.Tiles[x][y];

                    if (addTiles.Length == 0)
                    {
                        continue; // There are no tiles here, continue checking somewhere else
                    }
                    Point3D testPoint = new Point3D(tileX, tileY, center.Z);

                    Region reg = Region.Find(testPoint, map);

                    if (!reg.AllowHousing(from, testPoint)) // Cannot place houses in dungeons, towns, treasure map areas etc
                    {
                        if (reg.IsPartOf(typeof(TempNoHousingRegion)))
                        {
                            return(HousePlacementResult.BadRegionTemp);
                        }

                        if (reg.IsPartOf(typeof(TreasureRegion)) || reg.IsPartOf(typeof(HouseRegion)))
                        {
                            return(HousePlacementResult.BadRegionHidden);
                        }

                        if (reg.IsPartOf(typeof(HouseRaffleRegion)))
                        {
                            return(HousePlacementResult.BadRegionRaffle);
                        }

                        return(HousePlacementResult.BadRegion);
                    }

                    LandTile landTile = map.Tiles.GetLandTile(tileX, tileY);
                    int      landID   = landTile.ID & TileData.MaxLandValue;

                    StaticTile[] oldTiles = map.Tiles.GetStaticTiles(tileX, tileY, true);

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

                    items.Clear();

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

                        if (item.Visible && item.X == tileX && item.Y == tileY)
                        {
                            items.Add(item);
                        }
                    }

                    mobiles.Clear();

                    for (int i = 0; i < sector.Mobiles.Count; ++i)
                    {
                        Mobile m = sector.Mobiles[i];

                        if (m.X == tileX && m.Y == tileY)
                        {
                            mobiles.Add(m);
                        }
                    }

                    int landStartZ = 0, landAvgZ = 0, landTopZ = 0;

                    map.GetAverageZ(tileX, tileY, ref landStartZ, ref landAvgZ, ref landTopZ);

                    bool hasFoundation = false;

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

                        if (addTile.ID == 0x1) // Nodraw
                        {
                            continue;
                        }

                        TileFlag addTileFlags = TileData.ItemTable[addTile.ID & TileData.MaxItemValue].Flags;

                        bool isFoundation = (addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0);
                        bool hasSurface   = false;

                        if (isFoundation)
                        {
                            hasFoundation = true;
                        }

                        int addTileZ   = center.Z + addTile.Z;
                        int addTileTop = addTileZ + addTile.Height;

                        if ((addTileFlags & TileFlag.Surface) != 0)
                        {
                            addTileTop += 16;
                        }

                        if (addTileTop > landStartZ && landAvgZ > addTileZ)
                        {
                            return(HousePlacementResult.BadLand); // Broke rule #2
                        }
                        if (isFoundation && ((TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) == 0) && landAvgZ == center.Z)
                        {
                            hasSurface = true;
                        }

                        for (int j = 0; j < oldTiles.Length; ++j)
                        {
                            StaticTile oldTile = oldTiles[j];
                            ItemData   id      = TileData.ItemTable[oldTile.ID & TileData.MaxItemValue];

                            if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)) && addTileTop > oldTile.Z && (oldTile.Z + id.CalcHeight) > addTileZ)
                            {
                                return(HousePlacementResult.BadStatic); // Broke rule #2
                            }

                            /*else if ( isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (oldTile.Z + id.CalcHeight) == center.Z )
                             * hasSurface = true;*/
                        }

                        for (int j = 0; j < items.Count; ++j)
                        {
                            Item     item = items[j];
                            ItemData id   = item.ItemData;

                            if (addTileTop > item.Z && (item.Z + id.CalcHeight) > addTileZ)
                            {
                                if (item.Movable)
                                {
                                    toMove.Add(item);
                                }
                                else if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)))
                                {
                                    return(HousePlacementResult.BadItem); // Broke rule #2
                                }
                            }

                            /*else if ( isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (item.Z + id.CalcHeight) == center.Z )
                             * {
                             * hasSurface = true;
                             * }*/
                        }

                        if (isFoundation && !hasSurface)
                        {
                            return(HousePlacementResult.NoSurface); // Broke rule #4
                        }
                        for (int j = 0; j < mobiles.Count; ++j)
                        {
                            Mobile m = mobiles[j];

                            if (addTileTop > m.Z && (m.Z + 16) > addTileZ)
                            {
                                toMove.Add(m);
                            }
                        }
                    }

                    for (int i = 0; i < m_RoadIDs.Length; i += 2)
                    {
                        if (landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1])
                        {
                            return(HousePlacementResult.BadLand); // Broke rule #5
                        }
                    }

                    if (hasFoundation)
                    {
                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -YardSize; yOffset <= YardSize; ++yOffset)
                            {
                                Point2D yardPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!yard.Contains(yardPoint))
                                {
                                    yard.Add(yardPoint);
                                }
                            }
                        }

                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -1; yOffset <= 1; ++yOffset)
                            {
                                if (xOffset == 0 && yOffset == 0)
                                {
                                    continue;
                                }

                                // To ease this rule, we will not add to the border list if the tile here is under a base floor (z<=8)

                                int vx = x + xOffset;
                                int vy = y + yOffset;

                                if (vx >= 0 && vx < mcl.Width && vy >= 0 && vy < mcl.Height)
                                {
                                    StaticTile[] breakTiles  = mcl.Tiles[vx][vy];
                                    bool         shouldBreak = false;

                                    for (int i = 0; !shouldBreak && i < breakTiles.Length; ++i)
                                    {
                                        StaticTile breakTile = breakTiles[i];

                                        if (breakTile.Height == 0 && breakTile.Z <= 8 && TileData.ItemTable[breakTile.ID & TileData.MaxItemValue].Surface)
                                        {
                                            shouldBreak = true;
                                        }
                                    }

                                    if (shouldBreak)
                                    {
                                        continue;
                                    }
                                }

                                Point2D borderPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!borders.Contains(borderPoint))
                                {
                                    borders.Add(borderPoint);
                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < borders.Count; ++i)
            {
                Point2D borderPoint = borders[i];

                LandTile landTile = map.Tiles.GetLandTile(borderPoint.X, borderPoint.Y);
                int      landID   = landTile.ID & TileData.MaxLandValue;

                if ((TileData.LandTable[landID].Flags & TileFlag.Impassable) != 0)
                {
                    return(HousePlacementResult.BadLand);
                }

                for (int j = 0; j < m_RoadIDs.Length; j += 2)
                {
                    if (landID >= m_RoadIDs[j] && landID <= m_RoadIDs[j + 1])
                    {
                        return(HousePlacementResult.BadLand); // Broke rule #5
                    }
                }

                StaticTile[] tiles = map.Tiles.GetStaticTiles(borderPoint.X, borderPoint.Y, true);

                for (int j = 0; j < tiles.Length; ++j)
                {
                    StaticTile tile = tiles[j];
                    ItemData   id   = TileData.ItemTable[tile.ID & TileData.MaxItemValue];

                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (tile.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        return(HousePlacementResult.BadStatic); // Broke rule #1
                    }
                }

                Sector      sector      = map.GetSector(borderPoint.X, borderPoint.Y);
                List <Item> sectorItems = sector.Items;

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

                    if (item.X != borderPoint.X || item.Y != borderPoint.Y || item.Movable)
                    {
                        continue;
                    }

                    ItemData id = item.ItemData;

                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (item.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        return(HousePlacementResult.BadItem); // Broke rule #1
                    }
                }
            }

            List <Sector>    _sectors = new List <Sector>();
            List <BaseHouse> _houses  = new List <BaseHouse>();

            for (int i = 0; i < yard.Count; i++)
            {
                Sector sector = map.GetSector(yard[i]);

                if (!_sectors.Contains(sector))
                {
                    _sectors.Add(sector);

                    if (sector.Multis != null)
                    {
                        for (int j = 0; j < sector.Multis.Count; j++)
                        {
                            if (sector.Multis[j] is BaseHouse)
                            {
                                BaseHouse _house = (BaseHouse)sector.Multis[j];
                                if (!_houses.Contains(_house))
                                {
                                    _houses.Add(_house);
                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < yard.Count; ++i)
            {
                foreach (BaseHouse b in _houses)
                {
                    if (b.Contains(yard[i]))
                    {
                        return(HousePlacementResult.BadStatic); // Broke rule #3
                    }
                }

                /*Point2D yardPoint = yard[i];
                 * IPooledEnumerable eable = map.GetMultiTilesAt( yardPoint.X, yardPoint.Y );
                 * foreach ( StaticTile[] tile in eable )
                 * {
                 * for ( int j = 0; j < tile.Length; ++j )
                 * {
                 * if ( (TileData.ItemTable[tile[j].ID & TileData.MaxItemValue].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0 )
                 * {
                 * eable.Free();
                 * return HousePlacementResult.BadStatic; // Broke rule #3
                 * }
                 * }
                 * }
                 * eable.Free();*/
            }

            return(HousePlacementResult.Valid);
        }
Example #30
0
 private static bool Verify(Item item, TileFlag reqFlags, bool ignoreMovableImpassables) =>
 item != null && (!ignoreMovableImpassables || !item.Movable || !item.ItemData.Impassable) &&
 (item.ItemData.Flags & reqFlags) != 0 && !(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue;
Example #31
0
 private static bool Verify(Item item, TileFlag reqFlags, bool ignoreMovableImpassables, int x, int y)
 {
     return(Verify(item, reqFlags, ignoreMovableImpassables) && Verify(item, x, y));
 }
        private static ShopFlags ProcessDisplayedItem(int itemID)
        {
            itemID &= TileData.MaxItemValue;

            ShopFlags res = ShopFlags.None;

            ItemData id    = TileData.ItemTable[itemID];
            TileFlag flags = id.Flags;

            if ((flags & TileFlag.Wearable) != 0)
            {
                if (IsClothes(itemID))
                {
                    res |= ShopFlags.Clothes;
                }
                else if (IsArmor(itemID))
                {
                    res |= ShopFlags.Armor;
                }
                else if (IsMetalWeapon(itemID))
                {
                    res |= ShopFlags.MetalWeapon;
                }
                else if (IsArcheryWeapon(itemID))
                {
                    res |= ShopFlags.ArcheryWeapon;
                }
            }

            if (itemID == 0x98C || itemID == 0x103B || itemID == 0x103C)
            {
                res |= ShopFlags.Bread;
            }

            if (itemID >= 0xF0F && itemID <= 0xF30)
            {
                res |= ShopFlags.Jewel;
            }

            if (itemID >= 0xEFB && itemID <= 0xF0D)
            {
                res |= ShopFlags.Potion;
            }

            if (itemID >= 0xF78 && itemID <= 0xF91)
            {
                res |= ShopFlags.Reagent;
            }

            if ((itemID >= 0xE35 && itemID <= 0xE3A) || (itemID >= 0xEF4 && itemID <= 0xEF9) || (itemID >= 0x1F2D && itemID <= 0x1F72))
            {
                res |= ShopFlags.Scroll;
            }

            if (itemID == 0xE38 || itemID == 0xEFA)
            {
                res |= ShopFlags.Spellbook;
            }

            return(res);
        }
Example #33
0
        public static bool CheckMovement(Mobile m, Position3D loc, Direction d, out int newZ, bool forceOK = false)
        {
            Map map = m.Map;

            if (map == null)
            {
                newZ = 0;
                return(true);
            }

            int xStart = (int)loc.X;
            int yStart = (int)loc.Y;
            int xForward = xStart, yForward = yStart;
            int xRight = xStart, yRight = yStart;
            int xLeft = xStart, yLeft = yStart;

            bool checkDiagonals = ((int)d & 0x1) == 0x1;

            offsetXY(d, ref xForward, ref yForward);
            offsetXY((Direction)(((int)d - 1) & 0x7), ref xLeft, ref yLeft);
            offsetXY((Direction)(((int)d + 1) & 0x7), ref xRight, ref yRight);

            if (xForward < 0 || yForward < 0 || xForward >= map.Width || yForward >= map.Height)
            {
                newZ = 0;
                return(false);
            }

            int startZ, startTop;

            List <Item> itemsStart   = m_Pools[0];
            List <Item> itemsForward = m_Pools[1];
            List <Item> itemsLeft    = m_Pools[2];
            List <Item> itemsRight   = m_Pools[3];

            TileFlag reqFlags = ImpassableSurface;

            // if (m.CanSwim)
            //     reqFlags |= TileFlag.Wet;

            if (checkDiagonals)
            {
                MapTile tileStart   = map.GetMapTile(xStart, yStart);
                MapTile tileForward = map.GetMapTile(xForward, yForward);
                MapTile tileLeft    = map.GetMapTile(xLeft, yLeft);
                MapTile tileRight   = map.GetMapTile(xRight, yRight);
                if ((tileForward == null) || (tileStart == null) || (tileLeft == null) || (tileRight == null))
                {
                    newZ = (int)loc.Z;
                    return(false);
                }

                List <MapTile> tiles = new List <MapTile>(); //m_Sectors;

                tiles.Add(tileStart);
                tiles.Add(tileForward);
                tiles.Add(tileLeft);
                tiles.Add(tileRight);

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

                    for (int j = 0; j < tile.Entities.Count; ++j)
                    {
                        AEntity entity = tile.Entities[j]; //Item item = sector.Items[j];

                        // if (ignoreMovableImpassables && item.Movable && item.ItemData.Impassable)
                        //     continue;

                        if (entity is Item)
                        {
                            Item item = (Item)entity;

                            if ((item.ItemData.Flags & reqFlags) == 0)
                            {
                                continue;
                            }

                            if (tile == tileStart && item.AtWorldPoint(xStart, yStart) && item.ItemID < 0x4000)
                            {
                                itemsStart.Add(item);
                            }
                            else if (tile == tileForward && item.AtWorldPoint(xForward, yForward) && item.ItemID < 0x4000)
                            {
                                itemsForward.Add(item);
                            }
                            else if (tile == tileLeft && item.AtWorldPoint(xLeft, yLeft) && item.ItemID < 0x4000)
                            {
                                itemsLeft.Add(item);
                            }
                            else if (tile == tileRight && item.AtWorldPoint(xRight, yRight) && item.ItemID < 0x4000)
                            {
                                itemsRight.Add(item);
                            }
                        }
                    }
                }
            }
            else
            {
                MapTile tileStart   = map.GetMapTile(xStart, yStart);
                MapTile tileForward = map.GetMapTile(xForward, yForward);
                if ((tileForward == null) || (tileStart == null))
                {
                    newZ = (int)loc.Z;
                    return(false);
                }

                if (tileStart == tileForward)
                {
                    for (int i = 0; i < tileStart.Entities.Count; ++i)
                    {
                        AEntity entity = tileStart.Entities[i]; // Item item = sectorStart.Items[i];

                        if (entity is Item)
                        {
                            Item item = (Item)entity;

                            // if (ignoreMovableImpassables && item.Movable && item.ItemData.Impassable)
                            //     continue;

                            if ((item.ItemData.Flags & reqFlags) == 0)
                            {
                                continue;
                            }

                            if (item.AtWorldPoint(xStart, yStart) && item.ItemID < 0x4000)
                            {
                                itemsStart.Add(item);
                            }
                            else if (item.AtWorldPoint(xForward, yForward) && item.ItemID < 0x4000)
                            {
                                itemsForward.Add(item);
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < tileForward.Entities.Count; ++i)
                    {
                        AEntity entity = tileForward.Entities[i]; // Item item = sectorForward.Items[i];

                        if (entity is Item)
                        {
                            Item item = (Item)entity;

                            // if (ignoreMovableImpassables && item.Movable && item.ItemData.Impassable)
                            //     continue;

                            if ((item.ItemData.Flags & reqFlags) == 0)
                            {
                                continue;
                            }

                            if (item.AtWorldPoint(xForward, yForward) && item.ItemID < 0x4000)
                            {
                                itemsForward.Add(item);
                            }
                        }
                    }

                    for (int i = 0; i < tileStart.Entities.Count; ++i)
                    {
                        AEntity entity = tileStart.Entities[i]; // Item item = sectorStart.Items[i];

                        if (entity is Item)
                        {
                            Item item = (Item)entity;

                            // if (ignoreMovableImpassables && item.Movable && item.ItemData.Impassable)
                            //     continue;

                            if ((item.ItemData.Flags & reqFlags) == 0)
                            {
                                continue;
                            }

                            if (item.AtWorldPoint(xStart, yStart) && item.ItemID < 0x4000)
                            {
                                itemsStart.Add(item);
                            }
                        }
                    }
                }
            }

            getStartZ(m, map, loc, itemsStart, out startZ, out startTop);

            bool moveIsOk = check(map, m, itemsForward, xForward, yForward, startTop, startZ, out newZ) | forceOK;

            if (moveIsOk && checkDiagonals)
            {
                int hold;

                if (!check(map, m, itemsLeft, xLeft, yLeft, startTop, startZ, out hold) && !check(map, m, itemsRight, xRight, yRight, startTop, startZ, out hold))
                {
                    moveIsOk = false;
                }
            }

            for (int i = 0; i < (checkDiagonals ? 4 : 2); ++i)
            {
                if (m_Pools[i].Count > 0)
                {
                    m_Pools[i].Clear();
                }
            }

            if (!moveIsOk)
            {
                newZ = startZ;
            }

            return(moveIsOk);
        }
Example #34
0
		private void FindTileLocations( ref List<Point3D> locations, Map map, int startx, int starty, int width, int height, List<int> includetilelist, List<int> excludetilelist, TileFlag tileflag )
		{
			if( width < 0 || height < 0 || map == null ) return;

			if( locations == null ) locations = new List<Point3D>();

			bool includetile;
			bool excludetile;
			for( int x = startx; x <= startx + width; x++ )
			{
				for( int y = starty; y <= starty + height; y++ )
				{
					// go through all of the tiles at the location and find those that are in the allowed tiles list
					LandTile ltile = map.Tiles.GetLandTile( x, y );
					TileFlag lflags = TileData.LandTable[ltile.ID].Flags;

					// check the land tile
					if( includetilelist != null && includetilelist.Count > 0 )
					{
						includetile = includetilelist.Contains( ltile.ID );
					}
					else
					{
						includetile = true;
					}

					// non-excluded tiles must also be passable
					if( excludetilelist != null && excludetilelist.Count > 0 )
					{
						// also require the tile to be passable
						excludetile = ((lflags & TileFlag.Impassable) != 0) || excludetilelist.Contains( ltile.ID );
					}
					else
					{
						excludetile = false;
					}

					if( includetile && !excludetile && ((lflags & tileflag) == tileflag) )
					{
						//Console.WriteLine("found landtile {0}/{1} at {2},{3},{4}", ltile.ID, ltile.ID, x, y, ltile.Z + ltile.Height);
						locations.Add( new Point3D( x, y, ltile.Z + ltile.Height ) );
						continue;
					}

					StaticTile[] statictiles = map.Tiles.GetStaticTiles( x, y, true );

					// check the static tiles
					for( int i = 0; i < statictiles.Length; ++i )
					{
						StaticTile stile = statictiles[i];
						TileFlag sflags = TileData.ItemTable[stile.ID].Flags;

						if( includetilelist != null && includetilelist.Count > 0 )
						{
							includetile = includetilelist.Contains( stile.ID );
						}
						else
						{
							includetile = true;
						}

						// non-excluded tiles must also be passable
						if( excludetilelist != null && excludetilelist.Count > 0 )
						{
							excludetile = ((sflags & TileFlag.Impassable) != 0) || excludetilelist.Contains( stile.ID );
						}
						else
						{
							excludetile = false;
						}

						if( includetile && !excludetile && ((sflags & tileflag) == tileflag) )
						{
							//Console.WriteLine("found statictile {0}/{1} at {2},{3},{4}", stile.ID, stile.ID, x, y, stile.Z + stile.Height);
							locations.Add( new Point3D( x, y, stile.Z + stile.Height ) );
							break;
						}
					}
				}
			}
		}
Example #35
0
        public static HousePlacementResult Check(Mobile from, int multiID, Point3D center, out ArrayList toMove, bool tent)
        {
            // If this spot is considered valid, every item and mobile in this list will be moved under the house sign
            toMove = new ArrayList();

            Map map = from.Map;

            if (map == null || map == Map.Internal)
            {
                return(HousePlacementResult.BadLand);                // A house cannot go here
            }
            if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                return(HousePlacementResult.Valid);                // Staff can place anywhere
            }
            if (map == Map.Ilshenar)
            {
                return(HousePlacementResult.BadRegion);                // No houses in Ilshenar
            }
            // This holds data describing the internal structure of the house
            MultiComponentList mcl = MultiData.GetComponents(multiID);

            if (multiID >= 0x13EC && multiID < 0x1D00)
            {
                HouseFoundation.AddStairsTo(ref mcl);                 // this is a AOS house, add the stairs
            }
            // Location of the nortwest-most corner of the house
            Point3D start = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z);

            // These are storage lists. They hold items and mobiles found in the map for further processing
            ArrayList items = new ArrayList(), mobiles = new ArrayList();

            // These are also storage lists. They hold location values indicating the yard and border locations.
            ArrayList yard = new ArrayList(), borders = new ArrayList();

            // This is also a storage lists. It holds the addons for tents as we will want to exclude them
            ArrayList TentComponents = new ArrayList();

            /* RULES:
             *
             * 1) All tiles which are around the -outside- of the foundation must not have anything impassable.
             * 2) No impassable object or land tile may come in direct contact with any part of the house.
             * 3) Five tiles from the front and back of the house must be completely clear of all house tiles.
             * 4) The foundation must rest flatly on a surface. Any bumps around the foundation are not allowed.
             * 5) No foundation tile may reside over terrain which is viewed as a road.
             * 6) Tried to place a tent but the area ws not clear of other retions
             * 7) if we are placing a house and there is a tent there at that we do not own, fail
             * 8) tried to place a non-tent and the area wasn't a valid region
             */

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

                    Tile[] addTiles = mcl.Tiles[x][y];

                    if (addTiles.Length == 0)
                    {
                        continue;                         // There are no tiles here, continue checking somewhere else
                    }
                    // okay, we have a house tile at this point, is there anything there to block us?
                    Point3D testPoint = new Point3D(tileX, tileY, center.Z);

                    #region REGION_CHECK
                    // maybe this point is in a region that doesn't allow housing?
                    Region region = null;
                    HousePlacementResult RegionCheck = HousePlacementRegionCheck(from, map, testPoint, out region);

                    // if we are placing a tent, the area must be clear of everything including other tents
                    if (tent == true)
                    {                           // if we are placing a tent and the region is not cool, fail
                        if (RegionCheck != HousePlacementResult.Valid)
                        {
                            return(RegionCheck);                            // Broke rule #6
                        }
                    }
                    if (TentComponents != null && TentComponents.Count > 0)
                    {                           // if we are placing a house and there is a tent there at that we do not own, fail
                        foreach (BaseHouse bx in TentComponents)
                        {                       // disabled annex() in tent.cs until better understood
                            if (bx != null && bx.Owner != from)
                            {
                                return(RegionCheck);                                // Broke rule #7
                            }
                        }
                    }
                    else
                    {                           // if we are placing a house, the area better either be clear or a tent
                        if (RegionCheck != HousePlacementResult.Valid && RegionCheck != HousePlacementResult.TentRegion)
                        {
                            return(RegionCheck);                            // Broke rule #7
                        }
                        ////
                        // save the list of all the addon components from the tent as we will want to exclude them from further tests
                        if (RegionCheck == HousePlacementResult.TentRegion && region != null)
                        {
                            BaseHouse house = (region as HouseRegion).House;
                            if (house is Tent == true)
                            {
                                // we will move this house after house is placed
                                if (toMove.Contains(house) == false)
                                {
                                    toMove.Add(house);
                                }

                                if (TentComponents.Contains(house) == false)
                                {
                                    TentComponents.Add(house);
                                }

                                if (TentComponents.Contains((house as Tent).TentPack) == false)
                                {
                                    TentComponents.Add((house as Tent).TentPack);
                                }

                                if (TentComponents.Contains((house as Tent).TentBed) == false)
                                {
                                    TentComponents.Add((house as Tent).TentBed);
                                }

                                if (house.Addons != null)
                                {
                                    for (int ix = 0; ix < house.Addons.Count; ix++)
                                    {
                                        if (house.Addons[ix] != null)
                                        {
                                            Server.Items.BaseAddon ba = house.Addons[ix] as Server.Items.BaseAddon;
                                            for (int jx = 0; jx < ba.Components.Count; jx++)
                                            {
                                                if (TentComponents.Contains(ba.Components[jx]) == false)
                                                {
                                                    TentComponents.Add(ba.Components[jx]);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // otherwise, all is a go!
                    #endregion REGION_CHECK

                    // look at the land tiles (water etc.)
                    Tile landTile = map.Tiles.GetLandTile(tileX, tileY);
                    int  landID   = landTile.ID & 0x3FFF;

                    Tile[] oldTiles = map.Tiles.GetStaticTiles(tileX, tileY, true);

                    // get the sector of this tile
                    Sector sector = map.GetSector(tileX, tileY);

                    #region ITEMS_MOBILES
                    // collect the items in this sector at this location
                    items.Clear();
                    foreach (Item item in sector.Items.Values)
                    {
                        if (item == null)
                        {
                            continue;
                        }

                        if (item.X == tileX && item.Y == tileY)
                        {
                            if (SpecialItemExclusion(item) == false)
                            {
                                if (TentComponents.Contains(item) == false)
                                {
                                    items.Add(item);
                                }
                            }
                        }
                    }

                    // collect the mobiles in this sector at this location
                    mobiles.Clear();
                    foreach (Mobile m in sector.Mobiles.Values)
                    {
                        if (m == null)
                        {
                            continue;
                        }

                        if (m.X == tileX && m.Y == tileY)
                        {
                            if (SpecialMobileExclusion(m) == false)
                            {
                                mobiles.Add(m);
                            }
                        }
                    }
                    #endregion ITEMS_MOBILES

                    #region LAND_TILES
                    int landStartZ = 0, landAvgZ = 0, landTopZ = 0;

                    map.GetAverageZ(tileX, tileY, ref landStartZ, ref landAvgZ, ref landTopZ);

                    bool hasFoundation = false;

                    if (addTiles != null)
                    {
                        for (int i = 0; i < addTiles.Length; ++i)
                        {
                            Tile addTile = addTiles[i];

                            if (addTile.ID == 0x4001)                             // Nodraw
                            {
                                continue;
                            }

                            TileFlag addTileFlags = TileData.ItemTable[addTile.ID & 0x3FFF].Flags;

                            bool isFoundation = (addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0);
                            bool hasSurface   = false;

                            if (isFoundation)
                            {
                                hasFoundation = true;
                            }

                            int addTileZ   = center.Z + addTile.Z;
                            int addTileTop = addTileZ + addTile.Height;

                            if ((addTileFlags & TileFlag.Surface) != 0)
                            {
                                addTileTop += 16;
                            }

                            if (addTileTop > landStartZ && landAvgZ > addTileZ)
                            {
                                return(HousePlacementResult.BadLand);                                // Broke rule #2
                            }
                            if (isFoundation && ((TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) == 0) && landAvgZ == center.Z)
                            {
                                hasSurface = true;
                            }

                            for (int j = 0; j < oldTiles.Length; ++j)
                            {
                                Tile     oldTile = oldTiles[j];
                                ItemData id      = TileData.ItemTable[oldTile.ID & 0x3FFF];

                                if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)) && addTileTop > oldTile.Z && (oldTile.Z + id.CalcHeight) > addTileZ)
                                {
                                    return(HousePlacementResult.BadStatic);                                    // Broke rule #2
                                }
                                else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (oldTile.Z + id.CalcHeight) == center.Z)
                                {
                                    hasSurface = true;
                                }
                            }

                            for (int j = 0; j < items.Count; ++j)
                            {
                                Item     item = (Item)items[j];
                                ItemData id   = item.ItemData;

                                if (addTileTop > item.Z && (item.Z + id.CalcHeight) > addTileZ)
                                {
                                    if (item.Movable)
                                    {
                                        toMove.Add(item);
                                    }
                                    else if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)))
                                    {
                                        return(HousePlacementResult.BadItem);                                        // Broke rule #2
                                    }
                                }
                                else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (item.Z + id.CalcHeight) == center.Z)
                                {
                                    hasSurface = true;
                                }
                            }

                            if (isFoundation && !hasSurface)
                            {
                                return(HousePlacementResult.NoSurface);                                // Broke rule #4
                            }
                            for (int j = 0; j < mobiles.Count; ++j)
                            {
                                Mobile m = (Mobile)mobiles[j];

                                if (addTileTop > m.Z && (m.Z + 16) > addTileZ)
                                {
                                    toMove.Add(m);
                                }
                            }
                        }
                    }
                    #endregion LAND_TILES

                    #region ROAD_TILES
                    for (int i = 0; i < m_RoadIDs.Length; i += 2)
                    {
                        if ((landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1]) && (ExceptionTiles(landID) == false))
                        {
                            //Console.WriteLine(landID.ToString());
                            return(HousePlacementResult.BadLand);                            // Broke rule #5
                        }
                    }
                    #endregion ROAD_TILES

                    #region YARD_CHECK
                    if (hasFoundation)
                    {
                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -YardSize; yOffset <= YardSize; ++yOffset)
                            {
                                Point2D yardPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!yard.Contains(yardPoint))
                                {
                                    yard.Add(yardPoint);
                                }
                            }
                        }

                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -1; yOffset <= 1; ++yOffset)
                            {
                                if (xOffset == 0 && yOffset == 0)
                                {
                                    continue;
                                }

                                // To ease this rule, we will not add to the border list if the tile here is under a base floor (z<=8)

                                int vx = x + xOffset;
                                int vy = y + yOffset;

                                if (vx >= 0 && vx < mcl.Width && vy >= 0 && vy < mcl.Height)
                                {
                                    Tile[] breakTiles  = mcl.Tiles[vx][vy];
                                    bool   shouldBreak = false;

                                    for (int i = 0; !shouldBreak && i < breakTiles.Length; ++i)
                                    {
                                        Tile breakTile = breakTiles[i];

                                        if (breakTile.Height == 0 && breakTile.Z <= 8 && TileData.ItemTable[breakTile.ID & 0x3FFF].Surface)
                                        {
                                            shouldBreak = true;
                                        }
                                    }

                                    if (shouldBreak)
                                    {
                                        continue;
                                    }
                                }

                                Point2D borderPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!borders.Contains(borderPoint))
                                {
                                    borders.Add(borderPoint);
                                }
                            }
                        }
                    }
                    #endregion YARD_CHECK
                }
            }

            for (int i = 0; i < borders.Count; ++i)
            {
                Point2D borderPoint = (Point2D)borders[i];

                Tile landTile = map.Tiles.GetLandTile(borderPoint.X, borderPoint.Y);
                int  landID   = landTile.ID & 0x3FFF;

                if ((TileData.LandTable[landID].Flags & TileFlag.Impassable) != 0)
                {
                    return(HousePlacementResult.BadLand);
                }

                #region ROAD_TILES
                for (int j = 0; j < m_RoadIDs.Length; j += 2)
                {
                    if ((landID >= m_RoadIDs[j] && landID <= m_RoadIDs[j + 1]) && (ExceptionTiles(landID) == false))
                    {
                        //Console.WriteLine(landID.ToString());
                        return(HousePlacementResult.BadLand);                        // Broke rule #5
                    }
                }
                #endregion ROAD_TILES

                Tile[] tiles = map.Tiles.GetStaticTiles(borderPoint.X, borderPoint.Y, true);

                for (int j = 0; j < tiles.Length; ++j)
                {
                    Tile     tile = tiles[j];
                    ItemData id   = TileData.ItemTable[tile.ID & 0x3FFF];

                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (tile.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        return(HousePlacementResult.BadStatic);                        // Broke rule #1
                    }
                }

                Sector sector = map.GetSector(borderPoint.X, borderPoint.Y);

                #region IMPASSABLE_TILE
                foreach (Item item in sector.Items.Values)
                {
                    if (item == null)
                    {
                        continue;
                    }

                    if (item.X != borderPoint.X || item.Y != borderPoint.Y || item.Movable)
                    {
                        continue;
                    }

                    // Adam: ignore these tent components
                    if (TentComponents.Contains(item) == true)
                    {
                        continue;
                    }

                    ItemData id = item.ItemData;

                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (item.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        return(HousePlacementResult.BadItem);                        // Broke rule #1
                    }
                }
                #endregion IMPASSABLE_TILE
            }

            for (int i = 0; i < yard.Count; ++i)
            {
                Point2D yardPoint = (Point2D)yard[i];

                IPooledEnumerable eable = map.GetMultiTilesAt(yardPoint.X, yardPoint.Y);

                foreach (Tile[] tile in eable)
                {
                    for (int j = 0; j < tile.Length; ++j)
                    {
                        if ((TileData.ItemTable[tile[j].ID & 0x3FFF].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0)
                        {
                            eable.Free();
                            return(HousePlacementResult.BadStatic);                            // Broke rule #3
                        }
                    }
                }

                eable.Free();
            }

            return(HousePlacementResult.Valid);

            /*if ( blockedLand || blockedStatic || blockedItem )
             * {
             *      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.
             * }
             * else if ( !foundationHasSurface )
             * {
             *      from.SendMessage( "The house could not be created here.  Part of the foundation would not be on any surface." );
             * }
             * else
             * {
             *      BaseHouse house = GetHouse( from );
             *      house.MoveToWorld( center, from.Map );
             *      this.Delete();
             *
             *      for ( int i = 0; i < toMove.Count; ++i )
             *      {
             *              object o = toMove[i];
             *
             *              if ( o is Mobile )
             *                      ((Mobile)o).Location = house.BanLocation;
             *              else if ( o is Item )
             *                      ((Item)o).Location = house.BanLocation;
             *      }
             * }*/
        }
Example #36
0
		public LandData( string name, TileFlag flags )
		{
			m_Name = name;
			m_Flags = flags;
		}
Example #37
0
		private static bool Verify(Item item, TileFlag reqFlags, bool ignoreMovableImpassables)
		{
			if (item == null)
			{
				return false;
			}

			if (ignoreMovableImpassables && item.Movable && item.ItemData.Impassable)
			{
				return false;
			}

			if ((item.ItemData.Flags & reqFlags) == 0)
			{
				return false;
			}

			if (item is BaseMulti || item.ItemID > TileData.MaxItemValue)
			{
				return false;
			}

			return true;
		}
Example #38
0
 public LandData(string name, TileFlag flags)
 {
     _name = name;
     _flags = flags;
 }
Example #39
0
 public void ReadData(string[] split)
 {
     int i = 1;
     m_Name = split[i++];
     m_TexID = (short)TileData.ConvertStringToInt(split[i++]);
     m_Unk1 = TileData.ConvertStringToInt(split[i++]);
     m_Flags = 0;
     int temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Background;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Weapon;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Transparent;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Translucent;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Wall;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Damaging;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Impassable;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Wet;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Unknown1;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Surface;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Bridge;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Generic;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Window;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.NoShoot;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.ArticleA;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.ArticleAn;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Internal;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Foliage;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.PartialHue;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Unknown2;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Map;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Container;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Wearable;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.LightSource;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Animation;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.HoverOver;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Unknown3;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Armor;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Roof;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.Door;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.StairBack;
     temp = System.Convert.ToByte(split[i++]);
     if (temp != 0)
         m_Flags |= TileFlag.StairRight;
 }
Example #40
0
 public ItemData(string name, TileFlag flags, int weight, int quality, int quantity, int value, int height, int anim, int hue, int stackingoffset, int MiscData, int unk2, int unk3)
 {
     m_Name = name;
     m_Flags = flags;
     m_Weight = (byte)weight;
     m_Quality = (byte)quality;
     m_Quantity = (byte)quantity;
     m_Value = (byte)value;
     m_Height = (byte)height;
     m_Animation = (short)anim;
     m_Hue = (byte)hue;
     m_StackOffset = (byte)stackingoffset;
     m_MiscData = (short)MiscData;
     m_Unk2 = (byte)unk2;
     m_Unk3 = (byte)unk3;
 }
        private static bool CanFit(Map map, int x, int y, int z)
        {
            bool hasSurface = false;

            LandTile lt = map.Tiles.GetLandTile(x, y);
            int      lowZ = 0, avgZ = 0, topZ = 0;

            map.GetAverageZ(x, y, ref lowZ, ref avgZ, ref topZ);
            TileFlag landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags;

            if ((landFlags & TileFlag.Impassable) != 0 && topZ > z && (z + 16) > lowZ)
            {
                return(false);
            }
            else if ((landFlags & TileFlag.Impassable) == 0 && z == avgZ && !lt.Ignored)
            {
                hasSurface = true;
            }

            StaticTile[] staticTiles = map.Tiles.GetStaticTiles(x, y);

            bool surface, impassable;

            for (int i = 0; i < staticTiles.Length; ++i)
            {
                if (IsDisplayCase(staticTiles[i].ID))
                {
                    continue;
                }

                ItemData id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue];

                surface    = id.Surface;
                impassable = id.Impassable;

                if ((surface || impassable) && (staticTiles[i].Z + id.CalcHeight) > z && (z + 16) > staticTiles[i].Z)
                {
                    return(false);
                }
                else if (surface && !impassable && z == (staticTiles[i].Z + id.CalcHeight))
                {
                    hasSurface = true;
                }
            }

            Sector      sector = map.GetSector(x, y);
            List <Item> items  = sector.Items;

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

                if (item.AtWorldPoint(x, y))
                {
                    ItemData id = item.ItemData;
                    surface    = id.Surface;
                    impassable = id.Impassable;

                    if ((surface || impassable) && (item.Z + id.CalcHeight) > z && (z + 16) > item.Z)
                    {
                        return(false);
                    }
                    else if (surface && !impassable && z == (item.Z + id.CalcHeight))
                    {
                        hasSurface = true;
                    }
                }
            }

            return(hasSurface);
        }
Example #42
0
 public LandData(string name, TileFlag flags,int id)
 {
     _name = name;
     _flags = flags;
     _id = id;
 }
Example #43
0
		private void FindRegionTileLocations( ref List<Point3D> locations, Region r, List<int> includetilelist, List<int> excludetilelist, TileFlag tileflag )
		{
			if( r == null || r.Area == null ) return;

			int count = r.Area.Length;

			if( locations == null ) locations = new List<Point3D>();

			// calculate fields of all rectangles (for probability calculating)
			for( int n = 0; n < count; n++ )
			{
				object o = r.Area[n];
				int sx = 0;
				int sy = 0;
				int w = -1;
				int h = -1;
				if( o is Rectangle2D )
				{
					sx = ((Rectangle2D)o).X;
					sy = ((Rectangle2D)o).Y;
					w = ((Rectangle2D)o).X + ((Rectangle2D)o).Width;
					h = ((Rectangle2D)o).Y + ((Rectangle2D)o).Height;
				}
				else
					if( o is Rectangle3D )
					{
						sx = ((Rectangle3D)o).Start.X;
						sy = ((Rectangle3D)o).Start.Y;
						w = ((Rectangle3D)o).Width;
						h = ((Rectangle3D)o).Height;
					}

				// find all of the valid tile locations in the area
				FindTileLocations( ref locations, r.Map, sx, sy, w, h, includetilelist, excludetilelist, tileflag );
			}


		}
Example #44
0
        private bool Check(Map map, Mobile m, List <Item> items, List <Mobile> mobiles, int x, int y, int startTop, int startZ, bool canSwim, bool cantWalk, out int newZ)
        {
            newZ = 0;

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

            bool landBlocks   = (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) != 0;
            bool considerLand = !landTile.Ignored;

            if (landBlocks && canSwim && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) != 0)   //Impassable, Can Swim, and Is water.  Don't block it.
            {
                landBlocks = false;
            }
            else if (cantWalk && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) == 0)   //Can't walk and it's not water
            {
                landBlocks = true;
            }

            int landZ = 0, landCenter = 0, landTop = 0;

            map.GetAverageZ(x, y, ref landZ, ref landCenter, ref landTop);

            bool moveIsOk = false;

            int stepTop  = startTop + StepHeight;
            int checkTop = startZ + PersonHeight;

            bool ignoreDoors       = (m_AlwaysIgnoreDoors || !m.Alive || m.Body.BodyID == 0x3DB || m.IsDeadBondedPet);
            bool ignoreSpellFields = m is PlayerMobile && map != Map.Felucca;

            #region Tiles
            for (int i = 0; i < tiles.Length; ++i)
            {
                StaticTile tile     = tiles[i];
                ItemData   itemData = TileData.ItemTable[tile.ID & TileData.MaxItemValue];
                TileFlag   flags    = itemData.Flags;

                if ((flags & ImpassableSurface) == TileFlag.Surface || (canSwim && (flags & TileFlag.Wet) != 0)) // Surface && !Impassable
                {
                    if (cantWalk && (flags & TileFlag.Wet) == 0)
                    {
                        continue;
                    }

                    int itemZ   = tile.Z;
                    int itemTop = itemZ;
                    int ourZ    = itemZ + itemData.CalcHeight;
                    int ourTop  = ourZ + PersonHeight;
                    int testTop = checkTop;

                    if (moveIsOk)
                    {
                        int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z);

                        if (cmp > 0 || (cmp == 0 && ourZ > newZ))
                        {
                            continue;
                        }
                    }

                    if (ourZ + PersonHeight > testTop)
                    {
                        testTop = ourZ + PersonHeight;
                    }

                    if (!itemData.Bridge)
                    {
                        itemTop += itemData.Height;
                    }

                    if (stepTop >= itemTop)
                    {
                        int landCheck = itemZ;

                        if (itemData.Height >= StepHeight)
                        {
                            landCheck += StepHeight;
                        }
                        else
                        {
                            landCheck += itemData.Height;
                        }

                        if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ)
                        {
                            continue;
                        }

                        if (IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items))
                        {
                            newZ     = ourZ;
                            moveIsOk = true;
                        }
                    }
                }
            }
            #endregion

            #region Items
            for (int i = 0; i < items.Count; ++i)
            {
                Item     item     = items[i];
                ItemData itemData = item.ItemData;
                TileFlag flags    = itemData.Flags;

                if (!item.Movable && ((flags & ImpassableSurface) == TileFlag.Surface || (m.CanSwim && (flags & TileFlag.Wet) != 0))) // Surface && !Impassable && !Movable
                {
                    if (cantWalk && (flags & TileFlag.Wet) == 0)
                    {
                        continue;
                    }

                    int itemZ   = item.Z;
                    int itemTop = itemZ;
                    int ourZ    = itemZ + itemData.CalcHeight;
                    int ourTop  = ourZ + PersonHeight;
                    int testTop = checkTop;

                    if (moveIsOk)
                    {
                        int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z);

                        if (cmp > 0 || (cmp == 0 && ourZ > newZ))
                        {
                            continue;
                        }
                    }

                    if (ourZ + PersonHeight > testTop)
                    {
                        testTop = ourZ + PersonHeight;
                    }

                    if (!itemData.Bridge)
                    {
                        itemTop += itemData.Height;
                    }

                    if (stepTop >= itemTop)
                    {
                        int landCheck = itemZ;

                        if (itemData.Height >= StepHeight)
                        {
                            landCheck += StepHeight;
                        }
                        else
                        {
                            landCheck += itemData.Height;
                        }

                        if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ)
                        {
                            continue;
                        }

                        if (IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items))
                        {
                            newZ     = ourZ;
                            moveIsOk = true;
                        }
                    }
                }
            }
            #endregion

            if (considerLand && !landBlocks && stepTop >= landZ)
            {
                int ourZ    = landCenter;
                int ourTop  = ourZ + PersonHeight;
                int testTop = checkTop;

                if (ourZ + PersonHeight > testTop)
                {
                    testTop = ourZ + PersonHeight;
                }

                bool shouldCheck = true;

                if (moveIsOk)
                {
                    int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z);

                    if (cmp > 0 || (cmp == 0 && ourZ > newZ))
                    {
                        shouldCheck = false;
                    }
                }

                if (shouldCheck && IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items))
                {
                    newZ     = ourZ;
                    moveIsOk = true;
                }
            }

            #region Mobiles
            if (moveIsOk)
            {
                for (int i = 0; moveIsOk && i < mobiles.Count; ++i)
                {
                    Mobile mob = mobiles[i];

                    if (mob != m && (mob.Z + 15) > newZ && (newZ + 15) > mob.Z && !CanMoveOver(m, mob))
                    {
                        moveIsOk = false;
                    }
                }
            }
            #endregion

            return(moveIsOk);
        }
Example #45
0
        public bool CheckMovement(Mobile m, Map map, Point3D loc, Direction d, out int newZ)
        {
            if (map == null || map == Map.Internal)
            {
                newZ = 0;
                return(false);
            }

            int xStart = loc.X;
            int yStart = loc.Y;
            int xForward = xStart, yForward = yStart;
            int xRight = xStart, yRight = yStart;
            int xLeft = xStart, yLeft = yStart;

            bool checkDiagonals = ((int)d & 0x1) == 0x1;

            Offset(d, ref xForward, ref yForward);
            Offset((Direction)(((int)d - 1) & 0x7), ref xLeft, ref yLeft);
            Offset((Direction)(((int)d + 1) & 0x7), ref xRight, ref yRight);

            if (xForward < 0 || yForward < 0 || xForward >= map.Width || yForward >= map.Height)
            {
                newZ = 0;
                return(false);
            }

            int startZ, startTop;

            List <Item> itemsStart   = m_Pools[0];
            List <Item> itemsForward = m_Pools[1];
            List <Item> itemsLeft    = m_Pools[2];
            List <Item> itemsRight   = m_Pools[3];

            bool     ignoreMovableImpassables = m_IgnoreMovableImpassables;
            TileFlag reqFlags = ImpassableSurface;

            if (m.CanSwim)
            {
                reqFlags |= TileFlag.Wet;
            }

            List <Mobile> mobsForward = m_MobPools[0];
            List <Mobile> mobsLeft    = m_MobPools[1];
            List <Mobile> mobsRight   = m_MobPools[2];

            bool checkMobs = (m is BaseCreature && !((BaseCreature)m).Controlled && (xForward != m_Goal.X || yForward != m_Goal.Y));

            if (checkDiagonals)
            {
                Sector sectorStart   = map.GetSector(xStart, yStart);
                Sector sectorForward = map.GetSector(xForward, yForward);
                Sector sectorLeft    = map.GetSector(xLeft, yLeft);
                Sector sectorRight   = map.GetSector(xRight, yRight);

                List <Sector> sectors = m_Sectors;

                sectors.Add(sectorStart);

                if (!sectors.Contains(sectorForward))
                {
                    sectors.Add(sectorForward);
                }

                if (!sectors.Contains(sectorLeft))
                {
                    sectors.Add(sectorLeft);
                }

                if (!sectors.Contains(sectorRight))
                {
                    sectors.Add(sectorRight);
                }

                for (int i = 0; i < sectors.Count; ++i)
                {
                    Sector sector = sectors[i];

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

                        if (ignoreMovableImpassables && item.Movable && (item.ItemData.Flags & ImpassableSurface) != 0)
                        {
                            continue;
                        }

                        if ((item.ItemData.Flags & reqFlags) == 0)
                        {
                            continue;
                        }

                        if (sector == sectorStart && item.AtWorldPoint(xStart, yStart) && !(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue)
                        {
                            itemsStart.Add(item);
                        }
                        else if (sector == sectorForward && item.AtWorldPoint(xForward, yForward) && !(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue)
                        {
                            itemsForward.Add(item);
                        }
                        else if (sector == sectorLeft && item.AtWorldPoint(xLeft, yLeft) && !(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue)
                        {
                            itemsLeft.Add(item);
                        }
                        else if (sector == sectorRight && item.AtWorldPoint(xRight, yRight) && !(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue)
                        {
                            itemsRight.Add(item);
                        }
                    }

                    if (checkMobs)
                    {
                        for (int j = 0; j < sector.Mobiles.Count; ++j)
                        {
                            Mobile mob = sector.Mobiles[j];

                            if (sector == sectorForward && mob.X == xForward && mob.Y == yForward)
                            {
                                mobsForward.Add(mob);
                            }
                            else if (sector == sectorLeft && mob.X == xLeft && mob.Y == yLeft)
                            {
                                mobsLeft.Add(mob);
                            }
                            else if (sector == sectorRight && mob.X == xRight && mob.Y == yRight)
                            {
                                mobsRight.Add(mob);
                            }
                        }
                    }
                }

                if (m_Sectors.Count > 0)
                {
                    m_Sectors.Clear();
                }
            }
            else
            {
                Sector sectorStart   = map.GetSector(xStart, yStart);
                Sector sectorForward = map.GetSector(xForward, yForward);

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

                        if (ignoreMovableImpassables && item.Movable && (item.ItemData.Flags & ImpassableSurface) != 0)
                        {
                            continue;
                        }

                        if ((item.ItemData.Flags & reqFlags) == 0)
                        {
                            continue;
                        }

                        if (item.AtWorldPoint(xStart, yStart) && !(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue)
                        {
                            itemsStart.Add(item);
                        }
                        else if (item.AtWorldPoint(xForward, yForward) && !(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue)
                        {
                            itemsForward.Add(item);
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < sectorForward.Items.Count; ++i)
                    {
                        Item item = sectorForward.Items[i];

                        if (ignoreMovableImpassables && item.Movable && (item.ItemData.Flags & ImpassableSurface) != 0)
                        {
                            continue;
                        }

                        if ((item.ItemData.Flags & reqFlags) == 0)
                        {
                            continue;
                        }

                        if (item.AtWorldPoint(xForward, yForward) && !(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue)
                        {
                            itemsForward.Add(item);
                        }
                    }

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

                        if (ignoreMovableImpassables && item.Movable && (item.ItemData.Flags & ImpassableSurface) != 0)
                        {
                            continue;
                        }

                        if ((item.ItemData.Flags & reqFlags) == 0)
                        {
                            continue;
                        }

                        if (item.AtWorldPoint(xStart, yStart) && !(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue)
                        {
                            itemsStart.Add(item);
                        }
                    }
                }

                if (checkMobs)
                {
                    for (int i = 0; i < sectorForward.Mobiles.Count; ++i)
                    {
                        Mobile mob = sectorForward.Mobiles[i];

                        if (mob.X == xForward && mob.Y == yForward)
                        {
                            mobsForward.Add(mob);
                        }
                    }
                }
            }

            GetStartZ(m, map, loc, itemsStart, out startZ, out startTop);

            bool moveIsOk = Check(map, m, itemsForward, mobsForward, xForward, yForward, startTop, startZ, m.CanSwim, m.CantWalk, out newZ);

            if (moveIsOk && checkDiagonals)
            {
                int hold;

                if (m.Player && m.AccessLevel < AccessLevel.GameMaster)
                {
                    if (!Check(map, m, itemsLeft, mobsLeft, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk, out hold) || !Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim, m.CantWalk, out hold))
                    {
                        moveIsOk = false;
                    }
                }
                else
                {
                    if (!Check(map, m, itemsLeft, mobsLeft, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk, out hold) && !Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim, m.CantWalk, out hold))
                    {
                        moveIsOk = false;
                    }
                }
            }

            for (int i = 0; i < (checkDiagonals ? 4 : 2); ++i)
            {
                if (m_Pools[i].Count != 0)
                {
                    m_Pools[i].Clear();
                }
            }

            for (int i = 0; i < (checkDiagonals ? 3 : 1); ++i)
            {
                if (m_MobPools[i].Count != 0)
                {
                    m_MobPools[i].Clear();
                }
            }

            if (!moveIsOk)
            {
                newZ = startZ;
            }

            return(moveIsOk);
        }
Example #46
0
        static TileData()
        {
            string filePath = Core.FindDataFile("tiledata.mul");

            if (File.Exists(filePath))
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader bin = new BinaryReader(fs);

                    if (fs.Length == 3188736)                         // 7.0.9.0
                    {
                        m_LandData = new LandData[0x4000];

                        for (int i = 0; i < 0x4000; ++i)
                        {
                            if (i == 1 || (i > 0 && (i & 0x1F) == 0))
                            {
                                bin.ReadInt32();                                 // header
                            }

                            TileFlag flags = (TileFlag)bin.ReadInt64();
                            bin.ReadInt16();                             // skip 2 bytes -- textureID

                            m_LandData[i] = new LandData(ReadNameString(bin), flags);
                        }

                        m_ItemData = new ItemData[0x10000];

                        for (int i = 0; i < 0x10000; ++i)
                        {
                            if ((i & 0x1F) == 0)
                            {
                                bin.ReadInt32();                                 // header
                            }

                            TileFlag flags   = (TileFlag)bin.ReadInt64();
                            int      weight  = bin.ReadByte();
                            int      quality = bin.ReadByte();
                            bin.ReadInt16();
                            bin.ReadByte();
                            int quantity = bin.ReadByte();
                            bin.ReadInt32();
                            bin.ReadByte();
                            int value  = bin.ReadByte();
                            int height = bin.ReadByte();

                            m_ItemData[i] = new ItemData(ReadNameString(bin), flags, weight, quality, quantity, value, height);
                        }
                    }
                    else
                    {
                        m_LandData = new LandData[0x4000];

                        for (int i = 0; i < 0x4000; ++i)
                        {
                            if ((i & 0x1F) == 0)
                            {
                                bin.ReadInt32();                                 // header
                            }

                            TileFlag flags = (TileFlag)bin.ReadInt32();
                            bin.ReadInt16();                             // skip 2 bytes -- textureID

                            m_LandData[i] = new LandData(ReadNameString(bin), flags);
                        }

                        if (fs.Length == 1644544)                             // 7.0.0.0
                        {
                            m_ItemData = new ItemData[0x8000];

                            for (int i = 0; i < 0x8000; ++i)
                            {
                                if ((i & 0x1F) == 0)
                                {
                                    bin.ReadInt32();                                     // header
                                }

                                TileFlag flags   = (TileFlag)bin.ReadInt32();
                                int      weight  = bin.ReadByte();
                                int      quality = bin.ReadByte();
                                bin.ReadInt16();
                                bin.ReadByte();
                                int quantity = bin.ReadByte();
                                bin.ReadInt32();
                                bin.ReadByte();
                                int value  = bin.ReadByte();
                                int height = bin.ReadByte();

                                m_ItemData[i] = new ItemData(ReadNameString(bin), flags, weight, quality, quantity, value, height);
                            }
                        }
                        else
                        {
                            m_ItemData = new ItemData[0x4000];

                            for (int i = 0; i < 0x4000; ++i)
                            {
                                if ((i & 0x1F) == 0)
                                {
                                    bin.ReadInt32();                                     // header
                                }

                                TileFlag flags   = (TileFlag)bin.ReadInt32();
                                int      weight  = bin.ReadByte();
                                int      quality = bin.ReadByte();
                                bin.ReadInt16();
                                bin.ReadByte();
                                int quantity = bin.ReadByte();
                                bin.ReadInt32();
                                bin.ReadByte();
                                int value  = bin.ReadByte();
                                int height = bin.ReadByte();

                                m_ItemData[i] = new ItemData(ReadNameString(bin), flags, weight, quality, quantity, value, height);
                            }
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("tiledata.mul was not found");
                Console.WriteLine("Make sure your Scripts/Misc/DataPath.cs is properly configured");
                Console.WriteLine("After pressing return an exception will be thrown and the server will terminate");

                throw new Exception(String.Format("TileData: {0} not found", filePath));
            }
        }
Example #47
0
 private void SetFlag(TileFlag flag, bool set)
 {
     if (set)
     {
         this.Flags |= flag;
         return;
     }
     this.Flags &= ~flag;
 }
Example #48
0
 public LandData(string name, TileFlag flags)
 {
     m_Name  = name;
     m_Flags = flags;
 }
Example #49
0
 public unsafe ItemData(ItemTileDataMul mulstruct)
 {
     m_Name = TileData.ReadNameString(mulstruct.name);
     m_Flags = (TileFlag)mulstruct.flags;
     m_Weight = mulstruct.weight;
     m_Quality = mulstruct.quality;
     m_Quantity = mulstruct.quantity;
     m_Value = mulstruct.value;
     m_Height = mulstruct.height;
     m_Animation = mulstruct.anim;
     m_Hue = mulstruct.hue;
     m_StackOffset = mulstruct.stackingoffset;
     m_MiscData = mulstruct.miscdata;
     m_Unk2 = mulstruct.unk2;
     m_Unk3 = mulstruct.unk3;
 }
Example #50
0
        public void ReadData(string[] split)
        {
            m_Name        = split[1];
            m_Weight      = Convert.ToByte(split[2]);
            m_Quality     = Convert.ToByte(split[3]);
            m_Animation   = (short)TileData.ConvertStringToInt(split[4]);
            m_Height      = Convert.ToByte(split[5]);
            m_Hue         = Convert.ToByte(split[6]);
            m_Quantity    = Convert.ToByte(split[7]);
            m_StackOffset = Convert.ToByte(split[8]);
            m_MiscData    = Convert.ToInt16(split[9]);
            m_Unk1        = Convert.ToInt32(split[10]);
            m_Unk2        = Convert.ToByte(split[11]);
            m_Unk3        = Convert.ToByte(split[12]);

            m_Flags = 0;
            int temp = Convert.ToByte(split[13]);

            if (temp != 0)
            {
                m_Flags |= TileFlag.Background;
            }
            temp = Convert.ToByte(split[14]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Weapon;
            }
            temp = Convert.ToByte(split[15]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Transparent;
            }
            temp = Convert.ToByte(split[16]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Translucent;
            }
            temp = Convert.ToByte(split[17]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Wall;
            }
            temp = Convert.ToByte(split[18]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Damaging;
            }
            temp = Convert.ToByte(split[19]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Impassable;
            }
            temp = Convert.ToByte(split[20]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Wet;
            }
            temp = Convert.ToByte(split[21]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Unknown1;
            }
            temp = Convert.ToByte(split[22]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Surface;
            }
            temp = Convert.ToByte(split[23]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Bridge;
            }
            temp = Convert.ToByte(split[24]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Generic;
            }
            temp = Convert.ToByte(split[25]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Window;
            }
            temp = Convert.ToByte(split[26]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.NoShoot;
            }
            temp = Convert.ToByte(split[27]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.ArticleA;
            }
            temp = Convert.ToByte(split[28]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.ArticleAn;
            }
            temp = Convert.ToByte(split[29]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Internal;
            }
            temp = Convert.ToByte(split[30]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Foliage;
            }
            temp = Convert.ToByte(split[31]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.PartialHue;
            }
            temp = Convert.ToByte(split[32]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Unknown2;
            }
            temp = Convert.ToByte(split[33]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Map;
            }
            temp = Convert.ToByte(split[34]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Container;
            }
            temp = Convert.ToByte(split[35]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Wearable;
            }
            temp = Convert.ToByte(split[36]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.LightSource;
            }
            temp = Convert.ToByte(split[37]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Animation;
            }
            temp = Convert.ToByte(split[38]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.HoverOver;
            }
            temp = Convert.ToByte(split[39]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Unknown3;
            }
            temp = Convert.ToByte(split[40]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Armor;
            }
            temp = Convert.ToByte(split[41]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Roof;
            }
            temp = Convert.ToByte(split[42]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Door;
            }
            temp = Convert.ToByte(split[43]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.StairBack;
            }
            temp = Convert.ToByte(split[44]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.StairRight;
            }
        }
Example #51
0
 public LandData(string name, int TexID, TileFlag flags)
 {
     m_Name = name;
     m_TexID = (short)TexID;
     m_Flags = flags;
 }
Example #52
0
        public void ReadData(string[] split)
        {
            int i = 1;

            m_Name  = split[i++];
            m_TexID = (short)TileData.ConvertStringToInt(split[i++]);
            m_Unk1  = TileData.ConvertStringToInt(split[i++]);
            m_Flags = 0;
            int temp = Convert.ToByte(split[i++]);

            if (temp != 0)
            {
                m_Flags |= TileFlag.Background;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Weapon;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Transparent;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Translucent;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Wall;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Damaging;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Impassable;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Wet;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Unknown1;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Surface;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Bridge;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Generic;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Window;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.NoShoot;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.ArticleA;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.ArticleAn;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Internal;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Foliage;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.PartialHue;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Unknown2;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Map;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Container;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Wearable;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.LightSource;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Animation;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.HoverOver;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Unknown3;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Armor;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Roof;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.Door;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.StairBack;
            }
            temp = Convert.ToByte(split[i++]);
            if (temp != 0)
            {
                m_Flags |= TileFlag.StairRight;
            }
        }
Example #53
0
        public void ReadData(string[] split)
        {
            m_Name = split[1];
            m_TexID = (short)TileData.ConvertStringToInt(split[2]);

            m_Flags = (TileFlag)((long)m_Flags & unchecked((long)0xFFFFFFFF00000000));
            //m_Flags = 0;
            int temp = System.Convert.ToByte(split[3]);
            if (temp != 0)
                m_Flags |= TileFlag.Background;
            temp = System.Convert.ToByte(split[4]);
            if (temp != 0)
                m_Flags |= TileFlag.Weapon;
            temp = System.Convert.ToByte(split[5]);
            if (temp != 0)
                m_Flags |= TileFlag.Transparent;
            temp = System.Convert.ToByte(split[6]);
            if (temp != 0)
                m_Flags |= TileFlag.Translucent;
            temp = System.Convert.ToByte(split[7]);
            if (temp != 0)
                m_Flags |= TileFlag.Wall;
            temp = System.Convert.ToByte(split[8]);
            if (temp != 0)
                m_Flags |= TileFlag.Damaging;
            temp = System.Convert.ToByte(split[9]);
            if (temp != 0)
                m_Flags |= TileFlag.Impassable;
            temp = System.Convert.ToByte(split[10]);
            if (temp != 0)
                m_Flags |= TileFlag.Wet;
            temp = System.Convert.ToByte(split[11]);
            if (temp != 0)
                m_Flags |= TileFlag.Unknown1;
            temp = System.Convert.ToByte(split[12]);
            if (temp != 0)
                m_Flags |= TileFlag.Surface;
            temp = System.Convert.ToByte(split[13]);
            if (temp != 0)
                m_Flags |= TileFlag.Bridge;
            temp = System.Convert.ToByte(split[14]);
            if (temp != 0)
                m_Flags |= TileFlag.Generic;
            temp = System.Convert.ToByte(split[15]);
            if (temp != 0)
                m_Flags |= TileFlag.Window;
            temp = System.Convert.ToByte(split[16]);
            if (temp != 0)
                m_Flags |= TileFlag.NoShoot;
            temp = System.Convert.ToByte(split[17]);
            if (temp != 0)
                m_Flags |= TileFlag.ArticleA;
            temp = System.Convert.ToByte(split[18]);
            if (temp != 0)
                m_Flags |= TileFlag.ArticleAn;
            temp = System.Convert.ToByte(split[19]);
            if (temp != 0)
                m_Flags |= TileFlag.Internal;
            temp = System.Convert.ToByte(split[20]);
            if (temp != 0)
                m_Flags |= TileFlag.Foliage;
            temp = System.Convert.ToByte(split[21]);
            if (temp != 0)
                m_Flags |= TileFlag.PartialHue;
            temp = System.Convert.ToByte(split[22]);
            if (temp != 0)
                m_Flags |= TileFlag.Unknown2;
            temp = System.Convert.ToByte(split[23]);
            if (temp != 0)
                m_Flags |= TileFlag.Map;
            temp = System.Convert.ToByte(split[24]);
            if (temp != 0)
                m_Flags |= TileFlag.Container;
            temp = System.Convert.ToByte(split[25]);
            if (temp != 0)
                m_Flags |= TileFlag.Wearable;
            temp = System.Convert.ToByte(split[26]);
            if (temp != 0)
                m_Flags |= TileFlag.LightSource;
            temp = System.Convert.ToByte(split[27]);
            if (temp != 0)
                m_Flags |= TileFlag.Animation;
            temp = System.Convert.ToByte(split[28]);
            if (temp != 0)
                m_Flags |= TileFlag.HoverOver;
            temp = System.Convert.ToByte(split[29]);
            if (temp != 0)
                m_Flags |= TileFlag.Unknown3;
            temp = System.Convert.ToByte(split[30]);
            if (temp != 0)
                m_Flags |= TileFlag.Armor;
            temp = System.Convert.ToByte(split[31]);
            if (temp != 0)
                m_Flags |= TileFlag.Roof;
            temp = System.Convert.ToByte(split[32]);
            if (temp != 0)
                m_Flags |= TileFlag.Door;
            temp = System.Convert.ToByte(split[33]);
            if (temp != 0)
                m_Flags |= TileFlag.StairBack;
            temp = System.Convert.ToByte(split[34]);
            if (temp != 0)
                m_Flags |= TileFlag.StairRight;
        }
Example #54
0
 private void SetFlag(TileFlag flag, bool value)
 {
     if (ArtTiles == null) return;
     for (int i = 0; i < ArtTiles.Length; ++i) {
         if (value)
             Ultima.TileData.ItemTable[ArtTiles[i]].Flags |= flag;
         else
             Ultima.TileData.ItemTable[ArtTiles[i]].Flags &= ~flag;
     }
     ReadTileData();
 }