From bde111af2022e8ad1fa1307caa82b7e9f88a80bd Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 1 Nov 2025 10:23:01 -0500 Subject: [PATCH] WA9: add audino, fix OT name/ID fetch Since ZA was forked before S/V 2.0, they reverted the raw ID fix lol. --- PKHeX.Core/MysteryGifts/WA9.cs | 20 +++++++++++++------- PKHeX.Core/MysteryGifts/WC9.cs | 2 +- PKHeX.Core/Resources/legality/mgdb/wa9.pkl | Bin 1424 -> 2136 bytes 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/PKHeX.Core/MysteryGifts/WA9.cs b/PKHeX.Core/MysteryGifts/WA9.cs index b4eee9d3d..112df94d7 100644 --- a/PKHeX.Core/MysteryGifts/WA9.cs +++ b/PKHeX.Core/MysteryGifts/WA9.cs @@ -107,10 +107,18 @@ private uint GetShinyXor() return ShinyUtil.GetShinyXor(PID, ID32); } - // When applying the TID32, the game sets the DisplayTID7 directly, then sets PA9.DisplaySID7 as (wc9.DisplaySID7 - wc9.CardID) + // When applying the ID32, the game sets the DisplayTID7 directly, then sets PA9.DisplaySID7 as (wa9.DisplaySID7 - wa9.CardID) // Since we expose the 16bit (PA9) component values here, just adjust them accordingly with an inlined calc. public override uint ID32 { get => ReadUInt32LittleEndian(Data[0x18..]); set => WriteUInt32LittleEndian(Data[0x18..], value); } + private bool IsOldIDFormat => true; + + public uint ID32Old + { + get => ReadUInt32LittleEndian(Data[0x18..]) - (1000000u * (uint)CardID); + set => WriteUInt32LittleEndian(Data[0x18..], value + (1000000u * (uint)CardID)); + } + public int OriginGame { get => ReadInt32LittleEndian(Data[0x1C..]); set => WriteInt32LittleEndian(Data[0x1C..], value); } public uint EncryptionConstant { get => ReadUInt32LittleEndian(Data[0x20..]); set => WriteUInt32LittleEndian(Data[0x20..], value); } public uint PID { get => ReadUInt32LittleEndian(Data[0x24..]); set => WriteUInt32LittleEndian(Data[0x24..], value); } @@ -311,7 +319,7 @@ public bool CanHaveLanguage(int language) } public int GetLanguage(int redeemLanguage) => Data[GetLanguageOffset(GetLanguageIndex(redeemLanguage))]; - private static int GetLanguageOffset(int index) => 0x28 + (index * 0x1C) + 0x1A; + private static int GetLanguageOffset(int index) => 0x140 + (index * 0x1C) + 0x1A; public bool GetHasOT(int language) => ReadUInt16LittleEndian(Data[GetOTOffset(language)..]) != 0; @@ -378,11 +386,9 @@ private static int GetNicknameOffset(int language) private static int GetOTOffset(int language) { int index = GetLanguageIndex(language); - return 0x124 + (index * 0x1C); + return 0x140 + (index * 0x1C); } - public bool IsHOMEGift => CardID >= 9000; - public bool CanHandleOT(int language) => !GetHasOT(language); public override GameVersion Version => OriginGame != 0 ? (GameVersion)OriginGame : GameVersion.SV; @@ -403,7 +409,7 @@ public override PA9 ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria) var pk = new PA9 { EncryptionConstant = EncryptionConstant != 0 ? EncryptionConstant : rnd.Rand32(), - ID32 = OTGender >= 2 ? tr.ID32 : ID32, + ID32 = OTGender >= 2 ? tr.ID32 : IsOldIDFormat ? ID32Old : ID32, Species = Species, Form = Form, CurrentLevel = currentLevel, @@ -565,7 +571,7 @@ public override bool IsMatchExact(PKM pk, EvoCriteria evo) { if (OTGender < 2) { - var expect = ID32; + var expect = IsOldIDFormat ? ID32Old : ID32; if (expect != pk.ID32) return false; if (OTGender != pk.OriginalTrainerGender) return false; } diff --git a/PKHeX.Core/MysteryGifts/WC9.cs b/PKHeX.Core/MysteryGifts/WC9.cs index 3b59a51ed..4831ede29 100644 --- a/PKHeX.Core/MysteryGifts/WC9.cs +++ b/PKHeX.Core/MysteryGifts/WC9.cs @@ -122,7 +122,7 @@ private uint GetShinyXor() return ShinyUtil.GetShinyXor(PID, ID32); } - // When applying the TID32, the game sets the DisplayTID7 directly, then sets pk9.DisplaySID7 as (wc9.DisplaySID7 - wc9.CardID) + // When applying the ID32, the game sets the DisplayTID7 directly, then sets pk9.DisplaySID7 as (wc9.DisplaySID7 - wc9.CardID) // Since we expose the 16bit (pk9) component values here, just adjust them accordingly with an inlined calc. public override uint ID32 { diff --git a/PKHeX.Core/Resources/legality/mgdb/wa9.pkl b/PKHeX.Core/Resources/legality/mgdb/wa9.pkl index c5828faf5e89c9b2d8bba9d37f0b22db8a37697f..4cec021e3a88e217438f8b9a9b43a5c91b0e5252 100644 GIT binary patch delta 160 zcmbQheM4Zw1tyVH1`uFmU}OYRq6`eOKRDPn%BV0-=3tSL4q(V<$YyxS;LMQ9kjGF0 zB#Xex85o!*+q0~c{ucc{SSeE1?{GX+7*25k