示例#1
0
        public static bool Calculate(int x, int y, int z, Direction dir, out int newZ, out int newDir)
        {
            int dir1 = (int)Engine.GetWalkDirection(dir);

            newZ   = z;
            newDir = dir1;
            if (!Walking.IsDiagonal(dir1))
            {
                int dir2 = Walking.Turn(dir1, 1);
                int dir3 = Walking.Turn(dir1, -1);
                Walking.m_Diag = true;
                int  zNew1;
                bool flag1 = Walking.CheckMovement(x, y, z, dir2, out zNew1);
                int  zNew2;
                bool flag2 = Walking.CheckMovement(x, y, z, dir3, out zNew2);
                Walking.m_Diag = false;
                int zNew3;
                if (Walking.CheckMovement(x, y, z, dir1, out zNew3) && ((int)World.Player.Body == 987 ? (flag1 ? 1 : (flag2 ? 1 : 0)) : (!flag1 ? 0 : (flag2 ? 1 : 0))) != 0)
                {
                    newZ = zNew3;
                }
                else if (flag1)
                {
                    newZ   = zNew1;
                    newDir = dir2;
                }
                else
                {
                    if (!flag2)
                    {
                        return(false);
                    }
                    newZ   = zNew2;
                    newDir = dir3;
                }
                return(true);
            }
            return(Walking.CheckMovement(x, y, z, dir1, out newZ));
        }
示例#2
0
        public static bool CheckMovement(int xStart, int yStart, int zStart, int dir, out int zNew)
        {
            Mobile player = World.Player;

            if (player == null)
            {
                zNew = 0;
                return(false);
            }
            int x = xStart;
            int y = yStart;

            Walking.Offset(dir, ref x, ref y);
            MapPackage cache = Map.GetCache();
            int        X     = x - cache.CellX;
            int        Y     = y - cache.CellY;

            if (!Map.IsValid(X, Y))
            {
                zNew = 0;
                return(false);
            }
            ArrayList tiles     = cache.cells[X, Y];
            LandTile  landTile1 = World.Viewport.GetLandTile(x, y, Engine.m_World);
            LandTile  landTile2 = World.Viewport.GetLandTile(xStart, yStart, Engine.m_World);

            try
            {
                if (player.Notoriety == Notoriety.Murderer)
                {
                    if (landTile1.m_Guarded)
                    {
                        if (!Options.Current.SiegeRuleset)
                        {
                            if (!landTile2.m_Guarded)
                            {
                                if ((Control.ModifierKeys & (Keys.Shift | Keys.Control)) != (Keys.Shift | Keys.Control))
                                {
                                    zNew = 0;
                                    return(false);
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }
            bool impassable = landTile1.Impassable;
            bool flag1      = (int)landTile1.m_ID != 2 && (int)landTile1.m_ID != 475 && ((int)landTile1.m_ID < 430 || (int)landTile1.m_ID > 437);
            int  z1         = 0;
            int  avg        = 0;
            int  top        = 0;

            Map.GetAverageZ(x, y, ref z1, ref avg, ref top);
            int zLow;
            int zTop;

            Walking.GetStartZ(xStart, yStart, zStart, out zLow, out zTop);
            zNew = zLow;
            bool flag2       = false;
            int  num1        = zTop + 2;
            int  num2        = zLow + 16;
            bool ignoreDoors = player.Ghost || (int)player.Body == 987;
            bool ignoreMobs  = ignoreDoors || player.CurrentStamina == player.MaximumStamina || Engine.m_World != 0;

            if (Engine.m_Stealth)
            {
                ignoreMobs = false;
            }
            for (int index = 0; index < tiles.Count; ++index)
            {
                ICell cell = (ICell)tiles[index];
                if (cell is StaticItem)
                {
                    StaticItem staticItem = (StaticItem)cell;
                    TileFlags  tileFlags  = Map.m_ItemFlags[(int)staticItem.m_RealID];
                    if (tileFlags[(TileFlag)512L] && !tileFlags[(TileFlag)64L])
                    {
                        int num3   = (int)staticItem.m_Z;
                        int num4   = num3;
                        int ourZ   = num3 + (int)staticItem.CalcHeight;
                        int ourTop = num2;
                        if (flag2)
                        {
                            int num5 = Math.Abs(ourZ - player.Z) - Math.Abs(zNew - player.Z);
                            if (num5 > 0 || num5 == 0 && ourZ > zNew)
                            {
                                continue;
                            }
                        }
                        if (ourZ + 16 > ourTop)
                        {
                            ourTop = ourZ + 16;
                        }
                        if (!tileFlags[(TileFlag)1024L])
                        {
                            num4 += (int)staticItem.Height;
                        }
                        if (num1 >= num4)
                        {
                            int num5 = num3;
                            int num6 = (int)staticItem.Height < 2 ? num5 + (int)staticItem.Height : num5 + 2;
                            if ((!flag1 || num6 >= avg || (avg <= ourZ || ourTop <= z1)) && Walking.IsOk(ignoreMobs, ignoreDoors, ourZ, ourTop, tiles))
                            {
                                zNew  = ourZ;
                                flag2 = true;
                            }
                        }
                    }
                }
                else if (cell is DynamicItem)
                {
                    Item      obj       = ((DynamicItem)cell).m_Item;
                    TileFlags tileFlags = Map.m_ItemFlags[obj.ID];
                    if (tileFlags[(TileFlag)512L] && !tileFlags[(TileFlag)64L])
                    {
                        int z2     = obj.Z;
                        int num3   = z2;
                        int num4   = z2;
                        int height = obj.Height;
                        int ourZ   = !tileFlags[(TileFlag)1024L] ? num4 + height : num4 + height / 2;
                        if (flag2)
                        {
                            int num5 = Math.Abs(ourZ - player.Z) - Math.Abs(zNew - player.Z);
                            if (num5 > 0 || num5 == 0 && ourZ > zNew)
                            {
                                continue;
                            }
                        }
                        int ourTop = num2;
                        if (ourZ + 16 > ourTop)
                        {
                            ourTop = ourZ + 16;
                        }
                        if (!tileFlags[(TileFlag)1024L])
                        {
                            num3 += height;
                        }
                        if (num1 >= num3)
                        {
                            int num5 = z2;
                            int num6 = height < 2 ? num5 + height : num5 + 2;
                            if ((!flag1 || num6 >= avg || (avg <= ourZ || ourTop <= z1)) && Walking.IsOk(ignoreMobs, ignoreDoors, ourZ, ourTop, tiles))
                            {
                                zNew  = ourZ;
                                flag2 = true;
                            }
                        }
                    }
                }
            }
            if (flag1 && !impassable && num1 >= z1)
            {
                int ourZ   = avg;
                int ourTop = num2;
                if (ourZ + 16 > ourTop)
                {
                    ourTop = ourZ + 16;
                }
                bool flag3 = true;
                if (flag2)
                {
                    int num3 = Math.Abs(ourZ - player.Z) - Math.Abs(zNew - player.Z);
                    if (num3 > 0 || num3 == 0 && ourZ > zNew)
                    {
                        flag3 = false;
                    }
                }
                if (flag3 && Walking.IsOk(ignoreMobs, ignoreDoors, ourZ, ourTop, tiles))
                {
                    zNew  = ourZ;
                    flag2 = true;
                }
            }
            return(flag2);
        }