JunctionableGFsData.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. namespace OpenVIII
  6. {
  7. namespace Kernel
  8. {
  9. /// <summary>
  10. /// Junctionable GFs Data
  11. /// </summary>
  12. /// <see cref="https://github.com/alexfilth/doomtrain/wiki/Junctionable-GFs"/>
  13. public class JunctionableGFsData
  14. {
  15. #region Fields
  16. public const int Count = 16;
  17. public const int ID = 2;
  18. #endregion Fields
  19. #region Constructors
  20. private JunctionableGFsData(BinaryReader br, int i)
  21. {
  22. Name = Memory.Strings.Read(Strings.FileID.Kernel, ID, i * 2);
  23. Description = Memory.Strings.Read(Strings.FileID.Kernel, ID, i * 2 + 1);
  24. br.BaseStream.Seek(4, SeekOrigin.Current);
  25. MagicID = (MagicID)br.ReadUInt16(); //0x0004 2 bytes[[Magic ID
  26. AttackType = (AttackType)br.ReadByte(); //0x0006 1 byte Attack type
  27. GFPower = br.ReadByte(); //0x0007 1 byte GF power(used in damage formula)
  28. Unknown0 = br.ReadBytes(2); //0x0008 2 bytes Unknown
  29. AttackFlags = (AttackFlags)(br.ReadByte()); //0x000A 1 byte Attack Flags
  30. Unknown1 = br.ReadBytes(2); //0x000B 2 bytes Unknown
  31. Element = (Element)br.ReadByte(); //0x000D 1 byte[[Element
  32. Statuses0 = (PersistentStatuses)br.ReadUInt16(); //0x000E 2 bytes[[Statuses 0
  33. Statuses1 = (BattleOnlyStatuses)br.ReadUInt32(); //0x0010 4 bytes[[Statuses 1
  34. HPMod = br.ReadByte(); //0x0014 1 byte GF HP Modifier(used in GF HP formula)
  35. Unknown21 = br.ReadBytes(3); //0x0015 3 bytes Unknown
  36. ExpPerLevel = (ushort)((br.ReadByte()) * 10); //0x0018
  37. Unknown22 = br.ReadBytes(2); //0x0019 2 bytes Unknown
  38. StatusAttack = br.ReadByte(); //0x001B 1 byte Status attack enabler
  39. Ability = new OrderedDictionary<Abilities, Unlocker>(21);
  40. for (i = 0; i < 21; i++)
  41. {
  42. var val = (Unlocker)br.ReadByte();
  43. br.BaseStream.Seek(1, SeekOrigin.Current);
  44. var key = (Abilities)br.ReadUInt16();
  45. Ability.Add(key, val);
  46. }
  47. //doomtrain shows this is a decimal number. i got formula from code.
  48. GFCompatibility = Enumerable.Range(0, 16)
  49. .ToDictionary(x => (GFs)x, x => (100 - Convert.ToDecimal(br.ReadByte())) / 5);
  50. Unknown3 = br.ReadBytes(2); //0x0080 2 bytes Unknown
  51. PowerMod = br.ReadByte(); //0x0082 1 byte Power Mod(used in damage formula)
  52. LevelMod = br.ReadByte(); //0x0083 1 byte Level Mod(used in damage formula)
  53. }
  54. #endregion Constructors
  55. #region Properties
  56. public OrderedDictionary<Abilities, Unlocker> Ability { get; }
  57. ///0x000A 1 byte Attack Flags
  58. public AttackFlags AttackFlags { get; }
  59. ///0x0006 1 byte Attack type
  60. public AttackType AttackType { get; }
  61. ///0x0002 2 bytes Offset to GF attack description
  62. public FF8String Description { get; }
  63. ///0x000D 1 byte[[Element
  64. public Element Element { get; }
  65. ///0x18 1 byte *10;
  66. public ushort ExpPerLevel { get; }
  67. /// <summary>
  68. /// <para>0x0070 1 byte Quezacotl compatibility</para>
  69. /// <para>0x0071 1 byte Shiva compatibility</para>
  70. /// <para>0x0072 1 byte Ifrit compatibility</para>
  71. /// <para>0x0073 1 byte Siren compatibility</para>
  72. /// <para>0x0074 1 byte Brothers compatibility</para>
  73. /// <para>0x0075 1 byte Diablos compatibility</para>
  74. /// <para>0x0076 1 byte Carbuncle compatibility</para>
  75. /// <para>0x0077 1 byte Leviathan compatibility</para>
  76. /// <para>0x0078 1 byte Pandemona compatibility</para>
  77. /// <para>0x0079 1 byte Cerberus compatibility</para>
  78. /// <para>0x007A 1 byte Alexander compatibility</para>
  79. /// <para>0x007B 1 byte Doomtrain compatibility</para>
  80. /// <para>0x007C 1 byte Bahamut compatibility</para>
  81. /// <para>0x007D 1 byte Cactuar compatibility</para>
  82. /// <para>0x007E 1 byte Tonberry compatibility</para>
  83. /// <para>0x007F 1 byte Eden compatibility</para>
  84. /// </summary>
  85. public IReadOnlyDictionary<GFs, decimal> GFCompatibility { get; }
  86. ///0x0007 1 byte GF power(used in damage formula)
  87. public byte GFPower { get; }
  88. ///0x0014 1 byte GF HP Modifier(used in GF HP formula)
  89. public byte HPMod { get; }
  90. ///0x0083 1 byte Level Mod(used in damage formula)
  91. public byte LevelMod { get; }
  92. ///0x0004 2 bytes[[Magic ID
  93. public MagicID MagicID { get; }
  94. ///0x0000 2 bytes Offset to GF attack name
  95. public FF8String Name { get; }
  96. ///0x0082 1 byte Power Mod(used in damage formula)
  97. public byte PowerMod { get; }
  98. ///0x001B 1 byte Status attack enabler
  99. public byte StatusAttack { get; }
  100. ///0x000E 2 bytes[[Statuses 0
  101. public PersistentStatuses Statuses0 { get; }
  102. ///0x0010 4 bytes[[Statuses 1
  103. public BattleOnlyStatuses Statuses1 { get; }
  104. ///0x0008 2 bytes Unknown
  105. public byte[] Unknown0 { get; }
  106. ///0x000B 2 bytes Unknown
  107. public byte[] Unknown1 { get; }
  108. ///0x0015 3 bytes Unknown
  109. public byte[] Unknown21 { get; }
  110. ///0x0019 2 bytes Unknown
  111. public byte[] Unknown22 { get; }
  112. ///0x0080 2 bytes Unknown
  113. public byte[] Unknown3 { get; }
  114. #endregion Properties
  115. #region Methods
  116. public static JunctionableGFsData CreateInstance(BinaryReader br, int i) => new JunctionableGFsData(br, i);
  117. public static IReadOnlyDictionary<GFs, JunctionableGFsData> Read(BinaryReader br)
  118. => Enumerable.Range(0, Count).ToDictionary(x => (GFs)x, x => CreateInstance(br, x));
  119. public override string ToString() => Name;
  120. #endregion Methods
  121. }
  122. }
  123. }