KernelDataInstaller.h 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468
  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 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 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 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 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 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 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 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 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 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 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 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 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. * Magic descriptions section in KERNEL.BIN.
  220. */
  221. KERNEL_MAGIC_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. * Magic Names section in KERNEL.BIN.
  252. */
  253. KERNEL_MAGIC_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 {@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 {@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 {@restore_typ} and {@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. * Target selection mode.
  792. *
  793. * Derived from {@see target_raw}.
  794. */
  795. Target target;
  796. /**
  797. * The damage formula.
  798. *
  799. * It's the upper nybble in {@see damage_raw}.
  800. */
  801. u8 damage_formula;
  802. /**
  803. * The damage modifier.
  804. *
  805. * It's the lower nybble in {@see damage_raw}.
  806. */
  807. u8 damage_modifier;
  808. /**
  809. * What the attack restores when used.
  810. *
  811. * Same as {@see condition_raw}, except for the wrong cases.
  812. */
  813. RESTORE_TYPE restore_type;
  814. /**
  815. * Status effects.
  816. *
  817. * Derived from {@see status_change_raw} and {@see status_raw}.
  818. */
  819. StatusEffect status;
  820. /**
  821. * Elements of the attack.
  822. *
  823. * Derived from {@see element_raw}.
  824. */
  825. std::vector<int> elements;
  826. };
  827. /**
  828. * Data for each items
  829. *
  830. * As found in KERNEL.BIN, file 4, in order, up to special. Members after special are not
  831. * found literally in KERNEL.BIN, but are derived from other members or found in other
  832. * files of the kernel (text files).
  833. */
  834. struct ItemData{
  835. /**
  836. * Unknown data (Always 0XFFFF). 4 bytes.
  837. */
  838. u32 unknown_0;
  839. /**
  840. * Unknown data (Always 0XFFFF). 4 bytes.
  841. */
  842. u32 unknown_1;
  843. /**
  844. * Camera movement ID. 2 bytes.
  845. *
  846. * Used for items useable in battle, determines the camera movement.
  847. */
  848. u16 camera;
  849. /**
  850. * Item restrictions. 2 bytes.
  851. *
  852. * Contains bits indicating if the item is {@see selleable}, {@see useable_battle} and
  853. * {@see useable_menu}.
  854. */
  855. u16 restrict_raw;
  856. /**
  857. * Targeting mode. 1 byte.
  858. *
  859. * See {@see target} and {@TargetModes} for more information.
  860. */
  861. u8 target_raw;
  862. /**
  863. * Item effect ID. 1 byte.
  864. *
  865. * Used for animation in battle.
  866. */
  867. u8 effect;
  868. /**
  869. * Damage formula. 1 byte.
  870. *
  871. * This byte is divided into two nybbles (four bits). Upper nybble determines what
  872. * considerations are made in calculating damage such as physical/magical, allowing
  873. * criticals, how to calculate accuracy, etc. There are also three sets of known
  874. * formulae that are paired with the upper nybble values. These are selected in the
  875. * Lower Nybble and determine how to calculate pre-defense damage
  876. */
  877. u8 damage_raw;
  878. /**
  879. * The item power. 1 byte.
  880. *
  881. * Used for damage/healing calculation.
  882. */
  883. u8 power;
  884. /**
  885. * The restore type.
  886. *
  887. * See {@restore_typ} and {@RESTORE_TYPE} for more information.
  888. */
  889. u8 condition_raw;
  890. /**
  891. * Information about status change mode and chance. 1 bytes.
  892. */
  893. u8 status_change_raw;
  894. /**
  895. * Special flags. 1 byte.
  896. *
  897. * @todo Document and retrieve with info from
  898. * https://wiki.ffrtt.ru/index.php?title=FF7/Battle/Attack_Special_Effects
  899. */
  900. u8 additional_effects_raw;
  901. /**
  902. * Special flags. 1 byte.
  903. *
  904. * @todo Document and retrieve with info from
  905. * https://wiki.ffrtt.ru/index.php?title=FF7/Item_data
  906. */
  907. u8 additional_effects_mod_raw;
  908. /**
  909. * Information about what status can be inflicted or cured. 4 bytes.
  910. *
  911. * The first six bits are the chance of inflicting/curing (out of 63). If the seventh
  912. * bit is set, the status is cured instead of inflicted. If the eighth bit is set, then
  913. * the status is toggled (cured if present, inflicted if not present).
  914. */
  915. u32 status_raw;
  916. /**
  917. * Information about the item elements. 2 bytes.
  918. */
  919. u16 element_raw;
  920. /**
  921. * Special flags. 2 bytes.
  922. *
  923. * @todo document and parse with info from
  924. * https://wiki.ffrtt.ru/index.php?title=FF7/Battle/Special_Attack_Flags
  925. */
  926. u16 special_raw;
  927. /**
  928. * Item ID.
  929. *
  930. * Not actually in the item file data, it's the order at which it appears.
  931. */
  932. int id;
  933. /**
  934. * Item name.
  935. *
  936. * Not found in the same file as the rest of the data, but on file 19.
  937. */
  938. std::string name;
  939. /**
  940. * Item description.
  941. *
  942. * Not found in the same file as the rest of the data, but on file 11.
  943. */
  944. std::string description;
  945. /**
  946. * Indicates if the item can be sold.
  947. *
  948. * True if the bit 0 in {@see restrict_raw} is 0.
  949. */
  950. bool sellable;
  951. /**
  952. * Indicates if the item can be used in battle.
  953. *
  954. * True if the bit 2 in {@see restrict_raw} is 0.
  955. */
  956. bool useable_battle;
  957. /**
  958. * Indicates if the item can be used in the menu.
  959. *
  960. * True if the bit 4 in {@see restrict_raw} is 0.
  961. */
  962. bool useable_menu;
  963. /**
  964. * Target selection mode.
  965. *
  966. * Derived from {@see target_raw}.
  967. */
  968. Target target;
  969. /**
  970. * The damage formula.
  971. *
  972. * It's the upper nybble in {@see damage_raw}.
  973. */
  974. u8 damage_formula;
  975. /**
  976. * The damage modifier.
  977. *
  978. * It's the lower nybble in {@see damage_raw}.
  979. */
  980. u8 damage_modifier;
  981. /**
  982. * What the item restores when used.
  983. *
  984. * Same as {@see condition_raw}, except for the wrong cases.
  985. */
  986. RESTORE_TYPE restore_type;
  987. /**
  988. * Status effects.
  989. *
  990. * Derived from {@see status_change_raw} and {@see status_raw}.
  991. */
  992. StatusEffect status;
  993. /**
  994. * Elements of the item.
  995. *
  996. * Derived from {@see element_raw}.
  997. */
  998. std::vector<int> elements;
  999. };
  1000. /**
  1001. * Materia slot types.
  1002. */
  1003. enum SLOT_TYPE{
  1004. /**
  1005. * A non linked slot.
  1006. */
  1007. SLOT_UNLINKED = 0,
  1008. /**
  1009. * A linked slot.
  1010. *
  1011. * If the slot is in an even position, it's linked to the one in the right. If it's in
  1012. * an odd position, it;s linked to the one in the Left. Remember that slot positions
  1013. * are 0-index.
  1014. */
  1015. SLOT_LINKED = 1
  1016. };
  1017. /**
  1018. * Bonus in stat givven by weapons or armor.
  1019. */
  1020. struct StatBonus{
  1021. /**
  1022. * ID of the raised stat.
  1023. */
  1024. u8 stat;
  1025. /**
  1026. * Stat value raise.
  1027. */
  1028. u8 bonus;
  1029. };
  1030. /**
  1031. * Data for each weapon
  1032. *
  1033. * As found in KERNEL.BIN, file 5, in order, up to special. Members after special are not
  1034. * found literally in KERNEL.BIN, but are derived from other members or found in other
  1035. * files of the kernel (text files).
  1036. */
  1037. struct WeaponData{
  1038. /**
  1039. * Targeting mode. 1 byte.
  1040. *
  1041. * See {@see target} and {@TargetModes} for more information.
  1042. */
  1043. u8 target_raw;
  1044. /**
  1045. * Effect ID, unused (Always 0XFF). 1 byte.
  1046. */
  1047. u8 unused_0;
  1048. /**
  1049. * Damage formula. 1 byte.
  1050. *
  1051. * This byte is divided into two nybbles (four bits). Upper nybble determines what
  1052. * considerations are made in calculating damage such as physical/magical, allowing
  1053. * criticals, how to calculate accuracy, etc. There are also three sets of known
  1054. * formulae that are paired with the upper nybble values. These are selected in the
  1055. * Lower Nybble and determine how to calculate pre-defense damage
  1056. */
  1057. u8 damage_raw;
  1058. /**
  1059. * Unused data (Always 0XFF). 1 byte.
  1060. */
  1061. u8 unused_1;
  1062. /**
  1063. * The weapon power. 1 byte.
  1064. *
  1065. * Used for damage calculation.
  1066. */
  1067. u8 power;
  1068. /**
  1069. * The status effect the weapon induces. 1 byte.
  1070. */
  1071. u8 status;
  1072. /**
  1073. * Weapon materia growth multiplier. 1 byte.
  1074. */
  1075. u8 growth;
  1076. /**
  1077. * Weapon critical chance. 1 byte.
  1078. */
  1079. u8 critical;
  1080. /**
  1081. * Weapon accuracy. 1 byte.
  1082. */
  1083. u8 accuracy;
  1084. /**
  1085. * Weapon battle model. 1 byte.
  1086. *
  1087. * This byte is divided into two nybbles (four bits). Upper nybble determines the
  1088. * attack animation modifier, and it's only used for Barret and Vincent. The lower
  1089. * nybble is actually the index of the weapon model.
  1090. */
  1091. u8 model_raw;
  1092. /**
  1093. * Unused data (Always 0XFF). 1 byte.
  1094. */
  1095. u8 unused_2;
  1096. /**
  1097. * Consider it unused.
  1098. *
  1099. * @todo Verify.
  1100. */
  1101. u8 high_sound;
  1102. /**
  1103. * Camera movement ID. 2 bytes.
  1104. *
  1105. * Used for both single and multiple targeted attacks with this weapon. Always 0xFFFF.
  1106. */
  1107. u16 camera;
  1108. /**
  1109. * Characters that can equip the weapon. 2 bytes.
  1110. *
  1111. * Contains bits indicating the characters that can equip the weapon {@see character}
  1112. * for more info.
  1113. */
  1114. u16 equip_raw;
  1115. /**
  1116. * Weapon element ids.
  1117. */
  1118. u16 element_raw;
  1119. /**
  1120. * Unused data (Always 0XFFFF). 1 byte.
  1121. */
  1122. u8 unused_3;
  1123. /**
  1124. * Stat the weapon raises.
  1125. *
  1126. * {@see stat_bonus} for more info.
  1127. */
  1128. u8 stat_raw[4];
  1129. /**
  1130. * The amount the raised stats are raised by.
  1131. *
  1132. * {@see stat_bonus} for more info.
  1133. */
  1134. u8 stat_bonus_raw[4];
  1135. /**
  1136. * Materia slots.
  1137. *
  1138. * {@see slots} for more info.
  1139. */
  1140. u8 slots_raw[8];
  1141. /**
  1142. * Sound effect id for normal hit.
  1143. */
  1144. u8 sound;
  1145. /**
  1146. * Sound effect id for critical hit.
  1147. */
  1148. u8 sound_critical;
  1149. /**
  1150. * Sound effect id for miss hit.
  1151. */
  1152. u8 sound_miss;
  1153. /**
  1154. * Impcat effect ID. 1 byte.
  1155. *
  1156. * Used for animation in battle.
  1157. */
  1158. u8 effect;
  1159. /**
  1160. * Special flags. 2 bytes.
  1161. *
  1162. * @todo document and parse with info from
  1163. * https://wiki.ffrtt.ru/index.php?title=FF7/Battle/Special_Attack_Flags
  1164. */
  1165. u16 special_raw;
  1166. /**
  1167. * Weapon restrictions. 2 bytes.
  1168. *
  1169. * Contains bits indicating if the item is {@see selleable}, {@see useable_battle} and
  1170. * {@see useable_menu}and {@see throwable}.
  1171. */
  1172. u16 restrict_raw;
  1173. /**
  1174. * Weapon ID.
  1175. *
  1176. * Not actually in the item file data, it's the order at which it appears.
  1177. */
  1178. int id;
  1179. /**
  1180. * Weapon name.
  1181. *
  1182. * Not found in the same file as the rest of the data, but on file 20.
  1183. */
  1184. std::string name;
  1185. /**
  1186. * Weapon description.
  1187. *
  1188. * Not found in the same file as the rest of the data, but on file 12.
  1189. */
  1190. std::string description;
  1191. /**
  1192. * Indicates if the weapon can be sold.
  1193. *
  1194. * True if the bit 0 in {@see restrict_raw} is 0.
  1195. */
  1196. bool sellable;
  1197. /**
  1198. * Indicates if the weapon can be used in battle.
  1199. *
  1200. * True if the bit 2 in {@see restrict_raw} is 0.
  1201. */
  1202. bool useable_battle;
  1203. /**
  1204. * Indicates if the weapon can be used in the menu.
  1205. *
  1206. * True if the bit 4 in {@see restrict_raw} is 0.
  1207. */
  1208. bool useable_menu;
  1209. /**
  1210. * Indicates if the weapon can be sold.
  1211. *
  1212. * True if the bit 8 in {@see restrict_raw} is 0.
  1213. */
  1214. bool throwable;
  1215. /**
  1216. * Target selection mode.
  1217. *
  1218. * Derived from {@see target_raw}.
  1219. */
  1220. Target target;
  1221. /**
  1222. * The damage formula.
  1223. *
  1224. * It's the upper nybble in {@see damage_raw}.
  1225. */
  1226. u8 damage_formula;
  1227. /**
  1228. * The damage modifier.
  1229. *
  1230. * It's the lower nybble in {@see damage_raw}.
  1231. */
  1232. u8 damage_modifier;
  1233. /**
  1234. * Attack animation ID.
  1235. *
  1236. * It's the upper nybble in {@see model_raw}. It's only used for Barret and Vincent.
  1237. */
  1238. u8 animation_index;
  1239. /**
  1240. * Weapon model ID.
  1241. *
  1242. * It's the lower nybble in {@see model_raw}.
  1243. */
  1244. u8 model;
  1245. /**
  1246. * The weapon battle model index.
  1247. *
  1248. * It's the lower nybble in {@see model_raw}.
  1249. */
  1250. std::vector<u8> equip;
  1251. /**
  1252. * Bonus in stats.
  1253. *
  1254. * Derived from {@see stat_raw} and {@stat_bonus_raw}.
  1255. */
  1256. std::vector<StatBonus> stat_bonus;
  1257. /**
  1258. * Materia slots.
  1259. *
  1260. * Derived and simplified from {@see slots_raw}.
  1261. */
  1262. std::vector<u8> materia_slots;
  1263. /**
  1264. * Elements of the weapon.
  1265. *
  1266. * Derived from {@see element_raw}.
  1267. */
  1268. std::vector<int> elements;
  1269. };
  1270. /**
  1271. * Data for each armor
  1272. *
  1273. * As found in KERNEL.BIN, file 6, in order, up to unknown_3. Members after unknown_3 are
  1274. * not found literally in KERNEL.BIN, but are derived from other members or found in other
  1275. * files of the kernel (text files).
  1276. */
  1277. struct ArmorData{
  1278. /**
  1279. * Unknown (Always 0XFF). 1 byte.
  1280. */
  1281. u8 unknown_0;
  1282. /**
  1283. * Elemental resistance mode. 1 byte.
  1284. *
  1285. * For all elements in {@see element_raw}:
  1286. * If 0: Absorbs.
  1287. * If 1: Nullifies.
  1288. * If 2: Halves.
  1289. * If any other value: normal.
  1290. */
  1291. u8 element_defense_mode;
  1292. /**
  1293. * Defense stat. 1 byte.
  1294. */
  1295. u8 defense;
  1296. /**
  1297. * Magic defense stat. 1 byte.
  1298. */
  1299. u8 m_defense;
  1300. /**
  1301. * Evasion stat. 1 byte.
  1302. */
  1303. u8 evasion;
  1304. /**
  1305. * Magic evasion stat. 1 byte.
  1306. */
  1307. u8 m_evasion;
  1308. /**
  1309. * The status effect the armor protects against. 1 byte.
  1310. */
  1311. u8 status;
  1312. /**
  1313. * Unknown (Always 0XFFFF). 1 byte.
  1314. */
  1315. u16 unknown_1;
  1316. /**
  1317. * Materia slots.
  1318. *
  1319. * {@see slots} for more info.
  1320. */
  1321. u8 slots_raw[8];
  1322. /**
  1323. * Armor materia growth multiplier. 1 byte.
  1324. */
  1325. u8 growth;
  1326. /**
  1327. * Characters that can equip the armor. 2 bytes.
  1328. *
  1329. * Contains bits indicating the characters that can equip the armor {@see character}
  1330. * for more info.
  1331. */
  1332. u16 equip_raw;
  1333. /**
  1334. * Elements the armor protects agains.
  1335. */
  1336. u16 element_raw;
  1337. /**
  1338. * Unknown (Always 0XFF). 1 byte.
  1339. */
  1340. u16 unknown_2;
  1341. /**
  1342. * Stat the weapon raises.
  1343. *
  1344. * {@see stat_bonus} for more info.
  1345. */
  1346. u8 stat_raw[4];
  1347. /**
  1348. * The amount the raised stats are raised by.
  1349. *
  1350. * {@see stat_bonus} for more info.
  1351. */
  1352. u8 stat_bonus_raw[4];
  1353. /**
  1354. * Weapon restrictions. 2 bytes.
  1355. *
  1356. * Contains bits indicating if the item is {@see selleable}, {@see useable_battle} and
  1357. * {@see useable_menu}and {@see throwable}.
  1358. */
  1359. u16 restrict_raw;
  1360. /**
  1361. * Unknown (Always 0XFFFF). 1 byte.
  1362. */
  1363. u16 unknown_3;
  1364. /**
  1365. * Armor ID.
  1366. *
  1367. * Not actually in the item file data, it's the order at which it appears.
  1368. */
  1369. int id;
  1370. /**
  1371. * Armor name.
  1372. *
  1373. * Not found in the same file as the rest of the data, but on file 20.
  1374. */
  1375. std::string name;
  1376. /**
  1377. * Armor description.
  1378. *
  1379. * Not found in the same file as the rest of the data, but on file 12.
  1380. */
  1381. std::string description;
  1382. /**
  1383. * Indicates if the armor can be sold.
  1384. *
  1385. * True if the bit 0 in {@see restrict_raw} is 0.
  1386. */
  1387. bool sellable;
  1388. /**
  1389. * Indicates if the armor can be used in battle.
  1390. *
  1391. * True if the bit 2 in {@see restrict_raw} is 0.
  1392. */
  1393. bool useable_battle;
  1394. /**
  1395. * Indicates if the armor can be used in the menu.
  1396. *
  1397. * True if the bit 4 in {@see restrict_raw} is 0.
  1398. */
  1399. bool useable_menu;
  1400. /**
  1401. * The weapon battle model index.
  1402. *
  1403. * It's the lower nybble in {@see model_raw}.
  1404. */
  1405. std::vector<u8> equip;
  1406. /**
  1407. * Bonus in stats.
  1408. *
  1409. * Derived from {@see stat_raw} and {@stat_bonus_raw}.
  1410. */
  1411. std::vector<StatBonus> stat_bonus;
  1412. /**
  1413. * Materia slots.
  1414. *
  1415. * Derived and simplified from {@see slots_raw}.
  1416. */
  1417. std::vector<u8> materia_slots;
  1418. /**
  1419. * Elements of the weapon.
  1420. *
  1421. * Derived from {@see element_raw}.
  1422. */
  1423. std::vector<int> elements;
  1424. };
  1425. /**
  1426. * Data for each accessory
  1427. *
  1428. * As found in KERNEL.BIN, file 7, in order, up to unknown_3. Members after unknown_3 are
  1429. * not found literally in KERNEL.BIN, but are derived from other members or found in other
  1430. * files of the kernel (text files).
  1431. */
  1432. struct AccessoryData{
  1433. /**
  1434. * Stat the weapon raises.
  1435. *
  1436. * {@see stat_bonus} for more info.
  1437. */
  1438. u8 stat_raw[2];
  1439. /**
  1440. * The amount the raised stats are raised by.
  1441. *
  1442. * {@see stat_bonus} for more info.
  1443. */
  1444. u8 stat_bonus_raw[2];
  1445. /**
  1446. * Elemental resistance mode. 1 byte.
  1447. *
  1448. * For all elements in {@see element_raw}:
  1449. * If 0: Absorbs.
  1450. * If 1: Nullifies.
  1451. * If 2: Halves.
  1452. * If any other value: normal.
  1453. */
  1454. u8 element_defense_mode;
  1455. /**
  1456. * The special status effect the accesory induces.
  1457. *
  1458. * 0: Auto haste.
  1459. * 1: Auto berserk.
  1460. * 2: Curse.
  1461. * 3: Auto reflect.
  1462. * 4: Steal rate +.
  1463. * 5: Manipulate rate +.
  1464. * 6: Barrier + MBarrier.
  1465. * Other: Nothing.
  1466. */
  1467. u8 effect;
  1468. /**
  1469. * Elements the armor protects against. 2 bytes.
  1470. *
  1471. * The defense type is defined in {@see element_defense_mode}.
  1472. */
  1473. u16 element_raw;
  1474. /**
  1475. * The status effect the armor protects against. 4 bytes.
  1476. */
  1477. u32 status_raw;
  1478. /**
  1479. * Characters that can equip the armor. 2 bytes.
  1480. *
  1481. * Contains bits indicating the characters that can equip the armor {@see character}
  1482. * for more info.
  1483. */
  1484. u16 equip_raw;
  1485. /**
  1486. * Weapon restrictions. 2 bytes.
  1487. *
  1488. * Contains bits indicating if the item is {@see selleable}, {@see useable_battle} and
  1489. * {@see useable_menu}and {@see throwable}.
  1490. */
  1491. u16 restrict_raw;
  1492. /**
  1493. * Accessory ID.
  1494. *
  1495. * Not actually in the item file data, it's the order at which it appears.
  1496. */
  1497. int id;
  1498. /**
  1499. * Accessory name.
  1500. *
  1501. * Not found in the same file as the rest of the data, but on file 20.
  1502. */
  1503. std::string name;
  1504. /**
  1505. * Accessory description.
  1506. *
  1507. * Not found in the same file as the rest of the data, but on file 12.
  1508. */
  1509. std::string description;
  1510. /**
  1511. * Indicates if the accessory can be sold.
  1512. *
  1513. * True if the bit 0 in {@see restrict_raw} is 0.
  1514. */
  1515. bool sellable;
  1516. /**
  1517. * Indicates if the accessory can be used in battle.
  1518. *
  1519. * True if the bit 2 in {@see restrict_raw} is 0.
  1520. */
  1521. bool useable_battle;
  1522. /**
  1523. * Indicates if the accessory can be used in the menu.
  1524. *
  1525. * True if the bit 4 in {@see restrict_raw} is 0.
  1526. */
  1527. bool useable_menu;
  1528. /**
  1529. * The weapon battle model index.
  1530. *
  1531. * It's the lower nybble in {@see model_raw}.
  1532. */
  1533. std::vector<u8> equip;
  1534. /**
  1535. * Bonus in stats.
  1536. *
  1537. * Derived from {@see stat_raw} and {@stat_bonus_raw}.
  1538. */
  1539. std::vector<StatBonus> stat_bonus;
  1540. /**
  1541. * Elements of the accesory.
  1542. *
  1543. * Derived from {@see element_raw}.
  1544. */
  1545. std::vector<int> elements;
  1546. /**
  1547. * Statuses the accessory protects against.
  1548. *
  1549. * Derived from {@see status_raw}.
  1550. */
  1551. std::vector<int> status;
  1552. };
  1553. /**
  1554. * Types of materia.
  1555. */
  1556. enum class MATERIA_TYPE{
  1557. /**
  1558. * Magic materia.
  1559. */
  1560. MAGIC = 1,
  1561. /**
  1562. * Support materia.
  1563. */
  1564. SUPPORT,
  1565. /**
  1566. * Command materia.
  1567. */
  1568. COMMAND,
  1569. /**
  1570. * Independent materia.
  1571. */
  1572. INDEPENDENT,
  1573. /**
  1574. * Summon materia.
  1575. */
  1576. SUMMON
  1577. };
  1578. /**
  1579. * Stat bonuses given by equipping materia.
  1580. *
  1581. * They can be negative.
  1582. */
  1583. struct MateriaStatBonus{
  1584. /**
  1585. * Strength bonus. Absolute.
  1586. */
  1587. int str;
  1588. /**
  1589. * Vitality bonus. Absolute.
  1590. */
  1591. int vit;
  1592. /**
  1593. * Magic bonus. Absolute.
  1594. */
  1595. int mag;
  1596. /**
  1597. * Spirit bonus. Absolute.
  1598. */
  1599. int spr;
  1600. /**
  1601. * Dexterity bonus. Absolute.
  1602. */
  1603. int dex;
  1604. /**
  1605. * Luck bonus. Absolute.
  1606. */
  1607. int lck;
  1608. /**
  1609. * Max HP bonus. Percentile.
  1610. */
  1611. int hp;
  1612. /**
  1613. * Max MP bonus. Percentile.
  1614. */
  1615. int mp;
  1616. /**
  1617. * Indicates if at least one of the stats is changed by the materia.
  1618. */
  1619. bool change;
  1620. };
  1621. /**
  1622. * Data for each materia.
  1623. *
  1624. * As found in KERNEL.BIN, file 8, in order, up to attributes. Members after attributes are
  1625. * not found literally in KERNEL.BIN, but are derived from other members or found in other
  1626. * files of the kernel (text files).
  1627. */
  1628. struct MateriaData{
  1629. /**
  1630. * AP amounts at which the materia levels up. 4 x 1 byte.
  1631. *
  1632. * It can be used to determine how many levels the materia has.
  1633. */
  1634. u16 level_up_ap[4];
  1635. /**
  1636. * Index of stat modifier. 1 byte.
  1637. */
  1638. u8 stat_raw;
  1639. /**
  1640. * Status effects. 3 bytes, not 4!
  1641. */
  1642. u32 status_raw;
  1643. /**
  1644. * Materia element. 1 byte.
  1645. */
  1646. u8 element;
  1647. /**
  1648. * Materia type. 1 byte.
  1649. *
  1650. * 2 nybbles. The upper one is the subtype, and it's ignored in V-Gears. The lower one
  1651. * the actual type.
  1652. */
  1653. u8 type_raw;
  1654. /**
  1655. * Materia attributes. 6 x 1 byte.
  1656. *
  1657. * They are mostly ignored in V-Gears.
  1658. */
  1659. u8 attribute[6];
  1660. /**
  1661. * Accessory ID.
  1662. *
  1663. * Not actually in the item file data, it's the order at which it appears.
  1664. */
  1665. int id;
  1666. /**
  1667. * Accessory name.
  1668. *
  1669. * Not found in the same file as the rest of the data, but on file 20.
  1670. */
  1671. std::string name;
  1672. /**
  1673. * Accessory description.
  1674. *
  1675. * Not found in the same file as the rest of the data, but on file 12.
  1676. */
  1677. std::string description;
  1678. /**
  1679. * Mateira type.
  1680. *
  1681. * Derived from {@see type_raw}.
  1682. */
  1683. int type;
  1684. /**
  1685. * Stat bonuses for equipping the materia.
  1686. *
  1687. * Derived from {@see stat_raw}.
  1688. */
  1689. MateriaStatBonus stats;
  1690. /**
  1691. * Statuses the materia inflicts.
  1692. *
  1693. * Derived from {@see status_raw}.
  1694. */
  1695. std::vector<int> status;
  1696. };
  1697. /**
  1698. * Data for each key item.
  1699. *
  1700. * There is no data file about key items in KERNEL.BIN, there are only names (file 24) and
  1701. * descriptions (file 16)
  1702. */
  1703. struct KeyItemData{
  1704. /**
  1705. * Key item ID.
  1706. *
  1707. * Not actually in KERNEL.BIN, it;s the order at which they appear.
  1708. */
  1709. int id;
  1710. /**
  1711. * Key item name.
  1712. */
  1713. std::string name;
  1714. /**
  1715. * Key item description.
  1716. */
  1717. std::string description;
  1718. };
  1719. /**
  1720. * List of summon names.
  1721. *
  1722. * There is no data file about key items in KERNEL.BIN, there are only names (file 26).
  1723. */
  1724. struct SummonNameData{
  1725. /**
  1726. * Summon ID.
  1727. *
  1728. * Not actually in KERNEL.BIN, it;s the order at which they appear.
  1729. */
  1730. int id;
  1731. /**
  1732. * Summon name.
  1733. */
  1734. std::string name;
  1735. };
  1736. /**
  1737. * Character data.
  1738. *
  1739. * Contains information about a character. Contained in the file 3 of the kernel, one
  1740. * entry for each character. Each section is 56 bytes long. The character ID is not
  1741. * actually in the data, but it's the order at which they appear. The character name is
  1742. * also not in the dataand it must be filled manually.
  1743. */
  1744. struct CharacterData{
  1745. /**
  1746. * Strength stat growth curve. 1 byte.
  1747. */
  1748. u8 curve_str;
  1749. /**
  1750. * Vitality stat growth curve. 1 byte.
  1751. */
  1752. u8 curve_vit;
  1753. /**
  1754. * Magic stat growth curve. 1 byte.
  1755. */
  1756. u8 curve_mag;
  1757. /**
  1758. * Spirit stat growth curve. 1 byte.
  1759. */
  1760. u8 curve_spr;
  1761. /**
  1762. * Dexterity stat growth curve. 1 byte.
  1763. */
  1764. u8 curve_dex;
  1765. /**
  1766. * Luck stat growth curve. 1 byte.
  1767. */
  1768. u8 curve_lck;
  1769. /**
  1770. * HP stat growth curve. 1 byte.
  1771. */
  1772. u8 curve_hp;
  1773. /**
  1774. * MP stat growth curve. 1 byte.
  1775. */
  1776. u8 curve_mp;
  1777. /**
  1778. * Experience-for-next-level growth curve. 1 byte.
  1779. */
  1780. u8 curve_exp;
  1781. /**
  1782. * Ignored data. 1 byte.
  1783. */
  1784. u8 unused_0;
  1785. /**
  1786. * Starting level. 1 byte.
  1787. */
  1788. u8 initial_level;
  1789. /**
  1790. * Ignored data. 1 byte.
  1791. */
  1792. u8 unused_1;
  1793. /**
  1794. * 1-1 limit slot command. 1 byte.
  1795. */
  1796. u8 limit_1_1;
  1797. /**
  1798. * 1-2 limit slot command. 1 byte.
  1799. */
  1800. u8 limit_1_2;
  1801. /**
  1802. * 1-3 limit slot command. 1 byte, unused.
  1803. */
  1804. u8 limit_1_3;
  1805. /**
  1806. * 2-1 limit slot command. 1 byte.
  1807. */
  1808. u8 limit_2_1;
  1809. /**
  1810. * 2-2 limit slot command. 1 byte.
  1811. */
  1812. u8 limit_2_2;
  1813. /**
  1814. * 2-3 limit slot command. 1 byte, unused.
  1815. */
  1816. u8 limit_2_3;
  1817. /**
  1818. * 3-1 limit slot command. 1 byte.
  1819. */
  1820. u8 limit_3_1;
  1821. /**
  1822. * 3-2 limit slot command. 1 byte.
  1823. */
  1824. u8 limit_3_2;
  1825. /**
  1826. * 3-3 limit slot command. 1 byte, unused.
  1827. */
  1828. u8 limit_3_3;
  1829. /**
  1830. * 4-1 limit slot command. 1 byte.
  1831. */
  1832. u8 limit_4_1;
  1833. /**
  1834. * 4-2 limit slot command. 1 byte, unused.
  1835. */
  1836. u8 limit_4_2;
  1837. /**
  1838. * 4-3 limit slot command. 1 byte, unused.
  1839. */
  1840. u8 limit_4_3;
  1841. /**
  1842. * Kills required to unlock limit level 2. 2 bytes.
  1843. */
  1844. u16 limit_2_kills;
  1845. /**
  1846. * Kills required to unlock limit level 3. 2 bytes.
  1847. */
  1848. u16 limit_3_kills;
  1849. /**
  1850. * Kills required to unlock limit 1-2. 2 bytes.
  1851. */
  1852. u16 limit_1_2_uses;
  1853. /**
  1854. * Kills required to unlock limit 1-3. 2 bytes, unused.
  1855. */
  1856. u16 limit_1_3_uses;
  1857. /**
  1858. * Kills required to unlock limit 2-2. 2 bytes.
  1859. */
  1860. u16 limit_2_2_uses;
  1861. /**
  1862. * Kills required to unlock limit 2-3. 2 bytes, unused.
  1863. */
  1864. u16 limit_2_3_uses;
  1865. /**
  1866. * Kills required to unlock limit 3-2. 2 bytes.
  1867. */
  1868. u16 limit_3_2_uses;
  1869. /**
  1870. * Kills required to unlock limit 3-3. 2 bytes, unused.
  1871. */
  1872. u16 limit_3_3_uses;
  1873. /**
  1874. * HP divisor for limit level 1.
  1875. */
  1876. u32 limit_1_div;
  1877. /**
  1878. * HP divisor for limit level 2.
  1879. */
  1880. u32 limit_2_div;
  1881. /**
  1882. * HP divisor for limit level 3.
  1883. */
  1884. u32 limit_3_div;
  1885. /**
  1886. * HP divisor for limit level 4.
  1887. */
  1888. u32 limit_4_div;
  1889. /**
  1890. * Character ID.
  1891. */
  1892. int id;
  1893. /**
  1894. * Character default name.
  1895. */
  1896. std::string name;
  1897. };
  1898. /**
  1899. * Types of stat curves.
  1900. *
  1901. * Althought any of them can be used for any stat, this is their intended use.
  1902. */
  1903. enum STAT_CURVE_TYPE{
  1904. /**
  1905. * Normal curve, used for primary stat.
  1906. */
  1907. CURVE_PRIMARY = 0,
  1908. /**
  1909. * HP curve. Base values must be multiplied by 40 when calculating.
  1910. */
  1911. CURVE_HP,
  1912. /**
  1913. * MP curve. Base values must be multiplied by 2 when calculating.
  1914. */
  1915. CURVE_MP,
  1916. /**
  1917. * Experience curve. Base must be ignored when calculating. Gradient is quadratic.
  1918. */
  1919. CURVE_EXP
  1920. };
  1921. /**
  1922. * Stat curve.
  1923. *
  1924. * determines value growth
  1925. */
  1926. struct StatCurve{
  1927. /**
  1928. * Curve ID.
  1929. */
  1930. int id;
  1931. /**
  1932. * Type of curve.
  1933. */
  1934. STAT_CURVE_TYPE type;
  1935. /**
  1936. * Curve gradients.
  1937. */
  1938. u8 gradient[8];
  1939. /**
  1940. * Curve bases.
  1941. */
  1942. u8 base[8];
  1943. };
  1944. /**
  1945. * Battle data.
  1946. *
  1947. * Contains several pieces of data related to character growth. Contained in the file 3 of
  1948. * the kernel, after the character data (starts at offset 0x01F8). The kernel contains more
  1949. * data, but it's not needed for V-Gears (random table, scene lookup...)
  1950. */
  1951. struct GrowthData{
  1952. /**
  1953. * Random bonus to primary stats, 12 entries of 1 byte.
  1954. */
  1955. u8 bonus_stat[12];
  1956. /**
  1957. * Random bonus to HP stat, 12 entries of 1 byte.
  1958. */
  1959. u8 bonus_hp[12];
  1960. /**
  1961. * Random bonus to MP stat, 12 entries of 1 byte.
  1962. */
  1963. u8 bonus_mp[12];
  1964. /**
  1965. * Stat curves. 64 curves of 16 bit each.
  1966. *
  1967. * 37 for primary stats, 9 for HP, 9 form MP, 9 for experience.
  1968. */
  1969. StatCurve curves[64];
  1970. };
  1971. /**
  1972. * Retrieves the 3-letter name of a basic stat from it's id.
  1973. *
  1974. * @param[in] id The stat ID.
  1975. * @return Stat name abbreviation. If the stat ID is unknown, "stat" will be returned.
  1976. */
  1977. std::string GetBasicStatName(int id);
  1978. /**
  1979. * Items read from the kernel.
  1980. */
  1981. std::vector<CommandData> commands_;
  1982. /**
  1983. * Attacks read from the kernel.
  1984. */
  1985. std::vector<AttackData> attacks_;
  1986. /**
  1987. * Character info read from the kernel.
  1988. */
  1989. std::vector<CharacterData> characters_;
  1990. GrowthData growth_;
  1991. /**
  1992. * Items read from the kernel.
  1993. */
  1994. std::vector<ItemData> items_;
  1995. /**
  1996. * Weapons read from the kernel.
  1997. */
  1998. std::vector<WeaponData> weapons_;
  1999. /**
  2000. * Armors read from the kernel.
  2001. */
  2002. std::vector<ArmorData> armors_;
  2003. /**
  2004. * Accessories read from the kernel.
  2005. */
  2006. std::vector<AccessoryData> accessories_;
  2007. /**
  2008. * Materia read from the kernel.
  2009. */
  2010. std::vector<MateriaData> materia_;
  2011. /**
  2012. * Key items read from the kernel.
  2013. */
  2014. std::vector<KeyItemData> key_items_;
  2015. /**
  2016. * Summon names read from the kernel.
  2017. */
  2018. std::vector<SummonNameData> summon_names_;
  2019. /**
  2020. * The initial savemap structure.
  2021. */
  2022. SaveMap savemap_;
  2023. /**
  2024. * The kernel file.
  2025. */
  2026. BinGZipFile kernel_;
  2027. /**
  2028. * Path to ff7.exe file.
  2029. */
  2030. std::string exe_path_;
  2031. /**
  2032. * Item and materia shop prices.
  2033. *
  2034. * Indexes 0 - 127: Items.
  2035. * Indexes 128 - 255: Weapons.
  2036. * Indexes 256 - 287: Armors.
  2037. * Indexes 288 - 319: Accessories
  2038. * Indxes 320 - 415: Materia.
  2039. */
  2040. u32 prices_[416];
  2041. };