Kernel_bin.Junctionable_GFs_Data.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Collections.Specialized;
  5. using System.IO;
  6. namespace OpenVIII
  7. {
  8. public partial class Kernel_bin
  9. {
  10. /// <summary>
  11. /// requirement to unlock abilities
  12. /// </summary>
  13. /// <see cref="https://github.com/alexfilth/doomtrain/blob/master/Doomtrain/MainForm.Designer.cs"/>
  14. public enum Unlocker:byte
  15. {
  16. None,
  17. GFLevel1,
  18. GFLevel2,
  19. GFLevel3,
  20. GFLevel4,
  21. GFLevel5,
  22. GFLevel6,
  23. GFLevel7,
  24. GFLevel8,
  25. GFLevel9,
  26. GFLevel10,
  27. GFLevel11,
  28. GFLevel12,
  29. GFLevel13,
  30. GFLevel14,
  31. GFLevel15,
  32. GFLevel16,
  33. GFLevel17,
  34. GFLevel18,
  35. GFLevel19,
  36. GFLevel20,
  37. GFLevel21,
  38. GFLevel22,
  39. GFLevel23,
  40. GFLevel24,
  41. GFLevel25,
  42. GFLevel26,
  43. GFLevel27,
  44. GFLevel28,
  45. GFLevel29,
  46. GFLevel30,
  47. GFLevel31,
  48. GFLevel32,
  49. GFLevel33,
  50. GFLevel34,
  51. GFLevel35,
  52. GFLevel36,
  53. GFLevel37,
  54. GFLevel38,
  55. GFLevel39,
  56. GFLevel40,
  57. GFLevel41,
  58. GFLevel42,
  59. GFLevel43,
  60. GFLevel44,
  61. GFLevel45,
  62. GFLevel46,
  63. GFLevel47,
  64. GFLevel48,
  65. GFLevel49,
  66. GFLevel50,
  67. GFLevel51,
  68. GFLevel52,
  69. GFLevel53,
  70. GFLevel54,
  71. GFLevel55,
  72. GFLevel56,
  73. GFLevel57,
  74. GFLevel58,
  75. GFLevel59,
  76. GFLevel60,
  77. GFLevel61,
  78. GFLevel62,
  79. GFLevel63,
  80. GFLevel64,
  81. GFLevel65,
  82. GFLevel66,
  83. GFLevel67,
  84. GFLevel68,
  85. GFLevel69,
  86. GFLevel70,
  87. GFLevel71,
  88. GFLevel72,
  89. GFLevel73,
  90. GFLevel74,
  91. GFLevel75,
  92. GFLevel76,
  93. GFLevel77,
  94. GFLevel78,
  95. GFLevel79,
  96. GFLevel80,
  97. GFLevel81,
  98. GFLevel82,
  99. GFLevel83,
  100. GFLevel84,
  101. GFLevel85,
  102. GFLevel86,
  103. GFLevel87,
  104. GFLevel88,
  105. GFLevel89,
  106. GFLevel90,
  107. GFLevel91,
  108. GFLevel92,
  109. GFLevel93,
  110. GFLevel94,
  111. GFLevel95,
  112. GFLevel96,
  113. GFLevel97,
  114. GFLevel98,
  115. GFLevel99,
  116. GFLevel100,
  117. Ability1,
  118. Ability2,
  119. Ability3,
  120. Ability4,
  121. Ability5,
  122. Ability6,
  123. Ability7,
  124. Ability8,
  125. Ability9,
  126. Ability10,
  127. Ability11,
  128. Ability12,
  129. Ability13,
  130. Ability14,
  131. Ability15,
  132. Ability16,
  133. Ability17,
  134. Ability18,
  135. Ability19,
  136. Ability20,
  137. Ability21,
  138. }
  139. /// <summary>
  140. /// Junctionable GFs Data
  141. /// </summary>
  142. /// <see cref="https://github.com/alexfilth/doomtrain/wiki/Junctionable-GFs"/>
  143. public class Junctionable_GFs_Data
  144. {
  145. public const int id = 2;
  146. public const int count = 16;
  147. private OrderedDictionary<Abilities, Unlocker> _ability;
  148. private Dictionary<GFs, decimal> _gF_Compatibility;
  149. public FF8String Name { get; private set; }
  150. public FF8String Description { get; private set; }
  151. public override string ToString() => Name;
  152. //0x0000 2 bytes Offset to GF attack name
  153. //0x0002 2 bytes Offset to GF attack description
  154. public Magic_ID MagicID { get; private set; } //0x0004 2 bytes[[Magic ID
  155. public Attack_Type Attack_type { get; private set; } //0x0006 1 byte Attack type
  156. public byte GF_power { get; private set; } //0x0007 1 byte GF power(used in damage formula)
  157. public byte[] Unknown0 { get; private set; } //0x0008 2 bytes Unknown
  158. public Attack_Flags Attack_flags { get; private set; } //0x000A 1 byte Attack Flags
  159. public byte[] Unknown1 { get; private set; } //0x000B 2 bytes Unknown
  160. public Element Element { get; private set; } //0x000D 1 byte[[Element
  161. public Persistent_Statuses Statuses0 { get; private set; } //0x000E 2 bytes[[Statuses 0
  162. public Battle_Only_Statuses Statuses1 { get; private set; } //0x0010 4 bytes[[Statuses 1
  163. public byte HP_MOD { get; private set; } //0x0014 1 byte GF HP Modifier(used in GF HP formula)
  164. public byte[] Unknown2_1 { get; private set; } //0x0015 3 bytes Unknown
  165. public ushort EXPperLevel { get; private set; } //0x18 1 byte *10;
  166. public byte[] Unknown2_2 { get; private set; } //0x0019 2 bytes Unknown
  167. public byte Status_attack { get; private set; } //0x001B 1 byte Status attack enabler
  168. public OrderedDictionary<Abilities, Unlocker> Ability { get => _ability; }
  169. public IReadOnlyDictionary<GFs, decimal> GF_Compatibility { get => _gF_Compatibility; }
  170. //0x0070 1 byte Quezacolt compatibility
  171. //0x0071 1 byte Shiva compatibility
  172. //0x0072 1 byte Ifrit compatibility
  173. //0x0073 1 byte Siren compatibility
  174. //0x0074 1 byte Brothers compatibility
  175. //0x0075 1 byte Diablos compatibility
  176. //0x0076 1 byte Carbuncle compatibility
  177. //0x0077 1 byte Leviathan compatibility
  178. //0x0078 1 byte Pandemona compatibility
  179. //0x0079 1 byte Cerberus compatibility
  180. //0x007A 1 byte Alexander compatibility
  181. //0x007B 1 byte Doomtrain compatibility
  182. //0x007C 1 byte Bahamut compatibility
  183. //0x007D 1 byte Cactuar compatibility
  184. //0x007E 1 byte Tonberry compatibility
  185. //0x007F 1 byte Eden compatibility
  186. public byte[] Unknown3 { get; private set; } //0x0080 2 bytes Unknown
  187. public byte PowerMod { get; private set; } //0x0082 1 byte Power Mod(used in damage formula)
  188. public byte LevelMod { get; private set; } //0x0083 1 byte Level Mod(used in damage formula)
  189. public void Read(BinaryReader br, int i)
  190. {
  191. Name = Memory.Strings.Read(Strings.FileID.KERNEL, id, i * 2);
  192. Description = Memory.Strings.Read(Strings.FileID.KERNEL, id, i * 2 + 1);
  193. br.BaseStream.Seek(4, SeekOrigin.Current);
  194. MagicID = (Magic_ID)br.ReadUInt16(); //0x0004 2 bytes[[Magic ID
  195. Attack_type = (Attack_Type)br.ReadByte(); //0x0006 1 byte Attack type
  196. GF_power = br.ReadByte(); //0x0007 1 byte GF power(used in damage formula)
  197. Unknown0 = br.ReadBytes(2); //0x0008 2 bytes Unknown
  198. Attack_flags = (Attack_Flags)(br.ReadByte()); //0x000A 1 byte Attack Flags
  199. Unknown1 = br.ReadBytes(2); //0x000B 2 bytes Unknown
  200. Element = (Element)br.ReadByte(); //0x000D 1 byte[[Element
  201. Statuses0 = (Persistent_Statuses)br.ReadUInt16(); //0x000E 2 bytes[[Statuses 0
  202. Statuses1 = (Battle_Only_Statuses)br.ReadUInt32(); //0x0010 4 bytes[[Statuses 1
  203. HP_MOD = br.ReadByte(); //0x0014 1 byte GF HP Modifier(used in GF HP formula)
  204. Unknown2_1 = br.ReadBytes(3); //0x0015 3 bytes Unknown
  205. EXPperLevel = (ushort)((br.ReadByte()) * 10); //0x0018
  206. Unknown2_2 = br.ReadBytes(2); //0x0019 2 bytes Unknown
  207. Status_attack = br.ReadByte(); //0x001B 1 byte Status attack enabler
  208. _ability = new OrderedDictionary<Abilities,Unlocker>(21);
  209. for (i = 0; i < 21; i++)
  210. {
  211. Unlocker val = (Unlocker)br.ReadByte();
  212. br.BaseStream.Seek(1, SeekOrigin.Current);
  213. Abilities key = (Abilities)br.ReadUInt16();
  214. _ability.Add(key, val);
  215. }
  216. _gF_Compatibility = new Dictionary<GFs, decimal>(16);
  217. for (i = 0; i < 16; i++)
  218. _gF_Compatibility.Add((GFs)i, (100 - Convert.ToDecimal(br.ReadByte())) / 5); //doomtrain shows this is a decimal number. i got formula from code.
  219. Unknown3 = br.ReadBytes(2); //0x0080 2 bytes Unknown
  220. PowerMod = br.ReadByte(); //0x0082 1 byte Power Mod(used in damage formula)
  221. LevelMod = br.ReadByte(); //0x0083 1 byte Level Mod(used in damage formula)
  222. }
  223. public static Dictionary<GFs, Junctionable_GFs_Data> Read(BinaryReader br)
  224. {
  225. var ret = new Dictionary<GFs, Junctionable_GFs_Data>(count);
  226. for (int i = 0; i < count; i++)
  227. {
  228. var tmp = new Junctionable_GFs_Data();
  229. tmp.Read(br, i);
  230. ret[(GFs)i] = tmp;
  231. }
  232. return ret;
  233. }
  234. }
  235. }
  236. }