From 64039b40700c8f00ccf9a3de68dded34b5f11ff3 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 3 Jun 2021 17:50:48 -0700 Subject: [PATCH] Force shiny state of raids Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com> --- .../EncounterStatic/EncounterStatic8Nest.cs | 3 +++ PKHeX.Core/Legality/RNG/RaidRNG.cs | 27 ++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs index b1143a046..f860d8d0a 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs @@ -110,6 +110,9 @@ namespace PKHeX.Core if (pk.Nature != pk.StatNature && ((Nature)pk.StatNature).IsNeutral()) pk.StatNature = (int)Nature.Serious; } + var pid = pk.PID; + RaidRNG.ForceShinyState(pk, Shiny == Shiny.Always, ref pid); + pk.PID = pid; } } } diff --git a/PKHeX.Core/Legality/RNG/RaidRNG.cs b/PKHeX.Core/Legality/RNG/RaidRNG.cs index 09ff0d8a5..2fc89aef4 100644 --- a/PKHeX.Core/Legality/RNG/RaidRNG.cs +++ b/PKHeX.Core/Legality/RNG/RaidRNG.cs @@ -1,4 +1,5 @@ using System.Linq; +using System.Runtime.CompilerServices; namespace PKHeX.Core { @@ -59,16 +60,7 @@ namespace PKHeX.Core isShiny = shiny == Shiny.Always; } - if (isShiny) - { - if (!GetIsShiny(pk.TID, pk.SID, pid)) - pid = GetShinyPID(pk.TID, pk.SID, pid, 0); - } - else - { - if (GetIsShiny(pk.TID, pk.SID, pid)) - pid ^= 0x1000_0000; - } + ForceShinyState(pk, isShiny, ref pid); if (pk.PID != pid) return false; @@ -181,6 +173,21 @@ namespace PKHeX.Core return true; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void ForceShinyState(PKM pk, bool isShiny, ref uint pid) + { + if (isShiny) + { + if (!GetIsShiny(pk.TID, pk.SID, pid)) + pid = GetShinyPID(pk.TID, pk.SID, pid, 0); + } + else + { + if (GetIsShiny(pk.TID, pk.SID, pid)) + pid ^= 0x1000_0000; + } + } + private static bool ApplyDetailsTo(PKM pk, ulong seed, int[] ivs, int iv_count, int ability_param, int gender_ratio, sbyte nature_param = -1, Shiny shiny = Shiny.Random) { var rng = new Xoroshiro128Plus(seed);