From 478413e8cd456b705ca1b176cc0d93d7227cd9e5 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 9 Jul 2023 20:22:01 -0700 Subject: [PATCH] Discard Fairy type Arceus when reversing https://projectpokemon.org/home/forums/topic/63635-pkhex-230709-bugs/ --- .../Evolutions/EvolutionGroup/EvolutionGroup6.cs | 9 ++++++++- PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionGroup/EvolutionGroup6.cs b/PKHeX.Core/Legality/Evolutions/EvolutionGroup/EvolutionGroup6.cs index 1588d6bce..fea06ff16 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionGroup/EvolutionGroup6.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionGroup/EvolutionGroup6.cs @@ -18,7 +18,8 @@ public int Devolve(Span result, PKM pk, EvolutionOrigin enc) int present = 1; for (int i = 1; i < result.Length; i++) { - var prev = result[i - 1]; + ref var prev = ref result[i - 1]; + RevertMutatedForms(ref prev); if (!TryDevolve(prev, pk, prev.LevelMax, enc.LevelMin, enc.SkipChecks, out var evo)) continue; @@ -30,6 +31,12 @@ public int Devolve(Span result, PKM pk, EvolutionOrigin enc) return present; } + private static void RevertMutatedForms(ref EvoCriteria evo) + { + if (evo is { Species: (ushort)Species.Arceus, Form: 17 }) // Fairy, prevent it hitting Gen5 (as Fairy does not exist yet). + evo = evo with { Form = 0 }; // Normal + } + public bool TryDevolve(ISpeciesForm head, PKM pk, byte currentMaxLevel, byte levelMin, bool skipChecks, out EvoCriteria result) { return Tree.Reverse.TryDevolve(head, pk, currentMaxLevel, levelMin, skipChecks, out result); diff --git a/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs b/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs index 2372d3d03..4bde7510b 100644 --- a/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs @@ -413,7 +413,7 @@ private static void VerifyTrade8b(LegalityAnalysis data, EncounterTrade8b t) data.AddLine(GetInvalid(string.Format(LOTLanguage, $"{Japanese}/{German}", $"{(LanguageID)pk.Language}"), CheckIdentifier.Language)); } - if (t.Species == (int)Species.Chatot && pk.Language == (int)French) + if (t.Species == (int)Species.Chatot && pk is { Language: (int)French, IsNicknamed: false }) { // NgWord disallows the French nickname (Pijouk) and resets it back to default (Pijako). // Let it be anything (Nicknamed or not) and just verify the OT.