mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Update shiny-type preserving from faketid
Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com>
This commit is contained in:
parent
0fe80edb37
commit
3f5c01a0b8
1 changed files with 17 additions and 10 deletions
|
@ -231,20 +231,27 @@
|
|||
private static uint GetRevisedPID(uint fakeTID, uint pid, ITrainerID tr)
|
||||
{
|
||||
var xor = GetShinyXor(pid, fakeTID);
|
||||
var newXor = GetShinyXor(pid, (uint)(tr.TID | (tr.SID << 16)));
|
||||
|
||||
var fakeRare = GetRareType(xor);
|
||||
var newRare = GetRareType(newXor);
|
||||
|
||||
if (fakeRare == newRare)
|
||||
return pid;
|
||||
|
||||
var isShiny = xor < 16;
|
||||
if (isShiny)
|
||||
{
|
||||
if (!GetIsShiny(tr.TID, tr.SID, pid))
|
||||
return (((uint)(tr.TID ^ tr.SID) ^ (pid & 0xFFFF) ^ (xor == 0 ? 0u : 1u)) << 16) | (pid & 0xFFFF); // force same shiny star type
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetIsShiny(tr.TID, tr.SID, pid))
|
||||
return pid ^ 0x1000_0000;
|
||||
}
|
||||
return pid;
|
||||
return (((uint)(tr.TID ^ tr.SID) ^ (pid & 0xFFFF) ^ (xor == 0 ? 0u : 1u)) << 16) | (pid & 0xFFFF); // force same shiny star type
|
||||
return pid ^ 0x1000_0000;
|
||||
}
|
||||
|
||||
private static Shiny GetRareType(uint xor) => xor switch
|
||||
{
|
||||
0 => Shiny.AlwaysSquare,
|
||||
< 16 => Shiny.AlwaysStar,
|
||||
_ => Shiny.Never,
|
||||
};
|
||||
|
||||
private static bool GetIsShiny(int tid, int sid, uint pid)
|
||||
{
|
||||
return GetIsShiny(pid, (uint)((sid << 16) | tid));
|
||||
|
|
Loading…
Add table
Reference in a new issue