diff --git a/PKHeX.Core/Editing/Bulk/BatchMods.cs b/PKHeX.Core/Editing/Bulk/BatchMods.cs
index 87ae6f208..409d987b8 100644
--- a/PKHeX.Core/Editing/Bulk/BatchMods.cs
+++ b/PKHeX.Core/Editing/Bulk/BatchMods.cs
@@ -67,7 +67,6 @@ public static class BatchMods
new ComplexSet(nameof(PKM.AbilityNumber), value => value.Length == 2 && value.StartsWith(CONST_SPECIAL), (pk, cmd) => pk.RefreshAbility(Convert.ToInt16(cmd.PropertyValue[1]) - 0x30)),
// Random
- new ComplexSet(nameof(PKM.EncryptionConstant), value => value == CONST_RAND, (pk, _) => pk.EncryptionConstant = Util.Rand32()),
new ComplexSet(nameof(PKM.PID), value => value == CONST_RAND, (pk, _) => pk.PID = Util.Rand32()),
new ComplexSet(nameof(PKM.Gender), value => value == CONST_RAND, (pk, _) => pk.SetPIDGender(pk.Gender)),
new ComplexSet(PROP_EVS, value => value == CONST_RAND, (pk, _) => SetRandomEVs(pk)),
@@ -82,7 +81,7 @@ public static class BatchMods
new ComplexSet(nameof(PKM.IsNicknamed), value => string.Equals(value, "false", StringComparison.OrdinalIgnoreCase), (pk, _) => pk.SetDefaultNickname()),
// Complicated
- new ComplexSet(nameof(PKM.EncryptionConstant), value => value.StartsWith(CONST_RAND), (pk, cmd) => pk.EncryptionConstant = CommonEdits.GetComplicatedEC(pk, option: cmd.PropertyValue[^1])),
+ new ComplexSet(nameof(PKM.EncryptionConstant), value => value.StartsWith(CONST_RAND), (pk, cmd) => pk.EncryptionConstant = CommonEdits.GetComplicatedEC(pk, option: (cmd.PropertyValue.Length == CONST_RAND.Length ? default : cmd.PropertyValue[^1]))),
];
private static void SetRandomTeraType(PKM pk)
diff --git a/PKHeX.Core/Editing/CommonEdits.cs b/PKHeX.Core/Editing/CommonEdits.cs
index 0385a2ed8..dd250ee0f 100644
--- a/PKHeX.Core/Editing/CommonEdits.cs
+++ b/PKHeX.Core/Editing/CommonEdits.cs
@@ -440,7 +440,7 @@ public static string GetLocationString(this PKM pk, bool eggmet)
///
/// Gets a to match the requested option.
///
- public static uint GetComplicatedEC(ISpeciesForm pk, char option = ' ')
+ public static uint GetComplicatedEC(ISpeciesForm pk, char option = default)
{
var species = pk.Species;
var form = pk.Form;
@@ -448,11 +448,11 @@ public static uint GetComplicatedEC(ISpeciesForm pk, char option = ' ')
}
///
- public static uint GetComplicatedEC(ushort species, byte form, char option = ' ')
+ public static uint GetComplicatedEC(ushort species, byte form, char option = default)
{
var rng = Util.Rand;
uint rand = rng.Rand32();
- uint mod = 1, noise = 0;
+ uint mod, noise;
if (species is >= (int)Species.Wurmple and <= (int)Species.Dustox)
{
mod = 10;
@@ -462,13 +462,16 @@ public static uint GetComplicatedEC(ushort species, byte form, char option = ' '
else if (species is (int)Species.Dunsparce or (int)Species.Dudunsparce or (int)Species.Tandemaus or (int)Species.Maushold)
{
mod = 100;
- noise = option switch
+ noise = species switch
{
- '0' or '3' => 0u,
- _ => species switch
+ // Retain requisite correlation to allow for evolving into this species too.
+ (int)Species.Dudunsparce => form == 1 ? 0 : (uint)rng.Next(1, 100), // 3 Segment
+ (int)Species.Maushold => form == 0 ? 0 : (uint)rng.Next(1, 100), // Family of 3
+
+ // Otherwise, check if one is preferred, and if not, just make it the more common outcome.
+ _ => option switch
{
- (int)Species.Dudunsparce when form == 1 => 0, // 3 Segment
- (int)Species.Maushold when form == 0 => 0, // Family of 3
+ '0' or '3' => 0u,
_ => (uint)rng.Next(1, 100),
},
};
@@ -478,6 +481,10 @@ public static uint GetComplicatedEC(ushort species, byte form, char option = ' '
mod = 6;
noise = (uint)(option - '0');
}
+ else
+ {
+ return rand;
+ }
return unchecked(rand - (rand % mod) + noise);
}
}