1 /***************************************************************************
2  *   Copyright (C) 2009 by Andrey Afletdinov <fheroes2@gmail.com>          *
3  *                                                                         *
4  *   Part of the Free Heroes2 Engine:                                      *
5  *   http://sourceforge.net/projects/fheroes2                              *
6  *                                                                         *
7  *   This program is free software; you can redistribute it and/or modify  *
8  *   it under the terms of the GNU General Public License as published by  *
9  *   the Free Software Foundation; either version 2 of the License, or     *
10  *   (at your option) any later version.                                   *
11  *                                                                         *
12  *   This program is distributed in the hope that it will be useful,       *
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
15  *   GNU General Public License for more details.                          *
16  *                                                                         *
17  *   You should have received a copy of the GNU General Public License     *
18  *   along with this program; if not, write to the                         *
19  *   Free Software Foundation, Inc.,                                       *
20  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
21  ***************************************************************************/
22 
23 #ifndef H2MONSTER_H
24 #define H2MONSTER_H
25 
26 #include "monster_info.h"
27 #include "payment.h"
28 
29 class Spell;
30 class StreamBase;
31 
32 class Monster
33 {
34 public:
35     enum
36     {
37         JOIN_CONDITION_SKIP = 0,
38         JOIN_CONDITION_MONEY = 1,
39         JOIN_CONDITION_FREE = 2
40     };
41 
42     enum class LevelType : int
43     {
44         LEVEL_ANY = 0,
45         LEVEL_1,
46         LEVEL_2,
47         LEVEL_3,
48         LEVEL_4
49     };
50 
51     enum monster_t
52     {
53         UNKNOWN,
54 
55         PEASANT,
56         ARCHER,
57         RANGER,
58         PIKEMAN,
59         VETERAN_PIKEMAN,
60         SWORDSMAN,
61         MASTER_SWORDSMAN,
62         CAVALRY,
63         CHAMPION,
64         PALADIN,
65         CRUSADER,
66         GOBLIN,
67         ORC,
68         ORC_CHIEF,
69         WOLF,
70         OGRE,
71         OGRE_LORD,
72         TROLL,
73         WAR_TROLL,
74         CYCLOPS,
75         SPRITE,
76         DWARF,
77         BATTLE_DWARF,
78         ELF,
79         GRAND_ELF,
80         DRUID,
81         GREATER_DRUID,
82         UNICORN,
83         PHOENIX,
84         CENTAUR,
85         GARGOYLE,
86         GRIFFIN,
87         MINOTAUR,
88         MINOTAUR_KING,
89         HYDRA,
90         GREEN_DRAGON,
91         RED_DRAGON,
92         BLACK_DRAGON,
93         HALFLING,
94         BOAR,
95         IRON_GOLEM,
96         STEEL_GOLEM,
97         ROC,
98         MAGE,
99         ARCHMAGE,
100         GIANT,
101         TITAN,
102         SKELETON,
103         ZOMBIE,
104         MUTANT_ZOMBIE,
105         MUMMY,
106         ROYAL_MUMMY,
107         VAMPIRE,
108         VAMPIRE_LORD,
109         LICH,
110         POWER_LICH,
111         BONE_DRAGON,
112 
113         ROGUE,
114         NOMAD,
115         GHOST,
116         GENIE,
117         MEDUSA,
118         EARTH_ELEMENT,
119         AIR_ELEMENT,
120         FIRE_ELEMENT,
121         WATER_ELEMENT,
122 
123         MONSTER_RND1,
124         MONSTER_RND2,
125         MONSTER_RND3,
126         MONSTER_RND4,
127         MONSTER_RND,
128 
129         // IMPORTANT! Put all new monsters just above this line.
130         MONSTER_COUNT
131     };
132 
133     Monster( const int m = UNKNOWN );
134     explicit Monster( const Spell & );
135     Monster( int race, u32 dw );
136     virtual ~Monster() = default;
137 
138     bool operator==( const Monster & ) const;
139     bool operator!=( const Monster & ) const;
140 
GetID(void)141     int GetID( void ) const
142     {
143         return id;
144     }
145 
146     void Upgrade( void );
147     Monster GetUpgrade( void ) const;
148     Monster GetDowngrade( void ) const;
149 
150     virtual u32 GetAttack( void ) const;
151     virtual u32 GetDefense( void ) const;
152     virtual int GetColor( void ) const;
153     virtual int GetMorale( void ) const;
154     virtual int GetLuck( void ) const;
155     virtual int GetRace( void ) const;
156 
157     u32 GetDamageMin( void ) const;
158     u32 GetDamageMax( void ) const;
159     u32 GetShots( void ) const;
160     u32 GetHitPoints( void ) const;
161     u32 GetSpeed( void ) const;
162     u32 GetGrown( void ) const;
163     int GetMonsterLevel() const;
164     LevelType GetRandomUnitLevel() const;
165     u32 GetRNDSize( bool skip ) const;
166 
167     const char * GetName( void ) const;
168     const char * GetMultiName( void ) const;
169     const char * GetPluralName( u32 ) const;
170 
171     bool isValid( void ) const;
172     bool isElemental( void ) const;
173     bool isUndead( void ) const;
174     bool isFlying( void ) const;
175     bool isWide( void ) const;
176     bool isArchers( void ) const;
177     bool isAllowUpgrade( void ) const;
178     bool isTwiceAttack( void ) const;
179     bool isRegenerating( void ) const;
180     bool isDoubleCellAttack( void ) const;
181     bool isAllAdjacentCellsAttack() const;
182     bool ignoreRetaliation( void ) const;
183     bool isDragons( void ) const;
184     bool isAffectedByMorale( void ) const;
185 
186     bool isAbilityPresent( const fheroes2::MonsterAbilityType abilityType ) const;
187 
188     double GetMonsterStrength( int attack = -1, int defense = -1 ) const;
189     int ICNMonh( void ) const;
190 
191     u32 GetSpriteIndex( void ) const;
192     payment_t GetCost( void ) const;
193     payment_t GetUpgradeCost( void ) const;
194     u32 GetDwelling( void ) const;
195 
196     int GetMonsterSprite() const;
197 
198     static Monster Rand( const LevelType type );
199 
200     static u32 GetCountFromHitPoints( const Monster &, u32 );
201 
202     static uint32_t GetMissileICN( uint32_t monsterID );
203 
204 protected:
205     static Monster FromDwelling( int race, u32 dw );
206 
207     int id;
208 };
209 
210 #endif
211