Exemplo n.º 1
0
        /// <summary>
        /// Gets the encounter areas with <see cref="EncounterSlot"/> information from Generation 1 Fishing data.
        /// </summary>
        /// <param name="data">Input raw data.</param>
        /// <returns>Array of encounter areas.</returns>
        public static EncounterArea[] GetArray1_F(byte[] data)
        {
            var ptr   = new int[255];
            var map   = new int[255];
            int count = 0;

            for (int i = 0; i < ptr.Length; i++)
            {
                map[i] = data[(i * 3) + 0];
                if (map[i] == 0xFF)
                {
                    count = i;
                    break;
                }
                ptr[i] = BitConverter.ToInt16(data, (i * 3) + 1);
            }

            EncounterArea[] areas = new EncounterArea[count];
            for (int i = 0; i < areas.Length; i++)
            {
                areas[i] = new EncounterArea
                {
                    Location = map[i],
                    Slots    = GetSlots1_F(data, ref ptr[i])
                };
            }
            return(areas);
        }
Exemplo n.º 2
0
        private static EncounterArea[] GetGoParkArea()
        {
            var area = new EncounterArea {
                Location = 50
            };

            IEnumerable <EncounterSlot> GetAllSlot(int species)
            {
                yield return(GetSlot(species, 0));

                if (Legal.AlolanOriginForms.Contains(species) || Legal.EvolveToAlolanForms.Contains(species))
                {
                    yield return(GetSlot(species, 1));
                }
            }

            EncounterSlot GetSlot(int species, int form)
            {
                return(new EncounterSlot
                {
                    Area = area,
                    Generation = 7,
                    Species = species,
                    LevelMin = 2,  // todo
                    LevelMax = 40, // todo
                    Form = form,
                    Type = SlotType.GoPark,
                    Version = GameVersion.GO,
                });
            }

            area.Slots = Enumerable.Range(1, 150).Concat(Enumerable.Range(808, 2)).SelectMany(GetAllSlot).ToArray();
            return(new[] { area });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the encounter areas with <see cref="EncounterSlot"/> information from Generation 1 Grass/Water data.
        /// </summary>
        /// <param name="data">Input raw data.</param>
        /// <returns>Array of encounter areas.</returns>
        public static EncounterArea[] GetArray1_GW(byte[] data)
        {
            // RBY Format
            var ptr   = new int[255];
            int count = 0;

            for (int i = 0; i < ptr.Length; i++)
            {
                ptr[i] = BitConverter.ToInt16(data, i * 2);
                if (ptr[i] != -1)
                {
                    continue;
                }

                count = i;
                break;
            }

            EncounterArea[] areas = new EncounterArea[count];
            for (int i = 0; i < areas.Length; i++)
            {
                var grass = GetSlots1_GW(data, ref ptr[i], SlotType.Grass);
                var water = GetSlots1_GW(data, ref ptr[i], SlotType.Surf);
                areas[i] = new EncounterArea
                {
                    Location = i,
                    Slots    = grass.Concat(water).ToArray()
                };
            }
            return(areas.Where(area => area.Slots.Length != 0).ToArray());
        }
Exemplo n.º 4
0
        private static EncounterArea[] GetAreas()
        {
            var red_gw   = EncounterArea.GetArray1_GW(Util.GetBinaryResource("encounter_red.pkl"));
            var blu_gw   = EncounterArea.GetArray1_GW(Util.GetBinaryResource("encounter_blue.pkl"));
            var ylw_gw   = EncounterArea.GetArray1_GW(Util.GetBinaryResource("encounter_yellow.pkl"));
            var rb_fish  = EncounterArea.GetArray1_F(Util.GetBinaryResource("encounter_rb_f.pkl"));
            var ylw_fish = EncounterArea.GetArray1_FY(Util.GetBinaryResource("encounter_yellow_f.pkl"));

            MarkEncountersVersion(red_gw, GameVersion.RD);
            MarkEncountersVersion(blu_gw, GameVersion.BU);
            MarkEncountersVersion(ylw_gw, GameVersion.YW);
            MarkEncountersVersion(rb_fish, GameVersion.RB);
            MarkEncountersVersion(ylw_fish, GameVersion.YW);

            var table = AddExtraTableSlots(red_gw, blu_gw, ylw_gw, rb_fish, ylw_fish);

            Array.Resize(ref table, table.Length + 1);
            table[table.Length - 1] = FishOldGood_RBY;

            foreach (var arr in table)
            {
                foreach (var slot in arr.Slots)
                {
                    slot.Area = arr;
                }
            }
            return(table);
        }
Exemplo n.º 5
0
 private static IEnumerable <EncounterSlot> GetValidEncounterSlots(PKM pkm, EncounterArea loc, IReadOnlyList <DexLevel> vs, int lvl)
 {
     if (pkm.Egg_Location != 0)
     {
         return(Enumerable.Empty <EncounterSlot>());
     }
     return(loc.GetMatchingSlots(pkm, vs, lvl));
 }
Exemplo n.º 6
0
        private static EncounterSuggestionData GetSuggestedEncounterWild(PKM pkm, EncounterArea area, int loc = -1)
        {
            var slots = area.Slots.OrderBy(s => s.LevelMin);
            var first = slots.First();
            var met   = loc != -1 ? loc : area.Location;

            return(new EncounterSuggestionData(pkm, first, met));
        }
Exemplo n.º 7
0
 /// <summary>
 /// Gets an array of areas from an array of raw area data
 /// </summary>
 /// <param name="entries">Simplified raw format of an Area</param>
 /// <returns>Array of areas</returns>
 public static EncounterArea[] GetArray(byte[][] entries)
 {
     EncounterArea[] data = new EncounterArea[entries.Length];
     for (int i = 0; i < data.Length; i++)
     {
         data[i] = new EncounterArea(entries[i]);
     }
     return(data);
 }
Exemplo n.º 8
0
 public EncounterArea[] Clone(int[] locations)
 {
     EncounterArea[] Areas = new EncounterArea[locations.Length];
     for (int i = 0; i < locations.Length; i++)
     {
         Areas[i] = Clone(locations[i]);
     }
     return(Areas);
 }
Exemplo n.º 9
0
        public static EncounterArea[] getArray(byte[][] entries)
        {
            if (entries == null)
                return null;

            EncounterArea[] data = new EncounterArea[entries.Length];
            for (int i = 0; i < data.Length; i++)
                data[i] = new EncounterArea(entries[i]);
            return data;
        }
Exemplo n.º 10
0
        protected EncounterSlotGO(EncounterArea area, int start, int end, Shiny shiny, PogoType type) : base(area)
        {
            LevelMin = type.GetMinLevel();
            LevelMax = EncountersGO.MAX_LEVEL;

            Start = start;
            End   = end;

            Shiny = shiny;
            Type  = type;
        }
Exemplo n.º 11
0
        private static EncounterStatic GetSuggestedEncounterWild(EncounterArea area, int loc = -1)
        {
            var slots = area.Slots.OrderBy(s => s.LevelMin);
            var first = slots.First();

            return(new EncounterStatic
            {
                Location = loc != -1 ? loc : area.Location,
                Species = first.Species,
                Level = first.LevelMin,
            });
        }
Exemplo n.º 12
0
        public EncounterArea Clone(int location)
        {
            EncounterArea Areas = new EncounterArea
            {
                Location = location,
                Slots    = new EncounterSlot[Slots.Length]
            };

            for (int i = 0; i < Slots.Length; i++)
            {
                Areas.Slots[i] = Slots[i].Clone();
            }
            return(Areas);
        }
Exemplo n.º 13
0
        private static EncounterStatic GetSuggestedEncounterWild(EncounterArea area, int loc)
        {
            var slots     = area.Slots.OrderBy(s => s.LevelMin);
            var first     = slots.First();
            var encounter = new EncounterStatic
            {
                Location = area.Location,
                Species  = first.Species,
                Level    = first.LevelMin,
            };

            if (loc != -1) // forced location
            {
                encounter.Location = loc;
            }
            return(encounter);
        }
Exemplo n.º 14
0
        private static EncounterArea[] GetTables2(GameVersion Version)
        {
            // Fishing
            var f = EncounterArea.GetArray2_F(Util.GetBinaryResource("encounter_gsc_f.pkl"));

            EncounterArea[] Slots = new EncounterArea[0];
            if (Version.Contains(GameVersion.GS))
            {
                Slots = GetSlots_GS(f);
            }
            if (Version.Contains(GameVersion.C))
            {
                Slots = AddExtraTableSlots(Slots, GetSlots_C(f));
            }

            return(Slots);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Gets the encounter areas with <see cref="EncounterSlot"/> information from Pokémon Yellow (Generation 1) Fishing data.
        /// </summary>
        /// <param name="data">Input raw data.</param>
        /// <returns>Array of encounter areas.</returns>
        public static EncounterArea[] GetArray1_FY(byte[] data)
        {
            const int size  = 9;
            int       count = data.Length / size;

            EncounterArea[] areas = new EncounterArea[count];
            for (int i = 0; i < count; i++)
            {
                int ofs = (i * size) + 1;
                areas[i] = new EncounterArea
                {
                    Location = data[(i * size) + 0],
                    Slots    = ReadSlots_FY(data, ref ofs, 4, SlotType.Super_Rod, -1)
                };
            }
            return(areas);
        }
Exemplo n.º 16
0
        private static EncounterArea[] GetSlots_C(EncounterArea[] f)
        {
            // Grass/Water
            var c = EncounterArea.GetArray2_GW(Util.GetBinaryResource("encounter_crystal.pkl"));
            // Headbutt/Rock Smash
            var h_c      = EncounterArea.GetArray2_H(Util.GetBinaryResource("encounter_crystal_h.pkl"));
            var safari_c = EncounterSafari_GSC;
            var bcc_c    = EncounterBCC_GSC;

            MarkEncountersVersion(bcc_c, GameVersion.C);
            MarkEncountersVersion(safari_c, GameVersion.C);
            MarkEncountersVersion(f, GameVersion.C);
            MarkEncountersVersion(c, GameVersion.C);
            MarkEncountersVersion(h_c, GameVersion.C);

            var extra = AddExtraTableSlots(c, h_c, f, bcc_c, safari_c);

            return(extra);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Gets the encounter areas with <see cref="EncounterSlot"/> information from Generation 3 data.
        /// </summary>
        /// <param name="entries">Raw data, one byte array per encounter area</param>
        /// <returns>Array of encounter areas.</returns>
        public static EncounterArea[] GetArray3(byte[][] entries)
        {
            if (entries == null)
            {
                return(null);
            }

            var Areas = new List <EncounterArea>();

            foreach (byte[] t in entries)
            {
                EncounterArea Area = GetArea3(t);
                if (Area.Slots.Length != 0)
                {
                    Areas.Add(Area);
                }
            }
            return(Areas.ToArray());
        }
Exemplo n.º 18
0
        private static IEnumerable <EncounterSlot> GetValidEncounterSlots(PKM pkm, EncounterArea loc, IEnumerable <DexLevel> vs, bool DexNav = false, int lvl = -1, bool ignoreLevel = false)
        {
            if (pkm.Egg_Location != 0)
            {
                return(Enumerable.Empty <EncounterSlot>());
            }
            if (lvl < 0)
            {
                lvl = GetMinLevelEncounter(pkm);
            }
            if (lvl <= 0)
            {
                return(Enumerable.Empty <EncounterSlot>());
            }

            int gen = pkm.GenNumber;

            if (gen < 3)
            {
                return(GetValidEncounterSlots12(pkm, loc, vs, lvl, ignoreLevel));
            }

            const int fluteBoost     = 4;
            const int dexnavBoost    = 30;
            const int comboLureBonus = 1; // +1 if combo/lure?
            int       df             = DexNav ? fluteBoost : IsCatchCombo(pkm) ? comboLureBonus : 0;
            int       dn             = DexNav ? fluteBoost + dexnavBoost : 0;

            // Get Valid levels
            var encounterSlots = GetValidEncounterSlotsByEvoLevel(pkm, loc.Slots, lvl, ignoreLevel, vs, df, dn);

            // Return enumerable of slots pkm might have originated from
            if (gen <= 5)
            {
                return(GetFilteredSlotsByForm(pkm, encounterSlots));
            }
            if (DexNav && gen == 6)
            {
                return(GetFilteredSlots6DexNav(pkm, lvl, encounterSlots, fluteBoost));
            }
            return(GetFilteredSlots67(pkm, encounterSlots));
        }
Exemplo n.º 19
0
        private static EncounterArea[] GetSlots_GS(EncounterArea[] f)
        {
            // Grass/Water
            var g = EncounterArea.GetArray2_GW(Util.GetBinaryResource("encounter_gold.pkl"));
            var s = EncounterArea.GetArray2_GW(Util.GetBinaryResource("encounter_silver.pkl"));
            // Headbutt/Rock Smash
            var h_g       = EncounterArea.GetArray2_H(Util.GetBinaryResource("encounter_gold_h.pkl"));
            var h_s       = EncounterArea.GetArray2_H(Util.GetBinaryResource("encounter_silver_h.pkl"));
            var safari_gs = EncounterSafari_GSC;
            var bcc_gs    = EncounterBCC_GSC;

            MarkEncountersVersion(bcc_gs, GameVersion.GS);
            MarkEncountersVersion(f, GameVersion.GS);
            MarkEncountersVersion(g, GameVersion.GD);
            MarkEncountersVersion(s, GameVersion.SV);
            MarkEncountersVersion(h_g, GameVersion.GD);
            MarkEncountersVersion(h_s, GameVersion.SV);
            MarkEncountersVersion(safari_gs, GameVersion.GS);

            return(AddExtraTableSlots(g, s, h_g, h_s, f, bcc_gs, safari_gs));
        }
Exemplo n.º 20
0
        private static EncounterArea GetArea4HGSS_Headbutt(byte[] data)
        {
            if (data.Length < 78)
            {
                return(new EncounterArea()); // bad data
            }
            //2 byte location ID (defer to end)
            //4 bytes padding
            var Slots = new List <EncounterSlot>();

            // 00-11 Normal trees
            // 12-17 Special trees
            for (int i = 0; i < 18; i++)
            {
                int Species = BitConverter.ToInt16(data, 6 + (i * 4));
                if (Species <= 0)
                {
                    continue;
                }
                Slots.Add(new EncounterSlot
                {
                    Species  = Species,
                    LevelMin = data[8 + (i * 4)],
                    LevelMax = data[9 + (i * 4)],
                    Type     = i <= 11 ? SlotType.Headbutt : SlotType.Headbutt_Special
                });
            }

            var Area = new EncounterArea
            {
                Location = BitConverter.ToUInt16(data, 0),
                Slots    = Slots.ToArray()
            };

            foreach (var slot in Area.Slots)
            {
                slot.Area = Area;
            }
            return(Area);
        }
Exemplo n.º 21
0
        private static EncounterArea GetArea3(byte[] data)
        {
            var HaveGrassSlots     = data[1] == 1;
            var HaveSurfSlots      = data[2] == 1;
            var HaveRockSmashSlots = data[3] == 1;
            var HaveFishingSlots   = data[4] == 1;

            int offset = 5;
            var slots  = new List <EncounterSlot>();

            if (HaveGrassSlots)
            {
                slots.AddRange(GetSlots3(data, ref offset, 12, SlotType.Grass));
            }
            if (HaveSurfSlots)
            {
                slots.AddRange(GetSlots3(data, ref offset, 5, SlotType.Surf));
            }
            if (HaveRockSmashSlots)
            {
                slots.AddRange(GetSlots3(data, ref offset, 5, SlotType.Rock_Smash));
            }
            if (HaveFishingSlots)
            {
                slots.AddRange(GetSlots3_F(data, ref offset, 10));
            }

            EncounterArea Area3 = new EncounterArea
            {
                Location = data[0],
                Slots    = slots.ToArray()
            };

            foreach (var slot in Area3.Slots)
            {
                slot.Area = Area3;
            }

            return(Area3);
        }
Exemplo n.º 22
0
        private static IEnumerable <EncounterArea> GetAreas2(byte[] data, ref int ofs, SlotType t, int slotSets, int slotCount)
        {
            var areas = new List <EncounterArea>();

            while (data[ofs] != 0xFF) // end
            {
                var location = data[ofs++] << 8 | data[ofs++];
                var slots    = GetSlots2_GW(data, ref ofs, t, slotSets, slotCount);
                var area     = new EncounterArea
                {
                    Location = location,
                    Slots    = slots,
                };
                foreach (var slot in slots)
                {
                    slot.Area = area;
                }
                areas.Add(area);
            }
            ofs++;
            return(areas);
        }
Exemplo n.º 23
0
        private static IEnumerable <EncounterSlot> GetValidEncounterSlots12(PKM pkm, EncounterArea loc, IEnumerable <DexLevel> vs, int lvl = -1, bool ignoreLevel = false)
        {
            if (lvl < 0)
            {
                lvl = GetMinLevelEncounter(pkm);
            }
            if (lvl <= 0)
            {
                return(Enumerable.Empty <EncounterSlot>());
            }

            var  Gen1Version = GameVersion.RBY;
            bool RBDragonair = false;

            if (!ignoreLevel && !FilterGBSlotsCatchRate(pkm, ref vs, ref Gen1Version, ref RBDragonair))
            {
                return(Enumerable.Empty <EncounterSlot>());
            }

            var encounterSlots = GetValidEncounterSlotsByEvoLevel(pkm, loc.Slots, lvl, ignoreLevel, vs);

            return(GetFilteredSlots12(pkm, pkm.GenNumber, Gen1Version, encounterSlots, RBDragonair).OrderBy(slot => slot.LevelMin)); // prefer lowest levels
        }
Exemplo n.º 24
0
        private static ILookup <int, EncounterSlot> GetFriendSafariArea()
        {
            var area = new EncounterArea {
                Location = 148
            };

            EncounterSlot FriendSafariSlot(int d)
            {
                return(new EncounterSlot
                {
                    Area = area,
                    Generation = 6,
                    Species = d,
                    LevelMin = 30,
                    LevelMax = 30,
                    Form = 0,
                    Type = SlotType.FriendSafari,
                });
            }

            area.Slots = Legal.FriendSafari.Select(FriendSafariSlot).ToArray();
            return(area.Slots.ToLookup(s => s.Species));
        }
Exemplo n.º 25
0
        private static EncounterArea GetArea3(byte[] data)
        {
            EncounterArea Area3 = new EncounterArea();

            if (data.Length < 6)
            {
                Area3.Location = 0; Area3.Slots = new EncounterSlot[0]; return(Area3);
            }

            Area3.Location = data[0];
            var HaveGrassSlots     = data[1] == 1;
            var HaveSurfSlots      = data[2] == 1;
            var HaveRockSmashSlots = data[3] == 1;
            var HaveFishingSlots   = data[4] == 1;

            int offset = 5;
            var slots  = new List <EncounterSlot>();

            if (HaveGrassSlots)
            {
                slots.AddRange(GetSlots3(data, ref offset, 12, SlotType.Grass));
            }
            if (HaveSurfSlots)
            {
                slots.AddRange(GetSlots3(data, ref offset, 5, SlotType.Surf));
            }
            if (HaveRockSmashSlots)
            {
                slots.AddRange(GetSlots3(data, ref offset, 5, SlotType.Rock_Smash));
            }
            if (HaveFishingSlots)
            {
                slots.AddRange(GetSlots3_F(data, ref offset, 10));
            }
            Area3.Slots = slots.ToArray();
            return(Area3);
        }
Exemplo n.º 26
0
 protected EncounterSlot(EncounterArea area) => Area = area;
Exemplo n.º 27
0
        private static EncounterArea GetArea4HGSS(byte[] data)
        {
            var Slots = new List <EncounterSlot>();

            var GrassRatio     = data[0x02];
            var SurfRatio      = data[0x03];
            var RockSmashRatio = data[0x04];
            var OldRodRatio    = data[0x05];
            var GoodRodRatio   = data[0x06];
            var SuperRodRatio  = data[0x07];

            // 2 bytes padding

            if (GrassRatio > 0)
            {
                // First 36 slots are morning, day and night grass slots
                // The order is 12 level values, 12 morning species, 12 day species and 12 night species
                var GrassSlots = GetSlots4_HGSS_G(data, 0x0A, 12, SlotType.Grass);
                //Grass slots with species = 0 are added too, it is needed for the swarm encounters, it will be deleted after swarms are added

                // Hoenn Sound and Sinnoh Sound replace slots 4 and 5
                var hoenn  = GetSlots4_G_Replace(data, 0x5E, 2, GrassSlots, Legal.Slot4_Sound); // Hoenn
                var sinnoh = GetSlots4_G_Replace(data, 0x62, 2, GrassSlots, Legal.Slot4_Sound); // Sinnoh

                Slots.AddRange(GrassSlots);
                Slots.AddRange(hoenn);
                Slots.AddRange(sinnoh);

                // Static / Magnet Pull
                var grass1 = GrassSlots.Take(12).ToList();
                var grass2 = GrassSlots.Skip(12).Take(12).ToList();
                var grass3 = GrassSlots.Skip(24).ToList();
                // Swarm slots do not displace electric/steel types, with exception of SoulSilver Mawile (which doesn't displace) -- handle separately

                foreach (var time in new[] { grass1, grass2, grass3 })
                {
                    // non radio
                    var regular = time.Where(z => !Legal.Slot4_Sound.Contains(z.SlotNumber)).ToList(); // every other slot is in the product
                    var radio   = new List <List <EncounterSlot> > {
                        time.Where(z => Legal.Slot4_Sound.Contains(z.SlotNumber)).ToList()
                    };
                    if (hoenn.Count > 0)
                    {
                        radio.Add(hoenn);
                    }
                    if (sinnoh.Count > 0)
                    {
                        radio.Add(sinnoh);
                    }

                    var extra = new List <EncounterSlot>();
                    foreach (var t in radio)
                    {
                        MarkStaticMagnetPermute(regular.Concat(t), extra);
                    }
                    Slots.AddRange(extra);
                }
            }

            if (SurfRatio > 0)
            {
                Slots.AddRange(GetSlots4HGSS_WFR(data, 0x66, 5, SlotType.Surf));
            }

            if (RockSmashRatio > 0)
            {
                Slots.AddRange(GetSlots4HGSS_WFR(data, 0x7A, 2, SlotType.Rock_Smash));
            }

            if (OldRodRatio > 0)
            {
                Slots.AddRange(GetSlots4HGSS_WFR(data, 0x82, 5, SlotType.Old_Rod));
            }

            if (GoodRodRatio > 0)
            {
                Slots.AddRange(GetSlots4HGSS_WFR(data, 0x96, 5, SlotType.Good_Rod));
            }

            if (SuperRodRatio > 0)
            {
                Slots.AddRange(GetSlots4HGSS_WFR(data, 0xAA, 5, SlotType.Super_Rod));
            }

            // Last 6 bytes only have species ID info
            if (data[0xC2] == 120) // Location = 182, 127, 130, 132, 167, 188, 210
            {
                Slots.AddRange(SlotsHGSS_Staryu);
            }

            EncounterArea Area4 = new EncounterArea
            {
                Location = BitConverter.ToUInt16(data, 0x00),
                Slots    = Slots.ToArray()
            };

            foreach (var slot in Area4.Slots)
            {
                slot.Area = Area4;
            }
            return(Area4);
        }
Exemplo n.º 28
0
        private static EncounterArea GetArea4HGSS(byte[] data)
        {
            EncounterArea Area4 = new EncounterArea();

            if (data.Length != 0xC6)
            {
                Area4.Location = 0; Area4.Slots = new EncounterSlot[0]; return(Area4);
            }

            var Slots = new List <EncounterSlot>();

            Area4.Location = BitConverter.ToUInt16(data, 0x00);

            var GrassRatio     = data[0x02];
            var SurfRatio      = data[0x03];
            var RockSmashRatio = data[0x04];
            var OldRodRatio    = data[0x05];
            var GoodRodRatio   = data[0x06];
            var SuperRodRatio  = data[0x07];

            // 2 bytes padding

            if (GrassRatio > 0)
            {
                // First 36 slots are morning, day and night grass slots
                // The order is 12 level values, 12 morning species, 12 day species and 12 night species
                var GrassSlots = GetSlots4_HGSS_G(data, 0x0A, 12, SlotType.Grass);
                //Grass slots with species = 0 are added too, it is needed for the swarm encounters, it will be deleted after add swarms
                Slots.AddRange(GrassSlots);

                // Hoenn Sound and Sinnoh Sound replace slots 4 and 5
                Slots.AddRange(GetSlots4_G_Replace(data, 0x5E, 2, GrassSlots, Legal.Slot4_Sound)); // Hoenn
                Slots.AddRange(GetSlots4_G_Replace(data, 0x62, 2, GrassSlots, Legal.Slot4_Sound)); // Sinnoh
            }

            if (SurfRatio > 0)
            {
                Slots.AddRange(GetSlots4HGSS_WFR(data, 0x66, 5, SlotType.Surf));
            }

            if (RockSmashRatio > 0)
            {
                Slots.AddRange(GetSlots4HGSS_WFR(data, 0x7A, 2, SlotType.Rock_Smash));
            }

            if (OldRodRatio > 0)
            {
                Slots.AddRange(GetSlots4HGSS_WFR(data, 0x82, 5, SlotType.Old_Rod));
            }

            if (GoodRodRatio > 0)
            {
                Slots.AddRange(GetSlots4HGSS_WFR(data, 0x96, 5, SlotType.Good_Rod));
            }

            if (SuperRodRatio > 0)
            {
                Slots.AddRange(GetSlots4HGSS_WFR(data, 0xAA, 5, SlotType.Super_Rod));
            }

            // Last 6 bytes only have species ID info
            if (data[0xC2] == 120) // Location = 182, 127, 130, 132, 167, 188, 210
            {
                Slots.AddRange(SlotsHGSS_Staryu);
            }

            Area4.Slots = Slots.ToArray();
            return(Area4);
        }
Exemplo n.º 29
0
        private static EncounterArea GetArea4DPPt(byte[] data, bool pt = false)
        {
            var Slots = new List <EncounterSlot>();

            int location   = BitConverter.ToUInt16(data, 0x00);
            var GrassRatio = BitConverter.ToInt32(data, 0x02);

            if (GrassRatio > 0)
            {
                EncounterSlot[] GrassSlots = GetSlots4_DPPt_G(data, 0x06, 12, SlotType.Grass);
                //Swarming slots replace slots 0 and 1
                var swarm = GetSlots4_G_Replace(data, 0x66, 4, GrassSlots, Legal.Slot4_Swarm, SlotType.Swarm);
                //Morning and Night slots replace slots 2 and 3
                var morning = GetSlots4_G_Replace(data, 0x6E, 4, GrassSlots, Legal.Slot4_Time); // Morning
                var night   = GetSlots4_G_Replace(data, 0x76, 4, GrassSlots, Legal.Slot4_Time); // Night
                //Pokéradar slots replace slots 4,5,10 and 11
                //Pokéradar is marked with different slot type because it have different PID-IV generationn
                var radar = GetSlots4_G_Replace(data, 0x7E, 4, GrassSlots, Legal.Slot4_Radar, SlotType.Pokeradar);

                //24 bytes padding

                //Dual Slots replace slots 8 and 9
                var ruby      = GetSlots4_G_Replace(data, 0xA6, 4, GrassSlots, Legal.Slot4_Dual); // Ruby
                var sapphire  = GetSlots4_G_Replace(data, 0xAE, 4, GrassSlots, Legal.Slot4_Dual); // Sapphire
                var emerald   = GetSlots4_G_Replace(data, 0xB6, 4, GrassSlots, Legal.Slot4_Dual); // Emerald
                var firered   = GetSlots4_G_Replace(data, 0xBE, 4, GrassSlots, Legal.Slot4_Dual); // FireRed
                var leafgreen = GetSlots4_G_Replace(data, 0xC6, 4, GrassSlots, Legal.Slot4_Dual); // LeafGreen

                Slots.AddRange(GrassSlots);
                Slots.AddRange(swarm);
                Slots.AddRange(morning);
                Slots.AddRange(night);
                Slots.AddRange(radar);
                Slots.AddRange(ruby);
                Slots.AddRange(sapphire);
                Slots.AddRange(emerald);
                Slots.AddRange(firered);
                Slots.AddRange(leafgreen);

                // Permute Static-Magnet Pull combinations
                // [None/Swarm]-[None/Morning/Night]-[None/Radar]-[None/R/S/E/F/L] [None/TrophyGarden]
                // 2 * 3 * 2 * 6 = 72 different combinations of slots (more with trophy garden)
                var regular = new List <List <EncounterSlot> > {
                    GrassSlots.Where(z => z.SlotNumber == 6 || z.SlotNumber == 7).ToList()
                };                                                                                                                    // every other slot is in the product
                var pair0 = new List <List <EncounterSlot> > {
                    GrassSlots.Where(z => Legal.Slot4_Swarm.Contains(z.SlotNumber)).ToList()
                };
                var pair1 = new List <List <EncounterSlot> > {
                    GrassSlots.Where(z => Legal.Slot4_Time.Contains(z.SlotNumber)).ToList()
                };
                var pair2 = new List <List <EncounterSlot> > {
                    GrassSlots.Where(z => Legal.Slot4_Radar.Contains(z.SlotNumber)).ToList()
                };
                var pair3 = new List <List <EncounterSlot> > {
                    GrassSlots.Where(z => Legal.Slot4_Dual.Contains(z.SlotNumber)).ToList()
                };
                if (swarm.Count != 0)
                {
                    pair0.Add(swarm);
                }
                if (morning.Count != 0)
                {
                    pair1.Add(morning);
                }
                if (night.Count != 0)
                {
                    pair1.Add(night);
                }
                if (radar.Count != 0)
                {
                    pair2.Add(radar);
                }
                if (ruby.Count != 0)
                {
                    pair3.Add(ruby);
                }
                if (sapphire.Count != 0)
                {
                    pair3.Add(sapphire);
                }
                if (emerald.Count != 0)
                {
                    pair3.Add(emerald);
                }
                if (firered.Count != 0)
                {
                    pair3.Add(firered);
                }
                if (leafgreen.Count != 0)
                {
                    pair3.Add(leafgreen);
                }
                if (location == 68) // Trophy Garden
                {
                    // Occupy Slots 6 & 7
                    var species = pt ? Encounters4.TrophyPt : Encounters4.TrophyDP;
                    var slots   = new List <EncounterSlot>();
                    foreach (var s in species)
                    {
                        var slot = regular[0][0].Clone();
                        slot.Species = s;
                        slots.Add(slot);

                        slot         = regular[0][1].Clone();
                        slot.Species = s;
                        slots.Add(slot);
                    }
                    Slots.AddRange(slots);
                    // get all permutations of trophy inhabitants
                    var trophy = regular[0].Concat(slots).ToArray();
                    for (int i = 0; i < trophy.Length; i++)
                    {
                        for (int j = i + 1; j < trophy.Length; j++)
                        {
                            regular.Add(new List <EncounterSlot> {
                                trophy[i], trophy[j]
                            });
                        }
                    }
                }

                var set     = new[] { regular, pair0, pair1, pair2, pair3 };
                var product = set.CartesianProduct();
                var extra   = MarkStaticMagnetExtras(product);
                Slots.AddRange(extra);
            }

            var SurfRatio = BitConverter.ToInt32(data, 0xCE);

            if (SurfRatio > 0)
            {
                Slots.AddRange(GetSlots4DPPt_WFR(data, 0xD2, 5, SlotType.Surf));
            }

            //44 bytes padding

            var OldRodRatio = BitConverter.ToInt32(data, 0x126);

            if (OldRodRatio > 0)
            {
                Slots.AddRange(GetSlots4DPPt_WFR(data, 0x12A, 5, SlotType.Old_Rod));
            }

            var GoodRodRatio = BitConverter.ToInt32(data, 0x152);

            if (GoodRodRatio > 0)
            {
                Slots.AddRange(GetSlots4DPPt_WFR(data, 0x156, 5, SlotType.Good_Rod));
            }

            var SuperRodRatio = BitConverter.ToInt32(data, 0x17E);

            if (SuperRodRatio > 0)
            {
                Slots.AddRange(GetSlots4DPPt_WFR(data, 0x182, 5, SlotType.Super_Rod));
            }

            EncounterArea Area4 = new EncounterArea
            {
                Location = location,
                Slots    = Slots.ToArray()
            };

            foreach (var slot in Area4.Slots)
            {
                slot.Area = Area4;
            }

            return(Area4);
        }
Exemplo n.º 30
0
 /// <summary>
 /// Direct fetch for <see cref="EncounterArea"/> data; can also be used to fetch supplementary encounter streams.
 /// </summary>
 /// <param name="ident">Unpacking identification ASCII characters (first two bytes of binary)</param>
 /// <param name="resource">Resource name (will be prefixed with "encounter_"</param>
 /// <returns>Array of encounter areas</returns>
 internal static EncounterArea[] GetEncounterTables(string ident, string resource)
 {
     byte[] mini = Util.GetBinaryResource($"encounter_{resource}.pkl");
     return(EncounterArea.GetArray(Data.UnpackMini(mini, ident)));
 }
Exemplo n.º 31
0
        private static EncounterArea GetArea4DPPt(byte[] data)
        {
            EncounterArea Area4 = new EncounterArea();

            if (data.Length != 0x1AA) // 426 Bytes
            {
                Area4.Location = 0; Area4.Slots = new EncounterSlot[0]; return(Area4);
            }

            var Slots = new List <EncounterSlot>();

            Area4.Location = BitConverter.ToUInt16(data, 0x00);

            var GrassRatio = BitConverter.ToInt32(data, 0x02);

            if (GrassRatio > 0)
            {
                EncounterSlot[] GrassSlots = GetSlots4_DPPt_G(data, 0x06, 12, SlotType.Grass);
                Slots.AddRange(GrassSlots);
                //Swarming slots replace slots 0 and 1
                Slots.AddRange(GetSlots4_G_Replace(data, 0x66, 4, GrassSlots, Legal.Slot4_Swarm, SlotType.Swarm));
                //Morning and Night slots replace slots 2 and 3
                Slots.AddRange(GetSlots4_G_Replace(data, 0x6E, 4, GrassSlots, Legal.Slot4_Time)); // Morning
                Slots.AddRange(GetSlots4_G_Replace(data, 0x76, 4, GrassSlots, Legal.Slot4_Time)); // Night
                //Pokéradar slots replace slots 4,5,10 and 11
                //Pokéradar is marked with different slot type because it have different PID-IV generationn
                Slots.AddRange(GetSlots4_G_Replace(data, 0x7E, 4, GrassSlots, Legal.Slot4_Radar, SlotType.Pokeradar));
                //24 bytes padding
                //Dual Slots replace slots 8 and 9
                Slots.AddRange(GetSlots4_G_Replace(data, 0xA6, 4, GrassSlots, Legal.Slot4_Dual)); // Ruby
                Slots.AddRange(GetSlots4_G_Replace(data, 0xAE, 4, GrassSlots, Legal.Slot4_Dual)); // Sapphire
                Slots.AddRange(GetSlots4_G_Replace(data, 0xB6, 4, GrassSlots, Legal.Slot4_Dual)); // Emerald
                Slots.AddRange(GetSlots4_G_Replace(data, 0xBE, 4, GrassSlots, Legal.Slot4_Dual)); // FireRed
                Slots.AddRange(GetSlots4_G_Replace(data, 0xC6, 4, GrassSlots, Legal.Slot4_Dual)); // LeafGreen
            }

            var SurfRatio = BitConverter.ToInt32(data, 0xCE);

            if (SurfRatio > 0)
            {
                Slots.AddRange(GetSlots4DPPt_WFR(data, 0xD2, 5, SlotType.Surf));
            }

            //44 bytes padding

            var OldRodRatio = BitConverter.ToInt32(data, 0x126);

            if (OldRodRatio > 0)
            {
                Slots.AddRange(GetSlots4DPPt_WFR(data, 0x12A, 5, SlotType.Old_Rod));
            }

            var GoodRodRatio = BitConverter.ToInt32(data, 0x152);

            if (GoodRodRatio > 0)
            {
                Slots.AddRange(GetSlots4DPPt_WFR(data, 0x156, 5, SlotType.Good_Rod));
            }

            var SuperRodRatio = BitConverter.ToInt32(data, 0x17E);

            if (SuperRodRatio > 0)
            {
                Slots.AddRange(GetSlots4DPPt_WFR(data, 0x182, 5, SlotType.Super_Rod));
            }

            Area4.Slots = Slots.ToArray();
            return(Area4);
        }