mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-08-28 04:06:35 -05:00
Fixes gen 5 force-shiny generation. (#1052)
Replicates the ingame PID generation for Forced Shiny
This commit is contained in:
@@ -14,7 +14,7 @@ public PGF(byte[] data = null)
|
||||
if (data == null) Data = new byte[Size];
|
||||
else Data = (byte[])data.Clone();
|
||||
}
|
||||
|
||||
|
||||
public ushort TID { get { return BitConverter.ToUInt16(Data, 0x00); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x00); } }
|
||||
public ushort SID { get { return BitConverter.ToUInt16(Data, 0x02); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x02); } }
|
||||
public int OriginGame { get { return Data[0x04]; } set { Data[0x04] = (byte)value; } }
|
||||
@@ -89,7 +89,7 @@ public override string CardTitle
|
||||
|
||||
// Card Attributes
|
||||
public override int Item { get { return BitConverter.ToUInt16(Data, 0x00); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x00); } }
|
||||
|
||||
|
||||
private ushort Year { get { return BitConverter.ToUInt16(Data, 0xAE); } set { BitConverter.GetBytes(value).CopyTo(Data, 0xAE); } }
|
||||
private byte Month { get { return Data[0xAD]; } set { Data[0xAD] = value; } }
|
||||
private byte Day { get { return Data[0xAC]; } set { Data[0xAC] = value; } }
|
||||
@@ -137,7 +137,7 @@ public override int CardID
|
||||
public int CardType { get { return Data[0xB3]; } set { Data[0xB3] = (byte)value; } }
|
||||
public override bool GiftUsed { get { return Data[0xB4] >> 1 > 0; } set { Data[0xB4] = (byte)(Data[0xB4] & ~2 | (value ? 2 : 0)); } }
|
||||
public bool MultiObtain { get { return Data[0xB4] == 1; } set { Data[0xB4] = (byte)(value ? 1 : 0); } }
|
||||
|
||||
|
||||
// Meta Accessible Properties
|
||||
public int[] IVs => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD };
|
||||
public bool IsNicknamed => Nickname.Length > 0;
|
||||
@@ -253,20 +253,24 @@ public override PKM convertToPKM(SaveFile SAV)
|
||||
pk.HiddenAbility = av == 2;
|
||||
pk.Ability = PersonalTable.B2W2.getAbilities(Species, pk.AltForm)[av];
|
||||
|
||||
if (PID != 0)
|
||||
if (PID != 0)
|
||||
pk.PID = PID;
|
||||
else
|
||||
{
|
||||
pk.PID = Util.rnd32();
|
||||
// Force Ability
|
||||
if (av == 0) pk.PID &= 0xFFFEFFFF; else pk.PID |= 0x10000;
|
||||
|
||||
// Force Gender
|
||||
do { pk.PID = (pk.PID & 0xFFFFFF00) | Util.rnd32() & 0xFF; } while (!pk.getGenderIsValid());
|
||||
|
||||
if (PIDType == 2) // Force Shiny
|
||||
{
|
||||
uint gb = pk.PID & 0xFF;
|
||||
pk.PID = (uint)(((gb ^ pk.TID ^ pk.SID) & 0xFFFE) << 16) | gb;
|
||||
if (av == 0) pk.PID &= 0xFFFEFFFE; else pk.PID |= 0x10001;
|
||||
|
||||
pk.PID = (uint)((gb ^ pk.TID ^ pk.SID) << 16) | gb;
|
||||
|
||||
if (av == 1) pk.PID |= 0x10000; else pk.PID &= 0xFFFEFFFF;
|
||||
}
|
||||
else if (PIDType != 1) // Force Not Shiny
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user