Пример #1
0
        private static void CheckLocation(ref Point3D location, Map map)
        {
            IPooledEnumerable <Spawner> spawners = map.GetItemsInRange <Spawner>(location, 0);

            if (!spawners.Any())
            {
                return;
            }

            for (int x = 0; x > -10; x--)
            {
                for (int y = 0; y > -10; y--)
                {
                    location.X += x;
                    location.Y += y;
                    location.Z  = map.GetAverageZ(location.X, location.Y);

                    spawners = map.GetItemsInRange <Spawner>(location, 0);

                    if (spawners.Any())
                    {
                        continue;
                    }

                    return;
                }
            }
        }
Пример #2
0
        public static bool FindEffectController(int x, int y, int z)
        {
            IPooledEnumerable <Item> eable = Map.Felucca.GetItemsInRange(new Point3D(x, y, z), 0);

            bool found = eable.Any(item => item is EffectController && item.Z == z);

            eable.Free();
            return(found);
        }
Пример #3
0
        public bool Find(Mobile from, int[] itemIDs)
        {
            Map map = from.Map;

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

            IPooledEnumerable <Item> eable = map.GetItemsInRange(from.Location, 2);
            bool found = eable.Any(item => item.Z + 16 > item.Z && item.Z + 16 > item.Z && Find(item.ItemID, itemIDs));

            eable.Free();

            if (found)
            {
                return(true);
            }

            for (int x = -2; x <= 2; ++x)
            {
                for (int y = -2; y <= 2; ++y)
                {
                    int vx = from.X + x;
                    int vy = from.Y + y;

                    StaticTile[] tiles = map.Tiles.GetStaticTiles(vx, vy, true);

                    for (int i = 0; i < tiles.Length; ++i)
                    {
                        int z  = tiles[i].Z;
                        int id = tiles[i].ID;

                        if (z + 16 > from.Z && from.Z + 16 > z && Find(id, itemIDs))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #4
0
        private static bool IsValidLocation(Point3D location, Map map)
        {
            LandTile lt = map.Tiles.GetLandTile(location.X, location.Y); // Land   Tiles

            if (IsValidTile(lt.ID) && lt.Z == location.Z)
            {
                return(true);
            }

            StaticTile[] tiles = map.Tiles.GetStaticTiles(location.X, location.Y); // Static Tiles

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

                int tand = t.ID;

                if (t.Z + id.CalcHeight != location.Z)
                {
                    continue;
                }
                if (IsValidTile(tand))
                {
                    return(true);
                }
            }

            IPooledEnumerable <Item> eable = map.GetItemsInRange(location, 0);

            bool found = eable.Any(item =>
                                   item.Z + item.ItemData.CalcHeight == location.Z && IsValidTile(item.ItemID));

            eable.Free();

            return(found);
        }
Пример #5
0
        private static void Process(Map map, Rectangle2D[] regions)
        {
            m_ShopTable = new Dictionary <Point2D, ShopInfo>();
            m_ShopList  = new List <ShopInfo>();

            World.Broadcast(0x35, true, "Generating vendor spawns for {0}, please wait.", map);

            for (int i = 0; i < regions.Length; ++i)
            {
                for (int x = 0; x < map.Width; ++x)
                {
                    for (int y = 0; y < map.Height; ++y)
                    {
                        CheckPoint(map, regions[i].X + x, regions[i].Y + y);
                    }
                }
            }

            for (int i = 0; i < m_ShopList.Count; ++i)
            {
                ShopInfo si = m_ShopList[i];

                int xTotal = 0;
                int yTotal = 0;

                bool hasSpawner = false;

                for (int j = 0; j < si.m_Floor.Count; ++j)
                {
                    Point2D fp = si.m_Floor[j];

                    xTotal += fp.X;
                    yTotal += fp.Y;

                    IPooledEnumerable <Spawner> eable = map.GetItemsInRange <Spawner>(new Point3D(fp.X, fp.Y, 0), 0);
                    hasSpawner = eable.Any();
                    eable.Free();

                    if (hasSpawner)
                    {
                        break;
                    }
                }

                if (hasSpawner)
                {
                    continue;
                }

                int xAvg = xTotal / si.m_Floor.Count;
                int yAvg = yTotal / si.m_Floor.Count;

                List <string> names = new List <string>();
                ShopFlags     flags = si.m_Flags;

                if ((flags & ShopFlags.Armor) != 0)
                {
                    names.Add("armorer");
                }

                if ((flags & ShopFlags.MetalWeapon) != 0)
                {
                    names.Add("weaponsmith");
                }

                if ((flags & ShopFlags.ArcheryWeapon) != 0)
                {
                    names.Add("bowyer");
                }

                if ((flags & ShopFlags.Scroll) != 0)
                {
                    names.Add("mage");
                }

                if ((flags & ShopFlags.Spellbook) != 0)
                {
                    names.Add("mage");
                }

                if ((flags & ShopFlags.Bread) != 0)
                {
                    names.Add("baker");
                }

                if ((flags & ShopFlags.Jewel) != 0)
                {
                    names.Add("jeweler");
                }

                if ((flags & ShopFlags.Potion) != 0)
                {
                    names.Add("herbalist");
                    names.Add("alchemist");
                    names.Add("mage");
                }

                if ((flags & ShopFlags.Reagent) != 0)
                {
                    names.Add("mage");
                    names.Add("herbalist");
                }

                if ((flags & ShopFlags.Clothes) != 0)
                {
                    names.Add("tailor");
                    names.Add("weaver");
                }

                for (int j = 0; j < names.Count; ++j)
                {
                    Point2D cp   = Point2D.Zero;
                    int     dist = 100000;

                    for (int k = 0; k < si.m_Floor.Count; ++k)
                    {
                        Point2D fp = si.m_Floor[k];

                        int rx = fp.X - xAvg;
                        int ry = fp.Y - yAvg;
                        int fd = (int)Math.Sqrt(rx * rx + ry * ry);

                        if (fd > 0 && fd < 5)
                        {
                            fd -= Utility.Random(10);
                        }

                        if (fd < dist && GetFloorZ(map, fp.X, fp.Y, out _))
                        {
                            dist = fd;
                            cp   = fp;
                        }
                    }

                    if (cp == Point2D.Zero)
                    {
                        continue;
                    }

                    if (!GetFloorZ(map, cp.X, cp.Y, out int z))
                    {
                        continue;
                    }

                    new Spawner(1, 1, 1, 0, 4, names[j]).MoveToWorld(new Point3D(cp.X, cp.Y, z), map);
                }
            }

            World.Broadcast(0x35, true, "Generation complete. {0} spawners generated.", m_ShopList.Count);
        }