Enemy.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /*
  2. * V-Gears
  3. * Copyright (C) 2022 V-Gears Team
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program 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. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <string>
  19. #include "common/TypeDefine.h"
  20. #include "data/GameData.h"
  21. struct Enemy{
  22. struct Element{
  23. /**
  24. * The element ID.
  25. */
  26. u8 id;
  27. /**
  28. * Damage modification factor when attacked by the element.
  29. *
  30. * 1 means normal damage taken.
  31. * 0 means no damage taken.
  32. * [0-1] means reduced damage.
  33. * [1-10) means extended damage.
  34. * (-10-0) means recovery
  35. * >10 means death.
  36. * <-10 means full recovery.
  37. */
  38. float factor;
  39. };
  40. /**
  41. * Enemy attack data.
  42. */
  43. struct Attack{
  44. /**
  45. * Attack ID.
  46. */
  47. u16 id = 0;
  48. /**
  49. * Camera ID to use during the attack.
  50. *
  51. * -1 to not move the camera.
  52. */
  53. int camera = -1;
  54. /**
  55. * Animation script of the model to play for the attack, as in the model animation scripts
  56. * ("scriptN"). -1 if there is none.
  57. */
  58. int animation = -1;
  59. };
  60. /**
  61. * Data for drop and steal items.
  62. */
  63. struct Item{
  64. /**
  65. * Item ID.
  66. */
  67. unsigned int id;
  68. /**
  69. * Steal or drop rate.
  70. */
  71. float rate;
  72. };
  73. /**
  74. * Status immunity.
  75. */
  76. struct Immunity{
  77. /**
  78. * Status ID.
  79. */
  80. unsigned int status;
  81. /**
  82. * Immunity rate.
  83. *
  84. * 0 or lower means no immunity, 1 or higher completely immune. Values
  85. * between 0 and 1 indicate resistance.
  86. */
  87. float rate;
  88. };
  89. /**
  90. * The enemy ID.
  91. */
  92. u32 id;
  93. /**
  94. * The enemy name.
  95. */
  96. std::string name;
  97. /**
  98. * The enemy level.
  99. */
  100. u8 level;
  101. /**
  102. * The enemy strength stat.
  103. */
  104. u8 str;
  105. /**
  106. * The enemy magic stat.
  107. */
  108. u8 mag;
  109. /**
  110. * The enemy defense stat.
  111. */
  112. u8 def;
  113. /**
  114. * The enemy magic defense stat.
  115. */
  116. u8 mdef;
  117. /**
  118. * The enemy speed stat.
  119. */
  120. u8 spd;
  121. /**
  122. * The enemy luck stat.
  123. */
  124. u8 lck;
  125. /**
  126. * The enemy evasion stat.
  127. */
  128. u8 eva;
  129. /**
  130. * The enemy HP.
  131. */
  132. u32 hp;
  133. /**
  134. * The enemy MP.
  135. */
  136. u32 mp;
  137. /**
  138. * Experience given upon defeat.
  139. */
  140. u32 exp;
  141. /**
  142. * AP given upon defeat.
  143. */
  144. u32 ap;
  145. /**
  146. * Money given upon defeat.
  147. */
  148. u32 money;
  149. /**
  150. * Back damage multiplier.
  151. */
  152. float back_damage;
  153. /**
  154. * List of animations.
  155. */
  156. std::vector<unsigned int> animations;
  157. /**
  158. * Elemental affinities.
  159. */
  160. std::vector<Element> elements;
  161. /**
  162. * Status immunities and resistances.
  163. */
  164. std::vector<Immunity> immunities;
  165. /**
  166. * Enemy attacks.
  167. */
  168. std::vector<Attack> attacks;
  169. /**
  170. * Enemy AI scripts, as bytecode.
  171. *
  172. * There are 16 slots: 0 initialization, 1 main (when it's the enemy turn), 2 general counter,
  173. * 3 death counter, 4 physical counter, 5 magic counter, 6 battle end, 7 pre-turn, and 8 to 15
  174. * custom event scripts. Empty vectors are slots without script.
  175. */
  176. std::vector<std::vector<u8>> ai_scripts;
  177. /**
  178. * List of attacks that can be used while manipulated.
  179. *
  180. * The first one is also the one used in berserkr. If empty, it means the
  181. * enemy can't be manipulated or berserkd.
  182. */
  183. std::vector<u16> manipulate_attacks;
  184. /**
  185. * List of the items that can be stolen from the enemy.
  186. */
  187. std::vector<Item> steal;
  188. /**
  189. * List of the items that can be dropped from the enemy.
  190. */
  191. std::vector<Item> drop;
  192. /**
  193. * Two-letter model code.
  194. */
  195. std::string model;
  196. /**
  197. * ID of the item the enemy can be morphed into.
  198. *
  199. * If -1, it can't be morphed.
  200. */
  201. unsigned int morph;
  202. /**
  203. * Constructor.
  204. *
  205. * Initializes to default values.
  206. */
  207. Enemy():
  208. id(0), name(""), level(1), str(1), mag(1), def(1), mdef(1), spd(1), lck(1), eva(1), hp(1),
  209. mp(1), exp(0), ap(0), money(0), back_damage(1.0f), morph(-1)
  210. {
  211. animations.clear();
  212. elements.clear();
  213. immunities.clear();
  214. attacks.clear();
  215. manipulate_attacks.clear();
  216. steal.clear();
  217. drop.clear();
  218. }
  219. };