2015-12-23 05:14:50 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.Core
|
2015-12-23 05:14:50 +00:00
|
|
|
|
{
|
2017-06-20 04:43:44 +00:00
|
|
|
|
public sealed class PGF : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4
|
2015-12-23 05:14:50 +00:00
|
|
|
|
{
|
2017-03-19 23:19:59 +00:00
|
|
|
|
public const int Size = 0xCC;
|
2016-09-04 17:38:53 +00:00
|
|
|
|
public override int Format => 5;
|
2015-12-23 05:14:50 +00:00
|
|
|
|
|
|
|
|
|
public PGF(byte[] data = null)
|
|
|
|
|
{
|
2016-06-20 04:22:43 +00:00
|
|
|
|
Data = (byte[])(data?.Clone() ?? new byte[Size]);
|
|
|
|
|
if (data == null) Data = new byte[Size];
|
|
|
|
|
else Data = (byte[])data.Clone();
|
2015-12-23 05:14:50 +00:00
|
|
|
|
}
|
2017-04-11 21:07:16 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public ushort TID { get => BitConverter.ToUInt16(Data, 0x00); set => BitConverter.GetBytes(value).CopyTo(Data, 0x00); }
|
|
|
|
|
public ushort SID { get => BitConverter.ToUInt16(Data, 0x02); set => BitConverter.GetBytes(value).CopyTo(Data, 0x02); }
|
|
|
|
|
public int OriginGame { get => Data[0x04]; set => Data[0x04] = (byte)value; }
|
2015-12-25 22:07:17 +00:00
|
|
|
|
// Unused 0x05 0x06, 0x07
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public uint PID { get => BitConverter.ToUInt32(Data, 0x08); set => BitConverter.GetBytes(value).CopyTo(Data, 0x08); }
|
2015-12-23 05:14:50 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
private byte RIB0 { get => Data[0x0C]; set => Data[0x0C] = value; }
|
|
|
|
|
public bool RibbonCountry { get => (RIB0 & (1 << 0)) == 1 << 0; set => RIB0 = (byte)(RIB0 & ~(1 << 0) | (value ? 1 << 0 : 0)); } // Country Ribbon
|
|
|
|
|
public bool RibbonNational { get => (RIB0 & (1 << 1)) == 1 << 1; set => RIB0 = (byte)(RIB0 & ~(1 << 1) | (value ? 1 << 1 : 0)); } // National Ribbon
|
|
|
|
|
public bool RibbonEarth { get => (RIB0 & (1 << 2)) == 1 << 2; set => RIB0 = (byte)(RIB0 & ~(1 << 2) | (value ? 1 << 2 : 0)); } // Earth Ribbon
|
|
|
|
|
public bool RibbonWorld { get => (RIB0 & (1 << 3)) == 1 << 3; set => RIB0 = (byte)(RIB0 & ~(1 << 3) | (value ? 1 << 3 : 0)); } // World Ribbon
|
|
|
|
|
public bool RibbonClassic { get => (RIB0 & (1 << 4)) == 1 << 4; set => RIB0 = (byte)(RIB0 & ~(1 << 4) | (value ? 1 << 4 : 0)); } // Classic Ribbon
|
|
|
|
|
public bool RibbonPremier { get => (RIB0 & (1 << 5)) == 1 << 5; set => RIB0 = (byte)(RIB0 & ~(1 << 5) | (value ? 1 << 5 : 0)); } // Premier Ribbon
|
|
|
|
|
public bool RibbonEvent { get => (RIB0 & (1 << 6)) == 1 << 6; set => RIB0 = (byte)(RIB0 & ~(1 << 6) | (value ? 1 << 6 : 0)); } // Event Ribbon
|
|
|
|
|
public bool RibbonBirthday { get => (RIB0 & (1 << 7)) == 1 << 7; set => RIB0 = (byte)(RIB0 & ~(1 << 7) | (value ? 1 << 7 : 0)); } // Birthday Ribbon
|
|
|
|
|
private byte RIB1 { get => Data[0x0D]; set => Data[0x0D] = value; }
|
|
|
|
|
public bool RibbonSpecial { get => (RIB1 & (1 << 0)) == 1 << 0; set => RIB1 = (byte)(RIB1 & ~(1 << 0) | (value ? 1 << 0 : 0)); } // Special Ribbon
|
|
|
|
|
public bool RibbonSouvenir { get => (RIB1 & (1 << 1)) == 1 << 1; set => RIB1 = (byte)(RIB1 & ~(1 << 1) | (value ? 1 << 1 : 0)); } // Souvenir Ribbon
|
|
|
|
|
public bool RibbonWishing { get => (RIB1 & (1 << 2)) == 1 << 2; set => RIB1 = (byte)(RIB1 & ~(1 << 2) | (value ? 1 << 2 : 0)); } // Wishing Ribbon
|
|
|
|
|
public bool RibbonChampionBattle { get => (RIB1 & (1 << 3)) == 1 << 3; set => RIB1 = (byte)(RIB1 & ~(1 << 3) | (value ? 1 << 3 : 0)); } // Battle Champ Ribbon
|
|
|
|
|
public bool RibbonChampionRegional { get => (RIB1 & (1 << 4)) == 1 << 4; set => RIB1 = (byte)(RIB1 & ~(1 << 4) | (value ? 1 << 4 : 0)); } // Regional Champ Ribbon
|
|
|
|
|
public bool RibbonChampionNational { get => (RIB1 & (1 << 5)) == 1 << 5; set => RIB1 = (byte)(RIB1 & ~(1 << 5) | (value ? 1 << 5 : 0)); } // National Champ Ribbon
|
|
|
|
|
public bool RibbonChampionWorld { get => (RIB1 & (1 << 6)) == 1 << 6; set => RIB1 = (byte)(RIB1 & ~(1 << 6) | (value ? 1 << 6 : 0)); } // World Champ Ribbon
|
|
|
|
|
public bool RIB1_7 { get => (RIB1 & (1 << 7)) == 1 << 7; set => RIB1 = (byte)(RIB1 & ~(1 << 7) | (value ? 1 << 7 : 0)); } // Empty
|
2015-12-23 05:14:50 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public override int Ball { get => Data[0x0E]; set => Data[0x0E] = (byte)value; }
|
|
|
|
|
public override int HeldItem { get => BitConverter.ToUInt16(Data, 0x10); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x10); }
|
|
|
|
|
public int Move1 { get => BitConverter.ToUInt16(Data, 0x12); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x12); }
|
|
|
|
|
public int Move2 { get => BitConverter.ToUInt16(Data, 0x14); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x14); }
|
|
|
|
|
public int Move3 { get => BitConverter.ToUInt16(Data, 0x16); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x16); }
|
|
|
|
|
public int Move4 { get => BitConverter.ToUInt16(Data, 0x18); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x18); }
|
|
|
|
|
public override int Species { get => BitConverter.ToUInt16(Data, 0x1A); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1A); }
|
|
|
|
|
public int Form { get => Data[0x1C]; set => Data[0x1C] = (byte)value; }
|
|
|
|
|
public int Language { get => Data[0x1D]; set => Data[0x1D] = (byte)value; }
|
2015-12-23 05:14:50 +00:00
|
|
|
|
public string Nickname
|
|
|
|
|
{
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => PKX.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x1E, 0x16));
|
|
|
|
|
set => Encoding.Unicode.GetBytes(value.PadRight(0xB, (char)0xFFFF)).CopyTo(Data, 0x1E);
|
2015-12-23 05:14:50 +00:00
|
|
|
|
}
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public int Nature { get => Data[0x34]; set => Data[0x34] = (byte)value; }
|
|
|
|
|
public int Gender { get => Data[0x35]; set => Data[0x35] = (byte)value; }
|
|
|
|
|
public int AbilityType { get => Data[0x36]; set => Data[0x36] = (byte)value; }
|
|
|
|
|
public int PIDType { get => Data[0x37]; set => Data[0x37] = (byte)value; }
|
|
|
|
|
public ushort EggLocation { get => BitConverter.ToUInt16(Data, 0x38); set => BitConverter.GetBytes(value).CopyTo(Data, 0x38); }
|
|
|
|
|
public ushort MetLocation { get => BitConverter.ToUInt16(Data, 0x3A); set => BitConverter.GetBytes(value).CopyTo(Data, 0x3A); }
|
|
|
|
|
public int MetLevel { get => Data[0x3C]; set => Data[0x3C] = (byte)value; }
|
|
|
|
|
public int CNT_Cool { get => Data[0x3D]; set => Data[0x3D] = (byte)value; }
|
|
|
|
|
public int CNT_Beauty { get => Data[0x3E]; set => Data[0x3E] = (byte)value; }
|
|
|
|
|
public int CNT_Cute { get => Data[0x3F]; set => Data[0x3F] = (byte)value; }
|
|
|
|
|
public int CNT_Smart { get => Data[0x40]; set => Data[0x40] = (byte)value; }
|
|
|
|
|
public int CNT_Tough { get => Data[0x41]; set => Data[0x41] = (byte)value; }
|
|
|
|
|
public int CNT_Sheen { get => Data[0x42]; set => Data[0x42] = (byte)value; }
|
|
|
|
|
public int IV_HP { get => Data[0x43]; set => Data[0x43] = (byte)value; }
|
|
|
|
|
public int IV_ATK { get => Data[0x44]; set => Data[0x44] = (byte)value; }
|
|
|
|
|
public int IV_DEF { get => Data[0x45]; set => Data[0x45] = (byte)value; }
|
|
|
|
|
public int IV_SPE { get => Data[0x46]; set => Data[0x46] = (byte)value; }
|
|
|
|
|
public int IV_SPA { get => Data[0x47]; set => Data[0x47] = (byte)value; }
|
|
|
|
|
public int IV_SPD { get => Data[0x48]; set => Data[0x48] = (byte)value; }
|
2015-12-23 05:14:50 +00:00
|
|
|
|
// Unused 0x49
|
|
|
|
|
public string OT {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => PKX.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x4A, 0x10));
|
|
|
|
|
set => Encoding.Unicode.GetBytes(value.PadRight(0x08, (char)0xFFFF)).CopyTo(Data, 0x4A); }
|
|
|
|
|
public int OTGender { get => Data[0x5A]; set => Data[0x5A] = (byte)value; }
|
|
|
|
|
public override int Level { get => Data[0x5B]; set => Data[0x5C] = (byte)value; }
|
|
|
|
|
public override bool IsEgg { get => Data[0x5C] == 1; set => Data[0x5C] = (byte)(value ? 1 : 0); }
|
2015-12-23 05:14:50 +00:00
|
|
|
|
// Unused 0x5D 0x5E 0x5F
|
2016-06-20 04:22:43 +00:00
|
|
|
|
public override string CardTitle
|
|
|
|
|
{
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => PKX.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x60, 0x4A));
|
|
|
|
|
set => Encoding.Unicode.GetBytes((value + '\uFFFF').PadRight(0x4A / 2, '\0')).CopyTo(Data, 0x60);
|
2016-06-20 04:22:43 +00:00
|
|
|
|
}
|
2015-12-23 05:14:50 +00:00
|
|
|
|
|
|
|
|
|
// Card Attributes
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override int ItemID { get => BitConverter.ToUInt16(Data, 0x00); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x00); }
|
2017-04-11 21:07:16 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
private ushort Year { get => BitConverter.ToUInt16(Data, 0xAE); set => BitConverter.GetBytes(value).CopyTo(Data, 0xAE); }
|
|
|
|
|
private byte Month { get => Data[0xAD]; set => Data[0xAD] = value; }
|
|
|
|
|
private byte Day { get => Data[0xAC]; set => Data[0xAC] = value; }
|
2016-08-10 14:02:31 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the date of the card.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DateTime? Date
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
// Check to see if date is valid
|
2016-08-13 00:16:03 +00:00
|
|
|
|
if (!Util.IsDateValid(Year, Month, Day))
|
2016-08-10 14:02:31 +00:00
|
|
|
|
return null;
|
2016-08-13 00:16:03 +00:00
|
|
|
|
|
|
|
|
|
return new DateTime(Year, Month, Day);
|
2016-08-10 14:02:31 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value.HasValue)
|
|
|
|
|
{
|
|
|
|
|
// Only update the properties if a value is provided.
|
2016-08-13 00:16:03 +00:00
|
|
|
|
Year = (ushort)value.Value.Year;
|
2016-08-10 14:02:31 +00:00
|
|
|
|
Month = (byte)value.Value.Month;
|
|
|
|
|
Day = (byte)value.Value.Day;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Clear the Met Date.
|
|
|
|
|
// If code tries to access MetDate again, null will be returned.
|
|
|
|
|
Year = 0;
|
|
|
|
|
Month = 0;
|
|
|
|
|
Day = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-06-20 04:22:43 +00:00
|
|
|
|
public override int CardID
|
2015-12-23 05:14:50 +00:00
|
|
|
|
{
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0xB0);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xB0);
|
2015-12-23 05:14:50 +00:00
|
|
|
|
}
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public int CardLocation { get => Data[0xB2]; set => Data[0xB2] = (byte)value; }
|
|
|
|
|
public int CardType { get => Data[0xB3]; set => Data[0xB3] = (byte)value; }
|
|
|
|
|
public override bool GiftUsed { get => Data[0xB4] >> 1 > 0; set => Data[0xB4] = (byte)(Data[0xB4] & ~2 | (value ? 2 : 0)); }
|
|
|
|
|
public bool MultiObtain { get => Data[0xB4] == 1; set => Data[0xB4] = (byte)(value ? 1 : 0); }
|
2017-04-11 21:07:16 +00:00
|
|
|
|
|
2015-12-23 05:14:50 +00:00
|
|
|
|
// Meta Accessible Properties
|
2016-01-17 21:27:24 +00:00
|
|
|
|
public int[] IVs => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD };
|
|
|
|
|
public bool IsNicknamed => Nickname.Length > 0;
|
2017-06-04 01:40:44 +00:00
|
|
|
|
public override bool IsShiny => PIDType == 2;
|
2016-01-17 21:27:24 +00:00
|
|
|
|
|
2017-01-05 06:25:45 +00:00
|
|
|
|
public override int[] Moves => new[] { Move1, Move2, Move3, Move4 };
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public override bool IsPokémon { get => CardType == 1; set { if (value) CardType = 1; } }
|
|
|
|
|
public override bool IsItem { get => CardType == 2; set { if (value) CardType = 2; } }
|
|
|
|
|
public bool IsPower { get => CardType == 3; set { if (value) CardType = 3; } }
|
2015-12-23 05:14:50 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override PKM ConvertToPKM(SaveFile SAV)
|
2015-12-23 05:14:50 +00:00
|
|
|
|
{
|
|
|
|
|
if (!IsPokémon)
|
|
|
|
|
return null;
|
|
|
|
|
|
2015-12-25 22:07:17 +00:00
|
|
|
|
DateTime dt = DateTime.Now;
|
|
|
|
|
if (Day == 0)
|
|
|
|
|
{
|
|
|
|
|
Day = (byte)dt.Day;
|
|
|
|
|
Month = (byte)dt.Month;
|
|
|
|
|
Year = (byte)dt.Year;
|
|
|
|
|
}
|
2017-06-18 01:37:19 +00:00
|
|
|
|
int currentLevel = Level > 0 ? Level : (int)(Util.Rand32() % 100 + 1);
|
|
|
|
|
var pi = PersonalTable.B2W2.GetFormeEntry(Species, Form);
|
2015-12-23 05:14:50 +00:00
|
|
|
|
PK5 pk = new PK5
|
|
|
|
|
{
|
|
|
|
|
Species = Species,
|
|
|
|
|
HeldItem = HeldItem,
|
|
|
|
|
Met_Level = currentLevel,
|
2017-06-18 01:37:19 +00:00
|
|
|
|
Nature = Nature != 0xFF ? Nature : (int)(Util.Rand32() % 25),
|
2017-05-17 03:34:24 +00:00
|
|
|
|
Gender = pi.Gender == 255 ? 2 : (Gender != 2 ? Gender : pi.RandomGender),
|
2015-12-23 05:14:50 +00:00
|
|
|
|
AltForm = Form,
|
2017-06-18 01:37:19 +00:00
|
|
|
|
Version = OriginGame == 0 ? new[] {20, 21, 22, 23}[Util.Rand32() & 0x3] : OriginGame,
|
2015-12-23 05:14:50 +00:00
|
|
|
|
Language = Language == 0 ? SAV.Language : Language,
|
2016-10-23 19:48:49 +00:00
|
|
|
|
Ball = Ball,
|
2015-12-23 05:14:50 +00:00
|
|
|
|
Move1 = Move1,
|
|
|
|
|
Move2 = Move2,
|
|
|
|
|
Move3 = Move3,
|
|
|
|
|
Move4 = Move4,
|
|
|
|
|
Met_Location = MetLocation,
|
2016-08-10 14:02:31 +00:00
|
|
|
|
MetDate = Date,
|
2015-12-23 05:14:50 +00:00
|
|
|
|
Egg_Location = EggLocation,
|
|
|
|
|
CNT_Cool = CNT_Cool,
|
|
|
|
|
CNT_Beauty = CNT_Beauty,
|
|
|
|
|
CNT_Cute = CNT_Cute,
|
|
|
|
|
CNT_Smart = CNT_Smart,
|
|
|
|
|
CNT_Tough = CNT_Tough,
|
|
|
|
|
CNT_Sheen = CNT_Sheen,
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
EXP = PKX.GetEXP(Level, Species),
|
2015-12-23 05:14:50 +00:00
|
|
|
|
|
|
|
|
|
// Ribbons
|
2016-07-16 22:52:33 +00:00
|
|
|
|
RibbonCountry = RibbonCountry,
|
|
|
|
|
RibbonNational = RibbonNational,
|
|
|
|
|
RibbonEarth = RibbonEarth,
|
|
|
|
|
RibbonWorld = RibbonWorld,
|
|
|
|
|
RibbonClassic = RibbonClassic,
|
|
|
|
|
RibbonPremier = RibbonPremier,
|
|
|
|
|
RibbonEvent = RibbonEvent,
|
|
|
|
|
RibbonBirthday = RibbonBirthday,
|
2015-12-25 22:07:17 +00:00
|
|
|
|
|
2016-07-16 22:52:33 +00:00
|
|
|
|
RibbonSpecial = RibbonSpecial,
|
|
|
|
|
RibbonSouvenir = RibbonSouvenir,
|
|
|
|
|
RibbonWishing = RibbonWishing,
|
|
|
|
|
RibbonChampionBattle = RibbonChampionBattle,
|
|
|
|
|
RibbonChampionRegional = RibbonChampionRegional,
|
|
|
|
|
RibbonChampionNational = RibbonChampionNational,
|
|
|
|
|
RibbonChampionWorld = RibbonChampionWorld,
|
2015-12-23 05:14:50 +00:00
|
|
|
|
|
|
|
|
|
FatefulEncounter = true,
|
|
|
|
|
};
|
2017-06-18 01:37:19 +00:00
|
|
|
|
pk.Move1_PP = pk.GetMovePP(Move1, 0);
|
|
|
|
|
pk.Move2_PP = pk.GetMovePP(Move2, 0);
|
|
|
|
|
pk.Move3_PP = pk.GetMovePP(Move3, 0);
|
|
|
|
|
pk.Move4_PP = pk.GetMovePP(Move4, 0);
|
2017-07-15 05:50:12 +00:00
|
|
|
|
if (IsEgg) // User's
|
2015-12-23 05:14:50 +00:00
|
|
|
|
{
|
2016-06-20 04:22:43 +00:00
|
|
|
|
pk.TID = SAV.TID;
|
|
|
|
|
pk.SID = SAV.SID;
|
|
|
|
|
pk.OT_Name = SAV.OT;
|
2015-12-25 22:07:17 +00:00
|
|
|
|
pk.OT_Gender = 1; // Red PKHeX OT
|
|
|
|
|
}
|
2017-07-15 05:50:12 +00:00
|
|
|
|
else // Hardcoded
|
2015-12-25 22:07:17 +00:00
|
|
|
|
{
|
2017-07-15 05:50:12 +00:00
|
|
|
|
pk.TID = TID;
|
|
|
|
|
pk.SID = SID;
|
|
|
|
|
pk.OT_Name = OT;
|
|
|
|
|
pk.OT_Gender = (OTGender == 3 ? SAV.Gender : OTGender) & 1; // some events have variable gender based on receiving SaveFile
|
2015-12-23 05:14:50 +00:00
|
|
|
|
}
|
|
|
|
|
pk.IsNicknamed = IsNicknamed;
|
2017-06-21 05:53:39 +00:00
|
|
|
|
pk.Nickname = IsNicknamed ? Nickname : PKX.GetSpeciesNameGeneration(Species, pk.Language, Format);
|
2015-12-23 05:14:50 +00:00
|
|
|
|
|
|
|
|
|
// More 'complex' logic to determine final values
|
|
|
|
|
|
|
|
|
|
// Dumb way to generate random IVs.
|
2015-12-25 22:07:17 +00:00
|
|
|
|
int[] finalIVs = new int[6];
|
2015-12-23 05:14:50 +00:00
|
|
|
|
for (int i = 0; i < IVs.Length; i++)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
finalIVs[i] = IVs[i] == 0xFF ? (int)(Util.Rand32() & 0x1F) : IVs[i];
|
2015-12-25 22:07:17 +00:00
|
|
|
|
pk.IVs = finalIVs;
|
2015-12-23 05:14:50 +00:00
|
|
|
|
|
|
|
|
|
int av = 0;
|
|
|
|
|
switch (AbilityType)
|
|
|
|
|
{
|
|
|
|
|
case 00: // 0 - 0
|
|
|
|
|
case 01: // 1 - 1
|
|
|
|
|
case 02: // 2 - H
|
|
|
|
|
av = AbilityType;
|
|
|
|
|
break;
|
|
|
|
|
case 03: // 0/1
|
|
|
|
|
case 04: // 0/1/H
|
2017-06-18 01:37:19 +00:00
|
|
|
|
av = (int)(Util.Rand32() % (AbilityType - 1));
|
2015-12-23 05:14:50 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2015-12-27 05:17:23 +00:00
|
|
|
|
pk.HiddenAbility = av == 2;
|
2017-05-17 03:34:24 +00:00
|
|
|
|
pk.Ability = pi.Abilities[av];
|
2015-12-23 05:14:50 +00:00
|
|
|
|
|
2017-04-11 21:07:16 +00:00
|
|
|
|
if (PID != 0)
|
2015-12-26 02:17:47 +00:00
|
|
|
|
pk.PID = PID;
|
|
|
|
|
else
|
2015-12-23 05:14:50 +00:00
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
pk.PID = Util.Rand32();
|
2017-04-11 21:07:16 +00:00
|
|
|
|
|
2015-12-26 02:17:47 +00:00
|
|
|
|
// Force Gender
|
2017-06-18 01:37:19 +00:00
|
|
|
|
do { pk.PID = (pk.PID & 0xFFFFFF00) | Util.Rand32() & 0xFF; } while (!pk.IsGenderValid());
|
2017-06-04 01:40:44 +00:00
|
|
|
|
|
|
|
|
|
// Force Ability
|
|
|
|
|
if (av == 1) pk.PID |= 0x10000; else pk.PID &= 0xFFFEFFFF;
|
2017-04-11 21:07:16 +00:00
|
|
|
|
|
2015-12-26 02:17:47 +00:00
|
|
|
|
if (PIDType == 2) // Force Shiny
|
|
|
|
|
{
|
|
|
|
|
uint gb = pk.PID & 0xFF;
|
2017-04-11 21:07:16 +00:00
|
|
|
|
pk.PID = (uint)((gb ^ pk.TID ^ pk.SID) << 16) | gb;
|
2017-06-04 01:40:44 +00:00
|
|
|
|
// double check forced ability
|
|
|
|
|
if (av == 1) pk.PID |= 0x10001; else pk.PID &= 0xFFFEFFFE;
|
2015-12-26 02:17:47 +00:00
|
|
|
|
}
|
|
|
|
|
else if (PIDType != 1) // Force Not Shiny
|
|
|
|
|
{
|
|
|
|
|
if (((pk.PID >> 16) ^ (pk.PID & 0xffff) ^ pk.SID ^ pk.TID) < 8)
|
2017-04-11 21:16:28 +00:00
|
|
|
|
pk.PID ^= 0x10000000;
|
2015-12-26 02:17:47 +00:00
|
|
|
|
}
|
2015-12-23 05:14:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsEgg)
|
|
|
|
|
{
|
2017-07-14 04:05:20 +00:00
|
|
|
|
pk.IsEgg = true;
|
2016-08-10 14:02:31 +00:00
|
|
|
|
pk.EggMetDate = Date;
|
2017-07-14 04:05:20 +00:00
|
|
|
|
pk.Nickname = PKX.GetSpeciesNameGeneration(0, pk.Language, Format);
|
|
|
|
|
pk.IsNicknamed = true;
|
2015-12-23 05:14:50 +00:00
|
|
|
|
}
|
2017-07-14 04:05:20 +00:00
|
|
|
|
pk.CurrentFriendship = pk.IsEgg ? pi.HatchCycles : pi.BaseFriendship;
|
2015-12-23 05:14:50 +00:00
|
|
|
|
|
|
|
|
|
pk.RefreshChecksum();
|
|
|
|
|
return pk;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|