KernelDataInstaller.h 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436
  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 "common/BinGZipFile.h"
  17. #include "common/TypeDefine.h"
  18. #include "Characters.h"
  19. #include "SaveMap.h"
  20. class KernelDataInstaller{
  21. public:
  22. /**
  23. * Constructor.
  24. *
  25. * @param[in] path Absolute path to the KERNEL.BIN file
  26. */
  27. KernelDataInstaller(std::string path);
  28. /**
  29. * Destructor.
  30. */
  31. ~KernelDataInstaller();
  32. /**
  33. * Reads the command data from the kernel.
  34. *
  35. * @return The number of commands read.
  36. */
  37. int ReadCommands();
  38. /**
  39. * Saves command data to an xml file
  40. *
  41. * @param file[in] Absolute path to the target XML file.
  42. */
  43. void WriteCommands(std::string file);
  44. /**
  45. * Reads the attack data from the kernel.
  46. *
  47. * @return The number of attacks read.
  48. */
  49. int ReadAttacks();
  50. /**
  51. * Saves command data to an xml file
  52. *
  53. * @param file[in] Absolute path to the target XML file.
  54. */
  55. void WriteAttacks(std::string file);
  56. /**
  57. * Reads character data from the kernel.
  58. *
  59. * @return The number of characters read.
  60. */
  61. int ReadCharacters();
  62. /**
  63. * Saves character data to an xml file
  64. *
  65. * @param file[in] Absolute path to the target XML file.
  66. */
  67. void WriteCharacters(std::string file);
  68. /**
  69. * Reads growth data from the kernel.
  70. */
  71. void ReadGrowth();
  72. /**
  73. * Saves growth data to an xml file
  74. *
  75. * @param file[in] Absolute path to the target XML file.
  76. */
  77. void WriteGrowth(std::string file);
  78. /**
  79. * Reads the items from the kernel.
  80. *
  81. * @return The number of items read.
  82. */
  83. int ReadItems();
  84. /**
  85. * Saves item data to an xml file
  86. *
  87. * @param file[in] Absolute path to the target XML file.
  88. */
  89. void WriteItems(std::string file);
  90. /**
  91. * Reads the weapon info from the kernel.
  92. *
  93. * @return The number of weapons read.
  94. */
  95. int ReadWeapons();
  96. /**
  97. * Saves weapon data to an xml file
  98. *
  99. * @param file[in] Absolute path to the target XML file.
  100. */
  101. void WriteWeapons(std::string file);
  102. /**
  103. * Reads the armor info from the kernel.
  104. *
  105. * @return The number of armor read.
  106. */
  107. int ReadArmors();
  108. /**
  109. * Saves armor data to an xml file
  110. *
  111. * @param file[in] Absolute path to the target XML file.
  112. */
  113. void WriteArmors(std::string file);
  114. /**
  115. * Reads the accessory info from the kernel.
  116. *
  117. * @return The number of accessories read.
  118. */
  119. int ReadAccessories();
  120. /**
  121. * Saves accessory data to an xml file
  122. *
  123. * @param file[in] Absolute path to the target XML file.
  124. */
  125. void WriteAccessories(std::string file);
  126. /**
  127. * Reads materia info from the kernel.
  128. *
  129. * @return The number of accessories read.
  130. */
  131. int ReadMateria();
  132. /**
  133. * Saves materia data to an xml file
  134. *
  135. * @param file[in] Absolute path to the target XML file.
  136. */
  137. void WriteMateria(std::string file);
  138. /**
  139. * Reads key item info from the kernel.
  140. *
  141. * @return The number of key items read.
  142. */
  143. int ReadKeyItems();
  144. /**
  145. * Saves key item data to an xml file
  146. *
  147. * @param file[in] Absolute path to the target XML file.
  148. */
  149. void WriteKeyItems(std::string file);
  150. /**
  151. * Reads summon name info from the kernel.
  152. *
  153. * @return The number of summons read.
  154. */
  155. int ReadSummonNames();
  156. /**
  157. * Saves summon names data to an xml file
  158. *
  159. * @param file[in] Absolute path to the target XML file.
  160. */
  161. void WriteSummonNames(std::string file);
  162. /**
  163. * Reads the initial savemap from the kernel.
  164. */
  165. void ReadInitialSaveMap();
  166. /**
  167. * Saves the initial savemap to an xml file
  168. *
  169. * @param file[in] Absolute path to the target XML file.
  170. */
  171. void WriteInitialSaveMap(std::string file);
  172. private:
  173. enum KERNEL_SECTIONS{
  174. /**
  175. * Command data section in KERNEL.BIN.
  176. */
  177. KERNEL_COMMAND_DATA = 0,
  178. /**
  179. * Attack data section in KERNEL.BIN.
  180. */
  181. KERNEL_ATTACK_DATA,
  182. /**
  183. * Battle and growth data section in KERNEL.BIN.
  184. */
  185. KERNEL_BATTLE_AND_GROWTH_DATA,
  186. /**
  187. * Initialization data section in KERNEL.BIN.
  188. */
  189. KERNEL_INITIALIZATION_DATA,
  190. /**
  191. * Item data section in KERNEL.BIN.
  192. */
  193. KERNEL_ITEM_DATA,
  194. /**
  195. * Weapon data section in KERNEL.BIN.
  196. */
  197. KERNEL_WEAPON_DATA,
  198. /**
  199. * Armor data section in KERNEL.BIN.
  200. */
  201. KERNEL_ARMOR_DATA,
  202. /**
  203. * Accessory data section in KERNEL.BIN.
  204. */
  205. KERNEL_ACCESSORY_DATA,
  206. /**
  207. * Materia data section in KERNEL.BIN.
  208. */
  209. KERNEL_MATERIA_DATA,
  210. /**
  211. * Command descriptions section in KERNEL.BIN.
  212. */
  213. KERNEL_COMMAND_DESCRIPTIONS,
  214. /**
  215. * Magic descriptions section in KERNEL.BIN.
  216. */
  217. KERNEL_MAGIC_DESCRIPTIONS,
  218. /**
  219. * Item descriptions section in KERNEL.BIN.
  220. */
  221. KERNEL_ITEM_DESCRIPTIONS,
  222. /**
  223. * Weapon descriptions section in KERNEL.BIN.
  224. */
  225. KERNEL_WEAPON_DESCRIPTIONS,
  226. /**
  227. * Armor descriptions section in KERNEL.BIN.
  228. */
  229. KERNEL_ARMOR_DESCRIPTIONS,
  230. /**
  231. * Accessory descriptions section in KERNEL.BIN.
  232. */
  233. KERNEL_ACCESSORY_DESCRIPTIONS,
  234. /**
  235. * Materia descriptions section in KERNEL.BIN.
  236. */
  237. KERNEL_MATERIA_DESCRIPTIONS,
  238. /**
  239. * Key Item descriptions section in KERNEL.BIN.
  240. */
  241. KERNEL_KEY_ITEM_DESCRIPTIONS,
  242. /**
  243. * Command Names section in KERNEL.BIN.
  244. */
  245. KERNEL_COMMAND_NAMES,
  246. /**
  247. * Magic Names section in KERNEL.BIN.
  248. */
  249. KERNEL_MAGIC_NAMES,
  250. /**
  251. * Item Names section in KERNEL.BIN.
  252. */
  253. KERNEL_ITEM_NAMES,
  254. /**
  255. * Weapon Names section in KERNEL.BIN.
  256. */
  257. KERNEL_WEAPON_NAMES,
  258. /**
  259. * Armor Names section in KERNEL.BIN.
  260. */
  261. KERNEL_ARMOR_NAMES,
  262. /**
  263. * Accessory Names section in KERNEL.BIN.
  264. */
  265. KERNEL_ACCESSORY_NAMES,
  266. /**
  267. * Materia Names section in KERNEL.BIN.
  268. */
  269. KERNEL_MATERIA_NAMES,
  270. /**
  271. * Key Item Names section in KERNEL.BIN.
  272. */
  273. KERNEL_KEY_ITEM_NAMES,
  274. /**
  275. * Battle and Battle-Screen Text section in KERNEL.BIN.
  276. */
  277. KERNEL_BATTLE_AND_BATTLE_SCREEN_TEXT,
  278. /**
  279. * Summon Attack Names section in KERNEL.BIN.
  280. */
  281. KERNEL_SUMMON_ATTACK_NAMES
  282. };
  283. enum ELEMENT{
  284. /**
  285. * Fire element.
  286. */
  287. FIRE = 0,
  288. /**
  289. * Ice element.
  290. */
  291. ICE,
  292. /**
  293. * Bolt element.
  294. */
  295. BOLT,
  296. /**
  297. * Earth element.
  298. */
  299. EARTH,
  300. /**
  301. * Poison element.
  302. */
  303. POISON,
  304. /**
  305. * Gravity element.
  306. */
  307. GRAVITY,
  308. /**
  309. * Water element.
  310. */
  311. WATER,
  312. /**
  313. * Wind element.
  314. */
  315. WIND,
  316. /**
  317. * Holy element.
  318. */
  319. HOLY,
  320. /**
  321. * Restorative element.
  322. */
  323. RESTORATIVE,
  324. /**
  325. * Cut element.
  326. */
  327. CUT,
  328. /**
  329. * Hit element.
  330. */
  331. HIT,
  332. /**
  333. * Punch element.
  334. */
  335. PUNCH,
  336. /**
  337. * Shoot element.
  338. */
  339. SHOOT,
  340. /**
  341. * Shout element.
  342. */
  343. SHOUT,
  344. /**
  345. * Hidden element.
  346. */
  347. HIDDEN,
  348. };
  349. /**
  350. * List of target selection options.
  351. */
  352. struct Target{
  353. /**
  354. * The target can be selected.
  355. *
  356. * If the target of the attack is selectable, at least between some subset of possible
  357. * targets, this must be true.
  358. */
  359. bool selection_enabled;
  360. /**
  361. * The default target is an enemy.
  362. *
  363. * When true, the cursor starts in an enemy row. When false, it starts in the ally row.
  364. * It may or may not be possible to change it.
  365. */
  366. bool default_enemy;
  367. /**
  368. * The default target is a group.
  369. *
  370. * When true, the cursor starts will all the members of a row selected. When false, it
  371. * starts with only one target selected. It may or may not be possible to change it.
  372. */
  373. bool default_multiple;
  374. /**
  375. * The selection can change between groups and individuals.
  376. *
  377. * When true, the target can be changed between groups and individuals When false,
  378. * only {@see default_multiple} determines if the target is an individual or a group.
  379. */
  380. bool toggle_multiple;
  381. /**
  382. * The target group can be changed.
  383. *
  384. * When true, the target cannot be changed between enemies and allies. In this case
  385. * {@see default_enemy} will determine the group that can be targeted.
  386. */
  387. bool fixed_row;
  388. /**
  389. * The command is short ranged.
  390. *
  391. * When true, if the target or the caster is not in the front of their row, the target
  392. * will take half damage. Also, when true, an enemy covered by another enemy can't be
  393. * targeted.
  394. */
  395. bool short_range;
  396. /**
  397. * Targets all, enemies and allies.
  398. *
  399. * When true, all allies and enemies are targets, and the selection can't be changed.
  400. */
  401. bool all_rows;
  402. /**
  403. * The target is random.
  404. *
  405. * When multiple targets are selected, one will be selected at random to be the
  406. * receiving target. Cursor will cycle among all viable targets.
  407. */
  408. bool random;
  409. };
  410. /**
  411. * Determines what an item affects on when used from the menu.
  412. */
  413. enum RESTORE_TYPE{
  414. /**
  415. * The item affects a party member or group HP.
  416. */
  417. RESTORE_HP = 0,
  418. /**
  419. * The item affects a party member or group MP.
  420. */
  421. RESTORE_MP = 1,
  422. /**
  423. * The item affects a party member or group status.
  424. */
  425. RESTORE_STATUS = 2,
  426. /**
  427. * The item is not restorative.
  428. */
  429. RESTORE_NONE = 3
  430. };
  431. /**
  432. * List of altered status.
  433. */
  434. enum STATUS{
  435. /**
  436. * The character is dead.
  437. */
  438. DEATH = 0,
  439. /**
  440. * The character has critical HP.
  441. */
  442. NEAR_DEATH,
  443. /**
  444. * The character is asleep.
  445. */
  446. SLEEP,
  447. /**
  448. * The character is poisoned.
  449. */
  450. POISONED,
  451. /**
  452. * The character is sad.
  453. */
  454. SADNESS,
  455. /**
  456. * The character is furious.
  457. */
  458. FURY,
  459. /**
  460. * The character is confused.
  461. */
  462. CONFU,
  463. /**
  464. * The character is silenced.
  465. */
  466. SILENCE,
  467. /**
  468. * The character is slow.
  469. */
  470. HASTE,
  471. /**
  472. * The character is
  473. */
  474. SLOW,
  475. /**
  476. * The character is stopped.
  477. */
  478. STOP,
  479. /**
  480. * The character is a frog.
  481. */
  482. FROG,
  483. /**
  484. * The character is small.
  485. */
  486. SMALL,
  487. /**
  488. * The character is going to be petrified.
  489. */
  490. SLOW_NUMB,
  491. /**
  492. * The character is petrified.
  493. */
  494. PETRIFY,
  495. /**
  496. * The character is regenerating health.
  497. */
  498. REGEN,
  499. /**
  500. * The character has a physical barrier.
  501. */
  502. BARRIER,
  503. /**
  504. * The character has a magical barrier
  505. */
  506. M_BARRIER,
  507. /**
  508. * The character reflects magical attacks.
  509. */
  510. REFLECT,
  511. /**
  512. * The character has dual status.
  513. *
  514. * @todo What does it do.
  515. */
  516. DUAL,
  517. /**
  518. * The character has a shield.
  519. */
  520. SHIELD,
  521. /**
  522. * The character has a death sentence.
  523. */
  524. D_SENTENCE,
  525. /**
  526. * The character is being manipulated.
  527. */
  528. MANIPULATE,
  529. /**
  530. * The character is berserk.
  531. */
  532. BERSERK,
  533. /**
  534. * The character is invincible.
  535. */
  536. PEERLESS,
  537. /**
  538. * The character is paralyzed.
  539. */
  540. PARALYSIS,
  541. /**
  542. * The character is blinded.
  543. */
  544. DARKNESS,
  545. /**
  546. * The character has dual drain.
  547. */
  548. DUAL_DRAIN,
  549. /**
  550. * The character has deathforce.
  551. */
  552. DEATH_FORCE,
  553. /**
  554. * The character has resist.
  555. */
  556. RESIST,
  557. /**
  558. * Cait' Sith lucky girl mode.
  559. */
  560. LUCKY_GIRL,
  561. /**
  562. * The character is imprisioned.
  563. */
  564. IMPRISONED
  565. };
  566. /**
  567. * How a status effect modifier attack or item can act.
  568. */
  569. enum STATUS_EFFECT{
  570. /**
  571. * Inflicts status changes.
  572. */
  573. INFLICT = 0,
  574. /**
  575. * Cures status changes.
  576. */
  577. CURE = 1,
  578. /**
  579. * Toggles status changes.
  580. *
  581. * If the target doesn't have the status change, inflict it. If the target already has
  582. * the status change, cure it.
  583. */
  584. TOGGLE = 2
  585. };
  586. struct StatusEffect{
  587. /**
  588. * The list of status to inflict or cure.
  589. */
  590. std::vector<int> status;
  591. /**
  592. * The chance of landing a status effect (out of 63).
  593. */
  594. u16 chance;
  595. /**
  596. * The status change mode.
  597. */
  598. STATUS_EFFECT mode;
  599. };
  600. /**
  601. * Data for each command.
  602. *
  603. * As found in KERNEL.BIN, file 0, in order, up to camera_multiple. Members after
  604. * camera_multiple are not found literally in KERNEL.BIN, but are derived from other
  605. * members or found in other files of the kernel (text files).
  606. */
  607. struct CommandData{
  608. /**
  609. * Cursor action when the command is selected.
  610. */
  611. u8 cursor_action;
  612. /**
  613. * Targeting mode. 1 byte.
  614. *
  615. * See {@see target} and {@TargetModes} for more information.
  616. */
  617. u8 target_raw;
  618. /**
  619. * Unknown data (Always 0XFFFF). 2 bytes.
  620. */
  621. u16 unknown;
  622. /**
  623. * Camera movement ID for single target. 2 bytes.
  624. *
  625. * Determines the camera movement when the command is executed over a single target.
  626. */
  627. u16 camera_single;
  628. /**
  629. * Camera movement ID for multiple target. 2 bytes.
  630. *
  631. * Determines the camera movement when the command is executed over multiple targets.
  632. */
  633. u16 camera_multiple;
  634. /**
  635. * Command ID.
  636. *
  637. * Not actually in the item file data, it's the order at which it appears.
  638. */
  639. int id;
  640. /**
  641. * Command name.
  642. *
  643. * Not found in the same file as the rest of the data, but on file 17.
  644. */
  645. std::string name;
  646. /**
  647. * Command description.
  648. *
  649. * Not found in the same file as the rest of the data, but on file 9.
  650. */
  651. std::string description;
  652. /**
  653. * Target selection mode.
  654. *
  655. * Derived from {@see target_raw}.
  656. */
  657. Target target;
  658. };
  659. /**
  660. * Data for each attack.
  661. *
  662. * As found in KERNEL.BIN, file 1, in order, up to camera_multiple. Members after
  663. * special_raw are not found literally in KERNEL.BIN, but are derived from other
  664. * members.
  665. */
  666. struct AttackData{
  667. /**
  668. * Probability of the attack to land. 1 byte.
  669. */
  670. u8 accuracy;
  671. /**
  672. * Impact effect. 1 byte.
  673. *
  674. * The sprite shown when the attack hits.
  675. */
  676. u8 impact_effect;
  677. /**
  678. * Index of the animation played by the target when hit. 1 byte.
  679. */
  680. u8 hurt_anim;
  681. /**
  682. * Unknown data. 1 bytes.
  683. */
  684. u8 unknown;
  685. /**
  686. * MP cost. 2 bytes.
  687. *
  688. * Determines the camera movement when the command is executed over a single target.
  689. */
  690. u16 mp;
  691. /**
  692. * Impact sound. 2 bytes.
  693. *
  694. * Determines the camera movement when the command is executed over multiple targets.
  695. */
  696. u16 sound;
  697. /**
  698. * Camera movement ID for single target. 2 bytes.
  699. *
  700. * Determines the camera movement when the command is executed over a single target.
  701. */
  702. u16 camera_single;
  703. /**
  704. * Camera movement ID for multiple target. 2 bytes.
  705. *
  706. * Determines the camera movement when the command is executed over multiple targets.
  707. */
  708. u16 camera_multiple;
  709. /**
  710. * Targeting mode. 1 byte.
  711. *
  712. * See {@see target} and {@TargetModes} for more information.
  713. */
  714. u8 target_raw;
  715. /**
  716. * Atack effect ID. 1 byte.
  717. *
  718. * Used for animation in battle.
  719. */
  720. u8 effect;
  721. /**
  722. * Damage formula. 1 byte.
  723. *
  724. * This byte is divided into two nybbles (four bits). Upper nybble determines what
  725. * considerations are made in calculating damage such as physical/magical, allowing
  726. * criticals, how to calculate accuracy, etc. There are also three sets of known
  727. * formulae that are paired with the upper nybble values. These are selected in the
  728. * Lower Nybble and determine how to calculate pre-defense damage
  729. */
  730. u8 damage_raw;
  731. /**
  732. * The attack power. 1 byte.
  733. *
  734. * Used for damage/healing calculation.
  735. */
  736. u8 power;
  737. /**
  738. * The restore type.
  739. *
  740. * See {@restore_typ} and {@RESTORE_TYPE} for more information.
  741. */
  742. u8 condition_raw;
  743. /**
  744. * Information about status change mode and chance. 1 bytes.
  745. */
  746. u8 status_change_raw;
  747. /**
  748. * Special flags. 1 byte.
  749. *
  750. * @todo Document and retrieve with info from
  751. * https://wiki.ffrtt.ru/index.php?title=FF7/Battle/Attack_Special_Effects
  752. */
  753. u8 additional_effects_raw;
  754. /**
  755. * Special flags. 1 byte.
  756. *
  757. * @todo Document and retrieve with info from
  758. * https://wiki.ffrtt.ru/index.php?title=FF7/Item_data
  759. */
  760. u8 additional_effects_mod_raw;
  761. /**
  762. * Information about what status can be inflicted or cured. 4 bytes.
  763. *
  764. * The first six bits are the chance of inflicting/curing (out of 63). If the seventh
  765. * bit is set, the status is cured instead of inflicted. If the eighth bit is set, then
  766. * the status is toggled (cured if present, inflicted if not present).
  767. */
  768. u32 status_raw;
  769. /**
  770. * Information about the item elements. 2 bytes.
  771. */
  772. u16 element_raw;
  773. /**
  774. * Special flags. 2 bytes.
  775. *
  776. * @todo document and parse with info from
  777. * https://wiki.ffrtt.ru/index.php?title=FF7/Battle/Special_Attack_Flags
  778. */
  779. u16 special_raw;
  780. /**
  781. * Attack ID.
  782. *
  783. * Not actually in the item file data, it's the order at which it appears.
  784. */
  785. int id;
  786. /**
  787. * Target selection mode.
  788. *
  789. * Derived from {@see target_raw}.
  790. */
  791. Target target;
  792. /**
  793. * The damage formula.
  794. *
  795. * It's the upper nybble in {@see damage_raw}.
  796. */
  797. u8 damage_formula;
  798. /**
  799. * The damage modifier.
  800. *
  801. * It's the lower nybble in {@see damage_raw}.
  802. */
  803. u8 damage_modifier;
  804. /**
  805. * What the attack restores when used.
  806. *
  807. * Same as {@see condition_raw}, except for the wrong cases.
  808. */
  809. RESTORE_TYPE restore_type;
  810. /**
  811. * Status effects.
  812. *
  813. * Derived from {@see status_change_raw} and {@see status_raw}.
  814. */
  815. StatusEffect status;
  816. /**
  817. * Elements of the attack.
  818. *
  819. * Derived from {@see element_raw}.
  820. */
  821. std::vector<int> elements;
  822. };
  823. /**
  824. * Data for each items
  825. *
  826. * As found in KERNEL.BIN, file 4, in order, up to special. Members after special are not
  827. * found literally in KERNEL.BIN, but are derived from other members or found in other
  828. * files of the kernel (text files).
  829. */
  830. struct ItemData{
  831. /**
  832. * Unknown data (Always 0XFFFF). 4 bytes.
  833. */
  834. u32 unknown_0;
  835. /**
  836. * Unknown data (Always 0XFFFF). 4 bytes.
  837. */
  838. u32 unknown_1;
  839. /**
  840. * Camera movement ID. 2 bytes.
  841. *
  842. * Used for items useable in battle, determines the camera movement.
  843. */
  844. u16 camera;
  845. /**
  846. * Item restrictions. 2 bytes.
  847. *
  848. * Contains bits indicating if the item is {@see selleable}, {@see useable_battle} and
  849. * {@see useable_menu}.
  850. */
  851. u16 restrict_raw;
  852. /**
  853. * Targeting mode. 1 byte.
  854. *
  855. * See {@see target} and {@TargetModes} for more information.
  856. */
  857. u8 target_raw;
  858. /**
  859. * Item effect ID. 1 byte.
  860. *
  861. * Used for animation in battle.
  862. */
  863. u8 effect;
  864. /**
  865. * Damage formula. 1 byte.
  866. *
  867. * This byte is divided into two nybbles (four bits). Upper nybble determines what
  868. * considerations are made in calculating damage such as physical/magical, allowing
  869. * criticals, how to calculate accuracy, etc. There are also three sets of known
  870. * formulae that are paired with the upper nybble values. These are selected in the
  871. * Lower Nybble and determine how to calculate pre-defense damage
  872. */
  873. u8 damage_raw;
  874. /**
  875. * The item power. 1 byte.
  876. *
  877. * Used for damage/healing calculation.
  878. */
  879. u8 power;
  880. /**
  881. * The restore type.
  882. *
  883. * See {@restore_typ} and {@RESTORE_TYPE} for more information.
  884. */
  885. u8 condition_raw;
  886. /**
  887. * Information about status change mode and chance. 1 bytes.
  888. */
  889. u8 status_change_raw;
  890. /**
  891. * Special flags. 1 byte.
  892. *
  893. * @todo Document and retrieve with info from
  894. * https://wiki.ffrtt.ru/index.php?title=FF7/Battle/Attack_Special_Effects
  895. */
  896. u8 additional_effects_raw;
  897. /**
  898. * Special flags. 1 byte.
  899. *
  900. * @todo Document and retrieve with info from
  901. * https://wiki.ffrtt.ru/index.php?title=FF7/Item_data
  902. */
  903. u8 additional_effects_mod_raw;
  904. /**
  905. * Information about what status can be inflicted or cured. 4 bytes.
  906. *
  907. * The first six bits are the chance of inflicting/curing (out of 63). If the seventh
  908. * bit is set, the status is cured instead of inflicted. If the eighth bit is set, then
  909. * the status is toggled (cured if present, inflicted if not present).
  910. */
  911. u32 status_raw;
  912. /**
  913. * Information about the item elements. 2 bytes.
  914. */
  915. u16 element_raw;
  916. /**
  917. * Special flags. 2 bytes.
  918. *
  919. * @todo document and parse with info from
  920. * https://wiki.ffrtt.ru/index.php?title=FF7/Battle/Special_Attack_Flags
  921. */
  922. u16 special_raw;
  923. /**
  924. * Item ID.
  925. *
  926. * Not actually in the item file data, it's the order at which it appears.
  927. */
  928. int id;
  929. /**
  930. * Item name.
  931. *
  932. * Not found in the same file as the rest of the data, but on file 19.
  933. */
  934. std::string name;
  935. /**
  936. * Item description.
  937. *
  938. * Not found in the same file as the rest of the data, but on file 11.
  939. */
  940. std::string description;
  941. /**
  942. * Indicates if the item can be sold.
  943. *
  944. * True if the bit 0 in {@see restrict_raw} is 0.
  945. */
  946. bool sellable;
  947. /**
  948. * Indicates if the item can be used in battle.
  949. *
  950. * True if the bit 2 in {@see restrict_raw} is 0.
  951. */
  952. bool useable_battle;
  953. /**
  954. * Indicates if the item can be used in the menu.
  955. *
  956. * True if the bit 4 in {@see restrict_raw} is 0.
  957. */
  958. bool useable_menu;
  959. /**
  960. * Target selection mode.
  961. *
  962. * Derived from {@see target_raw}.
  963. */
  964. Target target;
  965. /**
  966. * The damage formula.
  967. *
  968. * It's the upper nybble in {@see damage_raw}.
  969. */
  970. u8 damage_formula;
  971. /**
  972. * The damage modifier.
  973. *
  974. * It's the lower nybble in {@see damage_raw}.
  975. */
  976. u8 damage_modifier;
  977. /**
  978. * What the item restores when used.
  979. *
  980. * Same as {@see condition_raw}, except for the wrong cases.
  981. */
  982. RESTORE_TYPE restore_type;
  983. /**
  984. * Status effects.
  985. *
  986. * Derived from {@see status_change_raw} and {@see status_raw}.
  987. */
  988. StatusEffect status;
  989. /**
  990. * Elements of the item.
  991. *
  992. * Derived from {@see element_raw}.
  993. */
  994. std::vector<int> elements;
  995. };
  996. /**
  997. * Materia slot types.
  998. */
  999. enum SLOT_TYPE{
  1000. /**
  1001. * A non linked slot.
  1002. */
  1003. SLOT_UNLINKED = 0,
  1004. /**
  1005. * A linked slot.
  1006. *
  1007. * If the slot is in an even position, it's linked to the one in the right. If it's in
  1008. * an odd position, it;s linked to the one in the Left. Remember that slot positions
  1009. * are 0-index.
  1010. */
  1011. SLOT_LINKED = 1
  1012. };
  1013. /**
  1014. * Bonus in stat givven by weapons or armor.
  1015. */
  1016. struct StatBonus{
  1017. /**
  1018. * ID of the raised stat.
  1019. */
  1020. u8 stat;
  1021. /**
  1022. * Stat value raise.
  1023. */
  1024. u8 bonus;
  1025. };
  1026. /**
  1027. * Data for each weapon
  1028. *
  1029. * As found in KERNEL.BIN, file 5, in order, up to special. Members after special are not
  1030. * found literally in KERNEL.BIN, but are derived from other members or found in other
  1031. * files of the kernel (text files).
  1032. */
  1033. struct WeaponData{
  1034. /**
  1035. * Targeting mode. 1 byte.
  1036. *
  1037. * See {@see target} and {@TargetModes} for more information.
  1038. */
  1039. u8 target_raw;
  1040. /**
  1041. * Effect ID, unused (Always 0XFF). 1 byte.
  1042. */
  1043. u8 unused_0;
  1044. /**
  1045. * Damage formula. 1 byte.
  1046. *
  1047. * This byte is divided into two nybbles (four bits). Upper nybble determines what
  1048. * considerations are made in calculating damage such as physical/magical, allowing
  1049. * criticals, how to calculate accuracy, etc. There are also three sets of known
  1050. * formulae that are paired with the upper nybble values. These are selected in the
  1051. * Lower Nybble and determine how to calculate pre-defense damage
  1052. */
  1053. u8 damage_raw;
  1054. /**
  1055. * Unused data (Always 0XFF). 1 byte.
  1056. */
  1057. u8 unused_1;
  1058. /**
  1059. * The weapon power. 1 byte.
  1060. *
  1061. * Used for damage calculation.
  1062. */
  1063. u8 power;
  1064. /**
  1065. * The status effect the weapon induces. 1 byte.
  1066. */
  1067. u8 status;
  1068. /**
  1069. * Weapon materia growth multiplier. 1 byte.
  1070. */
  1071. u8 growth;
  1072. /**
  1073. * Weapon critical chance. 1 byte.
  1074. */
  1075. u8 critical;
  1076. /**
  1077. * Weapon accuracy. 1 byte.
  1078. */
  1079. u8 accuracy;
  1080. /**
  1081. * Weapon battle model. 1 byte.
  1082. *
  1083. * This byte is divided into two nybbles (four bits). Upper nybble determines the
  1084. * attack animation modifier, and it's only used for Barret and Vincent. The lower
  1085. * nybble is actually the index of the weapon model.
  1086. */
  1087. u8 model_raw;
  1088. /**
  1089. * Unused data (Always 0XFF). 1 byte.
  1090. */
  1091. u8 unused_2;
  1092. /**
  1093. * Consider it unused.
  1094. *
  1095. * @todo Verify.
  1096. */
  1097. u8 high_sound;
  1098. /**
  1099. * Camera movement ID. 2 bytes.
  1100. *
  1101. * Used for both single and multiple targeted attacks with this weapon. Always 0xFFFF.
  1102. */
  1103. u16 camera;
  1104. /**
  1105. * Characters that can equip the weapon. 2 bytes.
  1106. *
  1107. * Contains bits indicating the characters that can equip the weapon {@see character}
  1108. * for more info.
  1109. */
  1110. u16 equip_raw;
  1111. /**
  1112. * Weapon element ids.
  1113. */
  1114. u16 element_raw;
  1115. /**
  1116. * Unused data (Always 0XFFFF). 1 byte.
  1117. */
  1118. u8 unused_3;
  1119. /**
  1120. * Stat the weapon raises.
  1121. *
  1122. * {@see stat_bonus} for more info.
  1123. */
  1124. u8 stat_raw[4];
  1125. /**
  1126. * The amount the raised stats are raised by.
  1127. *
  1128. * {@see stat_bonus} for more info.
  1129. */
  1130. u8 stat_bonus_raw[4];
  1131. /**
  1132. * Materia slots.
  1133. *
  1134. * {@see slots} for more info.
  1135. */
  1136. u8 slots_raw[8];
  1137. /**
  1138. * Sound effect id for normal hit.
  1139. */
  1140. u8 sound;
  1141. /**
  1142. * Sound effect id for critical hit.
  1143. */
  1144. u8 sound_critical;
  1145. /**
  1146. * Sound effect id for miss hit.
  1147. */
  1148. u8 sound_miss;
  1149. /**
  1150. * Impcat effect ID. 1 byte.
  1151. *
  1152. * Used for animation in battle.
  1153. */
  1154. u8 effect;
  1155. /**
  1156. * Special flags. 2 bytes.
  1157. *
  1158. * @todo document and parse with info from
  1159. * https://wiki.ffrtt.ru/index.php?title=FF7/Battle/Special_Attack_Flags
  1160. */
  1161. u16 special_raw;
  1162. /**
  1163. * Weapon restrictions. 2 bytes.
  1164. *
  1165. * Contains bits indicating if the item is {@see selleable}, {@see useable_battle} and
  1166. * {@see useable_menu}and {@see throwable}.
  1167. */
  1168. u16 restrict_raw;
  1169. /**
  1170. * Weapon ID.
  1171. *
  1172. * Not actually in the item file data, it's the order at which it appears.
  1173. */
  1174. int id;
  1175. /**
  1176. * Weapon name.
  1177. *
  1178. * Not found in the same file as the rest of the data, but on file 20.
  1179. */
  1180. std::string name;
  1181. /**
  1182. * Weapon description.
  1183. *
  1184. * Not found in the same file as the rest of the data, but on file 12.
  1185. */
  1186. std::string description;
  1187. /**
  1188. * Indicates if the weapon can be sold.
  1189. *
  1190. * True if the bit 0 in {@see restrict_raw} is 0.
  1191. */
  1192. bool sellable;
  1193. /**
  1194. * Indicates if the weapon can be used in battle.
  1195. *
  1196. * True if the bit 2 in {@see restrict_raw} is 0.
  1197. */
  1198. bool useable_battle;
  1199. /**
  1200. * Indicates if the weapon can be used in the menu.
  1201. *
  1202. * True if the bit 4 in {@see restrict_raw} is 0.
  1203. */
  1204. bool useable_menu;
  1205. /**
  1206. * Indicates if the weapon can be sold.
  1207. *
  1208. * True if the bit 8 in {@see restrict_raw} is 0.
  1209. */
  1210. bool throwable;
  1211. /**
  1212. * Target selection mode.
  1213. *
  1214. * Derived from {@see target_raw}.
  1215. */
  1216. Target target;
  1217. /**
  1218. * The damage formula.
  1219. *
  1220. * It's the upper nybble in {@see damage_raw}.
  1221. */
  1222. u8 damage_formula;
  1223. /**
  1224. * The damage modifier.
  1225. *
  1226. * It's the lower nybble in {@see damage_raw}.
  1227. */
  1228. u8 damage_modifier;
  1229. /**
  1230. * Attack animation ID.
  1231. *
  1232. * It's the upper nybble in {@see model_raw}. It's only used for Barret and Vincent.
  1233. */
  1234. u8 animation_index;
  1235. /**
  1236. * Weapon model ID.
  1237. *
  1238. * It's the lower nybble in {@see model_raw}.
  1239. */
  1240. u8 model;
  1241. /**
  1242. * The weapon battle model index.
  1243. *
  1244. * It's the lower nybble in {@see model_raw}.
  1245. */
  1246. std::vector<u8> equip;
  1247. /**
  1248. * Bonus in stats.
  1249. *
  1250. * Derived from {@see stat_raw} and {@stat_bonus_raw}.
  1251. */
  1252. std::vector<StatBonus> stat_bonus;
  1253. /**
  1254. * Materia slots.
  1255. *
  1256. * Derived and simplified from {@see slots_raw}.
  1257. */
  1258. std::vector<u8> materia_slots;
  1259. /**
  1260. * Elements of the weapon.
  1261. *
  1262. * Derived from {@see element_raw}.
  1263. */
  1264. std::vector<int> elements;
  1265. };
  1266. /**
  1267. * Data for each armor
  1268. *
  1269. * As found in KERNEL.BIN, file 6, in order, up to unknown_3. Members after unknown_3 are
  1270. * not found literally in KERNEL.BIN, but are derived from other members or found in other
  1271. * files of the kernel (text files).
  1272. */
  1273. struct ArmorData{
  1274. /**
  1275. * Unknown (Always 0XFF). 1 byte.
  1276. */
  1277. u8 unknown_0;
  1278. /**
  1279. * Elemental resistance mode. 1 byte.
  1280. *
  1281. * For all elements in {@see element_raw}:
  1282. * If 0: Absorbs.
  1283. * If 1: Nullifies.
  1284. * If 2: Halves.
  1285. * If any other value: normal.
  1286. */
  1287. u8 element_defense_mode;
  1288. /**
  1289. * Defense stat. 1 byte.
  1290. */
  1291. u8 defense;
  1292. /**
  1293. * Magic defense stat. 1 byte.
  1294. */
  1295. u8 m_defense;
  1296. /**
  1297. * Evasion stat. 1 byte.
  1298. */
  1299. u8 evasion;
  1300. /**
  1301. * Magic evasion stat. 1 byte.
  1302. */
  1303. u8 m_evasion;
  1304. /**
  1305. * The status effect the armor protects against. 1 byte.
  1306. */
  1307. u8 status;
  1308. /**
  1309. * Unknown (Always 0XFFFF). 1 byte.
  1310. */
  1311. u16 unknown_1;
  1312. /**
  1313. * Materia slots.
  1314. *
  1315. * {@see slots} for more info.
  1316. */
  1317. u8 slots_raw[8];
  1318. /**
  1319. * Armor materia growth multiplier. 1 byte.
  1320. */
  1321. u8 growth;
  1322. /**
  1323. * Characters that can equip the armor. 2 bytes.
  1324. *
  1325. * Contains bits indicating the characters that can equip the armor {@see character}
  1326. * for more info.
  1327. */
  1328. u16 equip_raw;
  1329. /**
  1330. * Elements the armor protects agains.
  1331. */
  1332. u16 element_raw;
  1333. /**
  1334. * Unknown (Always 0XFF). 1 byte.
  1335. */
  1336. u16 unknown_2;
  1337. /**
  1338. * Stat the weapon raises.
  1339. *
  1340. * {@see stat_bonus} for more info.
  1341. */
  1342. u8 stat_raw[4];
  1343. /**
  1344. * The amount the raised stats are raised by.
  1345. *
  1346. * {@see stat_bonus} for more info.
  1347. */
  1348. u8 stat_bonus_raw[4];
  1349. /**
  1350. * Weapon restrictions. 2 bytes.
  1351. *
  1352. * Contains bits indicating if the item is {@see selleable}, {@see useable_battle} and
  1353. * {@see useable_menu}and {@see throwable}.
  1354. */
  1355. u16 restrict_raw;
  1356. /**
  1357. * Unknown (Always 0XFFFF). 1 byte.
  1358. */
  1359. u16 unknown_3;
  1360. /**
  1361. * Armor ID.
  1362. *
  1363. * Not actually in the item file data, it's the order at which it appears.
  1364. */
  1365. int id;
  1366. /**
  1367. * Armor name.
  1368. *
  1369. * Not found in the same file as the rest of the data, but on file 20.
  1370. */
  1371. std::string name;
  1372. /**
  1373. * Armor description.
  1374. *
  1375. * Not found in the same file as the rest of the data, but on file 12.
  1376. */
  1377. std::string description;
  1378. /**
  1379. * Indicates if the armor can be sold.
  1380. *
  1381. * True if the bit 0 in {@see restrict_raw} is 0.
  1382. */
  1383. bool sellable;
  1384. /**
  1385. * Indicates if the armor can be used in battle.
  1386. *
  1387. * True if the bit 2 in {@see restrict_raw} is 0.
  1388. */
  1389. bool useable_battle;
  1390. /**
  1391. * Indicates if the armor can be used in the menu.
  1392. *
  1393. * True if the bit 4 in {@see restrict_raw} is 0.
  1394. */
  1395. bool useable_menu;
  1396. /**
  1397. * The weapon battle model index.
  1398. *
  1399. * It's the lower nybble in {@see model_raw}.
  1400. */
  1401. std::vector<u8> equip;
  1402. /**
  1403. * Bonus in stats.
  1404. *
  1405. * Derived from {@see stat_raw} and {@stat_bonus_raw}.
  1406. */
  1407. std::vector<StatBonus> stat_bonus;
  1408. /**
  1409. * Materia slots.
  1410. *
  1411. * Derived and simplified from {@see slots_raw}.
  1412. */
  1413. std::vector<u8> materia_slots;
  1414. /**
  1415. * Elements of the weapon.
  1416. *
  1417. * Derived from {@see element_raw}.
  1418. */
  1419. std::vector<int> elements;
  1420. };
  1421. /**
  1422. * Data for each accessory
  1423. *
  1424. * As found in KERNEL.BIN, file 7, in order, up to unknown_3. Members after unknown_3 are
  1425. * not found literally in KERNEL.BIN, but are derived from other members or found in other
  1426. * files of the kernel (text files).
  1427. */
  1428. struct AccessoryData{
  1429. /**
  1430. * Stat the weapon raises.
  1431. *
  1432. * {@see stat_bonus} for more info.
  1433. */
  1434. u8 stat_raw[2];
  1435. /**
  1436. * The amount the raised stats are raised by.
  1437. *
  1438. * {@see stat_bonus} for more info.
  1439. */
  1440. u8 stat_bonus_raw[2];
  1441. /**
  1442. * Elemental resistance mode. 1 byte.
  1443. *
  1444. * For all elements in {@see element_raw}:
  1445. * If 0: Absorbs.
  1446. * If 1: Nullifies.
  1447. * If 2: Halves.
  1448. * If any other value: normal.
  1449. */
  1450. u8 element_defense_mode;
  1451. /**
  1452. * The special status effect the accesory induces.
  1453. *
  1454. * 0: Auto haste.
  1455. * 1: Auto berserk.
  1456. * 2: Curse.
  1457. * 3: Auto reflect.
  1458. * 4: Steal rate +.
  1459. * 5: Manipulate rate +.
  1460. * 6: Barrier + MBarrier.
  1461. * Other: Nothing.
  1462. */
  1463. u8 effect;
  1464. /**
  1465. * Elements the armor protects against. 2 bytes.
  1466. *
  1467. * The defense type is defined in {@see element_defense_mode}.
  1468. */
  1469. u16 element_raw;
  1470. /**
  1471. * The status effect the armor protects against. 4 bytes.
  1472. */
  1473. u32 status_raw;
  1474. /**
  1475. * Characters that can equip the armor. 2 bytes.
  1476. *
  1477. * Contains bits indicating the characters that can equip the armor {@see character}
  1478. * for more info.
  1479. */
  1480. u16 equip_raw;
  1481. /**
  1482. * Weapon restrictions. 2 bytes.
  1483. *
  1484. * Contains bits indicating if the item is {@see selleable}, {@see useable_battle} and
  1485. * {@see useable_menu}and {@see throwable}.
  1486. */
  1487. u16 restrict_raw;
  1488. /**
  1489. * Accessory ID.
  1490. *
  1491. * Not actually in the item file data, it's the order at which it appears.
  1492. */
  1493. int id;
  1494. /**
  1495. * Accessory name.
  1496. *
  1497. * Not found in the same file as the rest of the data, but on file 20.
  1498. */
  1499. std::string name;
  1500. /**
  1501. * Accessory description.
  1502. *
  1503. * Not found in the same file as the rest of the data, but on file 12.
  1504. */
  1505. std::string description;
  1506. /**
  1507. * Indicates if the accessory can be sold.
  1508. *
  1509. * True if the bit 0 in {@see restrict_raw} is 0.
  1510. */
  1511. bool sellable;
  1512. /**
  1513. * Indicates if the accessory can be used in battle.
  1514. *
  1515. * True if the bit 2 in {@see restrict_raw} is 0.
  1516. */
  1517. bool useable_battle;
  1518. /**
  1519. * Indicates if the accessory can be used in the menu.
  1520. *
  1521. * True if the bit 4 in {@see restrict_raw} is 0.
  1522. */
  1523. bool useable_menu;
  1524. /**
  1525. * The weapon battle model index.
  1526. *
  1527. * It's the lower nybble in {@see model_raw}.
  1528. */
  1529. std::vector<u8> equip;
  1530. /**
  1531. * Bonus in stats.
  1532. *
  1533. * Derived from {@see stat_raw} and {@stat_bonus_raw}.
  1534. */
  1535. std::vector<StatBonus> stat_bonus;
  1536. /**
  1537. * Elements of the accesory.
  1538. *
  1539. * Derived from {@see element_raw}.
  1540. */
  1541. std::vector<int> elements;
  1542. /**
  1543. * Statuses the accessory protects against.
  1544. *
  1545. * Derived from {@see status_raw}.
  1546. */
  1547. std::vector<int> status;
  1548. };
  1549. /**
  1550. * Types of materia.
  1551. */
  1552. enum class MATERIA_TYPE{
  1553. /**
  1554. * Magic materia.
  1555. */
  1556. MAGIC = 1,
  1557. /**
  1558. * Support materia.
  1559. */
  1560. SUPPORT,
  1561. /**
  1562. * Command materia.
  1563. */
  1564. COMMAND,
  1565. /**
  1566. * Independent materia.
  1567. */
  1568. INDEPENDENT,
  1569. /**
  1570. * Summon materia.
  1571. */
  1572. SUMMON
  1573. };
  1574. /**
  1575. * Stat bonuses given by equipping materia.
  1576. *
  1577. * They can be negative.
  1578. */
  1579. struct MateriaStatBonus{
  1580. /**
  1581. * Strength bonus. Absolute.
  1582. */
  1583. int str;
  1584. /**
  1585. * Vitality bonus. Absolute.
  1586. */
  1587. int vit;
  1588. /**
  1589. * Magic bonus. Absolute.
  1590. */
  1591. int mag;
  1592. /**
  1593. * Spirit bonus. Absolute.
  1594. */
  1595. int spr;
  1596. /**
  1597. * Dexterity bonus. Absolute.
  1598. */
  1599. int dex;
  1600. /**
  1601. * Luck bonus. Absolute.
  1602. */
  1603. int lck;
  1604. /**
  1605. * Max HP bonus. Percentile.
  1606. */
  1607. int hp;
  1608. /**
  1609. * Max MP bonus. Percentile.
  1610. */
  1611. int mp;
  1612. /**
  1613. * Indicates if at least one of the stats is changed by the materia.
  1614. */
  1615. bool change;
  1616. };
  1617. /**
  1618. * Data for each materia.
  1619. *
  1620. * As found in KERNEL.BIN, file 8, in order, up to attributes. Members after attributes are
  1621. * not found literally in KERNEL.BIN, but are derived from other members or found in other
  1622. * files of the kernel (text files).
  1623. */
  1624. struct MateriaData{
  1625. /**
  1626. * AP amounts at which the materia levels up. 4 x 1 byte.
  1627. *
  1628. * It can be used to determine how many levels the materia has.
  1629. */
  1630. u16 level_up_ap[4];
  1631. /**
  1632. * Index of stat modifier. 1 byte.
  1633. */
  1634. u8 stat_raw;
  1635. /**
  1636. * Status effects. 3 bytes, not 4!
  1637. */
  1638. u32 status_raw;
  1639. /**
  1640. * Materia element. 1 byte.
  1641. */
  1642. u8 element;
  1643. /**
  1644. * Materia type. 1 byte.
  1645. *
  1646. * 2 nybbles. The upper one is the subtype, and it's ignored in V-Gears. The lower one
  1647. * the actual type.
  1648. */
  1649. u8 type_raw;
  1650. /**
  1651. * Materia attributes. 6 x 1 byte.
  1652. *
  1653. * They are mostly ignored in V-Gears.
  1654. */
  1655. u8 attribute[6];
  1656. /**
  1657. * Accessory ID.
  1658. *
  1659. * Not actually in the item file data, it's the order at which it appears.
  1660. */
  1661. int id;
  1662. /**
  1663. * Accessory name.
  1664. *
  1665. * Not found in the same file as the rest of the data, but on file 20.
  1666. */
  1667. std::string name;
  1668. /**
  1669. * Accessory description.
  1670. *
  1671. * Not found in the same file as the rest of the data, but on file 12.
  1672. */
  1673. std::string description;
  1674. /**
  1675. * Mateira type.
  1676. *
  1677. * Derived from {@see type_raw}.
  1678. */
  1679. int type;
  1680. /**
  1681. * Stat bonuses for equipping the materia.
  1682. *
  1683. * Derived from {@see stat_raw}.
  1684. */
  1685. MateriaStatBonus stats;
  1686. /**
  1687. * Statuses the materia inflicts.
  1688. *
  1689. * Derived from {@see status_raw}.
  1690. */
  1691. std::vector<int> status;
  1692. };
  1693. /**
  1694. * Data for each key item.
  1695. *
  1696. * There is no data file about key items in KERNEL.BIN, there are only names (file 24) and
  1697. * descriptions (file 16)
  1698. */
  1699. struct KeyItemData{
  1700. /**
  1701. * Key item ID.
  1702. *
  1703. * Not actually in KERNEL.BIN, it;s the order at which they appear.
  1704. */
  1705. int id;
  1706. /**
  1707. * Key item name.
  1708. */
  1709. std::string name;
  1710. /**
  1711. * Key item description.
  1712. */
  1713. std::string description;
  1714. };
  1715. /**
  1716. * List of summon names.
  1717. *
  1718. * There is no data file about key items in KERNEL.BIN, there are only names (file 26).
  1719. */
  1720. struct SummonNameData{
  1721. /**
  1722. * Summon ID.
  1723. *
  1724. * Not actually in KERNEL.BIN, it;s the order at which they appear.
  1725. */
  1726. int id;
  1727. /**
  1728. * Summon name.
  1729. */
  1730. std::string name;
  1731. };
  1732. /**
  1733. * Character data.
  1734. *
  1735. * Contains information about a character. Contained in the file 3 of the kernel, one
  1736. * entry for each character. Each section is 56 bytes long. The character ID is not
  1737. * actually in the data, but it's the order at which they appear. The character name is
  1738. * also not in the dataand it must be filled manually.
  1739. */
  1740. struct CharacterData{
  1741. /**
  1742. * Strength stat growth curve. 1 byte.
  1743. */
  1744. u8 curve_str;
  1745. /**
  1746. * Vitality stat growth curve. 1 byte.
  1747. */
  1748. u8 curve_vit;
  1749. /**
  1750. * Magic stat growth curve. 1 byte.
  1751. */
  1752. u8 curve_mag;
  1753. /**
  1754. * Spirit stat growth curve. 1 byte.
  1755. */
  1756. u8 curve_spr;
  1757. /**
  1758. * Dexterity stat growth curve. 1 byte.
  1759. */
  1760. u8 curve_dex;
  1761. /**
  1762. * Luck stat growth curve. 1 byte.
  1763. */
  1764. u8 curve_lck;
  1765. /**
  1766. * HP stat growth curve. 1 byte.
  1767. */
  1768. u8 curve_hp;
  1769. /**
  1770. * MP stat growth curve. 1 byte.
  1771. */
  1772. u8 curve_mp;
  1773. /**
  1774. * Experience-for-next-level growth curve. 1 byte.
  1775. */
  1776. u8 curve_exp;
  1777. /**
  1778. * Ignored data. 1 byte.
  1779. */
  1780. u8 unused_0;
  1781. /**
  1782. * Starting level. 1 byte.
  1783. */
  1784. u8 initial_level;
  1785. /**
  1786. * Ignored data. 1 byte.
  1787. */
  1788. u8 unused_1;
  1789. /**
  1790. * 1-1 limit slot command. 1 byte.
  1791. */
  1792. u8 limit_1_1;
  1793. /**
  1794. * 1-2 limit slot command. 1 byte.
  1795. */
  1796. u8 limit_1_2;
  1797. /**
  1798. * 1-3 limit slot command. 1 byte, unused.
  1799. */
  1800. u8 limit_1_3;
  1801. /**
  1802. * 2-1 limit slot command. 1 byte.
  1803. */
  1804. u8 limit_2_1;
  1805. /**
  1806. * 2-2 limit slot command. 1 byte.
  1807. */
  1808. u8 limit_2_2;
  1809. /**
  1810. * 2-3 limit slot command. 1 byte, unused.
  1811. */
  1812. u8 limit_2_3;
  1813. /**
  1814. * 3-1 limit slot command. 1 byte.
  1815. */
  1816. u8 limit_3_1;
  1817. /**
  1818. * 3-2 limit slot command. 1 byte.
  1819. */
  1820. u8 limit_3_2;
  1821. /**
  1822. * 3-3 limit slot command. 1 byte, unused.
  1823. */
  1824. u8 limit_3_3;
  1825. /**
  1826. * 4-1 limit slot command. 1 byte.
  1827. */
  1828. u8 limit_4_1;
  1829. /**
  1830. * 4-2 limit slot command. 1 byte, unused.
  1831. */
  1832. u8 limit_4_2;
  1833. /**
  1834. * 4-3 limit slot command. 1 byte, unused.
  1835. */
  1836. u8 limit_4_3;
  1837. /**
  1838. * Kills required to unlock limit level 2. 2 bytes.
  1839. */
  1840. u16 limit_2_kills;
  1841. /**
  1842. * Kills required to unlock limit level 3. 2 bytes.
  1843. */
  1844. u16 limit_3_kills;
  1845. /**
  1846. * Kills required to unlock limit 1-2. 2 bytes.
  1847. */
  1848. u16 limit_1_2_uses;
  1849. /**
  1850. * Kills required to unlock limit 1-3. 2 bytes, unused.
  1851. */
  1852. u16 limit_1_3_uses;
  1853. /**
  1854. * Kills required to unlock limit 2-2. 2 bytes.
  1855. */
  1856. u16 limit_2_2_uses;
  1857. /**
  1858. * Kills required to unlock limit 2-3. 2 bytes, unused.
  1859. */
  1860. u16 limit_2_3_uses;
  1861. /**
  1862. * Kills required to unlock limit 3-2. 2 bytes.
  1863. */
  1864. u16 limit_3_2_uses;
  1865. /**
  1866. * Kills required to unlock limit 3-3. 2 bytes, unused.
  1867. */
  1868. u16 limit_3_3_uses;
  1869. /**
  1870. * HP divisor for limit level 1.
  1871. */
  1872. u32 limit_1_div;
  1873. /**
  1874. * HP divisor for limit level 2.
  1875. */
  1876. u32 limit_2_div;
  1877. /**
  1878. * HP divisor for limit level 3.
  1879. */
  1880. u32 limit_3_div;
  1881. /**
  1882. * HP divisor for limit level 4.
  1883. */
  1884. u32 limit_4_div;
  1885. /**
  1886. * Character ID.
  1887. */
  1888. int id;
  1889. /**
  1890. * Character default name.
  1891. */
  1892. std::string name;
  1893. };
  1894. /**
  1895. * Types of stat curves.
  1896. *
  1897. * Althought any of them can be used for any stat, this is their intended use.
  1898. */
  1899. enum STAT_CURVE_TYPE{
  1900. /**
  1901. * Normal curve, used for primary stat.
  1902. */
  1903. CURVE_PRIMARY = 0,
  1904. /**
  1905. * HP curve. Base values must be multiplied by 40 when calculating.
  1906. */
  1907. CURVE_HP,
  1908. /**
  1909. * MP curve. Base values must be multiplied by 2 when calculating.
  1910. */
  1911. CURVE_MP,
  1912. /**
  1913. * Experience curve. Base must be ignored when calculating. Gradient is quadratic.
  1914. */
  1915. CURVE_EXP
  1916. };
  1917. /**
  1918. * Stat curve.
  1919. *
  1920. * determines value growth
  1921. */
  1922. struct StatCurve{
  1923. /**
  1924. * Curve ID.
  1925. */
  1926. int id;
  1927. /**
  1928. * Type of curve.
  1929. */
  1930. STAT_CURVE_TYPE type;
  1931. /**
  1932. * Curve gradients.
  1933. */
  1934. u8 gradient[8];
  1935. /**
  1936. * Curve bases.
  1937. */
  1938. u8 base[8];
  1939. };
  1940. /**
  1941. * Battle data.
  1942. *
  1943. * Contains several pieces of data related to character growth. Contained in the file 3 of
  1944. * the kernel, after the character data (starts at offset 0x01F8). The kernel contains more
  1945. * data, but it's not needed for V-Gears (random table, scene lookup...)
  1946. */
  1947. struct GrowthData{
  1948. /**
  1949. * Random bonus to primary stats, 12 entries of 1 byte.
  1950. */
  1951. u8 bonus_stat[12];
  1952. /**
  1953. * Random bonus to HP stat, 12 entries of 1 byte.
  1954. */
  1955. u8 bonus_hp[12];
  1956. /**
  1957. * Random bonus to MP stat, 12 entries of 1 byte.
  1958. */
  1959. u8 bonus_mp[12];
  1960. /**
  1961. * Stat curves. 64 curves of 16 bit each.
  1962. *
  1963. * 37 for primary stats, 9 for HP, 9 form MP, 9 for experience.
  1964. */
  1965. StatCurve curves[64];
  1966. };
  1967. /**
  1968. * Items read from the kernel.
  1969. */
  1970. std::vector<CommandData> commands_;
  1971. /**
  1972. * Attacks read from the kernel.
  1973. */
  1974. std::vector<AttackData> attacks_;
  1975. /**
  1976. * Character info read from the kernel.
  1977. */
  1978. std::vector<CharacterData> characters_;
  1979. GrowthData growth_;
  1980. /**
  1981. * Items read from the kernel.
  1982. */
  1983. std::vector<ItemData> items_;
  1984. /**
  1985. * Weapons read from the kernel.
  1986. */
  1987. std::vector<WeaponData> weapons_;
  1988. /**
  1989. * Armors read from the kernel.
  1990. */
  1991. std::vector<ArmorData> armors_;
  1992. /**
  1993. * Accessories read from the kernel.
  1994. */
  1995. std::vector<AccessoryData> accessories_;
  1996. /**
  1997. * Materia read from the kernel.
  1998. */
  1999. std::vector<MateriaData> materia_;
  2000. /**
  2001. * Key items read from the kernel.
  2002. */
  2003. std::vector<KeyItemData> key_items_;
  2004. /**
  2005. * Summon names read from the kernel.
  2006. */
  2007. std::vector<SummonNameData> summon_names_;
  2008. SaveMap savemap_;
  2009. /**
  2010. * The kernel file.
  2011. */
  2012. BinGZipFile kernel_;
  2013. };