Force shiny state of raids

Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com>
This commit is contained in:
Kurt 2021-06-03 17:50:48 -07:00
parent 5636e1ef4a
commit 64039b4070
2 changed files with 20 additions and 10 deletions

View file

@ -110,6 +110,9 @@ namespace PKHeX.Core
if (pk.Nature != pk.StatNature && ((Nature)pk.StatNature).IsNeutral()) if (pk.Nature != pk.StatNature && ((Nature)pk.StatNature).IsNeutral())
pk.StatNature = (int)Nature.Serious; pk.StatNature = (int)Nature.Serious;
} }
var pid = pk.PID;
RaidRNG.ForceShinyState(pk, Shiny == Shiny.Always, ref pid);
pk.PID = pid;
} }
} }
} }

View file

@ -1,4 +1,5 @@
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
namespace PKHeX.Core namespace PKHeX.Core
{ {
@ -59,16 +60,7 @@ namespace PKHeX.Core
isShiny = shiny == Shiny.Always; isShiny = shiny == Shiny.Always;
} }
if (isShiny) ForceShinyState(pk, isShiny, ref pid);
{
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;
}
if (pk.PID != pid) if (pk.PID != pid)
return false; return false;
@ -181,6 +173,21 @@ namespace PKHeX.Core
return true; 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) 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); var rng = new Xoroshiro128Plus(seed);