mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 06:20:25 +00:00
Force PID for shiny ponyta
This commit is contained in:
parent
ea327a5c03
commit
07b3efd14d
2 changed files with 50 additions and 0 deletions
|
@ -59,6 +59,18 @@ public sealed record EncounterStatic8a(GameVersion Version) : EncounterStatic(Ve
|
|||
pk.SetRandomEC();
|
||||
}
|
||||
|
||||
protected override void SetPINGA(PKM pk, EncounterCriteria criteria)
|
||||
{
|
||||
var pi = pk.PersonalInfo;
|
||||
int gender = criteria.GetGender(Gender, pi);
|
||||
int nature = (int)criteria.GetNature(Nature);
|
||||
int ability = criteria.GetAbilityFromNumber(Ability);
|
||||
PIDGenerator.SetRandomWildPID(pk, pk.Format, nature, ability, gender);
|
||||
pk.PID = Overworld8aRNG.AdaptPID(pk, Shiny, pk.PID);
|
||||
SetIVs(pk);
|
||||
pk.StatNature = pk.Nature;
|
||||
}
|
||||
|
||||
protected override void ApplyDetailsBall(PKM pk) => pk.Ball = Gift ? Ball : (int)Core.Ball.LAPoke;
|
||||
|
||||
public override bool IsMatchExact(PKM pkm, DexLevel evo)
|
||||
|
|
38
PKHeX.Core/Legality/RNG/Overworld8aRNG.cs
Normal file
38
PKHeX.Core/Legality/RNG/Overworld8aRNG.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
namespace PKHeX.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Contains logic for the Generation 8 (Legends: Arceus) overworld spawns that walk around the overworld.
|
||||
/// </summary>
|
||||
public static class Overworld8aRNG
|
||||
{
|
||||
public static uint AdaptPID(PKM pk, Shiny shiny, uint pid)
|
||||
{
|
||||
if (shiny == Shiny.Never)
|
||||
{
|
||||
if (GetIsShiny(pk.TID, pk.SID, pid))
|
||||
pid ^= 0x1000_0000;
|
||||
}
|
||||
else if (shiny != Shiny.Random)
|
||||
{
|
||||
if (!GetIsShiny(pk.TID, pk.SID, pid))
|
||||
pid = GetShinyPID(pk.TID, pk.SID, pid, 0);
|
||||
}
|
||||
return pid;
|
||||
}
|
||||
|
||||
private static uint GetShinyPID(int tid, int sid, uint pid, int type)
|
||||
{
|
||||
return (uint)(((tid ^ sid ^ (pid & 0xFFFF) ^ type) << 16) | (pid & 0xFFFF));
|
||||
}
|
||||
|
||||
private static bool GetIsShiny(int tid, int sid, uint pid)
|
||||
{
|
||||
return GetShinyXor(pid, (uint)((sid << 16) | tid)) < 16;
|
||||
}
|
||||
|
||||
private static uint GetShinyXor(uint pid, uint oid)
|
||||
{
|
||||
var xor = pid ^ oid;
|
||||
return (xor ^ (xor >> 16)) & 0xFFFF;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue