Restrict old WC8 HOME gifts for 0 EC

Restores strict checks for stuff prior to May 30th that were removed via 36a696e446

Add sim cards for Gen9 HOME starters

Allow tracker-less transfer matching for WC8

Helpful for generating bots who can't assign a legitimate tracker for direct-in-Gen9 injects.
This commit is contained in:
Kurt 2023-06-10 20:18:34 -07:00
parent 36a696e446
commit cd22cc64ce
2 changed files with 31 additions and 5 deletions

View file

@ -489,7 +489,12 @@ public sealed class WC8 : DataMysteryGift, ILangNick, INature, IGigantamax, IDyn
if (pk.Species == (int)Core.Species.Meowstic)
pk.Form = (byte)(pk.Gender & 1);
pk.MetDate = IsDateRestricted && EncounterServerDate.WC8Gifts.TryGetValue(CardID, out var dt) ? dt : DateOnly.FromDateTime(DateTime.Now);
var date = IsDateRestricted && EncounterServerDate.WC8Gifts.TryGetValue(CardID, out var dt) ? dt : DateOnly.FromDateTime(DateTime.Now);
pk.MetDate = date;
// Prior to 3.0.0, HOME would set the Encryption Constant exactly and not give a random value if it was 0.
if (IsHOMEGiftOld(date))
pk.EncryptionConstant = EncryptionConstant;
var nickname_language = GetLanguage(language);
pk.Language = nickname_language != 0 ? nickname_language : tr.Language;
@ -520,6 +525,13 @@ public sealed class WC8 : DataMysteryGift, ILangNick, INature, IGigantamax, IDyn
return pk;
}
private bool IsHOMEGiftOld(DateOnly date)
{
// 2023/05/30 -- every date prior [*,29th] is an old gift.
const int DayNumberHOME300 = 738669;
return IsHOMEGift && date.DayNumber < DayNumberHOME300;
}
private void SetEggMetData(PKM pk)
{
pk.IsEgg = true;
@ -556,7 +568,7 @@ public sealed class WC8 : DataMysteryGift, ILangNick, INature, IGigantamax, IDyn
_ => AbilityPermission.Any12H,
};
private uint GetPID(ITrainerID32 tr, ShinyType8 type) => type switch
private uint GetPID(PKM tr, ShinyType8 type) => type switch
{
ShinyType8.Never => GetAntishiny(tr), // Random, Never Shiny
ShinyType8.Random => Util.Rand32(), // Random, Any
@ -566,11 +578,13 @@ public sealed class WC8 : DataMysteryGift, ILangNick, INature, IGigantamax, IDyn
_ => throw new ArgumentOutOfRangeException(nameof(type)),
};
private uint GetFixedPID(ITrainerID32 tr)
private uint GetFixedPID(PKM tr)
{
var pid = PID;
if (pid != 0 && ID32 != 0)
return pid;
if (pid == 0 && IsHOMEGift && tr.MetDate is { } x && !IsHOMEGiftOld(x))
pid = Util.Rand32(); // actually Random after 3.0.0
if (!tr.IsShiny(pid, 8))
return pid;
@ -646,6 +660,13 @@ public sealed class WC8 : DataMysteryGift, ILangNick, INature, IGigantamax, IDyn
}
else if (IsHOMEGift)
{
// Prior to 3.0.0, HOME would set the Encryption Constant exactly and not give a random value if it was 0.
if (pk.MetDate is { } x && IsHOMEGiftOld(x))
{
// HOME gifts -- PID and EC are zeroes...
if (EncryptionConstant != pk.EncryptionConstant)
return false;
}
if (IsShiny)
{
if (!pk.IsShiny)
@ -701,7 +722,7 @@ public sealed class WC8 : DataMysteryGift, ILangNick, INature, IGigantamax, IDyn
if (pk is PK8 pk8 && pk8.DynamaxLevel < DynamaxLevel)
return false;
if (IsHOMEGift && pk is IScaledSize s and not IHomeTrack { HasTracker: true })
if (IsHOMEGift && pk is IScaledSize s and not IHomeTrack { HasTracker: true } && ParseSettings.IgnoreTransferIfNoTracker)
{
if (s.HeightScalar != 0)
return false;
@ -719,7 +740,12 @@ public sealed class WC8 : DataMysteryGift, ILangNick, INature, IGigantamax, IDyn
var type = PIDType;
if (type is ShinyType8.Never or ShinyType8.Random)
return true;
return pk.PID == GetPID(pk, type);
if (pk.PID == GetPID(pk, type))
return true;
if (PID == 0 && IsHOMEGift && pk.MetDate is { } hg && !IsHOMEGiftOld(hg))
return true; // HOME gifts after patch are actually random (but WC8 is Fixed type)
return false;
}
private bool IsHOMEShinyPossible()