-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from petfriendamy/master
Add attack and command data
- Loading branch information
Showing
12 changed files
with
321 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Shojy.FF7.Elena.Battle; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shojy.FF7.Elena.Attacks | ||
{ | ||
public class Attack | ||
{ | ||
#region Public Constructors | ||
|
||
public Attack() { } | ||
|
||
#endregion | ||
|
||
#region Public Properties | ||
|
||
public byte AccuracyRate { get; set; } | ||
public byte AditionalEffects { get; set; } | ||
public byte AdditionalEffectsModifier { get; set; } | ||
public byte AttackEffectID { get; set; } | ||
public byte AttackStrength { get; set; } | ||
public ushort CameraMovementIDSingle { get; set; } | ||
public ushort CameraMovementIDMulti { get; set; } | ||
public ConditionSubmenu ConditionSubmenu { get; set; } | ||
public byte DamageCalculationID { get; set; } | ||
public string Description { get; set; } | ||
public Elements Elements { get; set; } | ||
public byte ImpactEffectID { get; set; } | ||
public ushort ImpactSound { get; set; } | ||
public int Index { get; set; } | ||
public ushort MPCost { get; set; } | ||
public string Name { get; set; } | ||
public SpecialEffects SpecialAttackFlags { get; set; } | ||
public StatusChange StatusChange { get; set; } | ||
public Statuses Statuses { get; set; } | ||
public TargetData TargetFlags { get; set; } | ||
public byte TargetHurtActionIndex { get; set; } | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shojy.FF7.Elena.Attacks | ||
{ | ||
public enum ConditionSubmenu : byte | ||
{ | ||
PartyHP = 0x00, | ||
PartyMP = 0x01, | ||
PartyStatus = 0x02, | ||
None = 0xFF | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shojy.FF7.Elena.Attacks | ||
{ | ||
public enum StatusChangeType | ||
{ | ||
None, Inflict, Cure, Swap | ||
} | ||
|
||
public class StatusChange | ||
{ | ||
public StatusChangeType Type { get; set; } | ||
public int Amount { get; set; } | ||
|
||
public StatusChange(byte value) | ||
{ | ||
if (value == 0xFF) | ||
{ | ||
Type = StatusChangeType.None; | ||
Amount = 0; | ||
} | ||
else if ((value & 0x40) != 0) | ||
{ | ||
Type = StatusChangeType.Cure; | ||
Amount = value - 0x40; | ||
} | ||
else if ((value & 0x80) != 0) | ||
{ | ||
Type = StatusChangeType.Swap; | ||
Amount = value - 0x80; | ||
} | ||
else | ||
{ | ||
Type = StatusChangeType.Inflict; | ||
Amount = value; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shojy.FF7.Elena.Battle | ||
{ | ||
public class Command | ||
{ | ||
#region Public Constructors | ||
|
||
public Command() { } | ||
|
||
#endregion | ||
|
||
#region Public Properties | ||
|
||
public ushort CameraMovementIDSingle { get; set; } | ||
public ushort CameraMovementIDMulti { get; set; } | ||
public string Description { get; set; } | ||
public int Index { get; set; } | ||
public string Name { get; set; } | ||
public byte InitialCursorAction { get; set; } | ||
public TargetData TargetFlags { get; set; } | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using Shojy.FF7.Elena.Attacks; | ||
using Shojy.FF7.Elena.Battle; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Shojy.FF7.Elena.Sections | ||
{ | ||
public class AttackData | ||
{ | ||
#region Private Fields | ||
|
||
private const int AttackSize = 28; | ||
private readonly byte[] _sectionData; | ||
|
||
#endregion | ||
|
||
#region Public Constructors | ||
|
||
public AttackData(byte[] sectionData, IReadOnlyList<string> names, IReadOnlyList<string> descriptions) | ||
{ | ||
this._sectionData = sectionData; | ||
|
||
var count = sectionData.Length / AttackSize; | ||
var attacks = new Attack[count]; | ||
|
||
for (var atk = 0; atk < count; ++atk) | ||
{ | ||
var atkBytes = new byte[AttackSize]; | ||
Array.Copy( | ||
sectionData, | ||
atk * AttackSize, | ||
atkBytes, | ||
0, | ||
AttackSize); | ||
attacks[atk] = this.ParseAttackData(atkBytes); | ||
|
||
attacks[atk].Index = atk; | ||
attacks[atk].Name = names[atk]; | ||
attacks[atk].Description = descriptions[atk]; | ||
} | ||
this.Attacks = attacks; | ||
} | ||
|
||
#endregion | ||
|
||
#region Public Properties | ||
|
||
public Attack[] Attacks; | ||
|
||
#endregion | ||
|
||
#region Private Methods | ||
|
||
private Attack ParseAttackData(byte[] atkData) | ||
{ | ||
var atk = new Attack(); | ||
atk.AccuracyRate = atkData[0x0]; | ||
atk.ImpactEffectID = atkData[0x1]; | ||
atk.TargetHurtActionIndex = atkData[0x2]; | ||
atk.MPCost = BitConverter.ToUInt16(atkData, 0x4); | ||
atk.ImpactSound = BitConverter.ToUInt16(atkData, 0x6); | ||
atk.CameraMovementIDSingle = BitConverter.ToUInt16(atkData, 0x8); | ||
atk.CameraMovementIDMulti = BitConverter.ToUInt16(atkData, 0xA); | ||
atk.TargetFlags = (TargetData)atkData[0xC]; | ||
atk.AttackEffectID = atkData[0xD]; | ||
atk.DamageCalculationID = atkData[0xE]; | ||
atk.AttackStrength = atkData[0xF]; | ||
atk.ConditionSubmenu = (ConditionSubmenu)atkData[0x10]; | ||
atk.StatusChange = new StatusChange(atkData[0x11]); | ||
atk.AditionalEffects = atkData[0x12]; | ||
atk.AdditionalEffectsModifier = atkData[0x13]; | ||
atk.Statuses = (Statuses)BitConverter.ToUInt32(atkData, 0x14); | ||
atk.Elements = (Elements)BitConverter.ToUInt16(atkData, 0x18); | ||
|
||
atk.SpecialAttackFlags = (SpecialEffects) ~ BitConverter.ToUInt16(atkData, 0x1A); | ||
return atk; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,66 @@ | ||
namespace Shojy.FF7.Elena.Sections | ||
using Shojy.FF7.Elena.Attacks; | ||
using Shojy.FF7.Elena.Battle; | ||
using System.Collections.Generic; | ||
using System; | ||
|
||
namespace Shojy.FF7.Elena.Sections | ||
{ | ||
public class CommandData | ||
{ | ||
|
||
#region Private Fields | ||
|
||
private const int CommandSize = 8; | ||
private readonly byte[] _sectionData; | ||
|
||
#endregion | ||
|
||
#region Public Constructors | ||
|
||
public CommandData(byte[] sectionData, IReadOnlyList<string> names, IReadOnlyList<string> descriptions) | ||
{ | ||
this._sectionData = sectionData; | ||
|
||
var count = sectionData.Length / CommandSize; | ||
var commands = new Command[count]; | ||
|
||
for (var cmd = 0; cmd < count; ++cmd) | ||
{ | ||
var cmdBytes = new byte[CommandSize]; | ||
Array.Copy( | ||
sectionData, | ||
cmd * CommandSize, | ||
cmdBytes, | ||
0, | ||
CommandSize); | ||
commands[cmd] = this.ParseCommandData(cmdBytes); | ||
|
||
commands[cmd].Index = cmd; | ||
commands[cmd].Name = names[cmd]; | ||
commands[cmd].Description = descriptions[cmd]; | ||
} | ||
this.Commands = commands; | ||
} | ||
|
||
#endregion | ||
|
||
#region Public Properties | ||
|
||
public Command[] Commands; | ||
|
||
#endregion | ||
|
||
#region Private Methods | ||
|
||
private Command ParseCommandData(byte[] cmdData) | ||
{ | ||
var cmd = new Command(); | ||
cmd.InitialCursorAction = cmdData[0x0]; | ||
cmd.TargetFlags = (TargetData)cmdData[0x1]; | ||
cmd.CameraMovementIDSingle = BitConverter.ToUInt16(cmdData, 0x4); | ||
cmd.CameraMovementIDMulti = BitConverter.ToUInt16(cmdData, 0x6); | ||
return cmd; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.