From cb269eca2b4f85af07ebf100df05bc7baafcf1e5 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 5 Aug 2018 00:53:28 -0700 Subject: [PATCH] Update move data Add export button too for both gens --- pk3DS.Core/Structures/Gen6/Move6.cs | 168 ++++++++++---------- pk3DS/Subforms/Gen6/MoveEditor6.Designer.cs | 13 ++ pk3DS/Subforms/Gen6/MoveEditor6.cs | 36 +++-- pk3DS/Subforms/Gen7/MoveEditor7.Designer.cs | 13 ++ pk3DS/Subforms/Gen7/MoveEditor7.cs | 33 ++-- 5 files changed, 152 insertions(+), 111 deletions(-) diff --git a/pk3DS.Core/Structures/Gen6/Move6.cs b/pk3DS.Core/Structures/Gen6/Move6.cs index e4127c1..1118dc4 100644 --- a/pk3DS.Core/Structures/Gen6/Move6.cs +++ b/pk3DS.Core/Structures/Gen6/Move6.cs @@ -1,102 +1,98 @@ using System; -using System.IO; namespace pk3DS.Core.Structures { public class Move { - public byte Type, Quality, Category, Power, Accuracy, PP, Priority, InflictPercent, - HitMin, HitMax, TurnMin, TurnMax, CritStage, Flinch, Recoil, Targeting, - Stat1, Stat2, Stat3, - Stat1Stage, Stat2Stage, Stat3Stage, - Stat1Percent, Stat2Percent, Stat3Percent; + private const int SIZE = 0x22; + private readonly byte[] Data; + public Move() => Data = new byte[SIZE]; + public Move(byte[] data) => Data = data ?? new byte[SIZE]; + public byte[] Write() => Data; + + public int Type { get => Data[0x00]; set => Data[0x00] = (byte)value; } + public int Quality { get => Data[0x01]; set => Data[0x01] = (byte)value; } + public int Category { get => Data[0x02]; set => Data[0x02] = (byte)value; } + public int Power { get => Data[0x03]; set => Data[0x03] = (byte)value; } + public int Accuracy { get => Data[0x04]; set => Data[0x04] = (byte)value; } + public int PP { get => Data[0x05]; set => Data[0x05] = (byte)value; } + public int Priority { get => Data[0x06]; set => Data[0x06] = (byte)value; } + public int HitMin { get => Data[0x07] & 0xF; set => Data[0x07] = (byte)(HitMax << 4 | value); } + public int HitMax { get => Data[0x07] >> 4; set => Data[0x07] = (byte)(value << 4 | HitMin); } + public int Inflict { get => BitConverter.ToUInt16(Data, 0x08); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x08); } + public int InflictPercent { get => Data[0x0A]; set => Data[0x0A] = (byte)value; } + public MoveInflictDuration InflictCount { get => (MoveInflictDuration)Data[0x0B]; set => Data[0x0B] = (byte)value; } + public int TurnMin { get => Data[0x0C]; set => Data[0x0C] = (byte)value; } + public int TurnMax { get => Data[0x0D]; set => Data[0x0D] = (byte)value; } + public int CritStage { get => Data[0x0E]; set => Data[0x0E] = (byte)value; } + public int Flinch { get => Data[0x0F]; set => Data[0x0F] = (byte)value; } + public int EffectSequence { get => BitConverter.ToUInt16(Data, 0x10); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x10); } + public int Recoil { get => Data[0x12]; set => Data[0x12] = (byte)value; } + public Heal Healing { get => (Heal)Data[0x13]; set => Data[0x13] = (byte)value; } + public MoveTarget Target { get => (MoveTarget)Data[0x14]; set => Data[0x14] = (byte)value; } + public int Stat1 { get => Data[0x15]; set => Data[0x15] = (byte)value; } + public int Stat2 { get => Data[0x16]; set => Data[0x16] = (byte)value; } + public int Stat3 { get => Data[0x17]; set => Data[0x17] = (byte)value; } + public int Stat1Stage { get => Data[0x18]; set => Data[0x18] = (byte)value; } + public int Stat2Stage { get => Data[0x19]; set => Data[0x19] = (byte)value; } + public int Stat3Stage { get => Data[0x1A]; set => Data[0x1A] = (byte)value; } + public int Stat1Percent { get => Data[0x1B]; set => Data[0x1B] = (byte)value; } + public int Stat2Percent { get => Data[0x1C]; set => Data[0x1C] = (byte)value; } + public int Stat3Percent { get => Data[0x1D]; set => Data[0x1D] = (byte)value; } + + public MoveFlag Flags { get => (MoveFlag)BitConverter.ToUInt32(Data, 0x1E); set => BitConverter.GetBytes((uint)value).CopyTo(Data, 0x1E); } - public Heal Healing; - public ushort Inflict, Effect; - public byte _0xB, _0x1E, _0x1F, _0x20, _0x21; - public Move(byte[] data) - { - Type = data[0]; - Quality = data[1]; - Category = data[2]; - Power = data[3]; - Accuracy = data[4]; - PP = data[5]; - Priority = data[6]; - HitMin = (byte)(data[7] & 0xF); - HitMax = (byte)(data[7] >> 4); - Inflict = BitConverter.ToUInt16(data, 0x8); - InflictPercent = data[0xA]; - _0xB = data[0xB]; - TurnMin = data[0xC]; - TurnMax = data[0xD]; - CritStage = data[0xE]; - Flinch = data[0xF]; - Effect = BitConverter.ToUInt16(data, 0x10); - Recoil = data[0x12]; - Healing = (Heal)data[0x13]; - Targeting = data[0x14]; - Stat1 = data[0x15]; - Stat2 = data[0x16]; - Stat3 = data[0x17]; - Stat1Stage = data[0x18]; - Stat2Stage = data[0x19]; - Stat3Stage = data[0x1A]; - Stat1Percent = data[0x1B]; - Stat2Percent = data[0x1C]; - Stat3Percent = data[0x1D]; - _0x1E = data[0x1E]; - _0x1F = data[0x1F]; - _0x20 = data[0x20]; - _0x21 = data[0x21]; - } - public byte[] Write() - { - using (MemoryStream ms = new MemoryStream()) - using (BinaryWriter bw = new BinaryWriter(ms)) - { - bw.Write(Type); - bw.Write(Quality); - bw.Write(Category); - bw.Write(Power); - bw.Write(Accuracy); - bw.Write(PP); - bw.Write(Priority); - bw.Write((byte)(HitMin | (HitMax << 4))); - bw.Write(Inflict); - bw.Write(InflictPercent); - bw.Write(_0xB); - bw.Write(TurnMin); - bw.Write(TurnMax); - bw.Write(CritStage); - bw.Write(Flinch); - bw.Write(Effect); - bw.Write(Recoil); - bw.Write((byte)Healing); - bw.Write(Targeting); - bw.Write(Stat1); - bw.Write(Stat2); - bw.Write(Stat3); - bw.Write(Stat1Stage); - bw.Write(Stat2Stage); - bw.Write(Stat3Stage); - bw.Write(Stat1Percent); - bw.Write(Stat2Percent); - bw.Write(Stat3Percent); - bw.Write(_0x1E); - bw.Write(_0x1F); - bw.Write(_0x20); - bw.Write(_0x21); - return ms.ToArray(); - } - } public enum Heal : byte { None = 0, - Full = 255, Half = 254, Quarter = 253, } } + + public enum MoveInflictDuration + { + None = 0, + Permanent, + TurnCount, + Unused, + Switch, + }; + + public enum MoveTarget : byte + { + // Specific target + AnyExceptSelf, + AllyOrSelf, + Ally, + Opponent, + AllAdjacent, + AllAdjacentOpponents, + AllAllies, + Self, + All, + RandomOpponent, + + // No pkm target + SideAll, + SideOpponent, + SideSelf, + Counter, + } + + [Flags] + public enum MoveFlag : uint + { + None, + // TBD + } + + public static class MoveFlagExtensions + { + public static bool HasFlagFast(this MoveFlag value, MoveFlag flag) + { + return (value & flag) != 0; + } + } } diff --git a/pk3DS/Subforms/Gen6/MoveEditor6.Designer.cs b/pk3DS/Subforms/Gen6/MoveEditor6.Designer.cs index 9a28487..5c96d69 100644 --- a/pk3DS/Subforms/Gen6/MoveEditor6.Designer.cs +++ b/pk3DS/Subforms/Gen6/MoveEditor6.Designer.cs @@ -93,6 +93,7 @@ private void InitializeComponent() this.CHK_Category = new System.Windows.Forms.CheckBox(); this.CHK_Type = new System.Windows.Forms.CheckBox(); this.B_Metronome = new System.Windows.Forms.Button(); + this.B_Table = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.NUD_HitMax)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_HitMin)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Priority)).BeginInit(); @@ -842,11 +843,22 @@ private void InitializeComponent() this.B_Metronome.UseVisualStyleBackColor = true; this.B_Metronome.Click += new System.EventHandler(this.B_Metronome_Click); // + // B_Table + // + this.B_Table.Location = new System.Drawing.Point(356, 117); + this.B_Table.Name = "B_Table"; + this.B_Table.Size = new System.Drawing.Size(75, 23); + this.B_Table.TabIndex = 66; + this.B_Table.Text = "Export Table"; + this.B_Table.UseVisualStyleBackColor = true; + this.B_Table.Click += new System.EventHandler(this.B_Table_Click); + // // MoveEditor6 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(439, 381); + this.Controls.Add(this.B_Table); this.Controls.Add(this.B_Metronome); this.Controls.Add(this.groupBox1); this.Controls.Add(this.B_RandAll); @@ -1004,5 +1016,6 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox CHK_Category; private System.Windows.Forms.CheckBox CHK_Type; private System.Windows.Forms.Button B_Metronome; + private System.Windows.Forms.Button B_Table; } } \ No newline at end of file diff --git a/pk3DS/Subforms/Gen6/MoveEditor6.cs b/pk3DS/Subforms/Gen6/MoveEditor6.cs index 4d00e02..5331b5e 100644 --- a/pk3DS/Subforms/Gen6/MoveEditor6.cs +++ b/pk3DS/Subforms/Gen6/MoveEditor6.cs @@ -1,6 +1,8 @@ using pk3DS.Core; using System; +using System.Linq; using System.Windows.Forms; +using pk3DS.Core.Structures; namespace pk3DS { @@ -23,25 +25,25 @@ public MoveEditor6(byte[][] infiles) private readonly string[] StatCategories = { "None", "Attack", "Defense", "Special Attack", "Special Defense", "Speed", "Accuracy", "Evasion", "All", }; private readonly string[] TargetingTypes = - { "Single Adjacent Ally/Foe", - "Any Ally", "Any Adjacent Ally", "Single Adjacent Foe", "Everyone but User", "All Foes", - "All Allies", "Self", "All Pokémon on Field", "Single Adjacent Foe (2)", "Entire Field", - "Opponent's Field", "User's Field", "Self", + { "Single Adjacent Ally/Foe", + "Any Ally", "Any Adjacent Ally", "Single Adjacent Foe", "Everyone but User", "All Foes", + "All Allies", "Self", "All Pokémon on Field", "Single Adjacent Foe (2)", "Entire Field", + "Opponent's Field", "User's Field", "Self", }; private readonly string[] InflictionTypes = - { "None", - "Paralyze", "Sleep", "Freeze", "Burn", "Poison", - "Confusion", "Attract", "Capture", "Nightmare", "Curse", - "Taunt", "Torment", "Disable", "Yawn", "Heal Block", - "?", "Detect", "Leech Seed", "Embargo", "Perish Song", - "Ingrain", + { "None", + "Paralyze", "Sleep", "Freeze", "Burn", "Poison", + "Confusion", "Attract", "Capture", "Nightmare", "Curse", + "Taunt", "Torment", "Disable", "Yawn", "Heal Block", + "?", "Detect", "Leech Seed", "Embargo", "Perish Song", + "Ingrain", }; private readonly string[] MoveQualities = - { "Only DMG", - "No DMG -> Inflict Status", "No DMG -> -Target/+User Stat", "No DMG | Heal User", "DMG | Inflict Status", "No DMG | STATUS | +Target Stat", - "DMG | -Target Stat", "DMG | +User Stat", "DMG | Absorbs DMG", "One-Hit KO", "Affects Whole Field", + { "Only DMG", + "No DMG -> Inflict Status", "No DMG -> -Target/+User Stat", "No DMG | Heal User", "DMG | Inflict Status", "No DMG | STATUS | +Target Stat", + "DMG | -Target Stat", "DMG | +User Stat", "DMG | Absorbs DMG", "One-Hit KO", "Affects Whole Field", "Affect One Side of the Field", "Forces Target to Switch", "Unique Effect", }; private void Setup() { @@ -158,6 +160,14 @@ private void setEntry() } files[entry] = data; } + + private void B_Table_Click(object sender, EventArgs e) + { + var items = files.Select(z => new Move(z)); + Clipboard.SetText(TableUtil.GetTable(items, movelist)); + System.Media.SystemSounds.Asterisk.Play(); + } + private void formClosing(object sender, FormClosingEventArgs e) { setEntry(); diff --git a/pk3DS/Subforms/Gen7/MoveEditor7.Designer.cs b/pk3DS/Subforms/Gen7/MoveEditor7.Designer.cs index e2e1f07..aa45f9b 100644 --- a/pk3DS/Subforms/Gen7/MoveEditor7.Designer.cs +++ b/pk3DS/Subforms/Gen7/MoveEditor7.Designer.cs @@ -93,6 +93,7 @@ private void InitializeComponent() this.CHK_Category = new System.Windows.Forms.CheckBox(); this.CHK_Type = new System.Windows.Forms.CheckBox(); this.B_Metronome = new System.Windows.Forms.Button(); + this.B_Table = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.NUD_HitMax)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_HitMin)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Priority)).BeginInit(); @@ -842,11 +843,22 @@ private void InitializeComponent() this.B_Metronome.UseVisualStyleBackColor = true; this.B_Metronome.Click += new System.EventHandler(this.B_Metronome_Click); // + // B_Table + // + this.B_Table.Location = new System.Drawing.Point(356, 117); + this.B_Table.Name = "B_Table"; + this.B_Table.Size = new System.Drawing.Size(75, 23); + this.B_Table.TabIndex = 67; + this.B_Table.Text = "Export Table"; + this.B_Table.UseVisualStyleBackColor = true; + this.B_Table.Click += new System.EventHandler(this.B_Table_Click); + // // MoveEditor7 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(439, 381); + this.Controls.Add(this.B_Table); this.Controls.Add(this.B_Metronome); this.Controls.Add(this.groupBox1); this.Controls.Add(this.B_RandAll); @@ -1004,5 +1016,6 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox CHK_Category; private System.Windows.Forms.CheckBox CHK_Type; private System.Windows.Forms.Button B_Metronome; + private System.Windows.Forms.Button B_Table; } } \ No newline at end of file diff --git a/pk3DS/Subforms/Gen7/MoveEditor7.cs b/pk3DS/Subforms/Gen7/MoveEditor7.cs index 35b4db2..829251b 100644 --- a/pk3DS/Subforms/Gen7/MoveEditor7.cs +++ b/pk3DS/Subforms/Gen7/MoveEditor7.cs @@ -1,6 +1,8 @@ using pk3DS.Core; using System; +using System.Linq; using System.Windows.Forms; +using pk3DS.Core.Structures; namespace pk3DS { @@ -23,25 +25,25 @@ public MoveEditor7(byte[][] infiles) private readonly string[] StatCategories = { "None", "Attack", "Defense", "Special Attack", "Special Defense", "Speed", "Accuracy", "Evasion", "All", }; private readonly string[] TargetingTypes = - { "Single Adjacent Ally/Foe", - "Any Ally", "Any Adjacent Ally", "Single Adjacent Foe", "Everyone but User", "All Foes", - "All Allies", "Self", "All Pokémon on Field", "Single Adjacent Foe (2)", "Entire Field", - "Opponent's Field", "User's Field", "Self", + { "Single Adjacent Ally/Foe", + "Any Ally", "Any Adjacent Ally", "Single Adjacent Foe", "Everyone but User", "All Foes", + "All Allies", "Self", "All Pokémon on Field", "Single Adjacent Foe (2)", "Entire Field", + "Opponent's Field", "User's Field", "Self", }; private readonly string[] InflictionTypes = - { "None", - "Paralyze", "Sleep", "Freeze", "Burn", "Poison", - "Confusion", "Attract", "Capture", "Nightmare", "Curse", - "Taunt", "Torment", "Disable", "Yawn", "Heal Block", - "?", "Detect", "Leech Seed", "Embargo", "Perish Song", + { "None", + "Paralyze", "Sleep", "Freeze", "Burn", "Poison", + "Confusion", "Attract", "Capture", "Nightmare", "Curse", + "Taunt", "Torment", "Disable", "Yawn", "Heal Block", + "?", "Detect", "Leech Seed", "Embargo", "Perish Song", "Ingrain", "??? 0x16", "??? 0x17", "Mute" }; private readonly string[] MoveQualities = - { "Only DMG", - "No DMG -> Inflict Status", "No DMG -> -Target/+User Stat", "No DMG | Heal User", "DMG | Inflict Status", "No DMG | STATUS | +Target Stat", - "DMG | -Target Stat", "DMG | +User Stat", "DMG | Absorbs DMG", "One-Hit KO", "Affects Whole Field", + { "Only DMG", + "No DMG -> Inflict Status", "No DMG -> -Target/+User Stat", "No DMG | Heal User", "DMG | Inflict Status", "No DMG | STATUS | +Target Stat", + "DMG | -Target Stat", "DMG | +User Stat", "DMG | Absorbs DMG", "One-Hit KO", "Affects Whole Field", "Affect One Side of the Field", "Forces Target to Switch", "Unique Effect", }; private void Setup() { @@ -164,6 +166,13 @@ private void formClosing(object sender, FormClosingEventArgs e) RandSettings.SetFormSettings(this, groupBox1.Controls); } + private void B_Table_Click(object sender, EventArgs e) + { + var items = files.Select(z => new Move(z)); + Clipboard.SetText(TableUtil.GetTable(items, movelist)); + System.Media.SystemSounds.Asterisk.Play(); + } + private void B_RandAll_Click(object sender, EventArgs e) { if (!CHK_Category.Checked && !CHK_Type.Checked)