示例#1
0
        private static bool CreateItemList(ref List <PathObject> list, int x, int y, int stepState)
        {
            Tile tile = World.Map.GetTile(x, y);

            if (tile == null)
            {
                return(false);
            }
            bool ignoreGameCharacters = IgnoreStaminaCheck || stepState == (int)PATH_STEP_STATE.PSS_DEAD_OR_GM || World.Player.IgnoreCharacters || !(World.Player.Stamina < World.Player.StaminaMax && World.Player.Map.Index == 0);
            bool isGM = World.Player.Graphic == 0x03DB;

            foreach (GameObject obj in tile.ObjectsOnTiles)
            {
                // TODO: custom house gump
                Graphic graphic = obj.Graphic;

                switch (obj)
                {
                case Tile tile1:

                    if (graphic < 0x01AE && graphic != 2 || graphic > 0x01B5 && graphic != 0x01DB)
                    {
                        uint flags         = (uint)PATH_OBJECT_FLAGS.POF_IMPASSABLE_OR_SURFACE;
                        long tileDataFlags = (long)tile1.TileData.Flags;

                        if (stepState == (int)PATH_STEP_STATE.PSS_ON_SEA_HORSE)
                        {
                            if (TileData.IsWet(tileDataFlags))
                            {
                                flags = (uint)(PATH_OBJECT_FLAGS.POF_IMPASSABLE_OR_SURFACE | PATH_OBJECT_FLAGS.POF_SURFACE | PATH_OBJECT_FLAGS.POF_BRIDGE);
                            }
                        }
                        else
                        {
                            if (!TileData.IsImpassable(tileDataFlags))
                            {
                                flags = (uint)(PATH_OBJECT_FLAGS.POF_IMPASSABLE_OR_SURFACE | PATH_OBJECT_FLAGS.POF_SURFACE | PATH_OBJECT_FLAGS.POF_BRIDGE);
                            }

                            if (stepState == (int)PATH_STEP_STATE.PSS_FLYING && TileData.IsNoDiagonal(tileDataFlags))
                            {
                                flags |= (uint)PATH_OBJECT_FLAGS.POF_NO_DIAGONAL;
                            }
                        }

                        int landMinZ     = tile.MinZ;
                        int landAverageZ = tile.AverageZ;
                        int landHeight   = landAverageZ - landMinZ;
                        list.Add(new PathObject(flags, landMinZ, landAverageZ, landHeight, obj));
                    }

                    break;

                default:
                    bool canBeAdd  = true;
                    bool dropFlags = false;

                    switch (obj)
                    {
                    case Mobile mobile:

                    {
                        if (!ignoreGameCharacters && !mobile.IsDead && !mobile.IgnoreCharacters)
                        {
                            list.Add(new PathObject((uint)PATH_OBJECT_FLAGS.POF_IMPASSABLE_OR_SURFACE, mobile.Position.Z, mobile.Position.Z + 16, 16, mobile));
                        }
                        canBeAdd = false;

                        break;
                    }

                    case Item item when item.IsMulti || TileData.IsInternal((long)item.ItemData.Flags):

                    {
                        canBeAdd = false;

                        break;
                    }

                    case IDynamicItem dyn when stepState == (int)PATH_STEP_STATE.PSS_DEAD_OR_GM && (TileData.IsDoor((long)dyn.ItemData.Flags) || dyn.ItemData.Weight <= 0x5A /*|| (isGM && !)*/):
                        dropFlags = true;

                        break;

                    default:
                        dropFlags = graphic >= 0x3946 && graphic <= 0x3964 || graphic == 0x0082;

                        break;
                    }

                    if (canBeAdd)
                    {
                        uint flags = 0;

                        if (obj is IDynamicItem dyn)
                        {
                            if (stepState == (int)PATH_STEP_STATE.PSS_ON_SEA_HORSE)
                            {
                                if (TileData.IsWet((long)dyn.ItemData.Flags))
                                {
                                    flags = (uint)(PATH_OBJECT_FLAGS.POF_SURFACE | PATH_OBJECT_FLAGS.POF_BRIDGE);
                                }
                            }
                            else
                            {
                                if (TileData.IsImpassable((long)dyn.ItemData.Flags) || TileData.IsSurface((long)dyn.ItemData.Flags))
                                {
                                    flags = (uint)PATH_OBJECT_FLAGS.POF_IMPASSABLE_OR_SURFACE;
                                }

                                if (!TileData.IsImpassable((long)dyn.ItemData.Flags))
                                {
                                    if (TileData.IsSurface((long)dyn.ItemData.Flags))
                                    {
                                        flags |= (uint)PATH_OBJECT_FLAGS.POF_SURFACE;
                                    }

                                    if (TileData.IsBridge((long)dyn.ItemData.Flags))
                                    {
                                        flags |= (uint)PATH_OBJECT_FLAGS.POF_BRIDGE;
                                    }
                                }

                                if (stepState == (int)PATH_STEP_STATE.PSS_DEAD_OR_GM)
                                {
                                    if (graphic <= 0x0846)
                                    {
                                        if (!(graphic != 0x0846 && graphic != 0x0692 && (graphic <= 0x06F4 || graphic > 0x06F6)))
                                        {
                                            dropFlags = true;
                                        }
                                    }
                                    else if (graphic == 0x0873)
                                    {
                                        dropFlags = true;
                                    }
                                }

                                if (dropFlags)
                                {
                                    flags &= 0xFFFFFFFE;
                                }

                                if (stepState == (int)PATH_STEP_STATE.PSS_FLYING && TileData.IsNoDiagonal((long)dyn.ItemData.Flags))
                                {
                                    flags |= (uint)PATH_OBJECT_FLAGS.POF_NO_DIAGONAL;
                                }
                            }

                            if (flags != 0)
                            {
                                int objZ           = obj.Position.Z;
                                int staticHeight   = dyn.ItemData.Height;
                                int staticAverageZ = staticHeight;

                                if (TileData.IsBridge((long)dyn.ItemData.Flags))
                                {
                                    staticAverageZ /= 2;
                                }
                                list.Add(new PathObject(flags, objZ, staticAverageZ + objZ, staticHeight, obj));
                            }
                        }
                    }

                    break;
                }
            }

            return(list.Count > 0);
        }
