示例#1
0
        private void SearchNextName(object sender, EventArgs e)
        {
            bool res = Options.DesignAlternative
                ? LandTilesAlternative.SearchName(textBoxItemName.Text, true)
                : LandTiles.SearchName(textBoxItemName.Text, true);

            if (res)
            {
                return;
            }

            DialogResult result = MessageBox.Show(
                "No landtile found",
                "Result",
                MessageBoxButtons.OKCancel,
                MessageBoxIcon.Error,
                MessageBoxDefaultButton.Button1);

            if (result == DialogResult.Cancel)
            {
                Close();
            }
        }
示例#2
0
        private static bool Check(Mobile m, List <IDynamicItem> items, int x, int y, int startTop, sbyte startZ, out sbyte newZ)
        {
            newZ = 0;
            Tile mapTile = World.Map.GetTile(x, y);

            if (mapTile == null)
            {
                return(false);
            }
            LandTiles     id = mapTile.TileData;
            List <Static> tiles = mapTile.GetStatics();
            bool          landBlocks = (id.Flags & 0x00000040) != 0;
            bool          considerLand = !mapTile.IsIgnored;
            sbyte         landCenter = 0;
            sbyte         landLow = 0, landTop = 0;

            landCenter = (sbyte)World.Map.GetAverageZ((short)x, (short)y, ref landLow, ref landTop);
            bool moveIsOk = false;
            int  stepTop  = startTop + STEP_HEIGHT;
            int  checkTop = startZ + PERSON_HEIGHT;
            bool ignoreDoors = m.IsDead || m.Graphic == 0x3DB;

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

                if ((tile.ItemData.Flags & IMPASSABLE_SURFACE) == 0x00000200) //  || (canSwim && (flags & TileFlag.Wet) != 0) Surface && !Impassable
                {
                    // if (cantWalk && (flags & TileFlag.Wet) == 0)
                    //     continue;
                    int   itemZ   = tile.Position.Z;
                    int   itemTop = itemZ;
                    sbyte ourZ    = (sbyte)(itemZ + ((tile.ItemData.Flags & 0x00000400) != 0 ? tile.ItemData.Height / 2 : tile.ItemData.Height));
                    int   ourTop  = ourZ + PERSON_HEIGHT;
                    int   testTop = checkTop;

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

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

                    if (ourZ + PERSON_HEIGHT > testTop)
                    {
                        testTop = ourZ + PERSON_HEIGHT;
                    }
                    if ((tile.ItemData.Flags & 0x00000400) == 0)
                    {
                        itemTop += tile.ItemData.Height;
                    }

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

                        if (tile.ItemData.Height >= STEP_HEIGHT)
                        {
                            landCheck += STEP_HEIGHT;
                        }
                        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;
                        }
                    }
                }
            }

            for (int i = 0; i < items.Count; ++i)
            {
                IDynamicItem item     = items[i];
                StaticTiles  itemData = item.ItemData;
                ulong        flags    = itemData.Flags;

                if ((flags & IMPASSABLE_SURFACE) == 0x00000200) // Surface && !Impassable && !Movable
                {
                    //  || (m.CanSwim && (flags & TileFlag.Wet) != 0))
                    // !item.Movable &&
                    // if (cantWalk && (flags & TileFlag.Wet) == 0)
                    //     continue;
                    int   itemZ   = item.Position.Z;
                    int   itemTop = itemZ;
                    sbyte ourZ    = (sbyte)(itemZ + ((item.ItemData.Flags & 0x00000400) != 0 ? item.ItemData.Height / 2 : item.ItemData.Height));
                    int   ourTop  = ourZ + PERSON_HEIGHT;
                    int   testTop = checkTop;

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

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

                    if (ourZ + PERSON_HEIGHT > testTop)
                    {
                        testTop = ourZ + PERSON_HEIGHT;
                    }
                    if ((itemData.Flags & 0x00000400) == 0)
                    {
                        itemTop += itemData.Height;
                    }

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

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

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

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

            if (considerLand && !landBlocks && stepTop >= landLow)
            {
                sbyte ourZ    = landCenter;
                int   ourTop  = ourZ + PERSON_HEIGHT;
                int   testTop = checkTop;
                if (ourZ + PERSON_HEIGHT > testTop)
                {
                    testTop = ourZ + PERSON_HEIGHT;
                }
                bool shouldCheck = true;

                if (moveIsOk)
                {
                    int cmp = Math.Abs(ourZ - m.Position.Z) - Math.Abs(newZ - m.Position.Z);
                    if (cmp > 0 || cmp == 0 && ourZ > newZ)
                    {
                        shouldCheck = false;
                    }
                }

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

            return(moveIsOk);
        }
示例#3
0
        public unsafe void Load(int map)
        {
            IndexMap im = GetIndex(map);

            if (im.MapAddress != 0)
            {
                MapBlock *block = (MapBlock *)im.MapAddress;
                MapCells *cells = (MapCells *)&block->Cells;
                int       bx    = X * 8;
                int       by    = Y * 8;

                for (int x = 0; x < 8; x++)
                {
                    for (int y = 0; y < 8; y++)
                    {
                        int       pos    = y * 8 + x;
                        ushort    tileID = (ushort)(cells[pos].TileID & 0x3FFF);
                        sbyte     z      = cells[pos].Z;
                        LandTiles info   = TileData.LandData[tileID];

                        Land land = new Land(tileID)
                        {
                            Graphic     = tileID,
                            AverageZ    = z,
                            MinZ        = z,
                            IsStretched = info.TexID == 0 && TileData.IsWet(info.Flags),
                        };
                        ushort tileX = (ushort)(bx + x);
                        ushort tileY = (ushort)(by + y);
                        land.Calculate(tileX, tileY, z);
                        land.Position = new Position(tileX, tileY, z);
                    }
                }

                if (im.StaticAddress != 0)
                {
                    StaticsBlock *sb = (StaticsBlock *)im.StaticAddress;

                    if (sb != null)
                    {
                        int count = (int)im.StaticCount;

                        for (int i = 0; i < count; i++, sb++)
                        {
                            if (sb->Color > 0 && sb->Color != 0xFFFF)
                            {
                                ushort x   = sb->X;
                                ushort y   = sb->Y;
                                int    pos = y * 8 + x;

                                if (pos >= 64)
                                {
                                    continue;
                                }
                                sbyte z = sb->Z;

                                Static staticObject = new Static(sb->Color, sb->Hue, pos)
                                {
                                    Position = new Position((ushort)(bx + x), (ushort)(by + y), z)
                                };

                                if (TileData.IsAnimated(staticObject.ItemData.Flags))
                                {
                                    staticObject.Effect = new AnimatedItemEffect(staticObject, staticObject.Graphic, staticObject.Hue, -1);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        public unsafe void Load(int map)
        {
            IndexMap im = GetIndex(map);

            if (im.MapAddress != 0)
            {
                MapBlock block = Marshal.PtrToStructure <MapBlock>((IntPtr)im.MapAddress);
                int      bx    = X * 8;
                int      by    = Y * 8;

                for (int x = 0; x < 8; x++)
                {
                    for (int y = 0; y < 8; y++)
                    {
                        int       pos    = y * 8 + x;
                        ushort    tileID = (ushort)(block.Cells[pos].TileID & 0x3FFF);
                        sbyte     z      = block.Cells[pos].Z;
                        Tile      tile   = Tiles[x][y];
                        LandTiles info   = TileData.LandData[tileID];
                        tile.Graphic     = tileID;
                        tile.Position    = new Position((ushort)(bx + x), (ushort)(by + y), z);
                        tile.AverageZ    = z;
                        tile.MinZ        = z;
                        tile.IsStretched = info.TexID == 0 && TileData.IsWet((long)info.Flags);
                        tile.AddGameObject(tile);
                        tile.Calculate();
                    }
                }

                if (im.StaticAddress != 0)
                {
                    StaticsBlock *sb = (StaticsBlock *)im.StaticAddress;

                    if (sb != null)
                    {
                        int count = (int)im.StaticCount;

                        for (int i = 0; i < count; i++, sb++)
                        {
                            if (sb->Color > 0 && sb->Color != 0xFFFF)
                            {
                                ushort x   = sb->X;
                                ushort y   = sb->Y;
                                int    pos = y * 8 + x;

                                if (pos >= 64)
                                {
                                    continue;
                                }
                                sbyte z = sb->Z;

                                Static staticObject = new Static(sb->Color, sb->Hue, pos)
                                {
                                    Position = new Position((ushort)(bx + x), (ushort)(by + y), z)
                                };

                                if (TileData.IsAnimated((long)staticObject.ItemData.Flags))
                                {
                                    staticObject.Effect = new AnimatedItemEffect(staticObject, staticObject.Graphic, staticObject.Hue, -1);
                                }
                                //Service.Get<EffectManager>().Add(GraphicEffectType.FixedXYZ, Serial.Invalid, Serial.Invalid, staticObject.Graphic, staticObject.Hue, staticObject.Position, Position.Invalid, 0, -1, false, false, false, GraphicEffectBlendMode.Normal);

                                Tiles[x][y].AddGameObject(staticObject);
                            }
                        }
                    }
                }
            }
        }
示例#5
0
 private void SearchGraphic(object sender, EventArgs e)
 {
     if (Utils.ConvertStringToInt(textBoxGraphic.Text, out int graphic, 0, 0x3FFF))
     {
         bool res = Options.DesignAlternative ? LandTilesAlternative.SearchGraphic(graphic) : LandTiles.SearchGraphic(graphic);
         if (!res)
         {
             DialogResult result = MessageBox.Show(
                 "No landtile found",
                 "Result",
                 MessageBoxButtons.OKCancel,
                 MessageBoxIcon.Error,
                 MessageBoxDefaultButton.Button1);
             if (result == DialogResult.Cancel)
             {
                 Close();
             }
         }
     }
 }