mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-09 01:16:13 -05:00
Add gen4/5 synthetic trade logic
was previously present for gen6 and gen7 only, resulting in eggs in gen4/5 not getting link trade values applied. that's really all. https://projectpokemon.org/home/forums/topic/44437-bug-eggs-transfer-for-gen-4-dppt-and-hgss/
This commit is contained in:
@@ -340,6 +340,18 @@ protected override ushort CalculateChecksum()
|
||||
return chk;
|
||||
}
|
||||
|
||||
// Synthetic Trading Logic
|
||||
public bool Trade(string SAV_Trainer, int SAV_TID, int SAV_SID, int SAV_GENDER, int Day = 1, int Month = 1, int Year = 2009)
|
||||
{
|
||||
// Eggs do not have any modifications done if they are traded
|
||||
if (IsEgg && !(SAV_Trainer == OT_Name && SAV_TID == TID && SAV_SID == SID && SAV_GENDER == OT_Gender))
|
||||
{
|
||||
SetLinkTradeEgg(Day, Month, Year);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override byte[] Encrypt()
|
||||
{
|
||||
RefreshChecksum();
|
||||
|
||||
@@ -323,6 +323,18 @@ protected override byte[] Encrypt()
|
||||
return PKX.EncryptArray45(Data);
|
||||
}
|
||||
|
||||
// Synthetic Trading Logic
|
||||
public bool Trade(string SAV_Trainer, int SAV_TID, int SAV_SID, int SAV_GENDER, int Day = 1, int Month = 1, int Year = 2009)
|
||||
{
|
||||
// Eggs do not have any modifications done if they are traded
|
||||
if (IsEgg && !(SAV_Trainer == OT_Name && SAV_TID == TID && SAV_SID == SID && SAV_GENDER == OT_Gender))
|
||||
{
|
||||
SetLinkTradeEgg(Day, Month, Year, 2002);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public BK4 ConvertToBK4()
|
||||
{
|
||||
BK4 bk4 = ConvertTo<BK4>();
|
||||
|
||||
@@ -287,6 +287,17 @@ protected override byte[] Encrypt()
|
||||
return PKX.EncryptArray45(Data);
|
||||
}
|
||||
|
||||
// Synthetic Trading Logic
|
||||
public bool Trade(string SAV_Trainer, int SAV_TID, int SAV_SID, int SAV_GENDER, int Day = 1, int Month = 1, int Year = 2013)
|
||||
{
|
||||
if (IsEgg && !(SAV_Trainer == OT_Name && SAV_TID == TID && SAV_SID == SID && SAV_GENDER == OT_Gender))
|
||||
{
|
||||
SetLinkTradeEgg(Day, Month, Year, 30003);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public PK6 ConvertToPK6()
|
||||
{
|
||||
PK6 pk6 = new PK6 // Convert away!
|
||||
|
||||
@@ -496,7 +496,7 @@ public void Trade(string SAV_Trainer, int SAV_TID, int SAV_SID, int SAV_COUNTRY,
|
||||
{
|
||||
// Eggs do not have any modifications done if they are traded
|
||||
if (IsEgg && !(SAV_Trainer == OT_Name && SAV_TID == TID && SAV_SID == SID && SAV_GENDER == OT_Gender))
|
||||
UpdateEgg(Day, Month, Year);
|
||||
SetLinkTradeEgg(Day, Month, Year);
|
||||
// Process to the HT if the OT of the Pokémon does not match the SAV's OT info.
|
||||
else if (!TradeOT(SAV_Trainer, SAV_TID, SAV_SID, SAV_COUNTRY, SAV_REGION, SAV_GENDER))
|
||||
TradeHT(SAV_Trainer, SAV_COUNTRY, SAV_REGION, SAV_GENDER, Bank);
|
||||
@@ -532,13 +532,6 @@ private void TradeHT(string SAV_Trainer, int SAV_COUNTRY, int SAV_REGION, int SA
|
||||
TradeMemory(Bank);
|
||||
}
|
||||
// Misc Updates
|
||||
private void UpdateEgg(int Day, int Month, int Year)
|
||||
{
|
||||
Met_Location = 30002;
|
||||
Met_Day = Day;
|
||||
Met_Month = Month;
|
||||
Met_Year = Year - 2000;
|
||||
}
|
||||
private void TradeGeoLocation(int GeoCountry, int GeoRegion)
|
||||
{
|
||||
// Allow the method to abort if the values are invalid
|
||||
|
||||
@@ -544,7 +544,7 @@ public void Trade(string SAV_Trainer, int SAV_TID, int SAV_SID, int SAV_COUNTRY,
|
||||
{
|
||||
// Eggs do not have any modifications done if they are traded
|
||||
if (IsEgg && !(SAV_Trainer == OT_Name && SAV_TID == TID && SAV_SID == SID && SAV_GENDER == OT_Gender))
|
||||
UpdateEgg(Day, Month, Year);
|
||||
SetLinkTradeEgg(Day, Month, Year);
|
||||
// Process to the HT if the OT of the Pokémon does not match the SAV's OT info.
|
||||
else if (!TradeOT(SAV_Trainer, SAV_TID, SAV_SID, SAV_COUNTRY, SAV_REGION, SAV_GENDER))
|
||||
TradeHT(SAV_Trainer, SAV_COUNTRY, SAV_REGION, SAV_GENDER, Bank);
|
||||
@@ -580,13 +580,6 @@ private void TradeHT(string SAV_Trainer, int SAV_COUNTRY, int SAV_REGION, int SA
|
||||
TradeMemory(Bank);
|
||||
}
|
||||
// Misc Updates
|
||||
private void UpdateEgg(int Day, int Month, int Year)
|
||||
{
|
||||
Met_Location = 30002;
|
||||
Met_Day = Day;
|
||||
Met_Month = Month;
|
||||
Met_Year = Year - 2000;
|
||||
}
|
||||
private void TradeGeoLocation(int GeoCountry, int GeoRegion)
|
||||
{
|
||||
// No geolocations are set, ever! -- except for bank. Don't set them anyway.
|
||||
|
||||
@@ -766,6 +766,21 @@ public virtual bool CanHoldItem(ushort[] ValidArray)
|
||||
/// <returns>Cloned <see cref="PKM"/> object</returns>
|
||||
public abstract PKM Clone();
|
||||
|
||||
/// <summary>
|
||||
/// Sets Link Trade data for an <see cref="IsEgg"/>.
|
||||
/// </summary>
|
||||
/// <param name="day">Day the <see cref="PKM"/> was traded.</param>
|
||||
/// <param name="month">Month the <see cref="PKM"/> was traded.</param>
|
||||
/// <param name="y">Day the <see cref="PKM"/> was traded.</param>
|
||||
/// <param name="location">Link Trade location value.</param>
|
||||
protected void SetLinkTradeEgg(int day, int month, int y, int location = 30002)
|
||||
{
|
||||
Met_Day = day;
|
||||
Met_Month = month;
|
||||
Met_Year = y - 2000;
|
||||
Met_Location = location;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the PP of a Move ID with consideration of the amount of PP Ups applied.
|
||||
/// </summary>
|
||||
|
||||
@@ -584,6 +584,15 @@ public override byte[] DecryptPKM(byte[] data)
|
||||
return PKX.DecryptArray45(data);
|
||||
}
|
||||
|
||||
protected override void SetPKM(PKM pkm)
|
||||
{
|
||||
var pk4 = (PK4)pkm;
|
||||
// Apply to this Save File
|
||||
DateTime Date = DateTime.Now;
|
||||
if (pk4.Trade(OT, TID, SID, Gender, Date.Day, Date.Month, Date.Year))
|
||||
pkm.RefreshChecksum();
|
||||
}
|
||||
|
||||
// Daycare
|
||||
public override int GetDaycareSlotOffset(int loc, int slot)
|
||||
{
|
||||
|
||||
@@ -148,6 +148,14 @@ public override byte[] DecryptPKM(byte[] data)
|
||||
}
|
||||
|
||||
protected override void SetDex(PKM pkm) { }
|
||||
protected override void SetPKM(PKM pkm)
|
||||
{
|
||||
var pk4 = (BK4)pkm;
|
||||
// Apply to this Save File
|
||||
DateTime Date = DateTime.Now;
|
||||
if (pk4.Trade(OT, TID, SID, Gender, Date.Day, Date.Month, Date.Year))
|
||||
pkm.RefreshChecksum();
|
||||
}
|
||||
|
||||
public static byte[] DecryptPBRSaveData(byte[] input)
|
||||
{
|
||||
|
||||
@@ -249,6 +249,14 @@ public override byte[] DecryptPKM(byte[] data)
|
||||
{
|
||||
return PKX.DecryptArray45(data);
|
||||
}
|
||||
protected override void SetPKM(PKM pkm)
|
||||
{
|
||||
var pk5 = (PK5)pkm;
|
||||
// Apply to this Save File
|
||||
DateTime Date = DateTime.Now;
|
||||
if (pk5.Trade(OT, TID, SID, Gender, Date.Day, Date.Month, Date.Year))
|
||||
pkm.RefreshChecksum();
|
||||
}
|
||||
|
||||
// Mystery Gift
|
||||
public override MysteryGiftAlbum GiftAlbum
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user