BattleManager.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  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 <map>
  17. #include <string>
  18. #include <tuple>
  19. #include <vector>
  20. #include <OgreManualObject.h>
  21. #include <OgreSingleton.h>
  22. #include "Enemy.h"
  23. #include "Event.h"
  24. #include "Manager.h"
  25. #include "core/XmlBattleCharactersFile.h"
  26. #include "core/XmlBattleScenesFile.h"
  27. #include "core/XmlAttackFile.h"
  28. /**
  29. * The battle manager.
  30. */
  31. class BattleManager : public Manager, public Ogre::Singleton<BattleManager>{
  32. public:
  33. /**
  34. * Possible battle layouts.
  35. */
  36. enum LAYOUT{
  37. /**
  38. * Normal battle.
  39. *
  40. * Party facing enemies, all ATBs filled at random, they start filling at the battle
  41. * start.
  42. */
  43. NORMAL = 0,
  44. /**
  45. * Preemptive attack.
  46. *
  47. * Enemies are facing backwards, their ATBs start empty and only start to fill after an
  48. * attack or after a set amount of time. PArty starts with full ATBs.
  49. */
  50. PREEMPTIVE = 1,
  51. /**
  52. * Party attacked from the back.
  53. *
  54. * Party members are facing backwards, with their rows reversed. Their ATBs are empty
  55. * and only start to fill after an attack or after a set amount of time. Enemies start
  56. * with full ATBs.
  57. */
  58. BACK_ATTACK = 2,
  59. /**
  60. * Party surrounds the enemy.
  61. *
  62. * Party members alternated on both sides of the battle. They are considered front row
  63. * for offense and back row for defense. Their ATBs start full. Party-targeted commands
  64. * only target one side. Enemies in the middle, facing in a random direction. Their
  65. * ATBs start with a random amount. When attacked, an enemy turns to the attacker.
  66. */
  67. SIDE_ATTACK = 3,
  68. /**
  69. * Enemies surrounds the party.
  70. *
  71. * Enemies alternated on both sides of the battle. They are considered front row for
  72. * offense and back row for defense. Their ATBs start full. Multiple-targeted commands
  73. * only target one side. Party members in the middle, facing in a random direction.
  74. * Their ATBs start with a random amount. When attacked, they turn to the attacker.
  75. */
  76. PINCER_ATTACK = 4,
  77. /**
  78. * Reserved for scripted battles with only one character.
  79. *
  80. * Works the same as {@see NORMAL}. In the original game, it's used for the Yuffie
  81. * pagoda battles and Cloud's last battle against sephiroth
  82. */
  83. SOLO = 5,
  84. /**
  85. * Unknown.
  86. *
  87. * Never used in the original game.
  88. */
  89. UNKNOWN_0 = 6,
  90. /**
  91. * Unknown.
  92. *
  93. * Never used in the original game.
  94. */
  95. UNKNOWN_1 = 7,
  96. /**
  97. * Locked formation.
  98. *
  99. * Same as {@see NORMAL}, but every party member and enemy is forced in the front row,
  100. * and the "Change" command is disabled.
  101. */
  102. LOCKED = 8,
  103. };
  104. /**
  105. * Item earned during the battle.
  106. */
  107. struct Spoil {
  108. /**
  109. * Item ID.
  110. */
  111. unsigned int id;
  112. /**
  113. * Item quantity.
  114. */
  115. unsigned int qty;
  116. };
  117. /**
  118. * A battle camera settings.
  119. */
  120. struct BattleCamera{
  121. /**
  122. * Camera ID.
  123. */
  124. unsigned int id;
  125. /**
  126. * Camera location.
  127. */
  128. Ogre::Vector3 location;
  129. /**
  130. * Camera orientation.
  131. *
  132. * It's not an angle, or a rotation. but the coordinates the camera points at.
  133. */
  134. Ogre::Vector3 orientation;
  135. };
  136. /**
  137. * Constructor.
  138. */
  139. BattleManager();
  140. /**
  141. * Destructor.
  142. */
  143. virtual ~BattleManager();
  144. /**
  145. * Handles an input event.
  146. *
  147. * @param[in] event Event to handle.
  148. */
  149. void Input(const VGears::Event& event) override;
  150. /**
  151. * Updates the battle in the manager with debug information.
  152. *
  153. * It's automatically called from {@see Update}.
  154. */
  155. void UpdateDebug() override;
  156. /**
  157. * Handles resizing events
  158. */
  159. void OnResize() override;
  160. /**
  161. * Clears all field information in the battle manager.
  162. *
  163. * Does nothing.
  164. */
  165. void ClearField() override;
  166. /**
  167. * Clears all battle information in the battle manager.
  168. */
  169. void ClearBattle() override;
  170. /**
  171. * Clears all world map information in the battle manager.
  172. */
  173. void ClearWorld() override;
  174. /**
  175. * Starts a battle.
  176. *
  177. * @param id Battle ID.
  178. */
  179. void StartBattle(const unsigned int id);
  180. /**
  181. * Ends the current battle.
  182. */
  183. void EndBattle();
  184. /**
  185. * Retrieves the list of enemies.
  186. *
  187. * @return The list of enemies.
  188. */
  189. std::vector<Enemy> GetEnemies() const;
  190. /**
  191. * Adds an enemy to the manager for the next battle.
  192. *
  193. * @param[in] id Enemy ID.
  194. * @param[in] pos Enemy position (x, y, z).
  195. * @param[in] front True to set the enemy in the front row, false for back row.
  196. * @param[in] visible Indicates enemy visibility.
  197. * @param[in] targeteable Indicates if the enemy can be targeted.
  198. * @param[in] active Indicates whether the enemy main script is active or not.
  199. * @param[in] cover Cover binary flags string.
  200. */
  201. void AddEnemy(
  202. const unsigned int id, const Ogre::Vector3 pos, const bool front, const bool visible,
  203. const bool targeteable, const bool active, const std::string cover
  204. );
  205. /**
  206. * Retrieves the number of enemies in the battle.
  207. *
  208. * To be called from Lua scripts.
  209. *
  210. * @return The number of enemies in the battle formation.
  211. */
  212. unsigned int ScriptGetEnemyCount() const;
  213. /**
  214. * Retrieves an enemy.
  215. *
  216. * To be called from Lua scripts.
  217. *
  218. * @param[in] index The enemy index, 0 based. must be lower than reported by
  219. * {@see ScriptGetEnemyCount}.
  220. * @return The enemy at the selected indes, nullptr if it doesn't exists.
  221. */
  222. Enemy* ScriptGetEnemy(const unsigned int index);
  223. /**
  224. * Adds an attack model to the battle.
  225. *
  226. * @param[in] id Attack model ID.
  227. * @param[in] model Model name, without path or extension.
  228. * @param[in] pos Model position.
  229. * @param[in] orientation Model orientation.
  230. * @param[in] animation Initial animation name for the model. If empty or null, the first
  231. * available animation will be used.
  232. */
  233. void AddAttackModel(
  234. const unsigned int id, const std::string model, const Ogre::Vector3 pos,
  235. const Ogre::Degree orientation, const std::string animation
  236. );
  237. /**
  238. * Adds an attack model to the battle.
  239. *
  240. * Simplified version of {@see AddAttackModel}, to be used from Lua scripts.
  241. *
  242. * @param[in] id Attack model ID.
  243. * @param[in] model Model name, without path or extension.
  244. * @param[in] x Model position, X coordinate.
  245. * @param[in] y Model position, Y coordinate.
  246. * @param[in] z Model position, Z coordinate.
  247. * @param[in] orientation Model orientation.
  248. * @param[in] animation Initial animation name for the model. If empty or null, the first
  249. * available animation will be used.
  250. */
  251. void ScriptAddAttackModel(
  252. const unsigned int id, const char* model, const float x, const float y, const float z,
  253. const int orientation, const char* animation
  254. );
  255. /**
  256. * Adds a mesh of a visual effect to the battle scene.
  257. *
  258. * The meshes come from the installer, in models/battle/effects. The entity can be moved,
  259. * scaled and blended from the scripts, and should be removed with
  260. * {@see ScriptRemoveEffectModel} when the effect ends.
  261. *
  262. * @param[in] model Model name, without path or extension, like "magic_faira_1". A name
  263. * with a folder, like "attacks/cyvadat" for a summon, is looked for in models/battle.
  264. * @param[in] x Position, X coordinate.
  265. * @param[in] y Position, Y coordinate.
  266. * @param[in] z Position, Z coordinate.
  267. * @param[in] scale Scale, relative to the size of attack models. 1 is the original size.
  268. * @return Name of the new entity, empty if it couldn't be created.
  269. */
  270. std::string ScriptAddEffectModel(
  271. const char* model, const float x, const float y, const float z, const float scale
  272. );
  273. /**
  274. * Removes an effect mesh added with {@see ScriptAddEffectModel}.
  275. *
  276. * @param[in] name Name of the entity.
  277. */
  278. void ScriptRemoveEffectModel(const char* name);
  279. /**
  280. * Creates a mesh that the scripts fill with triangles, for the effects that are made of
  281. * geometry calculated every frame (like the ground of some summons).
  282. *
  283. * Use {@see ScriptSetDynamicMesh} to give it triangles and {@see ScriptRemoveDynamicMesh}
  284. * to remove it. The meshes that are left are removed when the battle ends.
  285. *
  286. * @param[in] texture Image to put on the triangles, a name of a resource (like
  287. * effects/common_rock_c.png in the battle models, or battle_fx/common_graund.png in the
  288. * images). Empty for no texture.
  289. * @param[in] blend 0 for opaque triangles, 1 for additive blending and 2 for alpha blending.
  290. * @return Name of the mesh, empty if it couldn't be created.
  291. */
  292. std::string ScriptCreateDynamicMesh(const char* texture, const int blend);
  293. /**
  294. * Sets the triangles of a mesh, replacing the previous ones.
  295. *
  296. * @param[in] name Name of the mesh.
  297. * @param[in] vertices Vertices of the triangles, 9 numbers each, 3 vertices per triangle:
  298. * x, y, z (scene position), u, v (position in the texture, 0 to 1), and r, g, b, a (colour,
  299. * 0 to 1). Empty to show nothing.
  300. */
  301. void ScriptSetDynamicMesh(const char* name, std::vector<float> vertices);
  302. /**
  303. * Removes a mesh created with {@see ScriptCreateDynamicMesh}.
  304. *
  305. * @param[in] name Name of the mesh.
  306. */
  307. void ScriptRemoveDynamicMesh(const char* name);
  308. /**
  309. * Sets the battle layout.
  310. *
  311. * @param[in] layout The battle layout. {@see LAYOUT}. When one of the unknowns is
  312. * specified, the normal will be applied.
  313. */
  314. void SetLayout(const LAYOUT layout);
  315. /**
  316. * Retrieves the battle layout.
  317. *
  318. * To be called from Lua scripts.
  319. *
  320. * @return The layout, as in {@see LAYOUT}, as an integer.
  321. */
  322. int ScriptGetLayout() const;
  323. /**
  324. * Retrieves the formation ID of the next battle.
  325. *
  326. * To be called from Lua scripts.
  327. *
  328. * @return The next battle formation ID, -1 if there is none.
  329. */
  330. int GetNextFormationId() const;
  331. /**
  332. * Sets the battle mode flags for the next battles (the BTLMD field opcode).
  333. *
  334. * To be called from Lua scripts. The flags are: 0x80 no results screens, 0x40 arena, 0x20 no
  335. * victory music, 0x08 can't escape, 0x04 preemptive attack, 0x02 timed battle and 0x100
  336. * disable game over. They are kept until they are set again or the field changes.
  337. *
  338. * @param[in] mode The flags.
  339. */
  340. void ScriptSetMode(const int mode);
  341. /**
  342. * Retrieves the battle mode flags.
  343. *
  344. * To be called from Lua scripts.
  345. *
  346. * @return The flags, as in {@see ScriptSetMode}.
  347. */
  348. int GetMode() const;
  349. /**
  350. * Retrieves the ID of the current battle formation.
  351. *
  352. * To be called from Lua scripts.
  353. *
  354. * @return The formation ID, -1 if there is none.
  355. */
  356. int GetFormationId() const;
  357. /**
  358. * Retrieves the escape difficulty of the battle.
  359. *
  360. * To be called from Lua scripts.
  361. *
  362. * @return Values between 0 and 1 (both included), from easy to hard. -1 if the battle
  363. * can't be escaped from.
  364. */
  365. float GetEscapeDifficulty() const;
  366. /**
  367. * Checks if the battle can start as preemptive.
  368. *
  369. * @return False if preemptive attacks are disabled for this battle.
  370. */
  371. bool IsPreemptiveAllowed() const;
  372. /**
  373. * Sets if preemptive attacks are disabled for the battle.
  374. *
  375. * @param[in] disabled True to disable preemptive attacks.
  376. */
  377. void SetPreemptiveDisabled(const bool disabled);
  378. /**
  379. * Checks if the victory pose must be shown.
  380. *
  381. * To be called from Lua scripts.
  382. */
  383. bool ShowVictoryPose() const;
  384. /**
  385. * Checks if the spoils screens must be shown.
  386. *
  387. * To be called from Lua scripts.
  388. */
  389. bool ShowSpoils() const;
  390. /**
  391. * Shows or hides an enemy model.
  392. *
  393. * To be called from Lua scripts.
  394. *
  395. * @param[in] index The enemy index, 0 based.
  396. * @param[in] visible True to show the enemy model, false to hide it.
  397. */
  398. void ScriptSetEnemyVisible(const unsigned int index, const bool visible);
  399. /**
  400. * Retrieves the name of the entity of an enemy.
  401. *
  402. * To be called from Lua scripts.
  403. *
  404. * @param[in] index The enemy index, 0 based.
  405. * @return The entity name, empty if the index is not valid.
  406. */
  407. std::string ScriptGetEnemyEntityName(const unsigned int index) const;
  408. /**
  409. * Retrieves the name of the entity of a party member.
  410. *
  411. * To be called from Lua scripts.
  412. *
  413. * @param[in] index The party position, 0 based (the same as in the party).
  414. * @return The entity name, empty if there is no one in that position.
  415. */
  416. std::string ScriptGetPartyEntityName(const unsigned int index) const;
  417. /**
  418. * Retrieves the prefix used in the animation names of a party member model.
  419. *
  420. * To be called from Lua scripts.
  421. *
  422. * @param[in] index The party position, 0 based (the same as in the party).
  423. * @return The animation prefix (the model name first two letters), empty if there is no
  424. * one in that position.
  425. */
  426. std::string ScriptGetPartyAnimationPrefix(const unsigned int index) const;
  427. /**
  428. * Retrieves the model name of a party member, without path or extension (as in
  429. * "rt_cloud").
  430. *
  431. * To be called from Lua scripts.
  432. *
  433. * @param[in] index The party position, 0 based (the same as in the party).
  434. * @return The model name, empty if there is no one in that position.
  435. */
  436. std::string ScriptGetPartyModelName(const unsigned int index) const;
  437. /**
  438. * Retrieves the data of an attack.
  439. *
  440. * Attack files are read the first time they are needed.
  441. *
  442. * @param[in] id Attack ID.
  443. * @return The attack data, nullptr if there is no such attack.
  444. */
  445. const AttackData* GetAttackData(const int id);
  446. /**
  447. * Checks if there is attack data for an attack, without logging an error if there isn't.
  448. *
  449. * To be called from Lua scripts.
  450. *
  451. * @param[in] id Attack ID.
  452. * @return True if there is an attack file for the attack.
  453. */
  454. bool HasAttackData(const int id);
  455. /**
  456. * Sets the battle formation ID.
  457. *
  458. * @param[in] id Battle formation ID. Negative values to clean the manager.
  459. */
  460. void SetFormationId(const int id);
  461. /**
  462. * Sets the battle formation ID for the next battle, if any.
  463. *
  464. * If set, a new battle will happen when this one is over, instead of returning to the
  465. * field.
  466. *
  467. * @param[in] id Next battle formation ID. Negative values if none.
  468. */
  469. void SetNextFormationId(const int id);
  470. /**
  471. * Sets escaping data for the battle.
  472. *
  473. * @param[in] difficulty Values between 0 and 1 (exclusive) set the escaping difficulty
  474. * from easy to hard. 0 Means the battle can be escaped instantly. Any other value means
  475. * the battle can't be escaped from.
  476. */
  477. void SetEscapeability(const float difficulty);
  478. /**
  479. * Sets the battle to show or skip the victory pose.
  480. */
  481. void SetSkipVictoryPose(const bool skip);
  482. /**
  483. * Sets the battle to show or skip the spoils screens.
  484. */
  485. void SetSkipSpoils(const bool skip);
  486. /**
  487. * Sets the battle location.
  488. *
  489. * @param[in] id Location ID.
  490. * @param[in] name Location name, for debug purposes only. Can be empty or null.
  491. */
  492. void SetLocation(const int id, const Ogre::String name);
  493. /**
  494. * Indicates if the battle is an arena battle.
  495. *
  496. * @param[in] arena True for arena battles, false for every other battles.
  497. */
  498. void SetArenaBattle(const bool arena);
  499. /**
  500. * Sets the initial camera.
  501. *
  502. * Can be set before configuring the camera, but if the battle starts and this index is
  503. * invalid, it's undefined behavior.
  504. *
  505. * @param[in] id ID of the initial camera.
  506. */
  507. void SetInitialCamera(const unsigned int id);
  508. /**
  509. * Sets the camera script of the start of the battle.
  510. *
  511. * @param[in] id ID of the script, -1 for none.
  512. */
  513. void SetIntroCamera(const int id);
  514. /**
  515. * Gets the camera script of the start of the battle.
  516. *
  517. * @return ID of the script, -1 if there is none.
  518. */
  519. int ScriptGetIntroCamera() const;
  520. /**
  521. * Changes the battle camera to one of the cameras of the formation.
  522. *
  523. * To be called from Lua scripts.
  524. *
  525. * @param[in] index Camera index, 0 based.
  526. * @return The number of cameras of the formation. The camera isn't changed if the index is
  527. * not valid.
  528. */
  529. int ScriptSetCamera(const int index);
  530. /**
  531. * Gets the position of a camera of the formation and the point it looks at.
  532. *
  533. * @param index Index of the camera.
  534. * @return X, Y and Z of the position and of the point it looks at, all zero if the camera
  535. * doesn't exist.
  536. */
  537. std::tuple<float, float, float, float, float, float> ScriptGetCamera(const int index);
  538. /**
  539. * Places the battle camera at any position, for the cameras of the effects.
  540. *
  541. * Use {@see ScriptSetCamera} to go back to one of the cameras of the formation.
  542. * To be called from Lua scripts.
  543. *
  544. * @param[in] x Camera position, X coordinate.
  545. * @param[in] y Camera position, Y coordinate.
  546. * @param[in] z Camera position, Z coordinate.
  547. * @param[in] look_x Point the camera looks at, X coordinate.
  548. * @param[in] look_y Point the camera looks at, Y coordinate.
  549. * @param[in] look_z Point the camera looks at, Z coordinate.
  550. */
  551. void ScriptSetCameraPosition(
  552. const float x, const float y, const float z,
  553. const float look_x, const float look_y, const float look_z
  554. );
  555. /**
  556. * Adds a camera for the next battle.
  557. *
  558. * @param[in] id Camera ID.
  559. * @param[in] pos Camera position (x, y, z).
  560. * @param[in] dir Camera orientation (a point the camera will point to).
  561. */
  562. void AddCamera(
  563. const unsigned int id, const Ogre::Vector3 pos, const Ogre::Vector3 dir
  564. );
  565. private:
  566. /**
  567. * Counter to give names to effect entities.
  568. */
  569. unsigned int next_effect_id_ = 0;
  570. /**
  571. * A mesh made of triangles that change, with the data needed to destroy it.
  572. */
  573. struct DynamicMesh{
  574. Ogre::ManualObject* object = nullptr;
  575. Ogre::String material;
  576. bool filled = false;
  577. };
  578. /**
  579. * The meshes made by {@see ScriptCreateDynamicMesh}, by name.
  580. */
  581. std::map<std::string, DynamicMesh> dynamic_meshes_;
  582. /**
  583. * Destroys all the meshes made by {@see ScriptCreateDynamicMesh}.
  584. */
  585. void ClearDynamicMeshes();
  586. /**
  587. * Loads the party members into the battle.
  588. */
  589. void LoadParty();
  590. /**
  591. * Logs the state of the camera.
  592. *
  593. * @param[in] title Text to start the message with.
  594. */
  595. void LogCamera(const std::string& title) const;
  596. /**
  597. * Model rotations, in degrees, to face the party, the enemies, or the left or right side
  598. * of the battle camera.
  599. */
  600. static const int FACING_TO_PARTY;
  601. static const int FACING_TO_ENEMIES;
  602. static const int FACING_TO_LEFT;
  603. static const int FACING_TO_RIGHT;
  604. /**
  605. * Updates the manager while in the field.
  606. *
  607. * It does nothing
  608. */
  609. void UpdateField() override;
  610. /**
  611. * Updates the manager during a battle.
  612. */
  613. void UpdateBattle() override;
  614. /**
  615. * Frames left until the initial battle camera is checked and set again.
  616. */
  617. int camera_check_frames_ = 0;
  618. /**
  619. * Battle mode flags, set by the field scripts. {@see ScriptSetMode}
  620. */
  621. int battle_mode_ = 0;
  622. /**
  623. * Updates manager while in the world map.
  624. *
  625. * It does nothing
  626. */
  627. void UpdateWorld() override;
  628. /**
  629. * Depth (Y coordinate) of the party in normal battles.
  630. */
  631. static const float PARTY_Y;
  632. /**
  633. * Distance between party members.
  634. */
  635. static constexpr float PARTY_SPACING = 6.0f;
  636. /**
  637. * Distance from the center to each side in side attacks.
  638. */
  639. static const float SIDE_DISTANCE;
  640. /**
  641. * Scale factor for battle enemy models: the one of the positions of the battle (the original units are
  642. * 255 times smaller than the ones of the scene).
  643. */
  644. static const float ENEMY_SCALE;
  645. /**
  646. * Scale factor for battle character models.
  647. */
  648. static const float PARTY_SCALE;
  649. /**
  650. * Scale factor for battle attack and spell models.
  651. */
  652. static const float ATTACK_SCALE;
  653. /**
  654. * The scene node.
  655. */
  656. Ogre::SceneNode* scene_node_;
  657. /**
  658. * The current battle formation ID.
  659. */
  660. int formation_id_;
  661. /**
  662. * The battle formation ID for the next battle, if any.
  663. */
  664. int next_formation_id_;
  665. // TODO: Location
  666. //BattleLocation location_;
  667. // TODO: Camera list
  668. std::vector<BattleCamera> camera_;
  669. /**
  670. * Default camera ID
  671. */
  672. unsigned int initial_camera_;
  673. /**
  674. * Camera script of the start of the battle.
  675. */
  676. int intro_camera_;
  677. /**
  678. * Battle layout.
  679. */
  680. LAYOUT layout_;
  681. /**
  682. * Difficulty to escape the battle.
  683. */
  684. float escape_difficulty_;
  685. /**
  686. * Indicates if the current battle is an arena one.
  687. */
  688. bool arena_battle_;
  689. /**
  690. * Indicates if the victory pose must be shown at the battle end.
  691. */
  692. bool show_victory_pose_;
  693. /**
  694. * Indicates if the spoils screens must be shown at the battle end.
  695. */
  696. bool show_spoils_;
  697. /**
  698. * True if the current battle started in the world map.
  699. */
  700. bool battle_from_world_ = false;
  701. /**
  702. * Indicates if the battle can be preemptive (not if it will definitely be).
  703. */
  704. bool preemptive_;
  705. /**
  706. * Money earned during the current battle.
  707. */
  708. unsigned int money_;
  709. /**
  710. * List of items earned during the battle.
  711. */
  712. std::vector<Spoil> spoil_;
  713. /**
  714. * List of enemies for the battle.
  715. */
  716. std::vector<Enemy> enemies_;
  717. /**
  718. * Names of the entities of the enemies in the battle, in the same order as the enemies.
  719. */
  720. std::vector<std::string> enemy_entity_name_;
  721. /**
  722. * Names of the entities of the party members, by party position. Empty if no one is in
  723. * that position.
  724. */
  725. std::vector<std::string> party_entity_name_;
  726. /**
  727. * Animation prefixes of the party members models, by party position.
  728. */
  729. std::vector<std::string> party_animation_prefix_;
  730. /**
  731. * Model names of the party members, by party position, without path or extension.
  732. */
  733. std::vector<std::string> party_model_name_;
  734. /**
  735. * File names of the attacks by ID, loaded the first time an attack is requested.
  736. */
  737. std::map<int, std::string> attack_index_;
  738. /**
  739. * Indicates if {@see attack_index_} has been loaded.
  740. */
  741. bool attack_index_loaded_ = false;
  742. /**
  743. * Attacks already read.
  744. */
  745. std::map<int, AttackData> attack_cache_;
  746. /**
  747. * Map of playable character models.
  748. */
  749. std::vector<XmlBattleCharactersFile::BattleCharacter> character_model_map_;
  750. /**
  751. * Map of battle scene models.
  752. */
  753. std::vector<XmlBattleScenesFile::BattleScene> scene_model_map_;
  754. /**
  755. * List of party members in the battle.
  756. */
  757. // TODO std::vector<Player> party_;
  758. };