KernelDataInstaller.h 63 KB

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