mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 22:10:21 +00:00
Move complicated EC get to Common Edits
Rerolling EC will match Maushold and Dudunsparce current form.
This commit is contained in:
parent
ae2d13432b
commit
80c856b618
2 changed files with 35 additions and 33 deletions
|
@ -81,33 +81,9 @@ 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) => SetComplicatedEC(pk, cmd.PropertyValue[^1])),
|
||||
new ComplexSet(nameof(PKM.EncryptionConstant), value => value.StartsWith(CONST_RAND), (pk, cmd) => pk.EncryptionConstant = CommonEdits.GetComplicatedEC(pk, option: cmd.PropertyValue[^1])),
|
||||
};
|
||||
|
||||
private static void SetComplicatedEC(PKM pk, char option)
|
||||
{
|
||||
var rng = Util.Rand;
|
||||
uint rand = rng.Rand32();
|
||||
uint mod = 1, noise = 0;
|
||||
if (pk.Species is >= (int)Species.Wurmple and <= (int)Species.Dustox)
|
||||
{
|
||||
mod = 10;
|
||||
bool lower = option is '0' or 'B' or 'S' || WurmpleUtil.GetWurmpleEvoGroup(pk.Species) == 0;
|
||||
noise = (lower ? 0u : 5u) + (uint)rng.Next(0, 5);
|
||||
}
|
||||
else if (pk.Species is (int)Species.Dunsparce or (int)Species.Dudunsparce or (int)Species.Tandemaus or (int)Species.Maushold)
|
||||
{
|
||||
mod = 100;
|
||||
noise = option is '0' or '3' ? 0u : (uint)rng.Next(1, 100);
|
||||
}
|
||||
else if (option is >= '0' and <= '5')
|
||||
{
|
||||
mod = 6;
|
||||
noise = (uint)(option - '0');
|
||||
}
|
||||
pk.EncryptionConstant = unchecked(rand - (rand % mod) + noise);
|
||||
}
|
||||
|
||||
private static void SetRandomEVs(PKM pk)
|
||||
{
|
||||
Span<int> evs = stackalloc int[6];
|
||||
|
|
|
@ -88,14 +88,7 @@ public static class CommonEdits
|
|||
pk.EncryptionConstant = pk.PID;
|
||||
return;
|
||||
}
|
||||
|
||||
int wIndex = WurmpleUtil.GetWurmpleEvoGroup(pk.Species);
|
||||
if (wIndex != -1)
|
||||
{
|
||||
pk.EncryptionConstant = WurmpleUtil.GetWurmpleEncryptionConstant(wIndex);
|
||||
return;
|
||||
}
|
||||
pk.EncryptionConstant = Util.Rand32();
|
||||
pk.EncryptionConstant = GetComplicatedEC(pk);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -452,4 +445,37 @@ public static class CommonEdits
|
|||
int location = eggmet ? pk.Egg_Location : pk.Met_Location;
|
||||
return GameInfo.GetLocationName(eggmet, location, pk.Format, pk.Generation, (GameVersion)pk.Version);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="PKM.EncryptionConstant"/> to match the requested option.
|
||||
/// </summary>
|
||||
public static uint GetComplicatedEC(ISpeciesForm pk, char option = ' ')
|
||||
{
|
||||
var rng = Util.Rand;
|
||||
uint rand = rng.Rand32();
|
||||
uint mod = 1, noise = 0;
|
||||
if (pk.Species is >= (int)Species.Wurmple and <= (int)Species.Dustox)
|
||||
{
|
||||
mod = 10;
|
||||
bool lower = option is '0' or 'B' or 'S' || WurmpleUtil.GetWurmpleEvoGroup(pk.Species) == 0;
|
||||
noise = (lower ? 0u : 5u) + (uint)rng.Next(0, 5);
|
||||
}
|
||||
else if (pk.Species is (int)Species.Dunsparce or (int)Species.Dudunsparce or (int)Species.Tandemaus or (int)Species.Maushold)
|
||||
{
|
||||
mod = 100;
|
||||
noise = option switch
|
||||
{
|
||||
'0' or '3' => 0u,
|
||||
_ when pk.Species is (int)Species.Dudunsparce && pk.Form == 1 => 0, // 3 Segment
|
||||
_ when pk.Species is (int)Species.Maushold && pk.Form == 0 => 0, // Family of 3
|
||||
_ => (uint)rng.Next(1, 100)
|
||||
};
|
||||
}
|
||||
else if (option is >= '0' and <= '5')
|
||||
{
|
||||
mod = 6;
|
||||
noise = (uint)(option - '0');
|
||||
}
|
||||
return unchecked(rand - (rand % mod) + noise);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue