コード例 #1
0
ファイル: EditorSWSH.cs プロジェクト: PMArkive/pkNX
        public void EditRBonusRewards()
        {
            IFileContainer fp         = ROM.GetFile(GameFile.NestData);
            var            data_table = new GFPack(fp[0]);
            const string   nest       = "nest_hole_bonus_rewards.bin";
            var            nest_bonus = FlatBufferConverter.DeserializeFrom <NestHoleReward8Archive>(data_table.GetDataFileName(nest));

            var arr   = nest_bonus.Table;
            var cache = new DataCache <NestHoleReward8Table>(arr);
            var names = arr.Select(z => $"{z.TableID}").ToArray();

            void Randomize()
            {
                int[] PossibleHeldItems = Legal.GetRandomItemList(ROM.Info.Game);
                foreach (var t in arr)
                {
                    foreach (var i in t.Entries)
                    {
                        i.ItemID = (uint)PossibleHeldItems[Randomization.Util.Random.Next(PossibleHeldItems.Length)];
                    }
                }
            }

            using var form = new GenericEditor <NestHoleReward8Table>(cache, names, "Raid Bonus Rewards Editor", Randomize);
            form.ShowDialog();
            if (!form.Modified)
            {
                return;
            }
            var data = FlatBufferConverter.SerializeFrom(nest_bonus);

            data_table.SetDataFileName(nest, data);
            fp[0] = data_table.Write();
        }
コード例 #2
0
        private void PopWildEdit(string file)
        {
            IFileContainer fp         = ROM.GetFile(GameFile.NestData);
            var            data_table = new GFPack(fp[0]);
            var            s          = FlatBufferConverter.DeserializeFrom <EncounterArchive8>(data_table.GetDataFileName($"encount_symbol_{file}.bin"));
            var            h          = FlatBufferConverter.DeserializeFrom <EncounterArchive8>(data_table.GetDataFileName($"encount_{file}.bin"));

            using var form = new SSWE(ROM, s, h);
            form.ShowDialog();

            var sd = FlatBufferConverter.SerializeFrom(s);
            var hd = FlatBufferConverter.SerializeFrom(s);

            data_table.SetDataFileName($"encount_symbol_{file}.bin", sd);
            data_table.SetDataFileName($"encount_{file}.bin", hd);

            fp[0] = data_table.Write();
        }
コード例 #3
0
ファイル: EditorSWSH.cs プロジェクト: PMArkive/pkNX
        public void EditRaids()
        {
            IFileContainer fp            = ROM.GetFile(GameFile.NestData);
            var            data_table    = new GFPack(fp[0]);
            const string   nest          = "nest_hole_encount.bin";
            var            nest_encounts = FlatBufferConverter.DeserializeFrom <EncounterNest8Archive>(data_table.GetDataFileName(nest));

            var arr   = nest_encounts.Table;
            var cache = new DataCache <EncounterNest8Table>(arr);
            var games = new[] { "Sword", "Shield" };
            var names = arr.Select((z, i) => $"{games[z.GameVersion - 1]} - {i / 2}").ToArray();

            void Randomize()
            {
                var pt = Data.PersonalData;

                int[] ban = pt.Table.Take(ROM.Info.MaxSpeciesID + 1)
                            .Select((z, i) => new { Species = i, Present = ((PersonalInfoSWSH)z).IsPresentInGame })
                            .Where(z => !z.Present).Select(z => z.Species).ToArray();

                var spec  = EditUtil.Settings.Species;
                var srand = new SpeciesRandomizer(ROM.Info, Data.PersonalData);
                var frand = new FormRandomizer(Data.PersonalData);

                srand.Initialize(spec, ban);
                foreach (var t in arr)
                {
                    foreach (var p in t.Entries)
                    {
                        p.Species      = srand.GetRandomSpecies(p.Species);
                        p.Form         = frand.GetRandomForme(p.Species, false, false, true, true, Data.PersonalData.Table);
                        p.Ability      = 4;     // "A4" -- 1, 2, or H
                        p.Gender       = 0;     // random
                        p.IsGigantamax = false; // don't allow gmax flag on non-gmax species
                    }
                }
            }

            using var form = new GenericEditor <EncounterNest8Table>(cache, names, "Max Raid Battles Editor", Randomize);
            form.ShowDialog();
            if (!form.Modified)
            {
                return;
            }
            var data = FlatBufferConverter.SerializeFrom(nest_encounts);

            data_table.SetDataFileName(nest, data);
            fp[0] = data_table.Write();
        }
コード例 #4
0
        public void EditRaid()
        {
            IFileContainer fp            = ROM.GetFile(GameFile.NestData);
            var            data_table    = new GFPack(fp[0]);
            const string   nest          = "nest_hole_encount.bin";
            var            nest_encounts = FlatBufferConverter.DeserializeFrom <EncounterNest8Archive>(data_table.GetDataFileName(nest));

            var arr   = nest_encounts.Tables;
            var cache = new DataCache <EncounterNest8Table>(arr);
            var games = new[] { "Sword", "Shield" };
            var names = arr.Select((z, i) => $"{games[z.GameVersion - 1]} - {i / 2}").ToArray();

            using var form = new GenericEditor <EncounterNest8Table>(cache, names, "Raid Encounters");
            form.ShowDialog();
            if (!form.Modified)
            {
                return;
            }

            var data = FlatBufferConverter.SerializeFrom(nest_encounts);

            data_table.SetDataFileName(nest, data);
            fp[0] = data_table.Write();
        }