Enemy.h 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  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 <tuple>
  18. #include <OgreString.h>
  19. #include "ScriptManager.h"
  20. /**
  21. * Any enemy in a battle.
  22. */
  23. class Enemy{
  24. public:
  25. struct Element{
  26. /**
  27. * The element ID.
  28. */
  29. unsigned int id;
  30. /**
  31. * Damage modification factor when attacked by the element.
  32. *
  33. * 1 means normal damage taken.
  34. * 0 means no damage taken.
  35. * [0-1] means reduced damage.
  36. * [1-10) means extended damage.
  37. * (-10-0) means recovery
  38. * >10 means death.
  39. * <-10 means full recovery.
  40. */
  41. float factor;
  42. };
  43. /**
  44. * Enemy attack data.
  45. */
  46. struct Attack{
  47. /**
  48. * Attack ID.
  49. */
  50. unsigned int id;
  51. /**
  52. * Camera ID to use during the attack.
  53. *
  54. * -1 to not move the camera.
  55. */
  56. int camera;
  57. /**
  58. * Animation script of the model to play for the attack. -1 if there is none.
  59. */
  60. int animation = -1;
  61. };
  62. /**
  63. * Data for drop and steal items.
  64. */
  65. struct Item{
  66. /**
  67. * Item ID.
  68. */
  69. unsigned int id;
  70. /**
  71. * Steal or drop rate.
  72. */
  73. float rate;
  74. };
  75. /**
  76. * Status immunity.
  77. */
  78. struct Immunity{
  79. /**
  80. * Status ID.
  81. */
  82. unsigned int status;
  83. /**
  84. * Immunity rate.
  85. *
  86. * 0 or lower means no immunity, 1 or higher completely immune. Values between 0 and 1
  87. * indicate resistance.
  88. */
  89. float rate;
  90. };
  91. /**
  92. * Constructor.
  93. *
  94. * @param[in] id Enemy ID.
  95. */
  96. Enemy(const unsigned int id);
  97. /**
  98. * Constructor.
  99. *
  100. * @param[in] id Enemy ID.
  101. * @param[in] pos Enemy position (x, y, z).
  102. * @param[in] front True to set the enemy in the front row, false for back row.
  103. * @param[in] visible Indicates enemy visibility.
  104. * @param[in] targeteable Indicates if the enemy can be targeted.
  105. * @param[in] active Indicates whether the enemy main script is active or not.
  106. * @param[in] cover Cover binary flags string.
  107. */
  108. Enemy(
  109. const unsigned int id, const Ogre::Vector3 pos, const bool front, const bool visible,
  110. const bool targeteable, const bool active, const std::string cover
  111. );
  112. /**
  113. * Destructor.
  114. */
  115. virtual ~Enemy();
  116. /**
  117. * Retrieves the enemy ID.
  118. *
  119. * @return The enemy ID, or -1 if it's not loaded.
  120. */
  121. const int GetId() const;
  122. /**
  123. * Sets the enemy ID.
  124. *
  125. * @param[in] id The enemy ID.
  126. */
  127. void SetId(const int id);
  128. /**
  129. * Retrieves the enemy model.
  130. *
  131. * The model name is the filename of the .mesh file, without extension.
  132. *
  133. * @return The enemy model.
  134. */
  135. const std::string GetModel() const;
  136. /**
  137. * Sets the enemy model.
  138. *
  139. * The model name must be the filename of the .mesh file, without extension.
  140. *
  141. * @param[in] model The enemy model name.
  142. */
  143. void SetModel(const std::string model);
  144. /**
  145. * Retrieves the enemy name.
  146. *
  147. * @return The enemy name.
  148. */
  149. const std::string GetName() const;
  150. /**
  151. * Sets the enemy name.
  152. *
  153. * @param[in] name The enemy name.
  154. */
  155. void SetName(const Ogre::String& name);
  156. /**
  157. * Retrieves the enemy level.
  158. *
  159. * @return The enemy level.
  160. */
  161. unsigned int GetLevel() const;
  162. /**
  163. * Sets the enemy level.
  164. *
  165. * @param[in] level The enemy level.
  166. */
  167. void SetLevel(const unsigned int level);
  168. /**
  169. * Retrieves the AP gain upon defeating the enemy.
  170. *
  171. * @return The AP gain.
  172. */
  173. unsigned int GetAp() const;
  174. /**
  175. * Sets the AP gain upon defeating the enemy.
  176. *
  177. * @param[in] ap The AP gain.
  178. */
  179. void SetAp(unsigned int ap);
  180. /**
  181. * Retrieves the EXP gain upon defeating the enemy.
  182. *
  183. * @return The EXP gain.
  184. */
  185. unsigned int GetExp() const;
  186. /**
  187. * Sets the EXP gain upon defeating the enemy.
  188. *
  189. * @param[in] exp The EXP gain.
  190. */
  191. void SetExp(const unsigned int exp);
  192. /**
  193. * Retrieves the money gain upon defeating the enemy.
  194. *
  195. * @return The money gain.
  196. */
  197. unsigned int GetMoney() const;
  198. /**
  199. * Sets the money gain upon defeating the enemy.
  200. *
  201. * @param[in] money The money gain.
  202. */
  203. void SetMoney(const unsigned int money);
  204. /**
  205. * Retrieves the enemy animation IDs.
  206. *
  207. * @return The list of animation IDs
  208. */
  209. std::vector<unsigned int> GetAnimations() const;
  210. /**
  211. * Adds an animation for the enemy.
  212. *
  213. * @param[in] animation Animation ID.
  214. */
  215. void AddAnimation(const unsigned int animation);
  216. /**
  217. * Retrieves the enemy attacks.
  218. *
  219. * @return The list of attacks.
  220. */
  221. std::vector<Attack> GetAttacks() const;
  222. /**
  223. * Adds an attack for the enemy.
  224. *
  225. * @param[in] attack Attack to add.
  226. */
  227. void AddAttack(const Attack attack);
  228. /**
  229. * Retrieves the enemy possible item drops.
  230. *
  231. * @return List of items that can be dropped by the enemy.
  232. */
  233. std::vector<Item> GetDrop() const;
  234. /**
  235. * Adds an item drop for the enemy.
  236. *
  237. * @param[in] item The dropable item.
  238. */
  239. void AddDrop(const Item item);
  240. /**
  241. * Retrieves the list of the enemy elemental affinities.
  242. *
  243. * @return The list of elemental affinities.
  244. */
  245. std::vector<Element> GetElements() const;
  246. /**
  247. * Adds an elemental affinity to the monster.
  248. *
  249. * @param[in] element Elemental affinity.
  250. */
  251. void AddElement(const Element element);
  252. /**
  253. * Retrieves the list of status immunities.
  254. *
  255. * @return The list of status immunities.
  256. */
  257. std::vector<Immunity> GetImmunities() const;
  258. /**
  259. * Adds an immunity to the monster.
  260. *
  261. * @param[in] immunity The immunity to add.
  262. */
  263. void AddImmunity(const Immunity immunity);
  264. /**
  265. * Retrieves the list of attacks that can be used during the manipulated state.
  266. *
  267. * The first attack of the list is also the attack the enemy will use when in berserkr
  268. * state. If the list is empty, the enemy can't be manipulated or berserkred.
  269. *
  270. * @return List of IDs of attacks usable during manipulation
  271. */
  272. std::vector<unsigned int> GetManipulateAttacks() const;
  273. /**
  274. * Adds an attack usable during manipulation.
  275. *
  276. * @param[in] attack ID of the attack.
  277. */
  278. void AddManipulateAttack(const unsigned int attack);
  279. /**
  280. * Retrieves the enemy possible item stelas.
  281. *
  282. * @return List of items that can be stolen from the enemy.
  283. */
  284. std::vector<Item> GetSteal() const;
  285. /**
  286. * Adds an item steal to the enemy.
  287. *
  288. * @param[in] item The stealableitem.
  289. */
  290. void AddSteal(const Item item);
  291. /**
  292. * Retrieves the ID of the item the monster can be morphed into.
  293. *
  294. * @return ID of the item the enemy can be morphed into, -1 if none.
  295. */
  296. unsigned int GetMorph() const;
  297. /**
  298. * Sets the ID of the item the monster can be morphed into.
  299. *
  300. * @param[in] morph ID of the item the enemy can be morphed into, -1 if none.
  301. */
  302. void SetMorph(const int morph);
  303. /**
  304. * Retrieves the multiplier for the damage the enemy receives when attacked from the back.
  305. *
  306. * @return Back attack damage multiplier.
  307. */
  308. float GetBackDamage() const;
  309. /**
  310. * Sets the multiplier for the damage the enemy receives when attacked from the back.
  311. *
  312. * @param[in] back_damage Back attack damage multiplier, 0 or positive.
  313. */
  314. void SetBackDamage(const float back_damage);
  315. /**
  316. * Retrieves the enemy's strength stat.
  317. *
  318. * @return The strength stat.
  319. */
  320. unsigned int GetStr() const;
  321. /**
  322. * Sets the enemy's strength stat.
  323. *
  324. * @param[in] str The strength stat.
  325. */
  326. void SetStr(const unsigned int str);
  327. /**
  328. * Retrieves the enemy's defense stat.
  329. *
  330. * @return The defense stat.
  331. */
  332. unsigned int GetDef() const;
  333. /**
  334. * Sets the enemy's defense stat.
  335. *
  336. * @param[in] def The defense stat.
  337. */
  338. void SetDef(const unsigned int def);
  339. /**
  340. * Retrieves the enemy's magic stat.
  341. *
  342. * @return The magic stat.
  343. */
  344. unsigned int GetMag() const;
  345. /**
  346. * Sets the enemy's magic stat.
  347. *
  348. * @param[in] mag The magic stat.
  349. */
  350. void SetMag(const unsigned int mag);
  351. /**
  352. * Retrieves the enemy's spirit stat.
  353. *
  354. * @return The spirit stat.
  355. */
  356. unsigned int GetSpr() const;
  357. /**
  358. * Sets the enemy's spirit stat.
  359. *
  360. * @param[in] spr The spirit stat.
  361. */
  362. void SetSpr(const unsigned int spr);
  363. /**
  364. * Retrieves the enemy's dexterity stat.
  365. *
  366. * @return The dexterity stat.
  367. */
  368. unsigned int GetDex() const;
  369. /**
  370. * Sets the enemy's dexterity stat.
  371. *
  372. * @param[in] dex The dexterity stat.
  373. */
  374. void SetDex(const unsigned int dex);
  375. /**
  376. * Retrieves the enemy's luck stat.
  377. *
  378. * @return The luck stat.
  379. */
  380. unsigned int GetLck() const;
  381. /**
  382. * Sets the enemy's luck stat.
  383. *
  384. * @param[in] lck The luck stat.
  385. */
  386. void SetLck(const unsigned int lck);
  387. /**
  388. * Retrieves the enemy's evasion stat.
  389. *
  390. * @return The evasion stat.
  391. */
  392. unsigned int GetEva() const;
  393. /**
  394. * Sets the enemy's evasion stat.
  395. *
  396. * @param[in] eva The evasion stat.
  397. */
  398. void SetEva(const unsigned int eva);
  399. /**
  400. * Retrieves the enemy's magic evasion stat.
  401. *
  402. * @return The magic evasion stat.
  403. */
  404. unsigned int GetMeva() const;
  405. /**
  406. * Sets the enemy's magic evasion stat.
  407. *
  408. * @param[in] meva The magic evasion stat.
  409. */
  410. void SetMeva(const unsigned int meva);
  411. /**
  412. * Retrieves the enemy's current HP.
  413. *
  414. * @return The current HP.
  415. */
  416. unsigned int GetHp() const;
  417. /**
  418. * Sets the enemy's current HP.
  419. *
  420. * If set to higher then max HP reported by {@see GetHpMax()}, it will be capped to that
  421. * value.
  422. *
  423. * @param[in] hp The current HP.
  424. */
  425. void SetHp(const unsigned int hp);
  426. /**
  427. * Retrieves the enemy's max HP.
  428. *
  429. * @return The max HP.
  430. */
  431. unsigned int GetHpMax() const;
  432. /**
  433. * Sets the enemy's max HP.
  434. *
  435. * If the new max HP is higher than the current HP, the current HP will be set to the new
  436. * max HP.
  437. *
  438. * @param[in] hp_max The max HP stat.
  439. */
  440. void SetHpMax(const unsigned int hp_max);
  441. /**
  442. * Retrieves the enemy's current MP.
  443. *
  444. * @return The current MP.
  445. */
  446. unsigned int GetMp() const;
  447. /**
  448. * Sets the enemy's current MP.
  449. *
  450. * If set to higher then max MP reported by {@see GetMpMax()}, it will be capped to that
  451. * value.
  452. *
  453. * @param[in] mp The current MP.
  454. */
  455. void SetMp(const unsigned int mp);
  456. /**
  457. * Retrieves the enemy's max MP.
  458. *
  459. * @return The max MP.
  460. */
  461. unsigned int GetMpMax() const;
  462. /**
  463. * Sets the enemy's max MP.
  464. *
  465. * If the new max MP is higher than the current MP, the current MP will be set to the new
  466. * max MP.
  467. *
  468. * @param[in] mp_max The max MP stat.
  469. */
  470. void SetMpMax(const unsigned int mp_max);
  471. /**
  472. * Retrieves the enemy position in the battlefield.
  473. *
  474. * @return The enemy position (x, y, z).
  475. */
  476. Ogre::Vector3& GetPos();
  477. /**
  478. * Sets the enemy position in the battlefield.
  479. *
  480. * @param[in] pos The enemy position (x, y, z).
  481. */
  482. void SetPos(const Ogre::Vector3 &pos);
  483. /**
  484. * Retrieves the enemy position.
  485. *
  486. * @return The X, Y and Z coordinates for Lua scripts.
  487. */
  488. std::tuple<float, float, float> ScriptGetPos() const;
  489. /**
  490. * Checks if the enemy is in the front row.
  491. *
  492. * @return True if the enemy is in the front row. false if not.
  493. */
  494. bool IsFront() const;
  495. /**
  496. * Sets the enemy in or out the front row.
  497. *
  498. * @param[in] front True to set the enemy in the front row, false for the back row.
  499. */
  500. void SetFront(bool front);
  501. /**
  502. * Checks the enemy visibility.
  503. *
  504. * @return True if the enemy is visible, false if not.
  505. */
  506. bool IsVisible() const;
  507. /**
  508. * Toggles the enemy visibility.
  509. *
  510. * @param[in] visible True to make the enemy visible, false to make it invisible.
  511. */
  512. void SetVisible(bool visible);
  513. /**
  514. * Checks whether the enemy can be targeted.
  515. *
  516. * @return True if the enemy can be targeted, false if not.
  517. */
  518. bool IsTargeteable() const;
  519. /**
  520. * Determines whether the enemy can be targeted.
  521. *
  522. * @param[in] targeteable True to allow targeting the enemy false to prevent it.
  523. */
  524. void SetTargeteable(bool targeteable);
  525. /**
  526. * Checks whether the enemy's main script is active.
  527. *
  528. * @return True if the script is active, false if not.
  529. */
  530. bool IsActive() const;
  531. /**
  532. * Activates or deactivates the enemy main script.
  533. *
  534. * @param[in] active True to activate the script, false to deactivate it.
  535. */
  536. void SetActive(bool active);
  537. /**
  538. * Retrieves the flags for enemy covering.
  539. *
  540. * {@see https://wiki.ffrtt.ru/index.php/FF7/Battle/Battle_Scenes#Binary_.22Cover_Flags.22}
  541. * for more info about cover flags.
  542. *
  543. * @return A string with five 0s or 1s indicating the cover flags.
  544. */
  545. std::string GetCover() const;
  546. /**
  547. * Sets the flags for enemy covering.
  548. *
  549. * {@see https://wiki.ffrtt.ru/index.php/FF7/Battle/Battle_Scenes#Binary_.22Cover_Flags.22}
  550. * for more info about cover flags.
  551. *
  552. * @param[in] cover A string with five 0s or 1s indicating the cover flags.
  553. */
  554. void SetCover(std::string cover);
  555. /**
  556. * Retrieves the number of attacks of the enemy.
  557. *
  558. * To be used from Lua scripts.
  559. *
  560. * @return The number of attacks.
  561. */
  562. int ScriptGetAttackCount();
  563. /**
  564. * Retrieves the number of items the enemy can drop.
  565. *
  566. * To be used from Lua scripts.
  567. *
  568. * @return The number of droppable items.
  569. */
  570. int ScriptGetDropCount() const;
  571. /**
  572. * Retrieves the number of items that can be stolen from the enemy.
  573. *
  574. * To be used from Lua scripts.
  575. *
  576. * @return The number of stealable items.
  577. */
  578. int ScriptGetStealCount() const;
  579. /**
  580. * Retrieves the ID of a stealable item.
  581. *
  582. * To be used from Lua scripts.
  583. *
  584. * @param[in] index Steal index, must be lower than reported by {@see ScriptGetStealCount}.
  585. * @return The item ID, -1 if the index is not valid.
  586. */
  587. int ScriptGetStealId(const unsigned int index) const;
  588. /**
  589. * Retrieves the steal rate of a stealable item.
  590. *
  591. * To be used from Lua scripts.
  592. *
  593. * @param[in] index Steal index, must be lower than reported by {@see ScriptGetStealCount}.
  594. * @return The steal rate, between 0 and 1. 0 if the index is not valid.
  595. */
  596. float ScriptGetStealRate(const unsigned int index) const;
  597. /**
  598. * Retrieves the animation script of an attack.
  599. *
  600. * To be used from Lua scripts.
  601. *
  602. * @param[in] index Attack index, lower than {@see ScriptGetAttackCount}.
  603. * @return The animation script number of the model, -1 if there is none.
  604. */
  605. int ScriptGetAttackAnimation(const unsigned int index) const;
  606. /**
  607. * Retrieves the number of elements the enemy reacts to.
  608. *
  609. * To be used from Lua scripts.
  610. */
  611. int ScriptGetElementCount() const;
  612. /**
  613. * Sets an AI script.
  614. *
  615. * @param[in] slot Script slot (0 initialization, 1 main, 2 general counter, 3 death
  616. * counter, 4 physical counter, 5 magic counter, 6 battle end, 7 pre-turn, 8 to 15 events).
  617. * @param[in] code The script bytecode.
  618. */
  619. void SetAiScript(const unsigned int slot, const std::string& code);
  620. /**
  621. * Retrieves an AI script.
  622. *
  623. * To be used from Lua scripts.
  624. *
  625. * @param[in] slot Script slot, as in {@see SetAiScript}.
  626. * @return The script bytecode, empty if the enemy has no script in that slot.
  627. */
  628. std::string ScriptGetAiScript(const unsigned int slot) const;
  629. /**
  630. * Retrieves the number of status immunities of the enemy.
  631. *
  632. * To be used from Lua scripts.
  633. */
  634. int ScriptGetImmunityCount() const;
  635. /**
  636. * Retrieves the status ID of an immunity (0 is death, 1 near death, 2 sleep, 3 poison...).
  637. *
  638. * To be used from Lua scripts.
  639. *
  640. * @param[in] index Index, lower than {@see ScriptGetImmunityCount}.
  641. * @return The status ID, -1 if the index is not valid.
  642. */
  643. int ScriptGetImmunity(const unsigned int index) const;
  644. /**
  645. * Retrieves the rate of an immunity.
  646. *
  647. * To be used from Lua scripts.
  648. *
  649. * @param[in] index Index, lower than {@see ScriptGetImmunityCount}.
  650. * @return The immunity rate, between 0 and 1. 0 if the index is not valid.
  651. */
  652. float ScriptGetImmunityRate(const unsigned int index) const;
  653. /**
  654. * Retrieves the element index (0 is fire, 1 ice, 2 lightning...) of an element reaction.
  655. *
  656. * To be used from Lua scripts.
  657. *
  658. * @param[in] index Index, lower than {@see ScriptGetElementCount}.
  659. * @return The element, -1 if the index is not valid.
  660. */
  661. int ScriptGetElement(const unsigned int index) const;
  662. /**
  663. * Retrieves the damage factor of an element reaction.
  664. *
  665. * To be used from Lua scripts.
  666. *
  667. * @param[in] index Index, lower than {@see ScriptGetElementCount}.
  668. * @return The factor: 1 normal, 2 double, 0.5 half, 0 nullified, negative for absorbed.
  669. * 1 if the index is not valid.
  670. */
  671. float ScriptGetElementFactor(const unsigned int index) const;
  672. /**
  673. * Retrieves the number of attack animations of the enemy.
  674. *
  675. * To be used from Lua scripts.
  676. *
  677. * @return The number of attack animations.
  678. */
  679. int ScriptGetAnimationCount() const;
  680. /**
  681. * Retrieves an attack animation index of the enemy.
  682. *
  683. * To be used from Lua scripts.
  684. *
  685. * @param[in] index Index in the enemy animation list, lower than
  686. * {@see ScriptGetAnimationCount}.
  687. * @return The animation number in the model (as in "XX_NN"), -1 if the index is not valid.
  688. */
  689. int ScriptGetAnimation(const unsigned int index) const;
  690. /**
  691. * Retrieves the model prefix used in the animation names (the first two characters of the
  692. * model name).
  693. *
  694. * To be used from Lua scripts.
  695. */
  696. std::string ScriptGetModelPrefix() const;
  697. /**
  698. * Retrieves the ID of a droppable item.
  699. *
  700. * To be used from Lua scripts.
  701. *
  702. * @param[in] index Drop index, must be lower than reported by {@see ScriptGetDropCount}.
  703. * @return The item ID, -1 if the index is not valid.
  704. */
  705. int ScriptGetDropId(const unsigned int index) const;
  706. /**
  707. * Retrieves the drop rate of a droppable item.
  708. *
  709. * To be used from Lua scripts.
  710. *
  711. * @param[in] index Drop index, must be lower than reported by {@see ScriptGetDropCount}.
  712. * @return The drop rate, between 0 and 1. 0 if the index is not valid.
  713. */
  714. float ScriptGetDropRate(const unsigned int index) const;
  715. /**
  716. * Retrieves an attack.
  717. *
  718. * To be used from Lua scripts.
  719. *
  720. * @param[in] index The index of the attack to retrieve. Must be lower than reported by
  721. * {@see ScriptGetAttackCount}.
  722. * @return The ID of the attack in the specified index, or -1 if no such attack exists.
  723. */
  724. int ScriptGetAttack(const unsigned int index);
  725. /**
  726. * Retrieves the camera for an attack.
  727. *
  728. * To be used from Lua scripts.
  729. *
  730. * @param[in] index The index of the attack to retrieve. Must be lower than reported by
  731. * {@see ScriptGetAttackCount}.
  732. * @return The ID of camera associated to the attack. -1 if no such attack exists or if it
  733. * doesn't have an specific camera associated.
  734. */
  735. int ScriptGetCameraForAttack(const unsigned int index);
  736. private:
  737. /**
  738. * Reads enemy data from the xml file.
  739. */
  740. void ReadFromXml();
  741. /**
  742. * The enemy ID.
  743. */
  744. int id_;
  745. /**
  746. * NAme of the enemy model file.
  747. */
  748. std::string model_;
  749. /**
  750. * The name of the enemy.
  751. */
  752. Ogre::String name_;
  753. /**
  754. * The enemy level.
  755. */
  756. unsigned int level_;
  757. /**
  758. * EXP given upon defeating the enemy.
  759. */
  760. unsigned int exp_;
  761. /**
  762. * AP given upon defeating the enemy.
  763. */
  764. unsigned int ap_;
  765. /**
  766. * Money given upon defeating the enemy.
  767. */
  768. unsigned int money_;
  769. /**
  770. * List of animations.
  771. */
  772. std::vector<unsigned int> animations_;
  773. /**
  774. * Elemental affinities.
  775. */
  776. std::vector<Element> elements_;
  777. /**
  778. * AI scripts by slot, as bytecode.
  779. */
  780. std::map<unsigned int, std::string> ai_scripts_;
  781. /**
  782. * Status immunities and resistances.
  783. */
  784. std::vector<Immunity> immunities_;
  785. /**
  786. * Enemy attacks.
  787. */
  788. std::vector<Attack> attacks_;
  789. /**
  790. * List of attacks that can be used while manipulated.
  791. *
  792. * The first one is also the one used in berserkr. If empty, it means the enemy can't be
  793. * manipulated or berserkd.
  794. */
  795. std::vector<unsigned int> manipulate_attacks_;
  796. /**
  797. * List of the items that can be stolen from the enemy.
  798. */
  799. std::vector<Item> steal_;
  800. /**
  801. * List of the items that can be dropped from the enemy.
  802. */
  803. std::vector<Item> drop_;
  804. /**
  805. * ID of the item the enemy can be morphed into. -1 if none..
  806. */
  807. int morph_;
  808. /**
  809. * Multiplier for back damage.
  810. */
  811. float back_damage_;
  812. /**
  813. * Enemy strength stat.
  814. */
  815. unsigned int str_;
  816. /**
  817. * Enemy defense stat.
  818. */
  819. unsigned int def_;
  820. /**
  821. * Enemy magic stat.
  822. */
  823. unsigned int mag_;
  824. /**
  825. * Enemy spirit stat.
  826. */
  827. unsigned int spr_;
  828. /**
  829. * Enemy dexterity stat.
  830. */
  831. unsigned int dex_;
  832. /**
  833. * Enemy luck stat.
  834. */
  835. unsigned int lck_;
  836. /**
  837. * Enemy evasion stat.
  838. */
  839. unsigned int eva_;
  840. /**
  841. * Enemy magic evasion stat.
  842. */
  843. unsigned int meva_;
  844. /**
  845. * Enemy's current HP.
  846. */
  847. unsigned int hp_;
  848. /**
  849. * Enemy's current MP.
  850. */
  851. unsigned int mp_;
  852. /**
  853. * Enemy's max HP.
  854. */
  855. unsigned int hp_max_;
  856. /**
  857. * Enemy's max MP.
  858. */
  859. unsigned int mp_max_;
  860. /**
  861. * Enemy position in the battlefield (x, y, z).
  862. */
  863. Ogre::Vector3 pos_;
  864. /**
  865. * Indicates if the enmy is in the frontline.
  866. */
  867. bool front_;
  868. /**
  869. * Indicates if the enemy is visible.
  870. */
  871. bool visible_;
  872. /**
  873. * Indicates if the enemy can be targeted.
  874. */
  875. bool targeteable_;
  876. /**
  877. * Indicates if the enemy's main script is active.
  878. */
  879. bool active_;
  880. /**
  881. * Cover binary flags.
  882. */
  883. std::string cover_;
  884. };