From 2116d528e487cf2805ac8c3bca8b466b8b0e7972 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sun, 14 Aug 2016 23:23:38 -0700 Subject: [PATCH] Improve batch randomization allow .EncryptionConstant=PID improve .PID=$rand to use random PID method instead of pure rand switch comparisons to match command appearance in richtextbox --- PKHeX/PKM/PKM.cs | 9 ++++++--- PKHeX/Subforms/PKM Editors/BatchEditor.cs | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/PKHeX/PKM/PKM.cs b/PKHeX/PKM/PKM.cs index 3008f6e80..0c39bcbd2 100644 --- a/PKHeX/PKM/PKM.cs +++ b/PKHeX/PKM/PKM.cs @@ -426,17 +426,20 @@ private int getBasePP(int move) public void setShinyPID() { do PID = PKX.getRandomPID(Species, Gender, Version, Nature, AltForm, PID); while (!IsShiny); - EncryptionConstant = PID; + if (GenNumber < 6) + EncryptionConstant = PID; } public void setPIDGender(int gender) { do PID = PKX.getRandomPID(Species, gender, Version, Nature, AltForm, PID); while (IsShiny); - EncryptionConstant = PID; + if (GenNumber < 6) + EncryptionConstant = PID; } public void setPIDNature(int nature) { do PID = PKX.getRandomPID(Species, Gender, Version, nature, AltForm, PID); while (IsShiny); - EncryptionConstant = PID; + if (GenNumber < 6) + EncryptionConstant = PID; } } } diff --git a/PKHeX/Subforms/PKM Editors/BatchEditor.cs b/PKHeX/Subforms/PKM Editors/BatchEditor.cs index 67613c4d5..6e67c5f68 100644 --- a/PKHeX/Subforms/PKM Editors/BatchEditor.cs +++ b/PKHeX/Subforms/PKM Editors/BatchEditor.cs @@ -262,11 +262,15 @@ private static ModifyResult ProcessPKM(PKM PKM, IEnumerable F { try { - if (cmd.PropertyValue == CONST_RAND && (cmd.PropertyName == "PID" || cmd.PropertyName == "EncryptionConstant")) + if (cmd.PropertyName == "EncryptionConstant" && cmd.PropertyValue == CONST_RAND) ReflectUtil.SetValue(PKM, cmd.PropertyName, Util.rnd32().ToString()); - else if (cmd.PropertyValue == CONST_SHINY && cmd.PropertyName == "PID") + else if(cmd.PropertyName == "PID" && cmd.PropertyValue == CONST_RAND) + PKM.setPIDGender(PKM.Gender); + else if (cmd.PropertyName == "EncryptionConstant" && cmd.PropertyValue == "PID") + PKM.EncryptionConstant = PKM.PID; + else if (cmd.PropertyName == "PID" && cmd.PropertyValue == CONST_SHINY) PKM.setShinyPID(); - else if (cmd.PropertyValue == "0" && cmd.PropertyName == "Species") + else if (cmd.PropertyName == "Species" && cmd.PropertyValue == "0") PKM.Data = new byte[PKM.Data.Length]; else ReflectUtil.SetValue(PKM, cmd.PropertyName, cmd.PropertyValue);