KernelMateriaData.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <string>
  17. #include <vector>
  18. #include "common/TypeDefine.h"
  19. #include "installer/extractors/KernelDataTypes.h"
  20. /*
  21. * Records of the materia.
  22. */
  23. namespace KernelData{
  24. /**
  25. * Types of materia.
  26. */
  27. enum class MATERIA_TYPE{
  28. /**
  29. * Magic materia.
  30. */
  31. MAGIC = 1,
  32. /**
  33. * Support materia.
  34. */
  35. SUPPORT,
  36. /**
  37. * Command materia.
  38. */
  39. COMMAND,
  40. /**
  41. * Independent materia.
  42. */
  43. INDEPENDENT,
  44. /**
  45. * Summon materia.
  46. */
  47. SUMMON
  48. };
  49. /**
  50. * Stat bonuses given by equipping materia.
  51. *
  52. * They can be negative.
  53. */
  54. struct MateriaStatBonus{
  55. /**
  56. * Strength bonus. Absolute.
  57. */
  58. int str;
  59. /**
  60. * Vitality bonus. Absolute.
  61. */
  62. int vit;
  63. /**
  64. * Magic bonus. Absolute.
  65. */
  66. int mag;
  67. /**
  68. * Spirit bonus. Absolute.
  69. */
  70. int spr;
  71. /**
  72. * Dexterity bonus. Absolute.
  73. */
  74. int dex;
  75. /**
  76. * Luck bonus. Absolute.
  77. */
  78. int lck;
  79. /**
  80. * Max HP bonus. Percentile.
  81. */
  82. int hp;
  83. /**
  84. * Max MP bonus. Percentile.
  85. */
  86. int mp;
  87. /**
  88. * Indicates if at least one of the stats is changed by the materia.
  89. */
  90. bool change;
  91. };
  92. /**
  93. * Data for each materia.
  94. *
  95. * As found in KERNEL.BIN, file 8, in order, up to attributes. Members
  96. * after attributes are not found literally in KERNEL.BIN, but are
  97. * derived from other members or found in other files of the kernel
  98. * (text files).
  99. */
  100. struct MateriaData{
  101. /**
  102. * AP amounts at which the materia levels up. 4 x 1 byte.
  103. *
  104. * It can be used to determine how many levels the materia has.
  105. */
  106. u16 level_up_ap[4];
  107. /**
  108. * Index of stat modifier. 1 byte.
  109. */
  110. u8 stat_raw;
  111. /**
  112. * Status effects. 3 bytes, not 4!
  113. */
  114. u32 status_raw;
  115. /**
  116. * Materia element. 1 byte.
  117. */
  118. u8 element;
  119. /**
  120. * Materia type. 1 byte.
  121. *
  122. * 2 nybbles. The upper one is the subtype, and it's ignored in
  123. * V-Gears. The lower one the is actual type.
  124. */
  125. u8 type_raw;
  126. /**
  127. * Materia attributes. 6 x 1 byte.
  128. *
  129. * They are mostly ignored in V-Gears.
  130. */
  131. u8 attribute[6];
  132. /**
  133. * Accessory ID.
  134. *
  135. * Not in the item file data, it's the order at which it appears.
  136. */
  137. int id;
  138. /**
  139. * Accessory name.
  140. *
  141. * Not in the same file as the rest of the data, but on file 20.
  142. */
  143. std::string name;
  144. /**
  145. * Accessory description.
  146. *
  147. * Not in the same file as the rest of the data, but on file 12.
  148. */
  149. std::string description;
  150. /**
  151. * Materia type.
  152. *
  153. * Derived from {@see type_raw}.
  154. */
  155. int type;
  156. /**
  157. * Materia type.
  158. *
  159. * Derived from {@see type_raw}.
  160. */
  161. int sub_type;
  162. /**
  163. * Stat bonuses for equipping the materia.
  164. *
  165. * Derived from {@see stat_raw}.
  166. */
  167. MateriaStatBonus stats;
  168. /**
  169. * Statuses the materia inflicts.
  170. *
  171. * Derived from {@see status_raw}.
  172. */
  173. std::vector<int> status;
  174. /**
  175. * Commands the materia enables in battle.
  176. *
  177. * Derived from {@see type_raw}.
  178. */
  179. std::vector<int> command;
  180. /**
  181. * Attacks the materia enables in battle, at each level.
  182. *
  183. * Derived from {@see type_raw} and {@see attribute}.
  184. */
  185. int attack[6];
  186. /**
  187. * Number of times per battle an attack can be used, per level.
  188. *
  189. * -1 means infinite times. Derived from {@see type_raw} and
  190. * {@see attribute}.
  191. */
  192. int attack_times[6];
  193. /**
  194. * Ability confered by the materia.
  195. *
  196. * Can be provided by independent and independent materia.
  197. */
  198. std::string ability;
  199. /**
  200. * Parameter for the ability, varies per level.
  201. *
  202. * It can be the number of times the ability can be executed, or the
  203. * chance to activate...
  204. */
  205. int ability_parameters[5];
  206. };
  207. }