diff --git a/PKHeX.Core/Saves/SAV7.cs b/PKHeX.Core/Saves/SAV7.cs index 82f1381b8..65f4093c1 100644 --- a/PKHeX.Core/Saves/SAV7.cs +++ b/PKHeX.Core/Saves/SAV7.cs @@ -62,7 +62,7 @@ namespace PKHeX.Core protected override int GiftCountMax => 48; protected override int GiftFlagMax => 0x100 * 8; protected override int EventFlagMax => USUM ? 4928 : 3968; - protected override int EventConstMax => (EventFlag - EventConst) / 2; + protected override int EventConstMax => 1000; public override int OTLength => 12; public override int NickLength => 12; @@ -248,7 +248,8 @@ namespace PKHeX.Core /* 35 */ QRSaveData = Blocks[35].Offset; // 0x6B800 // [1C8] QRReaderSaveData /* 36 */ // = Blocks[36].Offset; // 0x6BA00 // [200] TurtleSalmonSave - EventFlag = EventConst + 0x7D0; + EventFlag = EventConst + EventConstMax * 2; // After Event Const (u16)*n + HoF = EventFlag + EventFlagMax / 8; // After Event Flags (1b)*(1u8/8b)*n OFS_PouchHeldItem = Bag + 0; // 430 (Case 0) OFS_PouchKeyItem = Bag + 0x6B8; // 184 (Case 4) @@ -265,7 +266,6 @@ namespace PKHeX.Core LastViewedBox = PCLayout + 0x5E3; PCFlags = PCLayout + 0x5E0; - HoF = 0x25C0; // Inside EventWork (const/flag) block FashionLength = 0x1A08; @@ -1266,6 +1266,14 @@ namespace PKHeX.Core Array.Resize(ref TeamSlots, teamCount); } + private int FusedCount => USUM ? 3 : 1; + public int GetFusedSlotOffset(int slot) + { + if (Fused < 0 || slot < 0 || slot >= FusedCount) + return -1; + return Fused + SIZE_PARTY * slot; // 0x104*slot + } + public override int DaycareSeedSize => 32; // 128 bits public override int GetDaycareSlotOffset(int loc, int slot) { @@ -1445,32 +1453,17 @@ namespace PKHeX.Core return string.Join(Environment.NewLine, Blocks.Select(b => $"{b.ID:00}: {b.Offset:X5}-{b.Offset + b.Length:X5}, {b.Length:X5}")); } - public byte BallThrowTypeUnlocked - { - get => (byte)(((BitConverter.ToUInt16(Data, 0x23F4) << 4) >> 10) << 2); - set - { - ushort flags = (ushort)(BitConverter.ToUInt16(Data, 0x23F4) & 0xF03F); - flags |= (ushort)((value & 0xFC) << 4); - BitConverter.GetBytes(flags).CopyTo(Data, 0x23F4); - } - } - public byte BallThrowTypeLearned - { - get => (byte)((Data[0x2583] & 0x7F) << 1); - set => Data[0x2583] = (byte)((Data[0x2583] & 0x80) | ((value & 0xFE) >> 1)); - } - public byte BattleTreeSuperUnlocked - { - get => (byte)(Data[0x23F9] >> 5); - set => Data[0x23F9] = (byte)((Data[0x23F9] & 0x1F) | ((value & 0x07) << 5)); - } public bool MegaUnlocked { get => (Data[TrainerCard + 0x78] & 0x01) != 0; set => Data[TrainerCard + 0x78] = (byte)((Data[TrainerCard + 0x78] & 0xFE) | (value ? 1 : 0)); // in battle // Data[0x1F22] = (byte)((Data[0x1F22] & 0xFE) | (value ? 1 : 0)); // event } + public bool ZMoveUnlocked + { + get => (Data[TrainerCard + 0x78] & 2) != 0; + set => Data[TrainerCard + 0x78] = (byte)((Data[TrainerCard + 0x78] & ~2) | (value ? 2 : 0)); // in battle + } public override string GetString(int Offset, int Count) => StringConverter.GetString7(Data, Offset, Count); public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.Designer.cs index 9577a1f4a..863747c53 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.Designer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.Designer.cs @@ -192,6 +192,7 @@ namespace PKHeX.WinForms this.NUD_ThumbsTotal = new System.Windows.Forms.NumericUpDown(); this.L_ThumbsTotal = new System.Windows.Forms.Label(); this.B_Fashion = new System.Windows.Forms.Button(); + this.CHK_UnlockZMove = new System.Windows.Forms.CheckBox(); this.TC_Editor.SuspendLayout(); this.Tab_Overview.SuspendLayout(); this.GB_Stats.SuspendLayout(); @@ -1669,6 +1670,7 @@ namespace PKHeX.WinForms // // Tab_Misc // + this.Tab_Misc.Controls.Add(this.CHK_UnlockZMove); this.Tab_Misc.Controls.Add(this.CHK_UnlockMega); this.Tab_Misc.Controls.Add(this.L_BallThrowType); this.Tab_Misc.Controls.Add(this.CB_BallThrowType); @@ -1990,6 +1992,16 @@ namespace PKHeX.WinForms this.B_Fashion.UseVisualStyleBackColor = true; this.B_Fashion.Click += new System.EventHandler(this.B_Fashion_Click); // + // CHK_UnlockZMove + // + this.CHK_UnlockZMove.AutoSize = true; + this.CHK_UnlockZMove.Location = new System.Drawing.Point(6, 273); + this.CHK_UnlockZMove.Name = "CHK_UnlockZMove"; + this.CHK_UnlockZMove.Size = new System.Drawing.Size(105, 17); + this.CHK_UnlockZMove.TabIndex = 73; + this.CHK_UnlockZMove.Text = "Unlock Z Moves"; + this.CHK_UnlockZMove.UseVisualStyleBackColor = true; + // // SAV_Trainer7 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -2214,5 +2226,6 @@ namespace PKHeX.WinForms private System.Windows.Forms.CheckBox CHK_UnlockSuperDoubles; private System.Windows.Forms.CheckBox CHK_UnlockSuperSingles; private System.Windows.Forms.CheckBox CHK_UnlockMega; + private System.Windows.Forms.CheckBox CHK_UnlockZMove; } } diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs index 392da72f8..664ca73f4 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs @@ -107,7 +107,10 @@ namespace PKHeX.WinForms CB_Vivillon.ValueMember = "Value"; CB_Vivillon.DataSource = PKX.GetFormList(666, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols).ToList(); - foreach (string t in BattleStyles) + var styles = new List(BattleStyles); + if (SAV.USUM) + styles.Add("Nihilist"); + foreach (string t in styles) { CB_BallThrowType.Items.Add(t); LB_BallThrowTypeUnlocked.Items.Add(t); @@ -211,29 +214,26 @@ namespace PKHeX.WinForms if (SAV.BallThrowType >= 0 && SAV.BallThrowType < CB_BallThrowType.Items.Count) CB_BallThrowType.SelectedIndex = SAV.BallThrowType; - byte bttu = SAV.BallThrowTypeUnlocked; LB_BallThrowTypeUnlocked.SetSelected(0, true); LB_BallThrowTypeUnlocked.SetSelected(1, true); for (int i = 2; i < LB_BallThrowTypeUnlocked.Items.Count; i++) - LB_BallThrowTypeUnlocked.SetSelected(i, (bttu & (1 << i)) != 0); + LB_BallThrowTypeUnlocked.SetSelected(i, SAV.GetEventFlag(292 + i)); - byte bttl = SAV.BallThrowTypeLearned; LB_BallThrowTypeLearned.SetSelected(0, true); for (int i = 1; i < LB_BallThrowTypeLearned.Items.Count; i++) - LB_BallThrowTypeLearned.SetSelected(i, (bttl & (1 << i)) != 0); - + LB_BallThrowTypeLearned.SetSelected(i, SAV.GetEventFlag(3479 + i)); CB_BallThrowTypeListMode.SelectedIndex = 0; uint stampBits = SAV.Stamps; for (int i = 0; i < LB_Stamps.Items.Count; i++) LB_Stamps.SetSelected(i, (stampBits & (1 << i)) != 0); - byte btsu = SAV.BattleTreeSuperUnlocked; - CHK_UnlockSuperSingles.Checked = (btsu & 1) != 0; - CHK_UnlockSuperDoubles.Checked = (btsu & (1 << 1)) != 0; - CHK_UnlockSuperMulti.Checked = (btsu & (1 << 2)) != 0; + CHK_UnlockSuperSingles.Checked = SAV.GetEventFlag(333); + CHK_UnlockSuperDoubles.Checked = SAV.GetEventFlag(334); + CHK_UnlockSuperMulti.Checked = SAV.GetEventFlag(335); CHK_UnlockMega.Checked = SAV.MegaUnlocked; + CHK_UnlockZMove.Checked = SAV.ZMoveUnlocked; } private void Save() { @@ -247,6 +247,7 @@ namespace PKHeX.WinForms SAV.Country = WinFormsUtil.GetIndex(CB_Country); SAV.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg); SAV.Language = WinFormsUtil.GetIndex(CB_Language); + if (CB_AlolaTime.Enabled) SAV.AlolaTime = (ulong)WinFormsUtil.GetIndex(CB_AlolaTime); SAV.OT = TB_OTName.Text; @@ -321,18 +322,23 @@ namespace PKHeX.WinForms if (CB_Vivillon.SelectedIndex >= 0) SAV.Vivillon = CB_Vivillon.SelectedIndex; SAV.DaysFromRefreshed = (byte)NUD_DaysFromRefreshed.Value; - SAV.BallThrowType = CB_BallThrowType.SelectedIndex; - SAV.BallThrowTypeUnlocked = (byte)GetBits(LB_BallThrowTypeUnlocked); - SAV.BallThrowTypeLearned = (byte)GetBits(LB_BallThrowTypeLearned); + if (CB_BallThrowType.SelectedIndex >= 0) + SAV.BallThrowType = CB_BallThrowType.SelectedIndex; + + for (int i = 2; i < LB_BallThrowTypeUnlocked.Items.Count; i++) + SAV.SetEventFlag(292 + i, LB_BallThrowTypeUnlocked.GetSelected(i)); + + for (int i = 1; i < LB_BallThrowTypeLearned.Items.Count; i++) + SAV.SetEventFlag(3479 + i, LB_BallThrowTypeLearned.GetSelected(i)); + SAV.Stamps = GetBits(LB_Stamps); - byte btsu = 0; - if (CHK_UnlockSuperSingles.Checked) btsu |= 1; - if (CHK_UnlockSuperDoubles.Checked) btsu |= 1 << 1; - if (CHK_UnlockSuperMulti.Checked) btsu |= 1 << 2; - SAV.BattleTreeSuperUnlocked = btsu; + SAV.SetEventFlag(333, CHK_UnlockSuperSingles.Checked); + SAV.SetEventFlag(334, CHK_UnlockSuperDoubles.Checked); + SAV.SetEventFlag(335, CHK_UnlockSuperMulti.Checked); SAV.MegaUnlocked = CHK_UnlockMega.Checked; + SAV.ZMoveUnlocked = CHK_UnlockZMove.Checked; } private static uint GetBits(ListBox listbox) {