Enemy.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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;
  48. /**
  49. * Camera ID to use during the attack.
  50. *
  51. * -1 to not move the camera.
  52. */
  53. int camera;
  54. };
  55. /**
  56. * Data for drop and steal items.
  57. */
  58. struct Item{
  59. /**
  60. * Item ID.
  61. */
  62. unsigned int id;
  63. /**
  64. * Steal or drop rate.
  65. */
  66. float rate;
  67. };
  68. /**
  69. * Status immunity.
  70. */
  71. struct Immunity{
  72. /**
  73. * Status ID.
  74. */
  75. unsigned int status;
  76. /**
  77. * Immunity rate.
  78. *
  79. * 0 or lower means no immunity, 1 or higher completely immune. Values
  80. * between 0 and 1 indicate resistance.
  81. */
  82. float rate;
  83. };
  84. /**
  85. * The enemy ID.
  86. */
  87. u32 id;
  88. /**
  89. * The enemy name.
  90. */
  91. std::string name;
  92. /**
  93. * The enemy level.
  94. */
  95. u8 level;
  96. /**
  97. * The enemy strength stat.
  98. */
  99. u8 str;
  100. /**
  101. * The enemy magic stat.
  102. */
  103. u8 mag;
  104. /**
  105. * The enemy defense stat.
  106. */
  107. u8 def;
  108. /**
  109. * The enemy magic defense stat.
  110. */
  111. u8 mdef;
  112. /**
  113. * The enemy speed stat.
  114. */
  115. u8 spd;
  116. /**
  117. * The enemy luck stat.
  118. */
  119. u8 lck;
  120. /**
  121. * The enemy evasion stat.
  122. */
  123. u8 eva;
  124. /**
  125. * The enemy HP.
  126. */
  127. u32 hp;
  128. /**
  129. * The enemy MP.
  130. */
  131. u32 mp;
  132. /**
  133. * Experience given upon defeat.
  134. */
  135. u32 exp;
  136. /**
  137. * AP given upon defeat.
  138. */
  139. u32 ap;
  140. /**
  141. * Money given upon defeat.
  142. */
  143. u32 money;
  144. /**
  145. * Back damage multiplier.
  146. */
  147. float back_damage;
  148. /**
  149. * List of animations.
  150. */
  151. std::vector<unsigned int> animations;
  152. /**
  153. * Elemental affinities.
  154. */
  155. std::vector<Element> elements;
  156. /**
  157. * Status immunities and resistances.
  158. */
  159. std::vector<Immunity> immunities;
  160. /**
  161. * Enemy attacks.
  162. */
  163. std::vector<Attack> attacks;
  164. /**
  165. * List of attacks that can be used while manipulated.
  166. *
  167. * The first one is also the one used in berserkr. If empty, it means the
  168. * enemy can't be manipulated or berserkd.
  169. */
  170. std::vector<u16> manipulate_attacks;
  171. /**
  172. * List of the items that can be stolen from the enemy.
  173. */
  174. std::vector<Item> steal;
  175. /**
  176. * List of the items that can be dropped from the enemy.
  177. */
  178. std::vector<Item> drop;
  179. /**
  180. * Two-letter model code.
  181. */
  182. std::string model;
  183. /**
  184. * ID of the item the enemy can be morphed into.
  185. *
  186. * If -1, it can't be morphed.
  187. */
  188. unsigned int morph;
  189. /**
  190. * Constructor.
  191. *
  192. * Initializes to default values.
  193. */
  194. Enemy():
  195. id(0), name(""), level(1), str(1), mag(1), def(1), mdef(1), spd(1), lck(1), eva(1), hp(1),
  196. mp(1), exp(0), ap(0), money(0), back_damage(1.0f), morph(-1)
  197. {
  198. animations.clear();
  199. elements.clear();
  200. immunities.clear();
  201. attacks.clear();
  202. manipulate_attacks.clear();
  203. steal.clear();
  204. drop.clear();
  205. }
  206. };