mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-12 23:37:07 +00:00
Add nidoran/volbeat-illumise gen3/4 gender check
Closes #4356 adds check revises egg->pk* logic to generate a valid pid for this case
This commit is contained in:
parent
3707ee5eb1
commit
86d1e5ce15
3 changed files with 37 additions and 1 deletions
|
@ -18,11 +18,33 @@ public static class Breeding
|
||||||
(int)Volbeat => true,
|
(int)Volbeat => true,
|
||||||
(int)Illumise => true,
|
(int)Illumise => true,
|
||||||
|
|
||||||
(int)Indeedee => true, // male/female
|
(int)Indeedee => true, // male/female form
|
||||||
|
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Species that are determined when the egg is received.
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsGenderSpeciesDetermination(ushort species) => species switch
|
||||||
|
{
|
||||||
|
(int)NidoranF => true,
|
||||||
|
(int)NidoranM => true,
|
||||||
|
|
||||||
|
(int)Volbeat => true,
|
||||||
|
(int)Illumise => true,
|
||||||
|
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the species <see cref="ec"/> is valid for the <see cref="gender"/> if originated from Gen3/4 daycare eggs.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ec">Encryption Constant</param>
|
||||||
|
/// <param name="gender">Gender</param>
|
||||||
|
/// <returns>True if valid</returns>
|
||||||
|
public static bool IsValidSpeciesBit34(uint ec, byte gender) => gender != (ec & 0x8000) >> 15; // 1 = Male, 0 = Female, valid if different from Gender value.
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the <see cref="species"/> can be born with inherited moves from the parents.
|
/// Checks if the <see cref="species"/> can be born with inherited moves from the parents.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -134,6 +134,15 @@ public sealed record EncounterEgg(ushort Species, byte Form, byte Level, byte Ge
|
||||||
pk.SetPIDGender(gender);
|
pk.SetPIDGender(gender);
|
||||||
pk.Gender = gender;
|
pk.Gender = gender;
|
||||||
pk.SetPIDNature(nature);
|
pk.SetPIDNature(nature);
|
||||||
|
if (pk.Format is 3 or 4 && Breeding.IsGenderSpeciesDetermination(pk.Species))
|
||||||
|
{
|
||||||
|
while (!Breeding.IsValidSpeciesBit34(pk.EncryptionConstant, gender))
|
||||||
|
{
|
||||||
|
// Try again.
|
||||||
|
pk.SetPIDGender(gender);
|
||||||
|
pk.SetPIDNature(nature);
|
||||||
|
}
|
||||||
|
}
|
||||||
pk.Nature = nature;
|
pk.Nature = nature;
|
||||||
pk.RefreshAbility(pk.PIDAbility);
|
pk.RefreshAbility(pk.PIDAbility);
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,6 +126,11 @@ public sealed class PIDVerifier : Verifier
|
||||||
// Gen3-5 => Gen6 have PID==EC with an edge case exception.
|
// Gen3-5 => Gen6 have PID==EC with an edge case exception.
|
||||||
if (Info.Generation is 3 or 4 or 5)
|
if (Info.Generation is 3 or 4 or 5)
|
||||||
{
|
{
|
||||||
|
if (Info.Generation is 3 or 4 && Info.EncounterMatch is EncounterEgg egg && Breeding.IsGenderSpeciesDetermination(egg.Species))
|
||||||
|
{
|
||||||
|
if (!Breeding.IsValidSpeciesBit34(pk.EncryptionConstant, pk.Gender))
|
||||||
|
data.AddLine(GetInvalid(LPIDGenderMismatch, CheckIdentifier.EC));
|
||||||
|
}
|
||||||
VerifyTransferEC(data);
|
VerifyTransferEC(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue