From 07584a8774fe63bbb56d32785a468f097a767bdb Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 13 May 2021 23:12:53 -0700 Subject: [PATCH] Add chateau score, seaside cycle score Update some other areas too looks like this fixes the sube pkx fetch method for extraslots, yay. --- PKHeX.Core/Editing/IPlugin.cs | 2 +- PKHeX.Core/Editing/Saves/Slots/Extensions.cs | 3 +- PKHeX.Core/Legality/Tables/Tables7.cs | 12 ++- .../Saves/Substructures/Gen6/SubEventLog6.cs | 102 +++++++++++++++++- 4 files changed, 113 insertions(+), 6 deletions(-) diff --git a/PKHeX.Core/Editing/IPlugin.cs b/PKHeX.Core/Editing/IPlugin.cs index 00caeca34..598bbd813 100644 --- a/PKHeX.Core/Editing/IPlugin.cs +++ b/PKHeX.Core/Editing/IPlugin.cs @@ -30,7 +30,7 @@ /// Attempts to load a file using the plugin. /// /// Path to file to be loaded. - /// + /// True if the plugin has handled the file. bool TryLoadFile(string filePath); /// diff --git a/PKHeX.Core/Editing/Saves/Slots/Extensions.cs b/PKHeX.Core/Editing/Saves/Slots/Extensions.cs index 3aed67421..ee85e30a9 100644 --- a/PKHeX.Core/Editing/Saves/Slots/Extensions.cs +++ b/PKHeX.Core/Editing/Saves/Slots/Extensions.cs @@ -104,7 +104,7 @@ namespace PKHeX.Core { new SlotInfoMisc(sav.Data, 0, sav.GTS) {Type = StorageSlotType.GTS}, new SlotInfoMisc(sav.Data, 0, sav.Fused) {Type = StorageSlotType.Fused}, - new SlotInfoMisc(sav.Data, 0, sav.SUBE.Offset + 0x90) {Type = StorageSlotType.Misc}, // Old Man + new SlotInfoMisc(sav.Data, 0, sav.SUBE.Give) {Type = StorageSlotType.Misc}, // Old Man new SlotInfoMisc(sav.Data, 0, sav.GetBattleBoxSlot(0)) {Type = StorageSlotType.BattleBox}, new SlotInfoMisc(sav.Data, 1, sav.GetBattleBoxSlot(1)) {Type = StorageSlotType.BattleBox}, @@ -121,6 +121,7 @@ namespace PKHeX.Core { new SlotInfoMisc(sav.Data, 0, SAV6AO.GTS) {Type = StorageSlotType.GTS}, new SlotInfoMisc(sav.Data, 0, SAV6AO.Fused) {Type = StorageSlotType.Fused}, + new SlotInfoMisc(sav.Data, 0, sav.SUBE.Give) {Type = StorageSlotType.Misc}, new SlotInfoMisc(sav.Data, 0, sav.GetBattleBoxSlot(0)) {Type = StorageSlotType.BattleBox}, new SlotInfoMisc(sav.Data, 1, sav.GetBattleBoxSlot(1)) {Type = StorageSlotType.BattleBox}, diff --git a/PKHeX.Core/Legality/Tables/Tables7.cs b/PKHeX.Core/Legality/Tables/Tables7.cs index 97f442a41..6ad164bbe 100644 --- a/PKHeX.Core/Legality/Tables/Tables7.cs +++ b/PKHeX.Core/Legality/Tables/Tables7.cs @@ -145,9 +145,15 @@ namespace PKHeX.Core 921, 922, 923, 924, 925, 926 }); - public static readonly Dictionary ZCrystalDictionary = Pouch_ZCrystal_USUM - .Zip(Pouch_ZCrystalHeld_USUM, (k, v) => new KeyValuePair(k, v)) - .ToDictionary(x => x.Key, x => x.Value); + public static readonly Dictionary ZCrystalDictionary = GetDictionary(Pouch_ZCrystal_USUM, Pouch_ZCrystalHeld_USUM); + + private static Dictionary GetDictionary(IReadOnlyList key, IReadOnlyList held) + { + var result = new Dictionary(held.Count); + for (int i = 0; i < key.Count; i++) + result.Add(key[i], held[i]); + return result; + } internal static readonly ushort[] HeldItems_SM = ArrayUtil.ConcatAll(Pouch_Items_SM, Pouch_Berries_SM, Pouch_Medicine_SM, Pouch_ZCrystalHeld_SM); internal static readonly ushort[] HeldItems_USUM = ArrayUtil.ConcatAll(Pouch_Items_SM, Pouch_Berries_SM, Pouch_Medicine_SM, Pouch_ZCrystalHeld_USUM, Pouch_Roto_USUM); diff --git a/PKHeX.Core/Saves/Substructures/Gen6/SubEventLog6.cs b/PKHeX.Core/Saves/Substructures/Gen6/SubEventLog6.cs index d06611340..156c20f9a 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/SubEventLog6.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/SubEventLog6.cs @@ -11,6 +11,16 @@ namespace PKHeX.Core protected abstract int BadgeVictoryOffset { get; } + /// + /// Absolute offset of the that the player has given an NPC. + /// + public abstract int Give { get; } + + /// + /// Absolute offset of the that is unreferenced? + /// + public abstract int UnusedPKM { get; } + private int GetBadgeVictorySpeciesOffset(uint badge, uint slot) { if (badge >= 8) @@ -37,12 +47,102 @@ namespace PKHeX.Core public sealed class SubEventLog6XY : SubEventLog6 { public SubEventLog6XY(SAV6XY sav, int offset) : base(sav, offset) { } + + // Structure: + + // 0x00 + // u8[0x28] chateau data + private ushort ChateauValue + { + get => BitConverter.ToUInt16(Data, Offset); + set => BitConverter.GetBytes(value).CopyTo(Data, Offset); + } + + public ushort ChateauRank + { + get => (ushort)(ChateauValue & 0xF); + set => ChateauValue = (ushort)((ChateauValue & ~0xFu) | (value & 0xFu)); + } + + public ushort ChateauPoints + { + get => (ushort)(ChateauValue >> 4); + set => ChateauValue = (ushort)((ushort)(value << 4) | (ChateauValue & 0xFu)); + } + // other chateau data? + // u32 SUBE @ 0x28 + + // 0x2C protected override int BadgeVictoryOffset => 0x2C; // thru 0x8B + // u16[6 * 8] trainer teams for gyms + // u32 SUBE @ 0x8C + + // 0x90 + // u8[0xE8] pkm? + public override int Give => 0x90 + Offset; + // u32 SUBE @ 0x178 + + // 0x17C + // u8[0xE8] pkm? + public override int UnusedPKM => 0x17C + Offset; + // u32 SUBE @ 0x264 + + // 0x268 + // u8[0xA0] unused? } public sealed class SubEventLog6AO : SubEventLog6 { public SubEventLog6AO(SAV6AO sav, int offset) : base(sav, offset) { } + + // Structure: + + // 0x00 + // u8[0x5A] trainer rematch flags + // u8[2] unused (alignment) + // u32 SUBE @ 0x5C + + // 0x60 protected override int BadgeVictoryOffset => 0x60; // thru 0xBF + // u16[6 * 8] trainer teams for gyms + // u32 SUBE @ 0xC0 + + // 0xC4 + // u8[0xE8] pkm? + public override int Give => 0xC4 + Offset; + // u32 SUBE @ 0x1AC + + // 0x1B0 + // u8[0xE8] pkm? + public override int UnusedPKM => 0x1B0 + Offset; + // u32 SUBE @ 0x298 + + // 0x29C + // u16 SeasideCyclingRoadTimeMilliseconds 29C + public ushort SeasideCyclingRoadTimeMilliseconds + { + get => BitConverter.ToUInt16(Data, Offset + 0x29C); + set => BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x29C); + } + // u16 SeasideCyclingRoadCollisions 29E + public ushort SeasideCyclingRoadCollisions + { + get => BitConverter.ToUInt16(Data, Offset + 0x29E); + set => BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x29E); + } + // u16[7] 2A0 + // u16[7] 2AE + // u16[17] 2BC + // u16[7] 2EA + // u16 2EC + // u16 2EE + // u16 2F0 + // u16 2F2 + // u32 SUBE @ 0x2F4 + + // 0x2F8 + // u64[27] + // u8[16] + // u8[32] unused? } -} \ No newline at end of file +}