// Meta public void setPK6(PK6 pk6) { // Apply to this Save File int CT = pk6.CurrentHandler; DateTime Date = DateTime.Now; pk6.Trade(OT, TID, SID, Country, SubRegion, Gender, false, Date.Day, Date.Month, Date.Year); if (CT != pk6.CurrentHandler) // Logic updated Friendship { // Copy over the Friendship Value only under certain circumstances if (pk6.Moves.Contains(216)) // Return { pk6.CurrentFriendship = pk6.OppositeFriendship; } else if (pk6.Moves.Contains(218)) // Frustration { pk6.CurrentFriendship = pk6.OppositeFriendship; } else if (pk6.CurrentHandler == 1) // OT->HT, needs new Friendship/Affection { pk6.TradeFriendshipAffection(OT); } } pk6.RefreshChecksum(); }
private PKM preparePK6() { PK6 pk6 = pkm as PK6; if (pk6 == null) { return(null); } // Repopulate PK6 with Edited Stuff if (Util.getIndex(CB_GameOrigin) < 24) { uint EC = Util.getHEXval(TB_EC.Text); uint PID = Util.getHEXval(TB_PID.Text); uint SID = Util.ToUInt32(TB_TID.Text); uint TID = Util.ToUInt32(TB_TID.Text); uint LID = PID & 0xFFFF; uint HID = PID >> 16; uint XOR = TID ^ LID ^ SID ^ HID; // Ensure we don't have a shiny. if (XOR >> 3 == 1) // Illegal, fix. (not 16<XOR>=8) { // Keep as shiny, so we have to mod the PID PID ^= XOR; TB_PID.Text = PID.ToString("X8"); TB_EC.Text = PID.ToString("X8"); } else if ((XOR ^ 0x8000) >> 3 == 1 && PID != EC) { TB_EC.Text = (PID ^ 0x80000000).ToString("X8"); } else // Not Illegal, no fix. { TB_EC.Text = PID.ToString("X8"); } } pk6.EncryptionConstant = Util.getHEXval(TB_EC.Text); pk6.Checksum = 0; // 0 CHK for now // Block A pk6.Species = Util.getIndex(CB_Species); pk6.HeldItem = Util.getIndex(CB_HeldItem); pk6.TID = Util.ToInt32(TB_TID.Text); pk6.SID = Util.ToInt32(TB_SID.Text); pk6.EXP = Util.ToUInt32(TB_EXP.Text); pk6.Ability = (byte)Array.IndexOf(abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4)); pk6.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text); // Number // pkx[0x16], pkx[0x17] are handled by the Medals UI (Hits & Training Bag) pk6.PID = Util.getHEXval(TB_PID.Text); pk6.Nature = (byte)Util.getIndex(CB_Nature); pk6.FatefulEncounter = CHK_Fateful.Checked; pk6.Gender = PKX.getGender(Label_Gender.Text); pk6.AltForm = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.Enabled ? CB_Form.SelectedIndex : 0) & 0x1F; pk6.EV_HP = Util.ToInt32(TB_HPEV.Text); // EVs pk6.EV_ATK = Util.ToInt32(TB_ATKEV.Text); pk6.EV_DEF = Util.ToInt32(TB_DEFEV.Text); pk6.EV_SPE = Util.ToInt32(TB_SPEEV.Text); pk6.EV_SPA = Util.ToInt32(TB_SPAEV.Text); pk6.EV_SPD = Util.ToInt32(TB_SPDEV.Text); pk6.CNT_Cool = Util.ToInt32(TB_Cool.Text); // CNT pk6.CNT_Beauty = Util.ToInt32(TB_Beauty.Text); pk6.CNT_Cute = Util.ToInt32(TB_Cute.Text); pk6.CNT_Smart = Util.ToInt32(TB_Smart.Text); pk6.CNT_Tough = Util.ToInt32(TB_Tough.Text); pk6.CNT_Sheen = Util.ToInt32(TB_Sheen.Text); pk6.PKRS_Days = CB_PKRSDays.SelectedIndex; pk6.PKRS_Strain = CB_PKRSStrain.SelectedIndex; // Already in buff (then transferred to new pkx) // 0x2C, 0x2D, 0x2E, 0x2F // 0x30, 0x31, 0x32, 0x33 // 0x34, 0x35, 0x36, 0x37 // 0x38, 0x39 // Unused // 0x3A, 0x3B // 0x3C, 0x3D, 0x3E, 0x3F // Block B // Convert Nickname field back to bytes pk6.Nickname = TB_Nickname.Text; pk6.Move1 = Util.getIndex(CB_Move1); pk6.Move2 = Util.getIndex(CB_Move2); pk6.Move3 = Util.getIndex(CB_Move3); pk6.Move4 = Util.getIndex(CB_Move4); pk6.Move1_PP = Util.getIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0; pk6.Move2_PP = Util.getIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0; pk6.Move3_PP = Util.getIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0; pk6.Move4_PP = Util.getIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0; pk6.Move1_PPUps = Util.getIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0; pk6.Move2_PPUps = Util.getIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0; pk6.Move3_PPUps = Util.getIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0; pk6.Move4_PPUps = Util.getIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0; pk6.RelearnMove1 = Util.getIndex(CB_RelearnMove1); pk6.RelearnMove2 = Util.getIndex(CB_RelearnMove2); pk6.RelearnMove3 = Util.getIndex(CB_RelearnMove3); pk6.RelearnMove4 = Util.getIndex(CB_RelearnMove4); // 0x72 - Ribbon editor sets this flag (Secret Super Training) // 0x73 pk6.IV_HP = Util.ToInt32(TB_HPIV.Text); pk6.IV_ATK = Util.ToInt32(TB_ATKIV.Text); pk6.IV_DEF = Util.ToInt32(TB_DEFIV.Text); pk6.IV_SPE = Util.ToInt32(TB_SPEIV.Text); pk6.IV_SPA = Util.ToInt32(TB_SPAIV.Text); pk6.IV_SPD = Util.ToInt32(TB_SPDIV.Text); pk6.IsEgg = CHK_IsEgg.Checked; pk6.IsNicknamed = CHK_Nicknamed.Checked; // Block C pk6.HT_Name = TB_OTt2.Text; // 0x90-0xAF pk6.HT_Gender = PKX.getGender(Label_CTGender.Text); // Plus more, set by MemoryAmie (already in buff) // Block D pk6.OT_Name = TB_OT.Text; pk6.CurrentFriendship = Util.ToInt32(TB_Friendship.Text); DateTime?egg_date = null; int egg_location = 0; if (CHK_AsEgg.Checked) // If encountered as an egg, load the Egg Met data from fields. { egg_date = CAL_EggDate.Value; egg_location = Util.getIndex(CB_EggLocation); } // Egg Met Data pk6.EggMetDate = egg_date; pk6.Egg_Location = egg_location; // Met Data pk6.MetDate = CAL_MetDate.Value; pk6.Met_Location = Util.getIndex(CB_MetLocation); if (pk6.IsEgg && pk6.Met_Location == 0) // If still an egg, it has no hatch location/date. Zero it! { pk6.MetDate = null; } // 0xD7 Unknown pk6.Ball = Util.getIndex(CB_Ball); pk6.Met_Level = Util.ToInt32(TB_MetLevel.Text); pk6.OT_Gender = PKX.getGender(Label_OTGender.Text); pk6.EncounterType = Util.getIndex(CB_EncounterType); pk6.Version = Util.getIndex(CB_GameOrigin); pk6.Country = Util.getIndex(CB_Country); pk6.Region = Util.getIndex(CB_SubRegion); pk6.ConsoleRegion = Util.getIndex(CB_3DSReg); pk6.Language = Util.getIndex(CB_Language); // 0xE4-0xE7 // Toss in Party Stats Array.Resize(ref pk6.Data, pk6.SIZE_PARTY); pk6.Stat_Level = Util.ToInt32(TB_Level.Text); pk6.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text); pk6.Stat_HPMax = Util.ToInt32(Stat_HP.Text); pk6.Stat_ATK = Util.ToInt32(Stat_ATK.Text); pk6.Stat_DEF = Util.ToInt32(Stat_DEF.Text); pk6.Stat_SPE = Util.ToInt32(Stat_SPE.Text); pk6.Stat_SPA = Util.ToInt32(Stat_SPA.Text); pk6.Stat_SPD = Util.ToInt32(Stat_SPD.Text); // Unneeded Party Stats (Status, Flags, Unused) pk6.Data[0xE8] = pk6.Data[0xE9] = pk6.Data[0xEA] = pk6.Data[0xEB] = pk6.Data[0xED] = pk6.Data[0xEE] = pk6.Data[0xEF] = pk6.Data[0xFE] = pk6.Data[0xFF] = pk6.Data[0x100] = pk6.Data[0x101] = pk6.Data[0x102] = pk6.Data[0x103] = 0; // Hax Illegality if (HaX) { pk6.Ability = (byte)Util.getIndex(DEV_Ability); pk6.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue); } // Fix Moves if a slot is empty pk6.FixMoves(); pk6.FixRelearn(); // Fix Handler (Memories & OT) -- no foreign memories for Pokemon without a foreign trainer (none for eggs) if (Menu_ModifyPKM.Checked) { pk6.FixMemories(); } // PKX is now filled pk6.RefreshChecksum(); return(pk6); }
// Meta public void setPK6(PK6 pk6) { // Apply to this Save File int CT = pk6.CurrentHandler; DateTime Date = DateTime.Now; pk6.Trade(OT, TID, SID, Country, SubRegion, Gender, false, Date.Day, Date.Month, Date.Year); if (CT != pk6.CurrentHandler) // Logic updated Friendship { // Copy over the Friendship Value only under certain circumstances if (pk6.Moves.Contains(216)) // Return pk6.CurrentFriendship = pk6.OppositeFriendship; else if (pk6.Moves.Contains(218)) // Frustration pk6.CurrentFriendship = pk6.OppositeFriendship; else if (pk6.CurrentHandler == 1) // OT->HT, needs new Friendship/Affection pk6.TradeFriendshipAffection(OT); } pk6.RefreshChecksum(); }
public override PKM convertToPKM(SaveFile 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 = PersonalTable.AO[Species].Gender == 255 ? 2 : (Gender != 3 ? Gender : PersonalTable.AO[Species].RandomGender), AltForm = Form, EncryptionConstant = EncryptionConstant == 0 ? Util.rnd32() : EncryptionConstant, Version = OriginGame == 0 ? SAV.Game : OriginGame, Language = Language == 0 ? SAV.Language : Language, Ball = Ball, Country = SAV.Country, Region = SAV.SubRegion, ConsoleRegion = SAV.ConsoleRegion, Move1 = Move1, Move2 = Move2, Move3 = Move3, Move4 = 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 RibbonCountry = RibbonCountry, RibbonNational = RibbonNational, RibbonEarth = RibbonEarth, RibbonWorld = RibbonWorld, RibbonClassic = RibbonClassic, RibbonPremier = RibbonPremier, RibbonEvent = RibbonEvent, RibbonBirthday = RibbonBirthday, RibbonSpecial = RibbonSpecial, RibbonSouvenir = RibbonSouvenir, RibbonWishing = RibbonWishing, RibbonChampionBattle = RibbonChampionBattle, RibbonChampionRegional = RibbonChampionRegional, RibbonChampionNational = RibbonChampionNational, RibbonChampionWorld = RibbonChampionWorld, OT_Friendship = PersonalTable.AO[Species].BaseFriendship, OT_Intensity = OT_Intensity, OT_Memory = OT_Memory, OT_TextVar = OT_TextVar, OT_Feeling = OT_Feeling, FatefulEncounter = true, }; pk.Move1_PP = pk.getMovePP(Move1, 0); pk.Move2_PP = pk.getMovePP(Move2, 0); pk.Move3_PP = pk.getMovePP(Move3, 0); pk.Move4_PP = pk.getMovePP(Move4, 0); if (Date.HasValue) { pk.MetDate = Date.Value; } else { // No datetime set, typical for wc6full // Set it to now, instead of zeroing it out. pk.MetDate = DateTime.Now; } 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 = PersonalTable.AO.getAbilities(Species, pk.AltForm)[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.EggMetDate = Date; } pk.RefreshChecksum(); return pk; }
public override PKM convertToPKM(SaveFile 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 = PersonalTable.AO[Species].Gender == 255 ? 2 : (Gender != 3 ? Gender : PersonalTable.AO[Species].RandomGender), AltForm = Form, EncryptionConstant = EncryptionConstant == 0 ? Util.rnd32() : EncryptionConstant, Version = OriginGame == 0 ? SAV.Game : OriginGame, Language = Language == 0 ? SAV.Language : Language, Ball = Ball, Country = SAV.Country, Region = SAV.SubRegion, ConsoleRegion = SAV.ConsoleRegion, Move1 = Move1, Move2 = Move2, Move3 = Move3, Move4 = 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 RibbonCountry = RibbonCountry, RibbonNational = RibbonNational, RibbonEarth = RibbonEarth, RibbonWorld = RibbonWorld, RibbonClassic = RibbonClassic, RibbonPremier = RibbonPremier, RibbonEvent = RibbonEvent, RibbonBirthday = RibbonBirthday, RibbonSpecial = RibbonSpecial, RibbonSouvenir = RibbonSouvenir, RibbonWishing = RibbonWishing, RibbonChampionBattle = RibbonChampionBattle, RibbonChampionRegional = RibbonChampionRegional, RibbonChampionNational = RibbonChampionNational, RibbonChampionWorld = RibbonChampionWorld, OT_Friendship = PersonalTable.AO[Species].BaseFriendship, OT_Intensity = OT_Intensity, OT_Memory = OT_Memory, OT_TextVar = OT_TextVar, OT_Feeling = OT_Feeling, FatefulEncounter = true, }; pk.Move1_PP = pk.getMovePP(Move1, 0); pk.Move2_PP = pk.getMovePP(Move2, 0); pk.Move3_PP = pk.getMovePP(Move3, 0); pk.Move4_PP = pk.getMovePP(Move4, 0); if (Date.HasValue) { pk.MetDate = Date.Value; } else { // No datetime set, typical for wc6full // Set it to now, instead of zeroing it out. pk.MetDate = DateTime.Now; } 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 = PersonalTable.AO.getAbilities(Species, pk.AltForm)[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.EggMetDate = Date; } 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); }