Beispiel #1
0
        public static void GetCurrentEventTable(SaveBlockAccessor8SWSH blocks, RaidTables rt)
        {
            var archive = blocks.GetBlock(NORMAL_ENCOUNTER).Data;

            if (archive.Length < 0x20 || archive.Length != 4 + BitConverter.ToInt32(archive, 0x10) || BitConverter.ToInt32(archive, 0x8) != 0x20)
            {
                return; // no event loaded
            }
            var encount_data = new byte[archive.Length - 0x24];

            Array.Copy(archive, 0x20, encount_data, 0, encount_data.Length);

            var dist_encounts = DeserializeFrom <NestHoleDistributionEncounter8Archive>(encount_data);
            var sword_table   = dist_encounts.Tables.Where(z => z.GameVersion == 1).ToList();
            var shield_table  = dist_encounts.Tables.Where(z => z.GameVersion == 2).ToList();
            var swordTable    = new RaidTemplateTable(1721953670860364124, 1, new RaidTemplate[sword_table[0].Entries.Length]);
            var shieldTable   = new RaidTemplateTable(1721953670860364124, 2, new RaidTemplate[sword_table[0].Entries.Length]);

            for (int i = 0; i < sword_table[0].Entries.Length; i++)
            {
                var entry1 = sword_table[0].Entries[i];
                swordTable.Entries[i] = new RaidTemplate(entry1.Species, entry1.Probabilities, entry1.FlawlessIVs, entry1.MinRank, entry1.MaxRank, entry1.AltForm, entry1.Ability, entry1.Gender, entry1.IsGigantamax, entry1.ShinyForced);
                entry1 = shield_table[0].Entries[i];
                shieldTable.Entries[i] = new RaidTemplate(entry1.Species, entry1.Probabilities, entry1.FlawlessIVs, entry1.MinRank, entry1.MaxRank, entry1.AltForm, entry1.Ability, entry1.Gender, entry1.IsGigantamax, entry1.ShinyForced);
            }
            if (sword_table[0].Entries.Length > 0)
            {
                rt.SwordNestsEvent[0]  = swordTable;
                rt.ShieldNestsEvent[0] = shieldTable;
            }
        }
Beispiel #2
0
 private SAV8SWSH(IReadOnlyList <SCBlock> blocks) : base(Array.Empty <byte>())
 {
     AllBlocks    = blocks;
     Blocks       = new SaveBlockAccessor8SWSH(this);
     SaveRevision = Zukan.GetRevision();
     Initialize();
 }
 public RaidList(SaveBlockAccessor8SWSH blocks, GameVersion game, int badges, int tid, int sid)
 {
     InitializeComponent();
     IVs    = new[] { TB_HP_IV1, TB_ATK_IV1, TB_DEF_IV1, TB_SPA_IV1, TB_SPD_IV1, TB_SPE_IV1 };
     _raids = new RaidManager(blocks, game, badges, (uint)tid, (uint)sid);
     CB_Den.SelectedIndex = 0;
     CenterToParent();
 }
Beispiel #4
0
 public SAV8SWSH()
 {
     AllBlocks    = Meta8.GetBlankDataSWSH();
     Blocks       = new SaveBlockAccessor8SWSH(this);
     SaveRevision = Zukan.GetRevision();
     Initialize();
     ClearBoxes();
 }
        public RaidManager(SaveBlockAccessor8SWSH blocks, GameVersion game, int badges, uint tid, uint sid)
        {
            EventTableConverter.GetCurrentEventTable(blocks, _raidTables);
            DenList = InitializeDenList(blocks.Raid, blocks.RaidArmor);

            Game       = game;
            BadgeCount = Util.NumberOfSetBits(badges);
            if (BadgeCount == 0)
            {
                BadgeCount = 9; // enable all dens for basically no SaveFile loaded
            }
            TID = tid;
            SID = sid;
        }
        public static void GetCurrentEventTable(SaveBlockAccessor8SWSH blocks, RaidTables rt)
        {
            var archive = blocks.GetBlock(NORMAL_ENCOUNTER).Data;

            if (archive.Length < 0x20 || archive.Length != 4 + BitConverter.ToInt32(archive, 0x10) || BitConverter.ToInt32(archive, 0x8) != 0x20)
            {
                return; // no event loaded
            }
            var encount_data = new byte[archive.Length - 0x24];

            Array.Copy(archive, 0x20, encount_data, 0, encount_data.Length);


            var fbb           = new FlatBuffers.FlatBufferBuilder(new FlatBuffers.ByteBuffer(encount_data));
            var dist_encounts = PKHeX_Raid_Plugin.NestHoleDistributionEncounter8Archive.GetRootAsNestHoleDistributionEncounter8Archive(fbb.DataBuffer);

            var sword_table  = dist_encounts.Tables(0).Value;
            var shield_table = dist_encounts.Tables(1).Value;

            if (sword_table.GameVersion != 1)
            {
                sword_table  = dist_encounts.Tables(1).Value;
                shield_table = dist_encounts.Tables(0).Value;
            }

            var swordTable  = new RaidTemplateTable(1721953670860364124, 1, new RaidTemplate[sword_table.EntriesLength]);
            var shieldTable = new RaidTemplateTable(1721953670860364124, 2, new RaidTemplate[sword_table.EntriesLength]);

            for (int i = 0; i < sword_table.EntriesLength; i++)
            {
                var entry1 = sword_table.Entries(i).Value;

                swordTable.Entries[i] = new RaidTemplate(entry1.Species, entry1.GetProbabilitiesArray(), entry1.FlawlessIVs, entry1.AltForm, entry1.Ability, entry1.Gender, entry1.Nature, entry1.IsGigantamax, entry1.ShinyForced);
                entry1 = shield_table.Entries(i).Value;
                shieldTable.Entries[i] = new RaidTemplate(entry1.Species, entry1.GetProbabilitiesArray(), entry1.FlawlessIVs, entry1.AltForm, entry1.Ability, entry1.Gender, entry1.Nature, entry1.IsGigantamax, entry1.ShinyForced);
            }
            if (sword_table.EntriesLength > 0)
            {
                rt.SwordNestsEvent[0]  = swordTable;
                rt.ShieldNestsEvent[0] = shieldTable;
            }
        }