public void Handle(ReplaceStarterCommand command)
        {
            // Load files
            const string    nsoPath = "exefs/main";
            IMainExecutable nso     = MainExecutable.LoadFromNso(rom.ReadAllBytes(nsoPath));

            const string natureDiagnosisPath = "romfs/Data/StreamingAssets/data/nature_diagnosis/diagnosis.json";
            var          natureDiagnosis     = JsonConvert.DeserializeObject <NDConverterSharedData.DataStore>(rom.ReadAllText(natureDiagnosisPath));

            const string  fixedPokemonPath = "romfs/Data/StreamingAssets/native_data/dungeon/fixed_pokemon.bin";
            IFixedPokemon fixedPokemon     = new FixedPokemon(rom.ReadAllBytes(fixedPokemonPath));

            // Process
            var map = nso.StarterFixedPokemonMaps.First(m => m.PokemonId == command.OldPokemonId);

            map.PokemonId = command.NewPokemonId;

            var fixedPokemonEntry = fixedPokemon.Entries[(int)map.FixedPokemonId];

            fixedPokemonEntry.PokemonId = command.NewPokemonId;
            if (command.Move1 != default)
            {
                fixedPokemonEntry.Move1 = command.Move1;
            }
            if (command.Move2 != default)
            {
                fixedPokemonEntry.Move2 = command.Move2;
            }
            if (command.Move3 != default)
            {
                fixedPokemonEntry.Move3 = command.Move3;
            }
            if (command.Move4 != default)
            {
                fixedPokemonEntry.Move4 = command.Move4;
            }

            var ndEntry = natureDiagnosis.m_pokemonNatureAndTypeList.First(p => p.m_nameLabel == command.OldPokemonId);

            ndEntry.m_nameLabel = command.NewPokemonId;

            var symbolCandiate = PegasusActDatabase.ActorDataList
                                 .Where(a => a.raw_pokemonIndex == command.NewPokemonId &&
                                        a.bIsFemale == false) // bIsFemale is out of scope since this is just a proof-of-concept
                                 .OrderByDescending(a => (int)a.raw_formType)
                                 .FirstOrDefault();

            if (symbolCandiate != null)
            {
                ndEntry.m_symbolName       = symbolCandiate.symbolName !;
                ndEntry.m_symbolNameFemale = "";
            }

            // Save files
            rom.WriteAllBytes(nsoPath, nso.ToNso());
            rom.WriteAllText(natureDiagnosisPath, JsonConvert.SerializeObject(natureDiagnosis));
            rom.WriteAllBytes(fixedPokemonPath, fixedPokemon.Build().Data.ReadArray());
        }
 public StarterQueries(ICommonStrings commonStrings,
                       IMainExecutable mainExecutable,
                       NDConverterSharedData.DataStore natureDiagnosis,
                       IFixedPokemon fixedPokemon)
 {
     this.commonStrings   = commonStrings ?? throw new ArgumentNullException(nameof(commonStrings));
     this.mainExecutable  = mainExecutable ?? throw new ArgumentNullException(nameof(mainExecutable));
     this.natureDiagnosis = natureDiagnosis ?? throw new ArgumentNullException(nameof(natureDiagnosis));
     this.fixedPokemon    = fixedPokemon ?? throw new ArgumentNullException(nameof(fixedPokemon));
 }
示例#3
0
        public PegasusActDatabase(IMainExecutable executable)
        {
            this.executable = executable;

#if !NETSTANDARD2_0
            firstCreatureIdOffset = executable.SectionOffsets[".text"]
                                    + executable.GetIlConstructorOffset("PegasusActDatabase", new string[] {})
                                    + RelativeFirstCreatureIdOffset;

            Read();
#endif
        }
示例#4
0
        static void Main(string[] args)
        {
            //ChangeStarters();
            //return;

            var basePath        = @"D:\01003D200BAA2000";
            var natureDiagnosis = JsonConvert.DeserializeObject <NDConverterSharedData.DataStore>(File.ReadAllText(basePath + @"\romfs\Data\StreamingAssets\data\nature_diagnosis\diagnosis.json"));
            //var actorDataInfoPath = basePath + @"\romfs\Data\StreamingAssets\native_data\pokemon\pokemon_actor_data_info.bin";
            //var actorDataInfo = new PokemonActorDataInfo(File.ReadAllBytes(actorDataInfoPath));

            var graphicsDatabasePath = basePath + @"\romfs\Data\StreamingAssets\native_data\pokemon_graphics_database.bin";
            var graphicsDatabase     = new PokemonGraphicsDatabase(File.ReadAllBytes(graphicsDatabasePath));

            var             nsoPath = basePath + @"\exefs\main";
            IMainExecutable nso     = MainExecutable.LoadFromNso(File.ReadAllBytes(nsoPath));

            var           fixedPokemonPath = basePath + @"\romfs\Data\StreamingAssets\native_data\dungeon\fixed_pokemon.bin";
            IFixedPokemon fixedPokemon     = new FixedPokemon(File.ReadAllBytes(fixedPokemonPath));

            var messageBinPath = basePath + @"\romfs\Data\StreamingAssets\native_data\message_us.bin";
            var messageBin     = new Farc(File.ReadAllBytes(messageBinPath));
            var common         = new MessageBinEntry(messageBin.GetFile("common.bin"));

            ICommonStrings  commonStrings  = new CommonStrings(common);
            IStarterQueries starterQueries = new StarterQueries(commonStrings, nso, natureDiagnosis, fixedPokemon);

            Console.WriteLine("Starters:");
            var starters = starterQueries.GetStarters();

            foreach (var starter in starters)
            {
                Console.WriteLine(starter.PokemonName);
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadLine();
        }
示例#5
0
 public CodeGenerationHelper(IMainExecutable executable, string codeSectionName = ".text")
 {
     Executable    = executable;
     sectionOffset = executable.SectionOffsets[codeSectionName];
     Data          = executable.Data;
 }