Once you’ve loaded a save file, you can modify various aspects including Pokémon, items, trainer information, Pokédex entries, and game progress. PKHeX.Core provides safe APIs for all modifications.
Always work on a backup copy of save files. Validate checksums after modifications.
// Gen 6+ propertiesif (sav is SAV6 sav6){ sav6.Region = 1; // Region code sav6.Country = 49; // Country code sav6.GameSyncID = "1234567890123456";}// Gen 7+ propertiesif (sav is SAV7 sav7){ sav7.TrainerTID7 = 123456; // New TID format}// Gen 8+ propertiesif (sav is SAV8SWSH swsh){ swsh.MyStatus.OT = "TRAINER"; swsh.MyStatus.Money = 999999;}
var inventory = sav.Inventory;// Get all items of a specific pouchvar medicines = inventory.Medicine.Items;foreach (var item in medicines){ if (item.Count > 0) { Console.WriteLine($"{item.Index}: {item.Count}x"); }}
// Mark Pokémon as seen/caughtif (sav is SAV8SWSH swsh){ var dex = swsh.Zukan; // Set species as seen dex.SetSeen((ushort)Species.Pikachu, true); // Set species as caught dex.SetCaught((ushort)Species.Pikachu, true); // Set specific form as caught dex.SetCaught((ushort)Species.Pikachu, 0, true);}if (sav is SAV9SV sv){ var dex = sv.Zukan; // Complete Pokédex for (ushort species = 1; species <= sv.MaxSpeciesID; species++) { if (sv.Personal.IsSpeciesInGame(species)) { dex.SetCaught(species, true); dex.SetSeen(species, true); } }}
public void CompleteDex(SaveFile sav){ if (sav is SAV8SWSH swsh) { var dex = swsh.Zukan; for (ushort i = 1; i <= swsh.MaxSpeciesID; i++) { if (swsh.Personal.IsSpeciesInGame(i)) { dex.SetCaught(i, true); } } Console.WriteLine("Pokédex completed!"); }}
if (sav is IBoxDetailName boxNames){ // Set box names for (int i = 0; i < sav.BoxCount; i++) { boxNames.SetBoxName(i, $"Box {i + 1}"); }}if (sav is IBoxDetailWallpaper wallpapers){ // Set box wallpapers for (int i = 0; i < sav.BoxCount; i++) { wallpapers.SetBoxWallpaper(i, i % 16); // Cycle through wallpapers }}
if (sav is IEventFlagProvider flagProvider){ // Set a specific event flag flagProvider.SetEventFlag(1234, true); // Check if flag is set bool isSet = flagProvider.GetEventFlag(1234); Console.WriteLine($"Flag 1234: {isSet}");}// Gen-specific flagsif (sav is SAV8SWSH swsh){ // Set bike unlocked flag (example) swsh.SetEventFlag(0x1234, true);}
if (sav is IEventWorkProvider<ushort> workProvider){ // Set work value (variables used by game events) workProvider.SetWork(100, 999); // Get work value ushort value = workProvider.GetWork(100); Console.WriteLine($"Work 100: {value}");}
if (sav is SAV4 sav4){ // Set all badges for (int i = 0; i < 8; i++) { sav4.SetFlag(sav4.GetWorkBlock(), i, true); }}if (sav is SAV6 sav6){ sav6.Badges = 0xFF; // All 8 badges}
if (sav is SAV8SWSH swsh){ var records = swsh.Records; // Set battle records records.SetRecord(0, 999); // Example record Console.WriteLine("Records modified!");}
if (sav is SAV9SV sv){ var fashion = sv.PlayerFashion; var appearance = sv.PlayerAppearance; // Unlock all fashion items // (specific implementation depends on block structure) Console.WriteLine("Fashion unlocked!");}
using PKHeX.Core;var pk = sav.GetPartySlot(0);// Validate the Pokémonvar la = new LegalityAnalysis(pk);if (la.Valid){ Console.WriteLine("Pokémon is legal!");}else{ Console.WriteLine("Pokémon has legality issues:"); foreach (var line in la.Report) { Console.WriteLine($" - {line}"); }}
Always work on copies: Never modify the original save file directly
Validate data: Check bounds and legal values before setting
Update checksums: Call RefreshChecksum() on modified Pokémon
Mark as edited: The State.Edited flag tracks changes
Test modifications: Load the modified save in-game to verify
public SaveFile SafeModification(string path){ // Load save var sav = SaveUtil.GetSaveFile(path); if (sav == null) return null; // Clone for safety var modified = sav.Clone(); // Make modifications modified.OT = "TEST"; // Validate if (modified.ChecksumsValid) { return modified; } return null;}