From 8eed9f84ba131be55dbe1d33b9fbefe19d715736 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 28 May 2017 13:19:48 -0700 Subject: [PATCH] Fix pk1 catch rate overwriting CatchRateIsItem is always false, thus the catch rate was always overwritten with the base species catch rate regardless of if the base species was the encounter. For species like Metapod who have different catch rates from their base species, this would invalidate any Metapod capture. So all possible catch rates are checked. Instead of setting the catch rate to the base species catch rate, set it to the current species. Allows user to set the exact catch rate by toggling between a legendary and the target species... --- PKHeX.Core/PKM/PK1.cs | 7 ++++++- PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs | 9 ++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/PKHeX.Core/PKM/PK1.cs b/PKHeX.Core/PKM/PK1.cs index 12309aae1..3e42b0fec 100644 --- a/PKHeX.Core/PKM/PK1.cs +++ b/PKHeX.Core/PKM/PK1.cs @@ -138,7 +138,12 @@ public override int Species // Before updating catch rate, check if non-standard if (!CatchRateIsItem) - Catch_Rate = PersonalTable.RB[Legal.getBaseSpecies(this)].CatchRate; + { + int baseSpecies = Legal.getBaseSpecies(this); + int Rate = Catch_Rate; + if (Enumerable.Range(baseSpecies, value).All(z => Rate != PersonalTable.RB[z].CatchRate)) + Catch_Rate = PersonalTable.RB[value].CatchRate; + } Type_A = PersonalInfo.Types[0]; Type_B = PersonalInfo.Types[1]; } diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index daf8d21a0..2283f5eb5 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -527,7 +527,8 @@ private void clickGender(object sender, EventArgs e) do { TB_ATKIV.Text = (Util.rnd32() & pkm.MaxIV).ToString(); } while (PKX.getGender(Label_Gender.Text) != newGender); else if (pkm.Format <= 4) { - pkm.Species = WinFormsUtil.getIndex(CB_Species); + if (fieldsLoaded) + pkm.Species = WinFormsUtil.getIndex(CB_Species); pkm.Version = WinFormsUtil.getIndex(CB_GameOrigin); pkm.Nature = WinFormsUtil.getIndex(CB_Nature); pkm.AltForm = CB_Form.SelectedIndex; @@ -801,7 +802,8 @@ private void updateIVs(object sender, EventArgs e) CB_Form.SelectedIndex = pkm.AltForm; } setIsShiny(null); - UpdatePreviewSprite?.Invoke(this, null); + if (fieldsLoaded) + UpdatePreviewSprite?.Invoke(this, null); } CB_HPType.SelectedValue = pkm.HPType; @@ -1188,7 +1190,8 @@ private void updateCountry(object sender, EventArgs e) private void updateSpecies(object sender, EventArgs e) { // Get Species dependent information - pkm.Species = WinFormsUtil.getIndex(CB_Species); + if (fieldsLoaded) + pkm.Species = WinFormsUtil.getIndex(CB_Species); setAbilityList(); setForms(); updateForm(null, null);