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...
This commit is contained in:
Kurt
2017-05-28 13:19:48 -07:00
parent cbfa38b131
commit 8eed9f84ba
2 changed files with 12 additions and 4 deletions

View File

@@ -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];
}

View File

@@ -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);