KernelDataInstaller.h 61 KB

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