Initiate Moves. Fix DPPt bug for ENcounters tab.

This commit is contained in:
Miguel Terol Espino
2024-05-04 20:50:29 +02:00
parent d70c336e34
commit 4ce324d822
6 changed files with 210 additions and 4 deletions

View File

@@ -179,6 +179,12 @@
<Compile Include="LearnsetEditor.designer.cs">
<DependentUpon>LearnsetEditor.cs</DependentUpon>
</Compile>
<Compile Include="MoveEditor.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MoveEditor.Designer.cs">
<DependentUpon>MoveEditor.cs</DependentUpon>
</Compile>
<Compile Include="PersonalDataEditor.cs">
<SubType>Form</SubType>
</Compile>
@@ -232,6 +238,7 @@
<Compile Include="ROMFiles\LevelScriptFile.cs" />
<Compile Include="ROMFiles\LevelScriptTrigger.cs" />
<Compile Include="ROMFiles\MapScreenLoadTrigger.cs" />
<Compile Include="ROMFiles\MoveFile.cs" />
<Compile Include="ROMFiles\PokemonPersonalData.cs" />
<Compile Include="ROMFiles\RomFile.cs" />
<Compile Include="ROMFiles\SafariZoneEncounter.cs" />

View File

@@ -692,6 +692,9 @@ namespace DSPRE {
monEditorToolStripMenuItem.Enabled = true;
scriptCommandsButton.Enabled = true;
if (!RomInfo.gameFamily.Equals(GameFamilies.HGSS)) {
mainTabControl.TabPages.Remove(tabPageEncountersEditor);
}
Helpers.statusLabelMessage();
this.Text += " - " + RomInfo.fileName;
}

34
DS_Map/MoveEditor.Designer.cs generated Normal file
View File

@@ -0,0 +1,34 @@
namespace DSPRE {
partial class MoveEditor {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "MoveEditor";
}
#endregion
}
}

17
DS_Map/MoveEditor.cs Normal file
View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DSPRE {
public partial class MoveEditor : Form {
public MoveEditor() {
InitializeComponent();
}
}
}

View File

@@ -4,11 +4,11 @@ using System.Runtime.InteropServices;
// Le informazioni generali relative a un assembly sono controllate dal seguente
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
// associate a un assembly.
[assembly: AssemblyTitle("DSPRE Reloaded 1.12.2")]
[assembly: AssemblyTitle("DSPRE Reloaded 1.12.3")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DSPRE Reloaded 1.12.2")]
[assembly: AssemblyProduct("DSPRE Reloaded 1.12.3")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.12.2")]
[assembly: AssemblyFileVersion("1.12.2")]
[assembly: AssemblyVersion("1.12.3")]
[assembly: AssemblyFileVersion("1.12.3")]

145
DS_Map/ROMFiles/MoveFile.cs Normal file
View File

@@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DSPRE.ROMFiles {
public enum MoveTypes : short {
Normal,
Fighting,
Flying,
Poison,
Ground,
Rock,
Bug,
Ghost,
Steel,
Unknown,
Fire,
Water,
Grass,
Electric,
Psychic,
Ice,
Dragon,
Dark
}
public enum MoveCategory {
Physical,
Special,
Status
}
public enum ContestCategories {
One = 1,
Two = 2,
Three = 3,
Four = 4,
Five = 5,
Six = 6,
Seven = 7,
Eight = 8,
Nine = 9,
Ten = 10,
Eleven = 11,
Twelve = 12
}
[Flags]
public enum MoveTargets {
OneOpponent = 1,
Automatic = 2,
Random = 4,
BothOpponents = 16,
BothOpponentsAndAlly = 8,
User = 32,
UsersSideOfField = 64,
EntireField = 128,
OpponentsSideOfField = 256,
AutomaticWithAlly = 512,
UserOrAlly = 1024,
OneOpponentFailsIfTargetFaints = 2048
}
public struct MoveData {
public ushort Effect; // u16
public byte Category; // u8
public byte Power; // u8
public byte Type; // u8
public byte Accuracy; // u8
public byte PP; // u8
public byte EffectChance; // u8
public ushort Target; // u16
public sbyte Priority; // s8
public bool[] Flags; // u8
public byte ContestEffect; // u8
public byte ContestType; // u8
}
public class MoveFile : RomFile{
public MoveData moveData;
public MoveFile(Stream stream) {
moveData = new MoveData();
using (BinaryReader reader = new BinaryReader(stream)) {
moveData.Effect = reader.ReadUInt16();
moveData.Category = reader.ReadByte();
moveData.Power = reader.ReadByte();
moveData.Type = reader.ReadByte();
moveData.Accuracy = reader.ReadByte();
moveData.PP = reader.ReadByte();
moveData.EffectChance = reader.ReadByte();
moveData.Target = reader.ReadUInt16();
moveData.Priority = reader.ReadSByte();
// Reading flags
byte flagsByte = reader.ReadByte();
moveData.Flags = new bool[8];
for (int i = 0; i < 8; i++) {
moveData.Flags[i] = (flagsByte & (1 << i)) != 0;
}
moveData.ContestEffect = reader.ReadByte();
moveData.ContestType = reader.ReadByte();
}
}
public override byte[] ToByteArray() {
using (MemoryStream stream = new MemoryStream()) {
using (BinaryWriter writer = new BinaryWriter(stream)) {
writer.Write(moveData.Effect);
writer.Write(moveData.Category);
writer.Write(moveData.Power);
writer.Write(moveData.Type);
writer.Write(moveData.Accuracy);
writer.Write(moveData.PP);
writer.Write(moveData.EffectChance);
writer.Write(moveData.Target);
writer.Write(moveData.Priority);
// Writing flags
byte flagsByte = 0;
for (int i = 0; i < 8; i++) {
if (moveData.Flags[i])
flagsByte |= (byte)(1 << i);
}
writer.Write(flagsByte);
writer.Write(moveData.ContestEffect);
writer.Write(moveData.ContestType);
}
return stream.ToArray();
}
}
}
}