From 865d0693ca66fc0e99593f0799b901799920df71 Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 18 Dec 2017 12:23:23 -0800 Subject: [PATCH] Fix bst rand Closes #255 --- pk3DS.Core/Randomizers/SpeciesRandomizer.cs | 10 +++++----- pk3DS/Subforms/Gen6/TrainerRand.cs | 1 + pk3DS/Subforms/Gen7/SMTE.cs | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pk3DS.Core/Randomizers/SpeciesRandomizer.cs b/pk3DS.Core/Randomizers/SpeciesRandomizer.cs index 686819a..20cc884 100644 --- a/pk3DS.Core/Randomizers/SpeciesRandomizer.cs +++ b/pk3DS.Core/Randomizers/SpeciesRandomizer.cs @@ -73,7 +73,7 @@ public int GetRandomSpeciesType(int oldSpecies, int type) loopctr++; return newSpecies; } - private bool GetIsTypeMatch(int newSpecies, int type) => SpeciesStat[newSpecies].Types.Any(z => z == type) || loopctr > 9000; + private bool GetIsTypeMatch(int newSpecies, int type) => type == -1 || SpeciesStat[newSpecies].Types.Any(z => z == type) || loopctr > 9000; public int GetRandomSpecies(int oldSpecies) { @@ -118,11 +118,11 @@ private bool IsSpeciesBSTBad(PersonalInfo oldpkm, PersonalInfo pkm) { if (!rBST) return false; - // Base stat total has to be close + // Base stat total has to be close to original BST int expand = loopctr / MaxSpeciesID; - int lo = pkm.BST * l / (h + expand); - int hi = pkm.BST * (h + expand) / l; - return lo > oldpkm.BST || oldpkm.BST > hi; + int lo = oldpkm.BST * l / (h + expand); + int hi = oldpkm.BST * (h + expand) / l; + return lo > pkm.BST || pkm.BST > hi; } private int[] InitializeSpeciesList() diff --git a/pk3DS/Subforms/Gen6/TrainerRand.cs b/pk3DS/Subforms/Gen6/TrainerRand.cs index 1211017..0222b50 100644 --- a/pk3DS/Subforms/Gen6/TrainerRand.cs +++ b/pk3DS/Subforms/Gen6/TrainerRand.cs @@ -98,6 +98,7 @@ private void B_Save_Click(object sender, EventArgs e) Shedinja = true, rBST = CHK_BST.Checked, + rEXP = false, }; RSTE.rSpeciesRand.Initialize(); diff --git a/pk3DS/Subforms/Gen7/SMTE.cs b/pk3DS/Subforms/Gen7/SMTE.cs index 03f3891..17205c2 100644 --- a/pk3DS/Subforms/Gen7/SMTE.cs +++ b/pk3DS/Subforms/Gen7/SMTE.cs @@ -592,6 +592,7 @@ private void B_Randomize_Click(object sender, EventArgs e) E = CHK_E.Checked, L = CHK_L.Checked, rBST = CHK_BST.Checked, + rEXP = false, }; rnd.Initialize();