diff --git a/PKHeX.Core/Legality/Breeding.cs b/PKHeX.Core/Legality/Breeding.cs
index 78066378d..0ae4e412a 100644
--- a/PKHeX.Core/Legality/Breeding.cs
+++ b/PKHeX.Core/Legality/Breeding.cs
@@ -18,11 +18,33 @@ public static class Breeding
(int)Volbeat => true,
(int)Illumise => true,
- (int)Indeedee => true, // male/female
+ (int)Indeedee => true, // male/female form
_ => false,
};
+ ///
+ /// Species that are determined when the egg is received.
+ ///
+ public static bool IsGenderSpeciesDetermination(ushort species) => species switch
+ {
+ (int)NidoranF => true,
+ (int)NidoranM => true,
+
+ (int)Volbeat => true,
+ (int)Illumise => true,
+
+ _ => false,
+ };
+
+ ///
+ /// Checks if the species is valid for the if originated from Gen3/4 daycare eggs.
+ ///
+ /// Encryption Constant
+ /// Gender
+ /// True if valid
+ public static bool IsValidSpeciesBit34(uint ec, byte gender) => gender != (ec & 0x8000) >> 15; // 1 = Male, 0 = Female, valid if different from Gender value.
+
///
/// Checks if the can be born with inherited moves from the parents.
///
diff --git a/PKHeX.Core/Legality/Encounters/Templates/Shared/EncounterEgg.cs b/PKHeX.Core/Legality/Encounters/Templates/Shared/EncounterEgg.cs
index 4854298d7..ff699c4cb 100644
--- a/PKHeX.Core/Legality/Encounters/Templates/Shared/EncounterEgg.cs
+++ b/PKHeX.Core/Legality/Encounters/Templates/Shared/EncounterEgg.cs
@@ -134,6 +134,15 @@ private static void SetPINGA(PKM pk, EncounterCriteria criteria)
pk.SetPIDGender(gender);
pk.Gender = gender;
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.RefreshAbility(pk.PIDAbility);
}
diff --git a/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs b/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs
index 8395e8060..7b6c61d50 100644
--- a/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs
@@ -126,6 +126,11 @@ private static void VerifyEC(LegalityAnalysis data)
// 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 && Info.EncounterMatch is EncounterEgg egg && Breeding.IsGenderSpeciesDetermination(egg.Species))
+ {
+ if (!Breeding.IsValidSpeciesBit34(pk.EncryptionConstant, pk.Gender))
+ data.AddLine(GetInvalid(LPIDGenderMismatch, CheckIdentifier.EC));
+ }
VerifyTransferEC(data);
return;
}