示例#2
0
        private static bool CreateItemList(ref List <PathObject> list, int x, int y, int stepState)
        {
            Tile tile = World.Map.GetTile(x, y, false);

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

            bool ignoreGameCharacters = IgnoreStaminaCheck || stepState == (int)PATH_STEP_STATE.PSS_DEAD_OR_GM || World.Player.IgnoreCharacters || !(World.Player.Stamina < World.Player.StaminaMax && World.Map.Index == 0);
            bool isGM = World.Player.Graphic == 0x03DB;

            GameObject obj = tile.FirstNode;

            while (obj.Left != null)
            {
                obj = obj.Left;
            }

            for (; obj != null; obj = obj.Right)
            {
                // TODO: custom house gump
                Graphic graphic = obj.Graphic;

                switch (obj)
                {
                case Land tile1:

                    if (graphic < 0x01AE && graphic != 2 || graphic > 0x01B5 && graphic != 0x01DB)
                    {
                        uint flags = (uint)PATH_OBJECT_FLAGS.POF_IMPASSABLE_OR_SURFACE;

                        if (stepState == (int)PATH_STEP_STATE.PSS_ON_SEA_HORSE)
                        {
                            if (tile1.TileData.IsWet)
                            {
                                flags = (uint)(PATH_OBJECT_FLAGS.POF_IMPASSABLE_OR_SURFACE | PATH_OBJECT_FLAGS.POF_SURFACE | PATH_OBJECT_FLAGS.POF_BRIDGE);
                            }
                        }
                        else
                        {
                            if (!tile1.TileData.IsImpassable)
                            {
                                flags = (uint)(PATH_OBJECT_FLAGS.POF_IMPASSABLE_OR_SURFACE | PATH_OBJECT_FLAGS.POF_SURFACE | PATH_OBJECT_FLAGS.POF_BRIDGE);
                            }

                            if (stepState == (int)PATH_STEP_STATE.PSS_FLYING && tile1.TileData.IsNoDiagonal)
                            {
                                flags |= (uint)PATH_OBJECT_FLAGS.POF_NO_DIAGONAL;
                            }
                        }

                        int landMinZ     = tile1.MinZ;
                        int landAverageZ = tile1.AverageZ;
                        int landHeight   = landAverageZ - landMinZ;
                        list.Add(new PathObject(flags, landMinZ, landAverageZ, landHeight, obj));
                    }

                    break;

                default:
                    bool canBeAdd  = true;
                    bool dropFlags = false;

                    switch (obj)
                    {
                    case Mobile mobile:

                    {
                        if (!ignoreGameCharacters && !mobile.IsDead && !mobile.IgnoreCharacters)
                        {
                            list.Add(new PathObject((uint)PATH_OBJECT_FLAGS.POF_IMPASSABLE_OR_SURFACE, mobile.Position.Z, mobile.Position.Z + Constants.DEFAULT_CHARACTER_HEIGHT, Constants.DEFAULT_CHARACTER_HEIGHT, mobile));
                        }
                        canBeAdd = false;

                        break;
                    }

                    case Item item when item.IsMulti || item.ItemData.IsInternal:

                    {
                        canBeAdd = false;

                        break;
                    }

                    case Item item2:

                        if (stepState == (int)PATH_STEP_STATE.PSS_DEAD_OR_GM && (item2.ItemData.IsDoor || item2.ItemData.Weight <= 0x5A || isGM && !item2.IsLocked))
                        {
                            dropFlags = true;
                        }

                        else if (ProfileManager.Current.SmoothDoors && item2.ItemData.IsDoor)
                        {
                            dropFlags = true;
                        }
                        else
                        {
                            dropFlags = graphic >= 0x3946 && graphic <= 0x3964 || graphic == 0x0082;
                        }
                        break;
                    }

                    if (canBeAdd)
                    {
                        uint flags = 0;

                        if (!(obj is Mobile))
                        {
                            ref readonly var itemdata = ref UOFileManager.TileData.StaticData[obj.Graphic];