diff --git a/Legality/Checks.cs b/Legality/Checks.cs index d7c7374e3..5c33a70c4 100644 --- a/Legality/Checks.cs +++ b/Legality/Checks.cs @@ -584,7 +584,7 @@ private LegalityCheck verifyHistory() WC6 MatchedWC6 = EncounterMatch as WC6; if (MatchedWC6?.OT.Length > 0) // Has Event OT -- null propagation yields false if MatchedWC6=null { - if (pk6.OT_Friendship != PKX.getBaseFriendship(pk6.Species)) + if (pk6.OT_Friendship != PersonalTable.AO[pk6.Species].BaseFriendship) return new LegalityCheck(Severity.Invalid, "Event OT Friendship does not match base friendship."); if (pk6.OT_Affection != 0) return new LegalityCheck(Severity.Invalid, "Event OT Affection should be zero."); diff --git a/MainWindow/Main.cs b/MainWindow/Main.cs index 2586d82cb..13b715576 100644 --- a/MainWindow/Main.cs +++ b/MainWindow/Main.cs @@ -386,7 +386,7 @@ private void clickShowdownImportPK6(object sender, EventArgs e) CB_Form.SelectedIndex = form; // Set Ability - int[] abilities = PKX.getAbilities(Set.Species, form); + int[] abilities = SAV.Personal.getAbilities(Set.Species, form); int ability = Array.IndexOf(abilities, Set.Ability); if (ability < 0) ability = 0; CB_Ability.SelectedIndex = ability; @@ -1165,7 +1165,10 @@ private void setAbilityList() // PKX Data Calculation Functions // private void setIsShiny() { - bool isShiny = PKX.getIsShiny(Util.getHEXval(TB_PID.Text), Util.ToUInt32(TB_TID.Text), Util.ToUInt32(TB_SID.Text)); + pkm.PID = Util.getHEXval(TB_PID.Text); + pkm.TID = (int)Util.ToUInt32(TB_TID.Text); + pkm.SID = (int)Util.ToUInt32(TB_SID.Text); + bool isShiny = pkm.IsShiny; // Set the Controls BTN_Shinytize.Visible = BTN_Shinytize.Enabled = !isShiny; @@ -1229,7 +1232,7 @@ private void clickFriendship(object sender, EventArgs e) if (ModifierKeys == Keys.Control) // prompt to reset TB_Friendship.Text = pkm.CurrentFriendship.ToString(); else - TB_Friendship.Text = TB_Friendship.Text == "255" ? PKX.getBaseFriendship(pkm.Species).ToString() : "255"; + TB_Friendship.Text = TB_Friendship.Text == "255" ? SAV.Personal[pkm.Species].BaseFriendship.ToString() : "255"; } private void clickGender(object sender, EventArgs e) { @@ -1981,7 +1984,7 @@ private void updateIsEgg(object sender, EventArgs e) if (!CHK_Nicknamed.Checked) updateNickname(null, null); - TB_Friendship.Text = PKX.getBaseFriendship(Util.getIndex(CB_Species)).ToString(); + TB_Friendship.Text = SAV.Personal[Util.getIndex(CB_Species)].BaseFriendship.ToString(); if (CB_EggLocation.SelectedIndex == 0) { @@ -2050,13 +2053,15 @@ private void updateTSV(object sender, EventArgs e) { if (SAV.Generation < 6) return; - ushort TID = (ushort)Util.ToUInt32(TB_TID.Text); - ushort SID = (ushort)Util.ToUInt32(TB_SID.Text); - uint TSV = PKX.getTSV(TID, SID); + + pkm.TID = (int)Util.ToUInt32(TB_TID.Text); + pkm.SID = (int)Util.ToUInt32(TB_SID.Text); + var TSV = pkm.TSV; Tip1.SetToolTip(TB_TID, "TSV: " + TSV.ToString("0000")); Tip2.SetToolTip(TB_SID, "TSV: " + TSV.ToString("0000")); - uint PSV = PKX.getPSV(Util.getHEXval(TB_PID.Text)); + pkm.PID = Util.getHEXval(TB_PID.Text); + var PSV = pkm.PSV; Tip3.SetToolTip(TB_PID, "PSV: " + PSV.ToString("0000")); } private void update_ID(object sender, EventArgs e) diff --git a/MainWindow/MainPK3.cs b/MainWindow/MainPK3.cs index af808a5d0..de552ecaa 100644 --- a/MainWindow/MainPK3.cs +++ b/MainWindow/MainPK3.cs @@ -29,7 +29,7 @@ private void populateFieldsPK3() TB_PID.Text = pk3.PID.ToString("X8"); CB_HeldItem.SelectedValue = pk3.G3Item; setAbilityList(); - int[] abils = PKX.getAbilities(pk3.Species, 0); + int[] abils = SAV.Personal.getAbilities(pk3.Species, 0); int abil = Array.IndexOf(abils, pk3.Ability); CB_Ability.SelectedIndex = abil < 0 || abil >= CB_Ability.Items.Count ? 0 : abil; CB_Nature.SelectedValue = pk3.Nature; diff --git a/MainWindow/MainPK4.cs b/MainWindow/MainPK4.cs index 312cd63d8..c26762cfa 100644 --- a/MainWindow/MainPK4.cs +++ b/MainWindow/MainPK4.cs @@ -123,7 +123,7 @@ private void populateFieldsPK4() DEV_Ability.SelectedValue = pk4.Ability; else { - int[] abils = PKX.getAbilities(pk4.Species, pk4.AltForm); + int[] abils = SAV.Personal.getAbilities(pk4.Species, pk4.AltForm); int abil = Array.IndexOf(abils, pk4.Ability); CB_Ability.SelectedIndex = abil < 0 || abil >= CB_Ability.Items.Count ? 0 : abil; } diff --git a/MainWindow/MainPK5.cs b/MainWindow/MainPK5.cs index a1a8806d5..86defb20b 100644 --- a/MainWindow/MainPK5.cs +++ b/MainWindow/MainPK5.cs @@ -134,7 +134,7 @@ private void populateFieldsPK5() CB_Ability.SelectedIndex = CB_Ability.Items.Count - 1; else { - int[] abils = PKX.getAbilities(pk5.Species, pk5.AltForm); + int[] abils = SAV.Personal.getAbilities(pk5.Species, pk5.AltForm); int abil = Array.IndexOf(abils, pk5.Ability); CB_Ability.SelectedIndex = abil < 0 || abil >= CB_Ability.Items.Count ? 0 : abil; } diff --git a/MysteryGifts/PGF.cs b/MysteryGifts/PGF.cs index f1472806b..a31781ce4 100644 --- a/MysteryGifts/PGF.cs +++ b/MysteryGifts/PGF.cs @@ -186,7 +186,7 @@ public override PKM convertToPKM(SaveFile SAV) RibbonChampionNational = RibbonChampionNational, RibbonChampionWorld = RibbonChampionWorld, - OT_Friendship = PKX.getBaseFriendship(Species), + OT_Friendship = PersonalTable.B2W2[Species].BaseFriendship, FatefulEncounter = true, }; if (OTGender == 3) // User's diff --git a/MysteryGifts/WC6.cs b/MysteryGifts/WC6.cs index 47425de0e..92c24f0a5 100644 --- a/MysteryGifts/WC6.cs +++ b/MysteryGifts/WC6.cs @@ -273,7 +273,7 @@ public override PKM convertToPKM(SaveFile SAV) RibbonChampionNational = RibbonChampionNational, RibbonChampionWorld = RibbonChampionWorld, - OT_Friendship = PKX.getBaseFriendship(Species), + OT_Friendship = PersonalTable.AO[Species].BaseFriendship, OT_Intensity = OT_Intensity, OT_Memory = OT_Memory, OT_TextVar = OT_TextVar, diff --git a/PKM/PK5.cs b/PKM/PK5.cs index ae9edbed6..bb87d3ebe 100644 --- a/PKM/PK5.cs +++ b/PKM/PK5.cs @@ -332,8 +332,10 @@ public PK6 convertToPK6() Ability = Ability }; - int abilnum = PKX.getAbilityNumber(Species, Ability, AltForm); - if (abilnum > 0) pk6.AbilityNumber = abilnum; + int[] abilities = PersonalTable.AO.getAbilities(Species, AltForm); + int abilval = Array.IndexOf(abilities, Ability); + if (abilval >= 0) + pk6.AbilityNumber = 1 << abilval; else // Fallback (shouldn't happen) { if (HiddenAbility) pk6.AbilityNumber = 4; // Hidden, else G5 or G3/4 correlation. @@ -517,7 +519,7 @@ public PK6 convertToPK6() pk6.HT_Memory = 4; pk6.HT_Feeling = (int)(Util.rnd32() % 10); // When transferred, friendship gets reset. - pk6.OT_Friendship = pk6.HT_Friendship = PKX.getBaseFriendship(Species); + pk6.OT_Friendship = pk6.HT_Friendship = PersonalTable.B2W2[Species].BaseFriendship; // Antishiny Mechanism ushort LID = (ushort)(PID & 0xFFFF); diff --git a/PKM/PK6.cs b/PKM/PK6.cs index a3add1676..852e7635d 100644 --- a/PKM/PK6.cs +++ b/PKM/PK6.cs @@ -629,7 +629,7 @@ public void TradeFriendshipAffection(string SAV_TRAINER) return; // Reset - HT_Friendship = PKX.getBaseFriendship(Species); + HT_Friendship = PersonalTable.AO[Species].BaseFriendship; HT_Affection = 0; } diff --git a/PKM/PKX.cs b/PKM/PKX.cs index 41c0966c6..900f45ac3 100644 --- a/PKM/PKX.cs +++ b/PKM/PKX.cs @@ -243,10 +243,6 @@ internal static byte[] getRandomEVs() Util.Shuffle(evs); return evs; } - internal static int getBaseFriendship(int species) - { - return Personal[species].BaseFriendship; - } internal static int getLevel(int species, uint exp) { int growth = Personal[species].EXPGrowth; @@ -255,30 +251,12 @@ internal static int getLevel(int species, uint exp) if (tl == 100) return 100; return --tl; } - internal static bool getIsShiny(uint PID, uint TID, uint SID) - { - uint PSV = getPSV(PID); - uint TSV = getTSV(TID, SID); - return TSV == PSV; - } internal static uint getEXP(int level, int species) { if (level <= 1) return 0; if (level > 100) level = 100; return ExpTable[level, Personal[species].EXPGrowth]; } - internal static int[] getAbilities(int species, int formnum) - { - return Personal[Personal[species].FormeIndex(species, formnum)].Abilities; - } - internal static int getAbilityNumber(int species, int ability, int formnum) - { - int[] spec_abilities = getAbilities(species, formnum); - int abilval = Array.IndexOf(spec_abilities, ability); - if (abilval >= 0) - return 1 << abilval; - return -1; - } internal static int getGender(string s) { if (s == null) @@ -435,7 +413,6 @@ internal static ushort[] getStats(PKM pkm) return stats; } - // PKX Manipulation internal static readonly byte[][] blockPosition = { @@ -547,14 +524,6 @@ internal static bool verifychk(byte[] input) return chk == BitConverter.ToUInt16(input, 0x6); } - internal static uint getPSV(uint PID) - { - return (PID >> 16 ^ PID & 0xFFFF) >> 4; - } - internal static uint getTSV(uint TID, uint SID) - { - return (TID ^ SID) >> 4; - } internal static uint getRandomPID(int species, int cg, int origin, int nature, int form) { int gt = Personal[species].Gender; diff --git a/Subforms/Save Editors/Gen6/SAV_Trainer.cs b/Subforms/Save Editors/Gen6/SAV_Trainer.cs index fbf2da068..2d5be2a82 100644 --- a/Subforms/Save Editors/Gen6/SAV_Trainer.cs +++ b/Subforms/Save Editors/Gen6/SAV_Trainer.cs @@ -560,7 +560,7 @@ private void showTSV(object sender, EventArgs e) { uint TID = Util.ToUInt32(MT_TID.Text); uint SID = Util.ToUInt32(MT_SID.Text); - uint tsv = PKX.getTSV(TID, SID); + uint tsv = (TID ^ SID) >> 4; Tip1.SetToolTip(MT_TID, "TSV: " + tsv.ToString("0000")); Tip2.SetToolTip(MT_SID, "TSV: " + tsv.ToString("0000")); }