DuelZellLimitBreak.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using OpenVIII.Encoding.Tags;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. namespace OpenVIII
  6. {
  7. namespace Kernel
  8. {
  9. /// <summary>
  10. /// Duel (Zell limit break)
  11. /// </summary>
  12. /// <see cref="https://github.com/alexfilth/doomtrain/wiki/Duel-%28Zell-limit-break%29"/>
  13. /// <seealso cref="https://finalfantasy.fandom.com/wiki/Duel"/>
  14. public class DuelZellLimitBreak
  15. {
  16. #region Fields
  17. public const int Count = 10;
  18. public const int ID = 22;
  19. public const int Size = 32;
  20. #endregion Fields
  21. #region Constructors
  22. public DuelZellLimitBreak(BinaryReader br, int i)
  23. {
  24. Name = Memory.Strings.Read(Strings.FileID.Kernel, ID, i * 2);
  25. //0x0000 2 bytes Offset to name
  26. Description = Memory.Strings.Read(Strings.FileID.Kernel, ID, i * 2 + 1);
  27. //0x0002 2 bytes Offset to description
  28. br.BaseStream.Seek(4, SeekOrigin.Current);
  29. MagicID = (MagicID)br.ReadUInt16();
  30. //0x0004 2 bytes Magic ID
  31. AttackType = (AttackType)br.ReadByte();
  32. //0x0006 1 byte Attack type
  33. AttackPower = br.ReadByte();
  34. //0x0007 1 byte Attack power
  35. AttackFlags = (AttackFlags)br.ReadByte();
  36. //0x0008 1 byte Attack flags
  37. Unknown0 = br.ReadByte();
  38. //0x0009 1 byte Unknown
  39. Target = (Target)br.ReadByte();
  40. //0x000A 1 byte Target Info
  41. Unknown1 = br.ReadByte();
  42. //0x000B 1 bytes Unknown
  43. HitCount = br.ReadByte();
  44. //0x000C 1 byte Hit Count
  45. Element = (Element)br.ReadByte();
  46. //0x000D 1 byte Element Attack
  47. ElementPercent = br.ReadByte();
  48. //0x000E 1 byte Element Attack %
  49. StatusAttack = br.ReadByte();
  50. //0x000F 1 byte Status Attack Enabler
  51. ButtonCombo = new List<IReadOnlyList<FF8TextTagKey>>(5);
  52. for (var b = 0; b < 5; b++)
  53. {
  54. ButtonCombo.Add(Input2.Convert_Flags((Button_Flags)br.ReadUInt16()));
  55. }
  56. //0x0010 2 bytes Sequence Button 1
  57. //0x0012 2 bytes Sequence Button 2
  58. //0x0014 2 bytes Sequence Button 3
  59. //0x0016 2 bytes Sequence Button 4
  60. //0x0018 2 bytes Sequence Button 5
  61. Statuses0 = (PersistentStatuses)br.ReadUInt16();
  62. //0x001A 2 bytes status_0; //statuses 0-7
  63. Statuses1 = (BattleOnlyStatuses)br.ReadUInt32();
  64. //0x001C 4 bytes status_1; //statuses 8-39
  65. }
  66. #endregion Constructors
  67. #region Properties
  68. public AttackFlags AttackFlags { get; }
  69. public byte AttackPower { get; }
  70. public AttackType AttackType { get; }
  71. public List<IReadOnlyList<FF8TextTagKey>> ButtonCombo { get; }
  72. public FF8String Description { get; }
  73. public Element Element { get; }
  74. public byte ElementPercent { get; }
  75. public byte HitCount { get; }
  76. public MagicID MagicID { get; }
  77. public FF8String Name { get; }
  78. public byte StatusAttack { get; }
  79. public PersistentStatuses Statuses0 { get; }
  80. public BattleOnlyStatuses Statuses1 { get; }
  81. public Target Target { get; }
  82. public byte Unknown0 { get; }
  83. public byte Unknown1 { get; }
  84. #endregion Properties
  85. #region Methods
  86. public static IReadOnlyList<DuelZellLimitBreak> Read(BinaryReader br)
  87. => Enumerable.Range(0, Count).Select(x => CreateInstance(br, x)).ToList();
  88. public override string ToString() => Name;
  89. private static DuelZellLimitBreak CreateInstance(BinaryReader br, int i) => new DuelZellLimitBreak(br, i);
  90. #endregion Methods
  91. }
  92. }
  93. }