public SAV_BoxLayout(int box) { InitializeComponent(); Util.TranslateInterface(this, Main.curlanguage); sav = new SAV6((byte[])Main.SAV.Data.Clone()); editing = true; // Repopulate Wallpaper names CB_BG.Items.Clear(); foreach (string wallpaper in Main.wallpapernames) CB_BG.Items.Add(wallpaper); // Go MT_BG1.Text = sav.Data[sav.PCFlags + 0].ToString(); CB_Unlocked.SelectedIndex = sav.Data[sav.PCFlags + 1] - 1; MT_BG2.Text = sav.Data[sav.PCFlags + 2].ToString(); LB_BoxSelect.SelectedIndex = box; }
/// <summary>Creates an instance of a SaveFile using the given save data.</summary> /// <param name="data">Save data from which to create a SaveFile.</param> /// <returns>An appropriate type of save file for the given data, or null if the save data is invalid.</returns> public static SaveFile getVariantSAV(byte[] data) { // Pre-check for header/footer signatures SaveFile sav; byte[] header = new byte[0], footer = new byte[0]; CheckHeaderFooter(ref data, ref header, ref footer); switch (getSAVGeneration(data)) { // Main Games case GameVersion.Gen1: sav = new SAV1(data); break; case GameVersion.Gen2: sav = new SAV2(data); break; case GameVersion.Gen3: sav = new SAV3(data); break; case GameVersion.Gen4: sav = new SAV4(data); break; case GameVersion.Gen5: sav = new SAV5(data); break; case GameVersion.Gen6: sav = new SAV6(data); break; case GameVersion.Gen7: sav = new SAV7(data); break; // Side Games case GameVersion.COLO: sav = new SAV3Colosseum(data); break; case GameVersion.XD: sav = new SAV3XD(data); break; case GameVersion.RSBOX: sav = new SAV3RSBox(data); break; case GameVersion.BATREV: sav = new SAV4BR(data); break; // No pattern matched default: return(null); } sav.Header = header; sav.Footer = footer; return(sav); }
private void openMAIN(byte[] input, string path, bool ram = false) { if (!ram) ramsav = null; L_Save.Text = "SAV: " + Path.GetFileName(path); SAV = new SAV6(input); // Load CyberGadget B_ExportSAV.Enabled = true; openSave(SAV.ORAS); }
public PK5 convertToPK5(SAV6 SAV) { if (!IsPokémon) return null; DateTime dt = DateTime.Now; if (Day == 0) { Day = (byte)dt.Day; Month = (byte)dt.Month; Year = (byte)dt.Year; } int currentLevel = Level > 0 ? Level : (int)(Util.rnd32() % 100 + 1); PK5 pk = new PK5 { Species = Species, HeldItem = HeldItem, Met_Level = currentLevel, Nature = Nature != 0xFF ? Nature : (int)(Util.rnd32() % 25), Gender = PKX.Personal[Species].Gender == 255 ? 2 : (Gender != 2 ? Gender : PKX.Personal[Species].RandomGender), AltForm = Form, Version = OriginGame == 0 ? new[] {20, 21, 22, 23}[Util.rnd32() & 0x3] : OriginGame, Language = Language == 0 ? SAV.Language : Language, Ball = Pokéball, Move1 = Move1, Move2 = Move2, Move3 = Move3, Move4 = Move4, Move1_PP = PKX.getBasePP(Move1), Move2_PP = PKX.getBasePP(Move2), Move3_PP = PKX.getBasePP(Move3), Move4_PP = PKX.getBasePP(Move4), Met_Location = MetLocation, Met_Day = Day, Met_Month = Month, Met_Year = Year - 2000, Egg_Location = EggLocation, CNT_Cool = CNT_Cool, CNT_Beauty = CNT_Beauty, CNT_Cute = CNT_Cute, CNT_Smart = CNT_Smart, CNT_Tough = CNT_Tough, CNT_Sheen = CNT_Sheen, EXP = PKX.getEXP(Level, Species), // Ribbons RIB7_4 = RIB0_0, // Country Ribbon RIB7_5 = RIB0_1, // National Ribbon RIB7_6 = RIB0_2, // Earth Ribbon RIB7_7 = RIB0_3, // World Ribbon RIB3_2 = RIB0_4, // Classic Ribbon RIB3_3 = RIB0_5, // Premier Ribbon RIB2_3 = RIB0_6, // Event Ribbon RIB2_6 = RIB0_7, // Birthday Ribbon RIB2_7 = RIB1_0, // Special Ribbon RIB3_0 = RIB1_1, // Souvenir Ribbon RIB3_1 = RIB1_2, // Wishing Ribbon RIB7_1 = RIB1_3, // Battle Champ Ribbon RIB7_2 = RIB1_4, // Regional Champ Ribbon RIB7_3 = RIB1_5, // National Champ Ribbon RIB2_5 = RIB1_6, // World Champ Ribbon Friendship = PKX.getBaseFriendship(Species), FatefulEncounter = true, }; if (OTGender == 3) // User's { pk.TID = 12345; pk.SID = 54321; pk.OT_Name = "PKHeX"; pk.OT_Gender = 1; // Red PKHeX OT } else { pk.TID = TID; pk.SID = SID; pk.OT_Name = OT.Length > 0 ? OT : "PKHeX"; pk.OT_Gender = OTGender % 2; // %2 just in case? } pk.IsNicknamed = IsNicknamed; pk.Nickname = IsNicknamed ? Nickname : PKX.getSpeciesName(Species, pk.Language); // More 'complex' logic to determine final values // Dumb way to generate random IVs. int[] finalIVs = new int[6]; for (int i = 0; i < IVs.Length; i++) finalIVs[i] = IVs[i] == 0xFF ? (int)(Util.rnd32() & 0x1F) : IVs[i]; pk.IVs = finalIVs; int av = 0; switch (AbilityType) { case 00: // 0 - 0 case 01: // 1 - 1 case 02: // 2 - H av = AbilityType; break; case 03: // 0/1 case 04: // 0/1/H av = (int)(Util.rnd32() % (AbilityType - 1)); break; } pk.HiddenAbility = av == 2; pk.Ability = PKX.Personal[PKX.Personal[Species].FormeIndex(Species, pk.AltForm)].Abilities[av]; if (PID != 0) pk.PID = PID; else { pk.PID = Util.rnd32(); // Force Ability if (av == 0) pk.PID &= 0xFFFEFFFF; else pk.PID |= 0x10000; // Force Gender do { pk.PID = (pk.PID & 0xFFFFFF00) | Util.rnd32() & 0xFF; } while (!pk.getGenderIsValid()); if (PIDType == 2) // Force Shiny { uint gb = pk.PID & 0xFF; pk.PID = (uint)(((gb ^ pk.TID ^ pk.SID) & 0xFFFE) << 16) | gb; if (av == 0) pk.PID &= 0xFFFEFFFE; else pk.PID |= 0x10001; } else if (PIDType != 1) // Force Not Shiny { if (((pk.PID >> 16) ^ (pk.PID & 0xffff) ^ pk.SID ^ pk.TID) < 8) pk.PID ^= 0x80000000; } } if (IsEgg) { // pk.IsEgg = true; pk.Egg_Day = Day; pk.Egg_Month = Month; pk.Egg_Year = Year - 2000; // Force hatch pk.IsEgg = false; pk.Met_Location = 4; // Nuvema Town } pk.RefreshChecksum(); return pk; }
public PK6 convertToPK6(SAV6 SAV) { if (!IsPokémon) return null; int currentLevel = Level > 0 ? Level : (int)(Util.rnd32()%100 + 1); PK6 pk = new PK6 { Species = Species, HeldItem = HeldItem, TID = TID, SID = SID, Met_Level = currentLevel, Nature = Nature != 0xFF ? Nature : (int)(Util.rnd32() % 25), Gender = PKX.Personal[Species].Gender == 255 ? 2 : (Gender != 3 ? Gender : PKX.Personal[Species].RandomGender), AltForm = Form, EncryptionConstant = EncryptionConstant == 0 ? Util.rnd32() : EncryptionConstant, Version = OriginGame == 0 ? SAV.Game : OriginGame, Language = Language == 0 ? SAV.Language : Language, Ball = Pokéball, Country = SAV.Country, Region = SAV.SubRegion, ConsoleRegion = SAV.ConsoleRegion, Move1 = Move1, Move2 = Move2, Move3 = Move3, Move4 = Move4, Move1_PP = PKX.getBasePP(Move1), Move2_PP = PKX.getBasePP(Move2), Move3_PP = PKX.getBasePP(Move3), Move4_PP = PKX.getBasePP(Move4), RelearnMove1 = RelearnMove1, RelearnMove2 = RelearnMove2, RelearnMove3 = RelearnMove3, RelearnMove4 = RelearnMove4, Met_Location = MetLocation, Egg_Location = EggLocation, CNT_Cool = CNT_Cool, CNT_Beauty = CNT_Beauty, CNT_Cute = CNT_Cute, CNT_Smart = CNT_Smart, CNT_Tough = CNT_Tough, CNT_Sheen = CNT_Sheen, OT_Name = OT.Length > 0 ? OT : SAV.OT, OT_Gender = OTGender != 3 ? OTGender % 2 : SAV.Gender, HT_Name = OT.Length > 0 ? SAV.OT : "", HT_Gender = OT.Length > 0 ? SAV.Gender : 0, CurrentHandler = OT.Length > 0 ? 1 : 0, EXP = PKX.getEXP(Level, Species), // Ribbons RIB2_6 = RIB0_3, // Country Ribbon RIB2_7 = RIB0_4, // National Ribbon RIB3_0 = RIB0_5, // Earth Ribbon RIB3_1 = RIB0_6, // World Ribbon RIB3_2 = RIB1_5, // Classic Ribbon RIB3_3 = RIB1_6, // Premier Ribbon RIB3_4 = RIB0_7, // Event Ribbon RIB3_5 = RIB1_1, // Birthday Ribbon RIB3_6 = RIB1_2, // Special Ribbon RIB3_7 = RIB1_3, // Souvenir Ribbon RIB4_0 = RIB1_4, // Wishing Ribbon RIB4_1 = RIB0_0, // Battle Champ Ribbon RIB4_2 = RIB0_1, // Regional Champ Ribbon RIB4_3 = RIB0_2, // National Champ Ribbon RIB4_4 = RIB1_0, // World Champ Ribbon OT_Friendship = PKX.getBaseFriendship(Species), FatefulEncounter = true, }; if (Day + Month + Year == 0) // No datetime set, typical for wc6full { DateTime dt = DateTime.Now; pk.Met_Day = dt.Day; pk.Met_Month = dt.Month; pk.Met_Year = dt.Year - 2000; } else { pk.Met_Day = (int)Day; pk.Met_Month = (int)Month; pk.Met_Year = (int)(Year - 2000); } if (pk.CurrentHandler == 0) // OT { pk.OT_Memory = 3; pk.OT_TextVar = 9; pk.OT_Intensity = 1; pk.OT_Feeling = Util.rand.Next(0, 9); } else { pk.HT_Memory = 3; pk.HT_TextVar = 9; pk.HT_Intensity = 1; pk.HT_Feeling = Util.rand.Next(0, 9); pk.HT_Friendship = pk.OT_Friendship; } pk.IsNicknamed = IsNicknamed; pk.Nickname = IsNicknamed ? Nickname : PKX.getSpeciesName(Species, pk.Language); // More 'complex' logic to determine final values // Dumb way to generate random IVs. int[] finalIVs = new int[6]; switch (IVs[0]) { case 0xFE: finalIVs[0] = 31; do { // 31 HP IV, 2 other 31s for (int i = 1; i < 6; i++) finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i]; } while (finalIVs.Count(r => r == 31) < 3); // 31 + 2*31 break; case 0xFD: do { // 2 other 31s for (int i = 0; i < 6; i++) finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i]; } while (finalIVs.Count(r => r == 31) < 2); // 2*31 break; default: // Random IVs for (int i = 0; i < 6; i++) finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i]; break; } pk.IVs = finalIVs; int av = 0; switch (AbilityType) { case 00: // 0 - 0 case 01: // 1 - 1 case 02: // 2 - H av = AbilityType; break; case 03: // 0/1 case 04: // 0/1/H av = (int)(Util.rnd32()%(AbilityType - 1)); break; } pk.Ability = PKX.Personal[PKX.Personal[Species].FormeIndex(Species, pk.AltForm)].Abilities[av]; pk.AbilityNumber = 1 << av; switch (PIDType) { case 00: // Specified pk.PID = PID; break; case 01: // Random pk.PID = Util.rnd32(); break; case 02: // Random Shiny pk.PID = Util.rnd32(); pk.PID = (uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)); break; case 03: // Random Nonshiny do { pk.PID = Util.rnd32(); } while ((uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)) < 16); break; } if (IsEgg) { pk.IsEgg = true; pk.Egg_Day = (int) Day; pk.Egg_Month = (int) Month; pk.Egg_Year = (int) Year; } pk.RefreshChecksum(); return pk; }
public PK6 convertToPK6(SAV6 SAV) { if (!IsPokémon) { return(null); } int currentLevel = Level > 0 ? Level : (int)(Util.rnd32() % 100 + 1); PK6 pk = new PK6 { Species = Species, HeldItem = HeldItem, TID = TID, SID = SID, Met_Level = currentLevel, Nature = Nature != 0xFF ? Nature : (int)(Util.rnd32() % 25), Gender = PKX.Personal[Species].Gender == 255 ? 2 : (Gender != 3 ? Gender : PKX.Personal[Species].RandomGender), AltForm = Form, EncryptionConstant = EncryptionConstant == 0 ? Util.rnd32() : EncryptionConstant, Version = OriginGame == 0 ? SAV.Game : OriginGame, Language = Language == 0 ? SAV.Language : Language, Ball = Pokéball, Country = SAV.Country, Region = SAV.SubRegion, ConsoleRegion = SAV.ConsoleRegion, Move1 = Move1, Move2 = Move2, Move3 = Move3, Move4 = Move4, Move1_PP = PKX.getBasePP(Move1), Move2_PP = PKX.getBasePP(Move2), Move3_PP = PKX.getBasePP(Move3), Move4_PP = PKX.getBasePP(Move4), RelearnMove1 = RelearnMove1, RelearnMove2 = RelearnMove2, RelearnMove3 = RelearnMove3, RelearnMove4 = RelearnMove4, Met_Location = MetLocation, Met_Day = (int)Day, Met_Month = (int)Month, Met_Year = (int)Year - 2000, Egg_Location = EggLocation, CNT_Cool = CNT_Cool, CNT_Beauty = CNT_Beauty, CNT_Cute = CNT_Cute, CNT_Smart = CNT_Smart, CNT_Tough = CNT_Tough, CNT_Sheen = CNT_Sheen, OT_Name = OT.Length > 0 ? OT : SAV.OT, OT_Gender = OTGender != 3 ? OTGender % 2 : SAV.Gender, HT_Name = OT.Length > 0 ? SAV.OT : "", HT_Gender = OT.Length > 0 ? SAV.Gender : 0, CurrentHandler = OT.Length > 0 ? 1 : 0, EXP = PKX.getEXP(Level, Species), // Ribbons RIB2_6 = RIB0_3, // Country Ribbon RIB2_7 = RIB0_4, // National Ribbon RIB3_0 = RIB0_5, // Earth Ribbon RIB3_1 = RIB0_6, // World Ribbon RIB3_2 = RIB1_5, // Classic Ribbon RIB3_3 = RIB1_6, // Premier Ribbon RIB3_4 = RIB0_7, // Event Ribbon RIB3_5 = RIB1_1, // Birthday Ribbon RIB3_6 = RIB1_2, // Special Ribbon RIB3_7 = RIB1_3, // Souvenir Ribbon RIB4_0 = RIB1_4, // Wishing Ribbon RIB4_1 = RIB0_0, // Battle Champ Ribbon RIB4_2 = RIB0_1, // Regional Champ Ribbon RIB4_3 = RIB0_2, // National Champ Ribbon RIB4_4 = RIB1_0, // World Champ Ribbon OT_Friendship = PKX.getBaseFriendship(Species), FatefulEncounter = true, }; if (pk.CurrentHandler == 0) // OT { pk.OT_Memory = 3; pk.OT_TextVar = 9; pk.OT_Intensity = 1; pk.OT_Feeling = Util.rand.Next(0, 9); } else { pk.HT_Memory = 3; pk.HT_TextVar = 9; pk.HT_Intensity = 1; pk.HT_Feeling = Util.rand.Next(0, 9); pk.HT_Friendship = pk.OT_Friendship; } pk.IsNicknamed = IsNicknamed; pk.Nickname = IsNicknamed ? Nickname : PKX.getSpeciesName(Species, pk.Language); // More 'complex' logic to determine final values // Dumb way to generate random IVs. int[] finalIVs = new int[6]; switch (IVs[0]) { case 0xFE: finalIVs[0] = 31; do // 31 HP IV, 2 other 31s { for (int i = 1; i < 6; i++) { finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i]; } } while (finalIVs.Count(r => r == 31) < 3); // 31 + 2*31 break; case 0xFD: do // 2 other 31s { for (int i = 0; i < 6; i++) { finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i]; } } while (finalIVs.Count(r => r == 31) < 2); // 2*31 break; default: // Random IVs for (int i = 0; i < 6; i++) { finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i]; } break; } pk.IVs = finalIVs; int av = 0; switch (AbilityType) { case 00: // 0 - 0 case 01: // 1 - 1 case 02: // 2 - H av = AbilityType; break; case 03: // 0/1 case 04: // 0/1/H av = (int)(Util.rnd32() % (AbilityType - 1)); break; } pk.Ability = PKX.Personal[PKX.Personal[Species].FormeIndex(Species, pk.AltForm)].Abilities[av]; pk.AbilityNumber = 1 << av; switch (PIDType) { case 00: // Specified pk.PID = PID; break; case 01: // Random pk.PID = Util.rnd32(); break; case 02: // Random Shiny pk.PID = Util.rnd32(); pk.PID = (uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)); break; case 03: // Random Nonshiny do { pk.PID = Util.rnd32(); } while ((uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)) < 16); break; } if (IsEgg) { pk.IsEgg = true; pk.Egg_Day = (int)Day; pk.Egg_Month = (int)Month; pk.Egg_Year = (int)Year; } pk.RefreshChecksum(); return(pk); }
private void openMAIN(byte[] input, string path) { SAV = new SAV6(input) { FilePath = Path.GetDirectoryName(path), FileName = Path.GetExtension(path) == ".bak" ? Path.GetFileName(path).Split(new[] { " [" }, StringSplitOptions.None)[0] : Path.GetFileName(path) }; L_Save.Text = "SAV: " + Path.GetFileNameWithoutExtension(Util.CleanFileName(SAV.BAKName)); // more descriptive // Enable Secondary Tools GB_SAVtools.Enabled = B_JPEG.Enabled = true; Menu_ExportSAV.Enabled = B_VerifyCHK.Enabled = SAV.Exportable; setBoxNames(); // Display the Box Names setPKXBoxes(); // Reload all of the PKX Windows // Version Exclusive Editors GB_SUBE.Visible = !SAV.ORAS; if (SAV.Box > -1) { int startBox = SAV.CurrentBox; // FF if BattleBox if (startBox > 30) { tabBoxMulti.SelectedIndex = 1; CB_BoxSelect.SelectedIndex = 0; } else { tabBoxMulti.SelectedIndex = 0; CB_BoxSelect.SelectedIndex = startBox; } } TB_GameSync.Enabled = SAV.GameSyncID != 0; TB_GameSync.Text = SAV.GameSyncID.ToString("X16"); TB_Secure1.Text = SAV.Secure1.ToString("X16"); TB_Secure2.Text = SAV.Secure2.ToString("X16"); PB_Locked.Visible = SAV.BattleBoxLocked; // Hide content if not present in game. PAN_Box.Visible = CB_BoxSelect.Visible = B_BoxLeft.Visible = B_BoxRight.Visible = SAV.Box > -1; Menu_LoadBoxes.Enabled = Menu_DumpBoxes.Enabled = Menu_Report.Enabled = Menu_Modify.Enabled = B_SaveBoxBin.Enabled = SAV.Box > -1; PAN_BattleBox.Visible = L_BattleBox.Visible = L_ReadOnlyPBB.Visible = SAV.BattleBox > -1; GB_Daycare.Visible = SAV.Daycare > -1; GB_Fused.Visible = SAV.Fused > -1; GB_GTS.Visible = SAV.GTS > -1; B_OpenSecretBase.Enabled = SAV.SecretBase > -1; B_OpenPokepuffs.Enabled = SAV.Puff > -1; B_OUTPasserby.Enabled = SAV.PSS > -1; B_OpenBoxLayout.Enabled = SAV.BoxWallpapers > -1; B_OpenWondercards.Enabled = SAV.WondercardFlags > -1; B_OpenSuperTraining.Enabled = SAV.SuperTrain > -1; B_OpenHallofFame.Enabled = SAV.HoF > -1; B_OpenOPowers.Enabled = SAV.OPower > -1; B_OpenPokedex.Enabled = SAV.PokeDex > -1; B_OpenBerryField.Enabled = SAV.BerryField > -1; B_JPEG.Enabled = SAV.JPEG > -1; // Refresh PK#->PK6 conversion info Converter.updateConfig(SAV.SubRegion, SAV.Country, SAV.ConsoleRegion, SAV.OT, SAV.Gender); // Indicate audibly the save is loaded SystemSounds.Beep.Play(); // If backup folder exists, save a backup. string backupName = Path.Combine(BackupPath, Util.CleanFileName(SAV.BAKName)); if (SAV.Exportable && Directory.Exists(BackupPath) && !File.Exists(backupName)) File.WriteAllBytes(backupName, SAV.BAK); }
private void openMAIN(byte[] input, string path) { L_Save.Text = "SAV: " + Path.GetFileName(path); SAV = new SAV6(input); // Enable Secondary Tools GB_SAVtools.Enabled = B_JPEG.Enabled = true; Menu_ExportSAV.Enabled = B_VerifyCHK.Enabled = SAV.Exportable; DaycareSlot = 0; setBoxNames(); // Display the Box Names setPKXBoxes(); // Reload all of the PKX Windows // Version Exclusive Editors GB_SUBE.Visible = !SAV.ORAS; B_OpenSecretBase.Visible = SAV.ORAS; if (SAV.Box > -1) { int startBox = SAV.CurrentBox; // FF if BattleBox if (startBox > 30) { tabBoxMulti.SelectedIndex = 1; CB_BoxSelect.SelectedIndex = 0; } else { tabBoxMulti.SelectedIndex = 0; CB_BoxSelect.SelectedIndex = startBox; } } TB_GameSync.Enabled = SAV.GameSyncID != 0; TB_GameSync.Text = SAV.GameSyncID.ToString("X16"); TB_Secure1.Text = SAV.Secure1.ToString("X16"); TB_Secure2.Text = SAV.Secure2.ToString("X16"); PB_Locked.Visible = SAV.BattleBoxLocked; // Hide content if not present in game. PAN_Box.Visible = CB_BoxSelect.Visible = B_BoxLeft.Visible = B_BoxRight.Visible = SAV.Box > -1; Menu_LoadBoxes.Enabled = Menu_Report.Enabled = Menu_Modify.Enabled = B_SaveBoxBin.Enabled = SAV.Box > -1; PAN_BattleBox.Visible = L_BattleBox.Visible = L_ReadOnlyPBB.Visible = SAV.BattleBox > -1; GB_Daycare.Visible = SAV.Daycare > -1; GB_Fused.Visible = SAV.Fused > -1; GB_GTS.Visible = SAV.GTS > -1; B_OpenSecretBase.Enabled = SAV.SecretBase > -1; B_OpenPokepuffs.Enabled = SAV.Puff > -1; B_OUTPasserby.Enabled = SAV.PSS > -1; B_OpenBoxLayout.Enabled = SAV.BoxWallpapers > -1; B_OpenWondercards.Enabled = SAV.WondercardFlags > -1; B_OpenSuperTraining.Enabled = SAV.SuperTrain > -1; B_OpenHallofFame.Enabled = SAV.HoF > -1; B_OpenOPowers.Enabled = SAV.OPower > -1; B_OpenPokedex.Enabled = SAV.PokeDex > -1; B_OpenBerryField.Enabled = SAV.BerryField > -1; B_JPEG.Enabled = SAV.JPEG > -1; // Refresh PK#->PK6 conversion info Converter.updateConfig(SAV.SubRegion, SAV.Country, SAV.ConsoleRegion, SAV.OT, SAV.Gender); // Indicate audibly the save is loaded SystemSounds.Beep.Play(); }
public PK5 convertToPK5(SAV6 SAV) { if (!IsPokémon) { return(null); } DateTime dt = DateTime.Now; if (Day == 0) { Day = (byte)dt.Day; Month = (byte)dt.Month; Year = (byte)dt.Year; } int currentLevel = Level > 0 ? Level : (int)(Util.rnd32() % 100 + 1); PK5 pk = new PK5 { Species = Species, HeldItem = HeldItem, Met_Level = currentLevel, Nature = Nature != 0xFF ? Nature : (int)(Util.rnd32() % 25), Gender = PKX.Personal[Species].Gender == 255 ? 2 : (Gender != 2 ? Gender : PKX.Personal[Species].RandomGender), AltForm = Form, Version = OriginGame == 0 ? new[] { 20, 21, 22, 23 }[Util.rnd32() & 0x3] : OriginGame, Language = Language == 0 ? SAV.Language : Language, Ball = Pokéball, Move1 = Move1, Move2 = Move2, Move3 = Move3, Move4 = Move4, Move1_PP = PKX.getBasePP(Move1), Move2_PP = PKX.getBasePP(Move2), Move3_PP = PKX.getBasePP(Move3), Move4_PP = PKX.getBasePP(Move4), Met_Location = MetLocation, Met_Day = Day, Met_Month = Month, Met_Year = Year - 2000, Egg_Location = EggLocation, CNT_Cool = CNT_Cool, CNT_Beauty = CNT_Beauty, CNT_Cute = CNT_Cute, CNT_Smart = CNT_Smart, CNT_Tough = CNT_Tough, CNT_Sheen = CNT_Sheen, EXP = PKX.getEXP(Level, Species), // Ribbons RIB7_4 = RIB0_0, // Country Ribbon RIB7_5 = RIB0_1, // National Ribbon RIB7_6 = RIB0_2, // Earth Ribbon RIB7_7 = RIB0_3, // World Ribbon RIB3_2 = RIB0_4, // Classic Ribbon RIB3_3 = RIB0_5, // Premier Ribbon RIB2_3 = RIB0_6, // Event Ribbon RIB2_6 = RIB0_7, // Birthday Ribbon RIB2_7 = RIB1_0, // Special Ribbon RIB3_0 = RIB1_1, // Souvenir Ribbon RIB3_1 = RIB1_2, // Wishing Ribbon RIB7_1 = RIB1_3, // Battle Champ Ribbon RIB7_2 = RIB1_4, // Regional Champ Ribbon RIB7_3 = RIB1_5, // National Champ Ribbon RIB2_5 = RIB1_6, // World Champ Ribbon Friendship = PKX.getBaseFriendship(Species), FatefulEncounter = true, }; if (OTGender == 3) // User's { pk.TID = 12345; pk.SID = 54321; pk.OT_Name = "PKHeX"; pk.OT_Gender = 1; // Red PKHeX OT } else { pk.TID = TID; pk.SID = SID; pk.OT_Name = OT.Length > 0 ? OT : "PKHeX"; pk.OT_Gender = OTGender % 2; // %2 just in case? } pk.IsNicknamed = IsNicknamed; pk.Nickname = IsNicknamed ? Nickname : PKX.getSpeciesName(Species, pk.Language); // More 'complex' logic to determine final values // Dumb way to generate random IVs. int[] finalIVs = new int[6]; for (int i = 0; i < IVs.Length; i++) { finalIVs[i] = (IVs[i] == 0xFF) ? (int)(Util.rnd32() & 0x1F) : IVs[i]; } pk.IVs = finalIVs; int av = 0; switch (AbilityType) { case 00: // 0 - 0 case 01: // 1 - 1 case 02: // 2 - H av = AbilityType; break; case 03: // 0/1 case 04: // 0/1/H av = (int)(Util.rnd32() % (AbilityType - 1)); break; } if (av == 2) { pk.HiddenAbility = true; } pk.Ability = PKX.Personal[PKX.Personal[Species].FormeIndex(Species, pk.AltForm)].Abilities[av]; if (PID != 0) { pk.PID = PID; } else { pk.PID = Util.rnd32(); // Force Ability if (av == 0) { pk.PID &= 0xFFFEFFFF; } else { pk.PID |= 0x10000; } // Force Gender do { pk.PID = (pk.PID & 0xFFFFFF00) | Util.rnd32() & 0xFF; } while (!pk.getGenderIsValid()); if (PIDType == 2) // Force Shiny { uint gb = pk.PID & 0xFF; pk.PID = (uint)(((gb ^ pk.TID ^ pk.SID) & 0xFFFE) << 16) | gb; if (av == 0) { pk.PID &= 0xFFFEFFFE; } else { pk.PID |= 0x10001; } } else if (PIDType != 1) // Force Not Shiny { if (((pk.PID >> 16) ^ (pk.PID & 0xffff) ^ pk.SID ^ pk.TID) < 8) { pk.PID ^= 0x80000000; } } } if (IsEgg) { // pk.IsEgg = true; pk.Egg_Day = Day; pk.Egg_Month = Month; pk.Egg_Year = Year - 2000; // Force hatch pk.IsEgg = false; pk.Met_Location = 4; // Nuvema Town } pk.RefreshChecksum(); return(pk); }
public PK4 convertToPK4(SAV6 SAV) { if (!PokémonGift) { return(null); } PK4 pk4 = new PK4(PK.Data); if (!IsPokémon && Detail == 0) { pk4.OT_Name = "PKHeX"; pk4.TID = 12345; pk4.SID = 54321; pk4.OT_Gender = (int)(Util.rnd32() % 2); } if (IsManaphyEgg) { // Since none of this data is populated, fill in default info. pk4.Species = 490; // Level 1 Moves pk4.Move1 = 294; pk4.Move2 = 145; pk4.Move3 = 346; pk4.FatefulEncounter = true; pk4.Ball = 4; pk4.Version = 10; // Diamond pk4.Language = 2; // English pk4.Nickname = "MANAPHY"; pk4.Egg_Location = 1; // Ranger (will be +3000 later) } // Generate IV uint seed = Util.rnd32(); if (pk4.PID == 1) // Create Nonshiny { uint pid1 = PKM.LCRNG(ref seed) >> 16; uint pid2 = PKM.LCRNG(ref seed) >> 16; while ((pid1 ^ pid2 ^ pk4.TID ^ pk4.SID) < 8) { uint testPID = pid1 | pid2 << 16; // Call the ARNG to change the PID testPID = testPID * 0x6c078965 + 1; pid1 = testPID & 0xFFFF; pid2 = testPID >> 16; } pk4.PID = pid1 | (pid2 << 16); } // Generate IVs if (pk4.IV32 == 0) { uint iv1 = PKM.LCRNG(ref seed) >> 16; uint iv2 = PKM.LCRNG(ref seed) >> 16; pk4.IV32 = (iv1 | iv2 << 16) & 0x3FFFFFFF; } // Generate Met Info DateTime dt = DateTime.Now; if (IsPokémon) { pk4.Met_Location = pk4.Egg_Location + 3000; pk4.Egg_Location = 0; pk4.Met_Day = dt.Day; pk4.Met_Month = dt.Month; pk4.Met_Year = dt.Year - 2000; pk4.IsEgg = false; } else { pk4.Egg_Location = pk4.Egg_Location + 3000; pk4.Egg_Day = dt.Day; pk4.Egg_Month = dt.Month; pk4.Egg_Year = dt.Year - 2000; pk4.IsEgg = false; // Met Location is modified when transferred to pk5; don't worry about it. } if (pk4.Species == 201) // Never will be true; Unown was never distributed. { pk4.AltForm = PKM.getUnownForm(pk4.PID); } return(pk4); }
public PK4 convertToPK4(SAV6 SAV) { if (!PokémonGift) return null; PK4 pk4 = new PK4(PK.Data); if (!IsPokémon && Detail == 0) { pk4.OT_Name = "pk4HeX"; pk4.TID = 12345; pk4.SID = 54321; pk4.OT_Gender = (int)(Util.rnd32()%2); } if (IsManaphyEgg) { // Since none of this data is populated, fill in default info. pk4.Species = 490; // Level 1 Moves pk4.Move1 = 294; pk4.Move2 = 145; pk4.Move3 = 346; pk4.FatefulEncounter = true; pk4.Ball = 4; pk4.Version = 10; // Diamond pk4.Language = 2; // English pk4.Nickname = "MANAPHY"; pk4.Egg_Location = 1; // Ranger (will be +3000 later) } // Generate IV uint seed = Util.rnd32(); if (pk4.PID == 1) // Create Nonshiny { uint pid1 = PKM.LCRNG(ref seed) >> 16; uint pid2 = PKM.LCRNG(ref seed) >> 16; while ((pid1 ^ pid2 ^ pk4.TID ^ pk4.SID) < 8) { uint testPID = pid1 | pid2 << 16; // Call the ARNG to change the PID testPID = testPID * 0x6c078965 + 1; pid1 = testPID & 0xFFFF; pid2 = testPID >> 16; } pk4.PID = pid1 | (pid2 << 16); } // Generate IVs if (pk4.IV32 == 0) { uint iv1 = PKM.LCRNG(ref seed) >> 16; uint iv2 = PKM.LCRNG(ref seed) >> 16; pk4.IV32 = (iv1 | iv2 << 16) & 0x3FFFFFFF; } // Generate Met Info DateTime dt = DateTime.Now; if (IsPokémon) { pk4.Met_Location = pk4.Egg_Location + 3000; pk4.Egg_Location = 0; pk4.Met_Day = dt.Day; pk4.Met_Month = dt.Month; pk4.Met_Year = dt.Year - 2000; pk4.IsEgg = false; } else { pk4.Egg_Location = pk4.Egg_Location + 3000; pk4.Egg_Day = dt.Day; pk4.Egg_Month = dt.Month; pk4.Egg_Year = dt.Year - 2000; pk4.IsEgg = false; // Met Location is modified when transferred to pk5; don't worry about it. } if (pk4.Species == 201) // Never will be true; Unown was never distributed. pk4.AltForm = PKM.getUnownForm(pk4.PID); return pk4; }
/// <summary>Creates an instance of a SaveFile using the given save data.</summary> /// <param name="data">Save data from which to create a SaveFile.</param> /// <returns>An appropriate type of save file for the given data, or null if the save data is invalid.</returns> public static SaveFile getVariantSAV(byte[] data) { // Pre-check for header/footer signatures SaveFile sav; byte[] header = new byte[0], footer = new byte[0]; CheckHeaderFooter(ref data, ref header, ref footer); switch (getSAVGeneration(data)) { // Main Games case GameVersion.Gen1: sav = new SAV1(data); break; case GameVersion.Gen2: sav = new SAV2(data); break; case GameVersion.Gen3: sav = new SAV3(data); break; case GameVersion.Gen4: sav = new SAV4(data); break; case GameVersion.Gen5: sav = new SAV5(data); break; case GameVersion.Gen6: sav = new SAV6(data); break; case GameVersion.Gen7: sav = new SAV7(data); break; // Side Games case GameVersion.COLO: sav = new SAV3Colosseum(data); break; case GameVersion.XD: sav = new SAV3XD(data); break; case GameVersion.RSBOX: sav = new SAV3RSBox(data); break; case GameVersion.BATREV: sav = new SAV4BR(data); break; // No pattern matched default: return null; } sav.Header = header; sav.Footer = footer; return sav; }