1 /*************************************************************************** 2 * Free Heroes of Might and Magic II: https://github.com/ihhub/fheroes2 * 3 * Copyright (C) 2021 * 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 2 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, write to the * 17 * Free Software Foundation, Inc., * 18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 19 ***************************************************************************/ 20 21 #ifndef H2MONSTER_INFO_H 22 #define H2MONSTER_INFO_H 23 24 #include "resource.h" 25 26 #include <string> 27 #include <vector> 28 29 namespace fheroes2 30 { 31 enum class MonsterAbilityType : int 32 { 33 // Basic abilities. 34 NONE, 35 DOUBLE_HEX_SIZE, 36 FLYING, 37 DRAGON, 38 UNDEAD, 39 ELEMENTAL, 40 // Advanced abilities. 41 DOUBLE_SHOOTING, 42 DOUBLE_MELEE_ATTACK, 43 DOUBLE_DAMAGE_TO_UNDEAD, 44 MAGIC_RESISTANCE, 45 MIND_SPELL_IMMUNITY, 46 ELEMENTAL_SPELL_IMMUNITY, 47 FIRE_SPELL_IMMUNITY, 48 COLD_SPELL_IMMUNITY, 49 IMMUNE_TO_CERTAIN_SPELL, 50 ELEMENTAL_SPELL_DAMAGE_REDUCTION, 51 SPELL_CASTER, 52 HP_REGENERATION, 53 TWO_CELL_MELEE_ATTACK, 54 ALWAYS_RETALIATE, 55 ALL_ADJACENT_CELL_MELEE_ATTACK, 56 NO_MELEE_PENALTY, 57 NO_ENEMY_RETALIATION, 58 HP_DRAIN, 59 AREA_SHOT, 60 MORAL_DECREMENT, 61 ENEMY_HALFING, 62 SOUL_EATER 63 }; 64 65 enum class MonsterWeaknessType : int 66 { 67 // Basic abilities. 68 NONE, 69 // Advanced abilities. 70 EXTRA_DAMAGE_FROM_FIRE_SPELL, 71 EXTRA_DAMAGE_FROM_COLD_SPELL, 72 EXTRA_DAMAGE_FROM_CERTAIN_SPELL 73 }; 74 75 struct MonsterAbility 76 { MonsterAbilityMonsterAbility77 explicit MonsterAbility( const MonsterAbilityType type_ ) 78 : type( type_ ) 79 , percentage( 0 ) 80 , value( 0 ) 81 {} 82 MonsterAbilityMonsterAbility83 explicit MonsterAbility( const MonsterAbilityType type_, const uint32_t percentage_, const uint32_t value_ ) 84 : type( type_ ) 85 , percentage( percentage_ ) 86 , value( value_ ) 87 {} 88 89 bool operator==( const MonsterAbility & another ) const 90 { 91 return type == another.type; 92 } 93 94 MonsterAbilityType type; 95 96 uint32_t percentage; 97 98 uint32_t value; 99 }; 100 101 struct MonsterWeakness 102 { MonsterWeaknessMonsterWeakness103 explicit MonsterWeakness( const MonsterWeaknessType type_ ) 104 : type( type_ ) 105 , percentage( 0 ) 106 , value( 0 ) 107 {} 108 MonsterWeaknessMonsterWeakness109 explicit MonsterWeakness( const MonsterWeaknessType type_, const uint32_t percentage_, const uint32_t value_ ) 110 : type( type_ ) 111 , percentage( percentage_ ) 112 , value( value_ ) 113 {} 114 115 bool operator<( const MonsterWeakness & another ) const 116 { 117 return type < another.type || ( type == another.type && value < another.value ); 118 } 119 120 MonsterWeaknessType type; 121 122 uint32_t percentage; 123 124 uint32_t value; 125 }; 126 127 struct MonsterBattleStats 128 { 129 uint32_t attack; 130 uint32_t defense; 131 uint32_t damageMin; 132 uint32_t damageMax; 133 uint32_t hp; 134 uint32_t speed; 135 uint32_t shots; 136 137 std::vector<MonsterAbility> abilities; 138 std::vector<MonsterWeakness> weaknesses; 139 }; 140 141 struct MonsterGeneralStats 142 { 143 const char * name; 144 const char * pluralName; 145 146 uint32_t baseGrowth; 147 uint32_t race; 148 uint32_t level; 149 150 cost_t cost; 151 }; 152 153 struct MonsterSound 154 { 155 int meleeAttack; 156 int death; 157 int movement; 158 int wince; 159 int rangeAttack; 160 }; 161 162 struct MonsterData 163 { MonsterDataMonsterData164 MonsterData( const int icnId_, const char * binFileName_, const MonsterSound & sounds_, const MonsterBattleStats & battleStats_, 165 const MonsterGeneralStats & generalStats_ ) 166 : icnId( icnId_ ) 167 , binFileName( binFileName_ ) 168 , sounds( sounds_ ) 169 , battleStats( battleStats_ ) 170 , generalStats( generalStats_ ) 171 {} 172 173 int icnId; 174 175 const char * binFileName; 176 177 MonsterSound sounds; 178 179 MonsterBattleStats battleStats; 180 181 MonsterGeneralStats generalStats; 182 }; 183 184 const MonsterData & getMonsterData( const int monsterId ); 185 186 std::string getMonsterAbilityDescription( const MonsterAbility & ability, const bool ignoreBasicAbility ); 187 std::string getMonsterWeaknessDescription( const MonsterWeakness & weakness, const bool ignoreBasicAbility ); 188 189 std::string getMonsterDescription( const int monsterId ); // To be utilized in future. 190 191 std::vector<std::string> getMonsterPropertiesDescription( const int monsterId ); 192 193 uint32_t getSpellResistance( const int monsterId, const int spellId ); 194 } 195 #endif 196