KernelDataInstaller.h 61 KB

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