示例#1
0
文件: EditorSWSH.cs 项目: exgile/pkNX
        private void PopWildEdit(string file)
        {
            IFileContainer fp         = ROM.GetFile(GameFile.NestData);
            var            data_table = new GFPack(fp[0]);
            var            sdo        = data_table.GetDataFileName($"encount_symbol_{file}.bin");
            var            hdo        = data_table.GetDataFileName($"encount_{file}.bin");
            var            s          = FlatBufferConverter.DeserializeFrom <EncounterArchive8>(sdo);
            var            h          = FlatBufferConverter.DeserializeFrom <EncounterArchive8>(hdo);

            while (s.EncounterTables[0].SubTables.Length != 9)
            {
                s = FlatBufferConverter.DeserializeFrom <EncounterArchive8>(sdo);
                h = FlatBufferConverter.DeserializeFrom <EncounterArchive8>(hdo);
            }

            using var form = new SSWE(ROM, s, h);
            form.ShowDialog();
            if (!form.Modified)
            {
                return;
            }

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

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

            fp[0] = data_table.Write();
        }
示例#2
0
文件: EditorSWSH.cs 项目: exgile/pkNX
        public void EditRaidRewards()
        {
            IFileContainer fp         = ROM.GetFile(GameFile.NestData);
            var            data_table = new GFPack(fp[0]);
            const string   nest       = "nest_hole_drop_rewards.bin";

            byte[] originalData = data_table.GetDataFileName(nest);
            var    nest_drops   = FlatBufferConverter.DeserializeFrom <NestHoleReward8Archive>(originalData);

            var arr   = nest_drops.Tables;
            var cache = new DataCache <NestHoleReward8Table>(arr);
            var names = arr.Select((z, i) => $"{z.TableID}").ToArray();

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

            var data = FlatBufferConverter.SerializeFrom(nest_drops);

            data_table.SetDataFileName(nest, data);
            fp[0] = data_table.Write();
        }
示例#3
0
        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();
        }
示例#4
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();
        }
示例#5
0
        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 = ROM.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, ROM.Data.PersonalData);
                var frand = new FormRandomizer(ROM.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, ROM.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();
        }
示例#6
0
        public void EditPlacement()
        {
            var arc        = ROM.GetFile(GameFile.Placement);
            var placement  = new GFPack(arc[0]);
            var area_names = new AHTB(placement.GetDataFileName("AreaNameHashTable.tbl")).ToDictionary();

            List <PlacementArea8Archive> areas = new();
            List <string> names = new();

            foreach (var area in area_names)
            {
                var areaName = area.Value;
                var fileName = $"{areaName}.bin";
                if (placement.GetIndexFileName(fileName) < 0)
                {
                    continue;
                }

                var bin  = placement.GetDataFileName(fileName);
                var data = FlatBufferConverter.DeserializeFrom <PlacementArea8Archive>(bin);

                names.Add(fileName);
                areas.Add(data);
            }

            var arr     = areas.ToArray();
            var nameArr = names.ToArray();
            var cache   = new DataCache <PlacementArea8Archive>(arr);
            var form    = new GenericEditor <PlacementArea8Archive>(cache, nameArr, "Placement", canSave: true);

            form.ShowDialog();
            if (!form.Modified)
            {
                return;
            }

            // Stuff files back into the gfpak and save
            for (int i = 0; i < arr.Length; i++)
            {
                var obj = arr[i];
                var bin = FlatBufferConverter.SerializeFrom(obj);
                placement.SetDataFileName(nameArr[i], bin);
            }
            arc[0] = placement.Write();
        }
示例#7
0
文件: EditorSWSH.cs 项目: exgile/pkNX
        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();
        }
示例#8
0
        public void EditGift()
        {
            var arc  = ROM.GetFile(GameFile.EncounterGift);
            var data = arc[0];
            var objs = FlatBufferConverter.DeserializeFrom <EncounterGift8Archive>(data);

            var gifts = objs.Table;
            var names = Enumerable.Range(0, gifts.Length).Select(z => $"{z:000}").ToArray();
            var cache = new DirectCache <EncounterGift8>(gifts);

            void Randomize()
            {
                int[] PossibleHeldItems = Legal.GetRandomItemList(ROM.Game);
                var   pt = ROM.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, ROM.Data.PersonalData);
                var frand = new FormRandomizer(ROM.Data.PersonalData);

                srand.Initialize(spec, ban);
                foreach (var t in gifts)
                {
                    // swap gmax gifts and kubfu for other gmax capable species
                    if (t.CanGigantamax || t.Species == (int)Species.Kubfu)
                    {
                        t.Species = Legal.GigantamaxForms[Randomization.Util.Random.Next(Legal.GigantamaxForms.Length)];
                        t.Form    = (byte)(t.Species == (int)Species.Pikachu || t.Species == (int)Species.Meowth ? 0 : frand.GetRandomForme(t.Species, false, false, false, false, ROM.Data.PersonalData.Table)); // Pikachu & Meowth altforms can't gmax
                    }
                    else
                    {
                        t.Species = srand.GetRandomSpecies(t.Species);
                        t.Form    = (byte)frand.GetRandomForme(t.Species, false, false, true, true, ROM.Data.PersonalData.Table);
                    }

                    t.Ability   = Randomization.Util.Random.Next(1, 4); // 1, 2, or H
                    t.Ball      = (Ball)Randomization.Util.Random.Next(1, EncounterGift8.BallToItem.Length);
                    t.HeldItem  = PossibleHeldItems[Randomization.Util.Random.Next(PossibleHeldItems.Length)];
                    t.Nature    = (int)Nature.Random25;
                    t.Gender    = (byte)FixedGender.Random;
                    t.ShinyLock = (int)Shiny.Random;
                    if (t.IV_HP != -4 && t.IVs.Any(z => z != 31))
                    {
                        t.IVs = new[] { -1, -1, -1, -1, -1, -1 }
                    }
                    ;
                }

                UpdateStarters(); // update placement critter data to match new randomized species
            }

            void UpdateStarters()
            {
                var container = ROM.GetFile(GameFile.Placement);
                var placement = new GFPack(container[0]);

                // a_r0501_i0101.bin for Toxel
                // a_bt0101.bin for Type: Null
                // a_wr0201_i0101.bin for Bulbasaur, Squirtle, Porygon, and Kubfu
                // a_wr0301_i0401.bin for Cosmog
                // a_d0901.bin for Poipole
                const string file     = "a_0101.bin";
                var          table    = placement.GetDataFileName(file);
                var          obj      = FlatBufferConverter.DeserializeFrom <PlacementArea8Archive>(table);
                var          critters = obj.Table[0].Critters;

                // Grookey
                critters[3].Species = (uint)gifts[0].Species;
                critters[3].Form    = gifts[0].Form;

                // Scorbunny
                critters[1].Species = (uint)gifts[3].Species;
                critters[1].Form    = gifts[3].Form;

                // Sobble
                critters[2].Species = (uint)gifts[4].Species;
                critters[2].Form    = gifts[4].Form;

                var bin = FlatBufferConverter.SerializeFrom(obj);

                placement.SetDataFileName(file, bin);
                container[0] = placement.Write();
            }

            using var form = new GenericEditor <EncounterGift8>(cache, names, "Gift Pokémon Editor", Randomize);
            form.ShowDialog();
            if (!form.Modified)
            {
                arc.CancelEdits();
            }
            else
            {
                arc[0] = FlatBufferConverter.SerializeFrom(objs);
            }
        }