Skip to content

Commit 731a3fd

Browse files
committed
Add $rand0/$rand3 batch cmd for dudu/maus rare
.EncryptionConstant=$rand0 .EncryptionConstant=$rand3 ^ both will randomize so EC%100 = 0 Additionally, added $rand0/$randB/$randS for Wurmple/Beautifly/Silcoon to force EC%10 [0,4], otherwise EC%10 will be [5,9] for the Cascoon/Dustox evolution. For neither of the two above cases, can do EC%6=last char if someone cares about the EC tiebreaker for characteristic determination. No, I don't want to consider how allow the above cases to do that too :) -- just write your own syntax via a plugin and add your ComplexSet to the list!
1 parent 76ec39b commit 731a3fd

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

PKHeX.Core/Editing/Bulk/BatchMods.cs

+27
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,35 @@ public static class BatchMods
7979

8080
new ComplexSet(nameof(PKM.Species), value => value == "0", (pk, _) => Array.Clear(pk.Data, 0, pk.Data.Length)),
8181
new ComplexSet(nameof(PKM.IsNicknamed), value => string.Equals(value, "false", StringComparison.OrdinalIgnoreCase), (pk, _) => pk.SetDefaultNickname()),
82+
83+
// Complicated
84+
new ComplexSet(nameof(PKM.EncryptionConstant), value => value.StartsWith(CONST_RAND), (pk, cmd) => SetComplicatedEC(pk, cmd.PropertyValue[^1])),
8285
};
8386

87+
private static void SetComplicatedEC(PKM pk, char option)
88+
{
89+
var rng = Util.Rand;
90+
uint rand = rng.Rand32();
91+
uint mod = 1, noise = 0;
92+
if (pk.Species is >= (int)Species.Wurmple and <= (int)Species.Dustox)
93+
{
94+
mod = 10;
95+
bool lower = option is '0' or 'B' or 'S' || WurmpleUtil.GetWurmpleEvoGroup(pk.Species) == 0;
96+
noise = (lower ? 0u : 5u) + (uint)rng.Next(0, 5);
97+
}
98+
else if (pk.Species is (int)Species.Dunsparce or (int)Species.Dudunsparce or (int)Species.Tandemaus or (int)Species.Maushold)
99+
{
100+
mod = 100;
101+
noise = option is '0' or '3' ? 0u : (uint)rng.Next(1, 100);
102+
}
103+
else if (option is >= '0' and <= '5')
104+
{
105+
mod = 6;
106+
noise = (uint)(option - '0');
107+
}
108+
pk.EncryptionConstant = unchecked(rand - (rand % mod) + noise);
109+
}
110+
84111
private static void SetRandomEVs(PKM pk)
85112
{
86113
Span<int> evs = stackalloc int[6];

0 commit comments

Comments
 (0)