GameConstants.h 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196
  1. /*
  2. * GameConstants.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "ConstTransitivePtr.h"
  12. class Artifact;
  13. class ArtifactService;
  14. class Creature;
  15. class CreatureService;
  16. namespace spells
  17. {
  18. class Spell;
  19. class Service;
  20. }
  21. class CArtifact;
  22. class CArtifactInstance;
  23. class CCreature;
  24. class CHero;
  25. class CSpell;
  26. class CSkill;
  27. class CGameInfoCallback;
  28. class CNonConstInfoCallback;
  29. struct IdTag
  30. {};
  31. namespace GameConstants
  32. {
  33. DLL_LINKAGE extern const int VCMI_VERSION_MAJOR;
  34. DLL_LINKAGE extern const int VCMI_VERSION_MINOR;
  35. DLL_LINKAGE extern const int VCMI_VERSION_PATCH;
  36. DLL_LINKAGE extern const std::string VCMI_VERSION;
  37. const int PUZZLE_MAP_PIECES = 48;
  38. const int MAX_HEROES_PER_PLAYER = 8;
  39. const int AVAILABLE_HEROES_PER_PLAYER = 2;
  40. const int ALL_PLAYERS = 255; //bitfield
  41. const ui16 BACKPACK_START = 19;
  42. const int CREATURES_PER_TOWN = 7; //without upgrades
  43. const int SPELL_LEVELS = 5;
  44. const int SPELL_SCHOOL_LEVELS = 4;
  45. const int CRE_LEVELS = 10; // number of creature experience levels
  46. const int HERO_GOLD_COST = 2500;
  47. const int SPELLBOOK_GOLD_COST = 500;
  48. const int SKILL_GOLD_COST = 2000;
  49. const int BATTLE_PENALTY_DISTANCE = 10; //if the distance is > than this, then shooting stack has distance penalty
  50. const int ARMY_SIZE = 7;
  51. const int SKILL_PER_HERO = 8;
  52. const ui32 HERO_HIGH_LEVEL = 10; // affects primary skill upgrade order
  53. const int SKILL_QUANTITY=28;
  54. const int PRIMARY_SKILLS=4;
  55. const int RESOURCE_QUANTITY=8;
  56. const int HEROES_PER_TYPE=8; //amount of heroes of each type
  57. // amounts of OH3 objects. Can be changed by mods, should be used only during H3 loading phase
  58. const int F_NUMBER = 9;
  59. const int ARTIFACTS_QUANTITY=171;
  60. const int HEROES_QUANTITY=156;
  61. const int SPELLS_QUANTITY=70;
  62. const int CREATURES_COUNT = 197;
  63. const ui32 BASE_MOVEMENT_COST = 100; //default cost for non-diagonal movement
  64. const int HERO_PORTRAIT_SHIFT = 30;// 2 special frames + some extra portraits
  65. const std::array<int, 11> POSSIBLE_TURNTIME = {1, 2, 4, 6, 8, 10, 15, 20, 25, 30, 0};
  66. }
  67. #define ID_LIKE_CLASS_COMMON(CLASS_NAME, ENUM_NAME) \
  68. CLASS_NAME(const CLASS_NAME & other) \
  69. { \
  70. num = other.num; \
  71. } \
  72. CLASS_NAME & operator=(const CLASS_NAME & other) \
  73. { \
  74. num = other.num; \
  75. return *this; \
  76. } \
  77. explicit CLASS_NAME(si32 id) \
  78. : num(static_cast<ENUM_NAME>(id)) \
  79. {} \
  80. operator ENUM_NAME() const \
  81. { \
  82. return num; \
  83. } \
  84. si32 getNum() const \
  85. { \
  86. return static_cast<si32>(num); \
  87. } \
  88. ENUM_NAME toEnum() const \
  89. { \
  90. return num; \
  91. } \
  92. template <typename Handler> void serialize(Handler &h, const int version) \
  93. { \
  94. h & num; \
  95. } \
  96. CLASS_NAME & advance(int i) \
  97. { \
  98. num = (ENUM_NAME)((int)num + i); \
  99. return *this; \
  100. }
  101. // Operators are performance-critical and to be inlined they must be in header
  102. #define ID_LIKE_OPERATORS_INTERNAL(A, B, AN, BN) \
  103. STRONG_INLINE bool operator==(const A & a, const B & b) \
  104. { \
  105. return AN == BN ; \
  106. } \
  107. STRONG_INLINE bool operator!=(const A & a, const B & b) \
  108. { \
  109. return AN != BN ; \
  110. } \
  111. STRONG_INLINE bool operator<(const A & a, const B & b) \
  112. { \
  113. return AN < BN ; \
  114. } \
  115. STRONG_INLINE bool operator<=(const A & a, const B & b) \
  116. { \
  117. return AN <= BN ; \
  118. } \
  119. STRONG_INLINE bool operator>(const A & a, const B & b) \
  120. { \
  121. return AN > BN ; \
  122. } \
  123. STRONG_INLINE bool operator>=(const A & a, const B & b) \
  124. { \
  125. return AN >= BN ; \
  126. }
  127. #define ID_LIKE_OPERATORS(CLASS_NAME, ENUM_NAME) \
  128. ID_LIKE_OPERATORS_INTERNAL(CLASS_NAME, CLASS_NAME, a.num, b.num) \
  129. ID_LIKE_OPERATORS_INTERNAL(CLASS_NAME, ENUM_NAME, a.num, b) \
  130. ID_LIKE_OPERATORS_INTERNAL(ENUM_NAME, CLASS_NAME, a, b.num)
  131. #define OP_DECL_INT(CLASS_NAME, OP) \
  132. bool operator OP (const CLASS_NAME & b) const \
  133. { \
  134. return num OP b.num; \
  135. }
  136. #define INSTID_LIKE_CLASS_COMMON(CLASS_NAME, NUMERIC_NAME) \
  137. public: \
  138. CLASS_NAME() : BaseForID<CLASS_NAME, NUMERIC_NAME>(-1) {} \
  139. CLASS_NAME(const CLASS_NAME & other): \
  140. BaseForID<CLASS_NAME, NUMERIC_NAME>(other) \
  141. { \
  142. } \
  143. CLASS_NAME & operator=(const CLASS_NAME & other) \
  144. { \
  145. num = other.num; \
  146. return *this; \
  147. } \
  148. explicit CLASS_NAME(si32 id) \
  149. : BaseForID<CLASS_NAME, NUMERIC_NAME>(id) \
  150. {}
  151. template < typename Derived, typename NumericType>
  152. class BaseForID : public IdTag
  153. {
  154. protected:
  155. NumericType num;
  156. public:
  157. NumericType getNum() const
  158. {
  159. return num;
  160. }
  161. //to make it more similar to IDLIKE
  162. NumericType toEnum() const
  163. {
  164. return num;
  165. }
  166. template <typename Handler> void serialize(Handler &h, const int version)
  167. {
  168. h & num;
  169. }
  170. explicit BaseForID(NumericType _num = -1)
  171. {
  172. num = _num;
  173. }
  174. void advance(int change)
  175. {
  176. num += change;
  177. }
  178. typedef BaseForID<Derived, NumericType> __SelfType;
  179. OP_DECL_INT(__SelfType, ==)
  180. OP_DECL_INT(__SelfType, !=)
  181. OP_DECL_INT(__SelfType, <)
  182. OP_DECL_INT(__SelfType, >)
  183. OP_DECL_INT(__SelfType, <=)
  184. OP_DECL_INT(__SelfType, >=)
  185. };
  186. template<typename Der, typename Num>
  187. std::ostream & operator << (std::ostream & os, BaseForID<Der, Num> id);
  188. template<typename Der, typename Num>
  189. std::ostream & operator << (std::ostream & os, BaseForID<Der, Num> id)
  190. {
  191. //We use common type with short to force char and unsigned char to be promoted and formatted as numbers.
  192. typedef typename std::common_type<short, Num>::type Number;
  193. return os << static_cast<Number>(id.getNum());
  194. }
  195. class ArtifactInstanceID : public BaseForID<ArtifactInstanceID, si32>
  196. {
  197. INSTID_LIKE_CLASS_COMMON(ArtifactInstanceID, si32)
  198. friend class CGameInfoCallback;
  199. friend class CNonConstInfoCallback;
  200. };
  201. class QueryID : public BaseForID<QueryID, si32>
  202. {
  203. INSTID_LIKE_CLASS_COMMON(QueryID, si32)
  204. QueryID & operator++()
  205. {
  206. ++num;
  207. return *this;
  208. }
  209. };
  210. class ObjectInstanceID : public BaseForID<ObjectInstanceID, si32>
  211. {
  212. INSTID_LIKE_CLASS_COMMON(ObjectInstanceID, si32)
  213. friend class CGameInfoCallback;
  214. friend class CNonConstInfoCallback;
  215. };
  216. class HeroClassID : public BaseForID<HeroClassID, si32>
  217. {
  218. INSTID_LIKE_CLASS_COMMON(HeroClassID, si32)
  219. };
  220. class HeroTypeID : public BaseForID<HeroTypeID, si32>
  221. {
  222. INSTID_LIKE_CLASS_COMMON(HeroTypeID, si32)
  223. ///json serialization helpers
  224. static si32 decode(const std::string & identifier);
  225. static std::string encode(const si32 index);
  226. };
  227. class SlotID : public BaseForID<SlotID, si32>
  228. {
  229. INSTID_LIKE_CLASS_COMMON(SlotID, si32)
  230. friend class CGameInfoCallback;
  231. friend class CNonConstInfoCallback;
  232. DLL_LINKAGE static const SlotID COMMANDER_SLOT_PLACEHOLDER;
  233. DLL_LINKAGE static const SlotID SUMMONED_SLOT_PLACEHOLDER; ///<for all summoned creatures, only during battle
  234. DLL_LINKAGE static const SlotID WAR_MACHINES_SLOT; ///<for all war machines during battle
  235. DLL_LINKAGE static const SlotID ARROW_TOWERS_SLOT; ///<for all arrow towers during battle
  236. bool validSlot() const
  237. {
  238. return getNum() >= 0 && getNum() < GameConstants::ARMY_SIZE;
  239. }
  240. };
  241. class PlayerColor : public BaseForID<PlayerColor, ui8>
  242. {
  243. INSTID_LIKE_CLASS_COMMON(PlayerColor, ui8)
  244. enum EPlayerColor
  245. {
  246. PLAYER_LIMIT_I = 8
  247. };
  248. DLL_LINKAGE static const PlayerColor SPECTATOR; //252
  249. DLL_LINKAGE static const PlayerColor CANNOT_DETERMINE; //253
  250. DLL_LINKAGE static const PlayerColor UNFLAGGABLE; //254 - neutral objects (pandora, banks)
  251. DLL_LINKAGE static const PlayerColor NEUTRAL; //255
  252. DLL_LINKAGE static const PlayerColor PLAYER_LIMIT; //player limit per map
  253. DLL_LINKAGE bool isValidPlayer() const; //valid means < PLAYER_LIMIT (especially non-neutral)
  254. DLL_LINKAGE bool isSpectator() const;
  255. DLL_LINKAGE std::string getStr(bool L10n = false) const;
  256. DLL_LINKAGE std::string getStrCap(bool L10n = false) const;
  257. friend class CGameInfoCallback;
  258. friend class CNonConstInfoCallback;
  259. };
  260. class TeamID : public BaseForID<TeamID, ui8>
  261. {
  262. INSTID_LIKE_CLASS_COMMON(TeamID, ui8)
  263. DLL_LINKAGE static const TeamID NO_TEAM;
  264. friend class CGameInfoCallback;
  265. friend class CNonConstInfoCallback;
  266. };
  267. class TeleportChannelID : public BaseForID<TeleportChannelID, si32>
  268. {
  269. INSTID_LIKE_CLASS_COMMON(TeleportChannelID, si32)
  270. friend class CGameInfoCallback;
  271. friend class CNonConstInfoCallback;
  272. };
  273. // #ifndef INSTANTIATE_BASE_FOR_ID_HERE
  274. // extern template std::ostream & operator << <ArtifactInstanceID>(std::ostream & os, BaseForID<ArtifactInstanceID> id);
  275. // extern template std::ostream & operator << <ObjectInstanceID>(std::ostream & os, BaseForID<ObjectInstanceID> id);
  276. // #endif
  277. // Enum declarations
  278. namespace PrimarySkill
  279. {
  280. enum PrimarySkill { NONE = -1, ATTACK, DEFENSE, SPELL_POWER, KNOWLEDGE,
  281. EXPERIENCE = 4}; //for some reason changePrimSkill uses it
  282. }
  283. class SecondarySkill
  284. {
  285. public:
  286. enum ESecondarySkill
  287. {
  288. WRONG = -2,
  289. DEFAULT = -1,
  290. PATHFINDING = 0, ARCHERY, LOGISTICS, SCOUTING, DIPLOMACY, NAVIGATION, LEADERSHIP, WISDOM, MYSTICISM,
  291. LUCK, BALLISTICS, EAGLE_EYE, NECROMANCY, ESTATES, FIRE_MAGIC, AIR_MAGIC, WATER_MAGIC, EARTH_MAGIC,
  292. SCHOLAR, TACTICS, ARTILLERY, LEARNING, OFFENCE, ARMORER, INTELLIGENCE, SORCERY, RESISTANCE,
  293. FIRST_AID, SKILL_SIZE
  294. };
  295. static_assert(GameConstants::SKILL_QUANTITY == SKILL_SIZE, "Incorrect number of skills");
  296. SecondarySkill(ESecondarySkill _num = WRONG) : num(_num)
  297. {}
  298. ID_LIKE_CLASS_COMMON(SecondarySkill, ESecondarySkill)
  299. ESecondarySkill num;
  300. };
  301. ID_LIKE_OPERATORS(SecondarySkill, SecondarySkill::ESecondarySkill)
  302. namespace EAlignment
  303. {
  304. enum EAlignment { GOOD, EVIL, NEUTRAL };
  305. }
  306. namespace ETownType//deprecated
  307. {
  308. enum ETownType
  309. {
  310. ANY = -1,
  311. CASTLE, RAMPART, TOWER, INFERNO, NECROPOLIS, DUNGEON, STRONGHOLD, FORTRESS, CONFLUX, NEUTRAL
  312. };
  313. }
  314. class FactionID : public BaseForID<FactionID, si32>
  315. {
  316. INSTID_LIKE_CLASS_COMMON(FactionID, si32)
  317. DLL_LINKAGE static const FactionID ANY;
  318. DLL_LINKAGE static const FactionID CASTLE;
  319. DLL_LINKAGE static const FactionID RAMPART;
  320. DLL_LINKAGE static const FactionID TOWER;
  321. DLL_LINKAGE static const FactionID INFERNO;
  322. DLL_LINKAGE static const FactionID NECROPOLIS;
  323. DLL_LINKAGE static const FactionID DUNGEON;
  324. DLL_LINKAGE static const FactionID STRONGHOLD;
  325. DLL_LINKAGE static const FactionID FORTRESS;
  326. DLL_LINKAGE static const FactionID CONFLUX;
  327. DLL_LINKAGE static const FactionID NEUTRAL;
  328. ///json serialization helpers
  329. static si32 decode(const std::string & identifier);
  330. static std::string encode(const si32 index);
  331. };
  332. class BuildingID
  333. {
  334. public:
  335. //Quite useful as long as most of building mechanics hardcoded
  336. // NOTE: all building with completely configurable mechanics will be removed from list
  337. enum EBuildingID
  338. {
  339. DEFAULT = -50,
  340. NONE = -1,
  341. MAGES_GUILD_1 = 0, MAGES_GUILD_2, MAGES_GUILD_3, MAGES_GUILD_4, MAGES_GUILD_5,
  342. TAVERN, SHIPYARD, FORT, CITADEL, CASTLE,
  343. VILLAGE_HALL, TOWN_HALL, CITY_HALL, CAPITOL, MARKETPLACE,
  344. RESOURCE_SILO, BLACKSMITH, SPECIAL_1, HORDE_1, HORDE_1_UPGR,
  345. SHIP, SPECIAL_2, SPECIAL_3, SPECIAL_4, HORDE_2,
  346. HORDE_2_UPGR, GRAIL, EXTRA_TOWN_HALL, EXTRA_CITY_HALL, EXTRA_CAPITOL,
  347. DWELL_FIRST=30, DWELL_LVL_2, DWELL_LVL_3, DWELL_LVL_4, DWELL_LVL_5, DWELL_LVL_6, DWELL_LAST=36,
  348. DWELL_UP_FIRST=37, DWELL_LVL_2_UP, DWELL_LVL_3_UP, DWELL_LVL_4_UP, DWELL_LVL_5_UP,
  349. DWELL_LVL_6_UP, DWELL_UP_LAST=43,
  350. DWELL_LVL_1 = DWELL_FIRST,
  351. DWELL_LVL_7 = DWELL_LAST,
  352. DWELL_LVL_1_UP = DWELL_UP_FIRST,
  353. DWELL_LVL_7_UP = DWELL_UP_LAST,
  354. //Special buildings for towns.
  355. LIGHTHOUSE = SPECIAL_1,
  356. STABLES = SPECIAL_2, //Castle
  357. BROTHERHOOD = SPECIAL_3,
  358. MYSTIC_POND = SPECIAL_1,
  359. FOUNTAIN_OF_FORTUNE = SPECIAL_2, //Rampart
  360. TREASURY = SPECIAL_3,
  361. ARTIFACT_MERCHANT = SPECIAL_1,
  362. LOOKOUT_TOWER = SPECIAL_2, //Tower
  363. LIBRARY = SPECIAL_3,
  364. WALL_OF_KNOWLEDGE = SPECIAL_4,
  365. STORMCLOUDS = SPECIAL_2,
  366. CASTLE_GATE = SPECIAL_3, //Inferno
  367. ORDER_OF_FIRE = SPECIAL_4,
  368. COVER_OF_DARKNESS = SPECIAL_1,
  369. NECROMANCY_AMPLIFIER = SPECIAL_2, //Necropolis
  370. SKELETON_TRANSFORMER = SPECIAL_3,
  371. //ARTIFACT_MERCHANT - same ID as in tower
  372. MANA_VORTEX = SPECIAL_2,
  373. PORTAL_OF_SUMMON = SPECIAL_3, //Dungeon
  374. BATTLE_ACADEMY = SPECIAL_4,
  375. ESCAPE_TUNNEL = SPECIAL_1,
  376. FREELANCERS_GUILD = SPECIAL_2, //Stronghold
  377. BALLISTA_YARD = SPECIAL_3,
  378. HALL_OF_VALHALLA = SPECIAL_4,
  379. CAGE_OF_WARLORDS = SPECIAL_1,
  380. GLYPHS_OF_FEAR = SPECIAL_2, // Fortress
  381. BLOOD_OBELISK = SPECIAL_3,
  382. //ARTIFACT_MERCHANT - same ID as in tower
  383. MAGIC_UNIVERSITY = SPECIAL_2, // Conflux
  384. };
  385. BuildingID(EBuildingID _num = NONE) : num(_num)
  386. {}
  387. STRONG_INLINE
  388. bool IsSpecialOrGrail() const
  389. {
  390. return num == SPECIAL_1 || num == SPECIAL_2 || num == SPECIAL_3 || num == SPECIAL_4 || num == GRAIL;
  391. }
  392. ID_LIKE_CLASS_COMMON(BuildingID, EBuildingID)
  393. EBuildingID num;
  394. };
  395. ID_LIKE_OPERATORS(BuildingID, BuildingID::EBuildingID)
  396. namespace BuildingSubID
  397. {
  398. enum EBuildingSubID
  399. {
  400. DEFAULT = -50,
  401. NONE = -1,
  402. STABLES,
  403. BROTHERHOOD_OF_SWORD,
  404. CASTLE_GATE,
  405. CREATURE_TRANSFORMER,
  406. MYSTIC_POND,
  407. FOUNTAIN_OF_FORTUNE,
  408. ARTIFACT_MERCHANT,
  409. LOOKOUT_TOWER,
  410. LIBRARY,
  411. MANA_VORTEX,
  412. PORTAL_OF_SUMMONING,
  413. ESCAPE_TUNNEL,
  414. FREELANCERS_GUILD,
  415. BALLISTA_YARD,
  416. ATTACK_VISITING_BONUS,
  417. MAGIC_UNIVERSITY,
  418. SPELL_POWER_GARRISON_BONUS,
  419. ATTACK_GARRISON_BONUS,
  420. DEFENSE_GARRISON_BONUS,
  421. DEFENSE_VISITING_BONUS,
  422. SPELL_POWER_VISITING_BONUS,
  423. KNOWLEDGE_VISITING_BONUS,
  424. EXPERIENCE_VISITING_BONUS,
  425. LIGHTHOUSE,
  426. TREASURY,
  427. CUSTOM_VISITING_BONUS
  428. };
  429. }
  430. namespace MappedKeys
  431. {
  432. static const std::map<std::string, BuildingID> BUILDING_NAMES_TO_TYPES =
  433. {
  434. { "special1", BuildingID::SPECIAL_1 },
  435. { "special2", BuildingID::SPECIAL_2 },
  436. { "special3", BuildingID::SPECIAL_3 },
  437. { "special4", BuildingID::SPECIAL_4 },
  438. { "grail", BuildingID::GRAIL }
  439. };
  440. static const std::map<BuildingID, std::string> BUILDING_TYPES_TO_NAMES =
  441. {
  442. { BuildingID::SPECIAL_1, "special1", },
  443. { BuildingID::SPECIAL_2, "special2" },
  444. { BuildingID::SPECIAL_3, "special3" },
  445. { BuildingID::SPECIAL_4, "special4" },
  446. { BuildingID::GRAIL, "grail"}
  447. };
  448. static const std::map<std::string, BuildingSubID::EBuildingSubID> SPECIAL_BUILDINGS =
  449. {
  450. { "mysticPond", BuildingSubID::MYSTIC_POND },
  451. { "artifactMerchant", BuildingSubID::ARTIFACT_MERCHANT },
  452. { "freelancersGuild", BuildingSubID::FREELANCERS_GUILD },
  453. { "magicUniversity", BuildingSubID::MAGIC_UNIVERSITY },
  454. { "castleGate", BuildingSubID::CASTLE_GATE },
  455. { "creatureTransformer", BuildingSubID::CREATURE_TRANSFORMER },//only skeleton transformer yet
  456. { "portalOfSummoning", BuildingSubID::PORTAL_OF_SUMMONING },
  457. { "ballistaYard", BuildingSubID::BALLISTA_YARD },
  458. { "stables", BuildingSubID::STABLES },
  459. { "manaVortex", BuildingSubID::MANA_VORTEX },
  460. { "lookoutTower", BuildingSubID::LOOKOUT_TOWER },
  461. { "library", BuildingSubID::LIBRARY },
  462. { "brotherhoodOfSword", BuildingSubID::BROTHERHOOD_OF_SWORD },//morale garrison bonus
  463. { "fountainOfFortune", BuildingSubID::FOUNTAIN_OF_FORTUNE },//luck garrison bonus
  464. { "spellPowerGarrisonBonus", BuildingSubID::SPELL_POWER_GARRISON_BONUS },//such as 'stormclouds', but this name is not ok for good towns
  465. { "attackGarrisonBonus", BuildingSubID::ATTACK_GARRISON_BONUS },
  466. { "defenseGarrisonBonus", BuildingSubID::DEFENSE_GARRISON_BONUS },
  467. { "escapeTunnel", BuildingSubID::ESCAPE_TUNNEL },
  468. { "attackVisitingBonus", BuildingSubID::ATTACK_VISITING_BONUS },
  469. { "defenceVisitingBonus", BuildingSubID::DEFENSE_VISITING_BONUS },
  470. { "spellPowerVisitingBonus", BuildingSubID::SPELL_POWER_VISITING_BONUS },
  471. { "knowledgeVisitingBonus", BuildingSubID::KNOWLEDGE_VISITING_BONUS },
  472. { "experienceVisitingBonus", BuildingSubID::EXPERIENCE_VISITING_BONUS },
  473. { "lighthouse", BuildingSubID::LIGHTHOUSE },
  474. { "treasury", BuildingSubID::TREASURY }
  475. };
  476. }
  477. namespace EAiTactic
  478. {
  479. enum EAiTactic
  480. {
  481. NONE = -1,
  482. RANDOM,
  483. WARRIOR,
  484. BUILDER,
  485. EXPLORER
  486. };
  487. }
  488. namespace EBuildingState
  489. {
  490. enum EBuildingState
  491. {
  492. HAVE_CAPITAL, NO_WATER, FORBIDDEN, ADD_MAGES_GUILD, ALREADY_PRESENT, CANT_BUILD_TODAY,
  493. NO_RESOURCES, ALLOWED, PREREQUIRES, MISSING_BASE, BUILDING_ERROR, TOWN_NOT_OWNED
  494. };
  495. }
  496. namespace ESpellCastProblem
  497. {
  498. enum ESpellCastProblem
  499. {
  500. OK, NO_HERO_TO_CAST_SPELL, CASTS_PER_TURN_LIMIT, NO_SPELLBOOK,
  501. HERO_DOESNT_KNOW_SPELL, NOT_ENOUGH_MANA, ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL,
  502. SPELL_LEVEL_LIMIT_EXCEEDED, NO_SPELLS_TO_DISPEL,
  503. NO_APPROPRIATE_TARGET, STACK_IMMUNE_TO_SPELL, WRONG_SPELL_TARGET, ONGOING_TACTIC_PHASE,
  504. MAGIC_IS_BLOCKED, //For Orb of Inhibition and similar - no casting at all
  505. INVALID
  506. };
  507. }
  508. namespace EMarketMode
  509. {
  510. enum EMarketMode
  511. {
  512. RESOURCE_RESOURCE, RESOURCE_PLAYER, CREATURE_RESOURCE, RESOURCE_ARTIFACT,
  513. ARTIFACT_RESOURCE, ARTIFACT_EXP, CREATURE_EXP, CREATURE_UNDEAD, RESOURCE_SKILL,
  514. MARTKET_AFTER_LAST_PLACEHOLDER
  515. };
  516. }
  517. namespace ECommander
  518. {
  519. enum SecondarySkills {ATTACK, DEFENSE, HEALTH, DAMAGE, SPEED, SPELL_POWER, CASTS, RESISTANCE};
  520. const int MAX_SKILL_LEVEL = 5;
  521. }
  522. namespace EWallPart
  523. {
  524. enum EWallPart
  525. {
  526. INDESTRUCTIBLE_PART_OF_GATE = -3, INDESTRUCTIBLE_PART = -2, INVALID = -1,
  527. KEEP = 0, BOTTOM_TOWER, BOTTOM_WALL, BELOW_GATE, OVER_GATE, UPPER_WALL, UPPER_TOWER, GATE,
  528. PARTS_COUNT /* This constant SHOULD always stay as the last item in the enum. */
  529. };
  530. }
  531. namespace EWallState
  532. {
  533. enum EWallState
  534. {
  535. NONE = -1, //no wall
  536. DESTROYED,
  537. DAMAGED,
  538. INTACT
  539. };
  540. }
  541. enum class EGateState : ui8
  542. {
  543. NONE,
  544. CLOSED,
  545. BLOCKED, //dead or alive stack blocking from outside
  546. OPENED,
  547. DESTROYED
  548. };
  549. namespace ESiegeHex
  550. {
  551. enum ESiegeHex : si16
  552. {
  553. DESTRUCTIBLE_WALL_1 = 29,
  554. DESTRUCTIBLE_WALL_2 = 78,
  555. DESTRUCTIBLE_WALL_3 = 130,
  556. DESTRUCTIBLE_WALL_4 = 182,
  557. GATE_BRIDGE = 94,
  558. GATE_OUTER = 95,
  559. GATE_INNER = 96
  560. };
  561. }
  562. namespace ETileType
  563. {
  564. enum ETileType
  565. {
  566. FREE,
  567. POSSIBLE,
  568. BLOCKED,
  569. USED
  570. };
  571. }
  572. enum class ETeleportChannelType
  573. {
  574. IMPASSABLE,
  575. BIDIRECTIONAL,
  576. UNIDIRECTIONAL,
  577. MIXED
  578. };
  579. static std::vector<std::string> RIVER_NAMES {"", "rw", "ri", "rm", "rl"};
  580. static std::vector<std::string> ROAD_NAMES {"", "pd", "pg", "pc"};
  581. class Obj
  582. {
  583. public:
  584. enum EObj
  585. {
  586. NO_OBJ = -1,
  587. ALTAR_OF_SACRIFICE = 2,
  588. ANCHOR_POINT = 3,
  589. ARENA = 4,
  590. ARTIFACT = 5,
  591. PANDORAS_BOX = 6,
  592. BLACK_MARKET = 7,
  593. BOAT = 8,
  594. BORDERGUARD = 9,
  595. KEYMASTER = 10,
  596. BUOY = 11,
  597. CAMPFIRE = 12,
  598. CARTOGRAPHER = 13,
  599. SWAN_POND = 14,
  600. COVER_OF_DARKNESS = 15,
  601. CREATURE_BANK = 16,
  602. CREATURE_GENERATOR1 = 17,
  603. CREATURE_GENERATOR2 = 18,
  604. CREATURE_GENERATOR3 = 19,
  605. CREATURE_GENERATOR4 = 20,
  606. CURSED_GROUND1 = 21,
  607. CORPSE = 22,
  608. MARLETTO_TOWER = 23,
  609. DERELICT_SHIP = 24,
  610. DRAGON_UTOPIA = 25,
  611. EVENT = 26,
  612. EYE_OF_MAGI = 27,
  613. FAERIE_RING = 28,
  614. FLOTSAM = 29,
  615. FOUNTAIN_OF_FORTUNE = 30,
  616. FOUNTAIN_OF_YOUTH = 31,
  617. GARDEN_OF_REVELATION = 32,
  618. GARRISON = 33,
  619. HERO = 34,
  620. HILL_FORT = 35,
  621. GRAIL = 36,
  622. HUT_OF_MAGI = 37,
  623. IDOL_OF_FORTUNE = 38,
  624. LEAN_TO = 39,
  625. LIBRARY_OF_ENLIGHTENMENT = 41,
  626. LIGHTHOUSE = 42,
  627. MONOLITH_ONE_WAY_ENTRANCE = 43,
  628. MONOLITH_ONE_WAY_EXIT = 44,
  629. MONOLITH_TWO_WAY = 45,
  630. MAGIC_PLAINS1 = 46,
  631. SCHOOL_OF_MAGIC = 47,
  632. MAGIC_SPRING = 48,
  633. MAGIC_WELL = 49,
  634. MERCENARY_CAMP = 51,
  635. MERMAID = 52,
  636. MINE = 53,
  637. MONSTER = 54,
  638. MYSTICAL_GARDEN = 55,
  639. OASIS = 56,
  640. OBELISK = 57,
  641. REDWOOD_OBSERVATORY = 58,
  642. OCEAN_BOTTLE = 59,
  643. PILLAR_OF_FIRE = 60,
  644. STAR_AXIS = 61,
  645. PRISON = 62,
  646. PYRAMID = 63,//subtype 0
  647. WOG_OBJECT = 63,//subtype > 0
  648. RALLY_FLAG = 64,
  649. RANDOM_ART = 65,
  650. RANDOM_TREASURE_ART = 66,
  651. RANDOM_MINOR_ART = 67,
  652. RANDOM_MAJOR_ART = 68,
  653. RANDOM_RELIC_ART = 69,
  654. RANDOM_HERO = 70,
  655. RANDOM_MONSTER = 71,
  656. RANDOM_MONSTER_L1 = 72,
  657. RANDOM_MONSTER_L2 = 73,
  658. RANDOM_MONSTER_L3 = 74,
  659. RANDOM_MONSTER_L4 = 75,
  660. RANDOM_RESOURCE = 76,
  661. RANDOM_TOWN = 77,
  662. REFUGEE_CAMP = 78,
  663. RESOURCE = 79,
  664. SANCTUARY = 80,
  665. SCHOLAR = 81,
  666. SEA_CHEST = 82,
  667. SEER_HUT = 83,
  668. CRYPT = 84,
  669. SHIPWRECK = 85,
  670. SHIPWRECK_SURVIVOR = 86,
  671. SHIPYARD = 87,
  672. SHRINE_OF_MAGIC_INCANTATION = 88,
  673. SHRINE_OF_MAGIC_GESTURE = 89,
  674. SHRINE_OF_MAGIC_THOUGHT = 90,
  675. SIGN = 91,
  676. SIRENS = 92,
  677. SPELL_SCROLL = 93,
  678. STABLES = 94,
  679. TAVERN = 95,
  680. TEMPLE = 96,
  681. DEN_OF_THIEVES = 97,
  682. TOWN = 98,
  683. TRADING_POST = 99,
  684. LEARNING_STONE = 100,
  685. TREASURE_CHEST = 101,
  686. TREE_OF_KNOWLEDGE = 102,
  687. SUBTERRANEAN_GATE = 103,
  688. UNIVERSITY = 104,
  689. WAGON = 105,
  690. WAR_MACHINE_FACTORY = 106,
  691. SCHOOL_OF_WAR = 107,
  692. WARRIORS_TOMB = 108,
  693. WATER_WHEEL = 109,
  694. WATERING_HOLE = 110,
  695. WHIRLPOOL = 111,
  696. WINDMILL = 112,
  697. WITCH_HUT = 113,
  698. HOLE = 124,
  699. RANDOM_MONSTER_L5 = 162,
  700. RANDOM_MONSTER_L6 = 163,
  701. RANDOM_MONSTER_L7 = 164,
  702. BORDER_GATE = 212,
  703. FREELANCERS_GUILD = 213,
  704. HERO_PLACEHOLDER = 214,
  705. QUEST_GUARD = 215,
  706. RANDOM_DWELLING = 216,
  707. RANDOM_DWELLING_LVL = 217, //subtype = creature level
  708. RANDOM_DWELLING_FACTION = 218, //subtype = faction
  709. GARRISON2 = 219,
  710. ABANDONED_MINE = 220,
  711. TRADING_POST_SNOW = 221,
  712. CLOVER_FIELD = 222,
  713. CURSED_GROUND2 = 223,
  714. EVIL_FOG = 224,
  715. FAVORABLE_WINDS = 225,
  716. FIERY_FIELDS = 226,
  717. HOLY_GROUNDS = 227,
  718. LUCID_POOLS = 228,
  719. MAGIC_CLOUDS = 229,
  720. MAGIC_PLAINS2 = 230,
  721. ROCKLANDS = 231,
  722. };
  723. Obj(EObj _num = NO_OBJ) : num(_num)
  724. {}
  725. ID_LIKE_CLASS_COMMON(Obj, EObj)
  726. EObj num;
  727. };
  728. ID_LIKE_OPERATORS(Obj, Obj::EObj)
  729. namespace SecSkillLevel
  730. {
  731. enum SecSkillLevel
  732. {
  733. NONE,
  734. BASIC,
  735. ADVANCED,
  736. EXPERT,
  737. LEVELS_SIZE
  738. };
  739. }
  740. namespace Date
  741. {
  742. enum EDateType
  743. {
  744. DAY = 0,
  745. DAY_OF_WEEK = 1,
  746. WEEK = 2,
  747. MONTH = 3,
  748. DAY_OF_MONTH
  749. };
  750. }
  751. enum class EActionType : int32_t
  752. {
  753. CANCEL = -3,
  754. END_TACTIC_PHASE = -2,
  755. INVALID = -1,
  756. NO_ACTION = 0,
  757. HERO_SPELL,
  758. WALK, DEFEND,
  759. RETREAT,
  760. SURRENDER,
  761. WALK_AND_ATTACK,
  762. SHOOT,
  763. WAIT,
  764. CATAPULT,
  765. MONSTER_SPELL,
  766. BAD_MORALE,
  767. STACK_HEAL,
  768. DAEMON_SUMMONING
  769. };
  770. DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const EActionType actionType);
  771. class DLL_LINKAGE EDiggingStatus
  772. {
  773. public:
  774. enum EEDiggingStatus
  775. {
  776. UNKNOWN = -1,
  777. CAN_DIG = 0,
  778. LACK_OF_MOVEMENT,
  779. WRONG_TERRAIN,
  780. TILE_OCCUPIED
  781. };
  782. EDiggingStatus(EEDiggingStatus _num = UNKNOWN) : num(_num)
  783. {}
  784. ID_LIKE_CLASS_COMMON(EDiggingStatus, EEDiggingStatus)
  785. EEDiggingStatus num;
  786. };
  787. ID_LIKE_OPERATORS(EDiggingStatus, EDiggingStatus::EEDiggingStatus)
  788. class DLL_LINKAGE EPathfindingLayer
  789. {
  790. public:
  791. enum EEPathfindingLayer : ui8
  792. {
  793. LAND = 0, SAIL = 1, WATER, AIR, NUM_LAYERS, WRONG, AUTO
  794. };
  795. EPathfindingLayer(EEPathfindingLayer _num = WRONG) : num(_num)
  796. {}
  797. ID_LIKE_CLASS_COMMON(EPathfindingLayer, EEPathfindingLayer)
  798. EEPathfindingLayer num;
  799. };
  800. DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const EPathfindingLayer pathfindingLayer);
  801. ID_LIKE_OPERATORS(EPathfindingLayer, EPathfindingLayer::EEPathfindingLayer)
  802. namespace EPlayerStatus
  803. {
  804. enum EStatus {WRONG = -1, INGAME, LOSER, WINNER};
  805. }
  806. namespace PlayerRelations
  807. {
  808. enum PlayerRelations {ENEMIES, ALLIES, SAME_PLAYER};
  809. }
  810. class ArtifactPosition
  811. {
  812. public:
  813. enum EArtifactPosition
  814. {
  815. FIRST_AVAILABLE = -2,
  816. PRE_FIRST = -1, //sometimes used as error, sometimes as first free in backpack
  817. HEAD, SHOULDERS, NECK, RIGHT_HAND, LEFT_HAND, TORSO, //5
  818. RIGHT_RING, LEFT_RING, FEET, //8
  819. MISC1, MISC2, MISC3, MISC4, //12
  820. MACH1, MACH2, MACH3, MACH4, //16
  821. SPELLBOOK, MISC5, //18
  822. AFTER_LAST,
  823. //cres
  824. CREATURE_SLOT = 0,
  825. COMMANDER1 = 0, COMMANDER2, COMMANDER3, COMMANDER4, COMMANDER5, COMMANDER6, COMMANDER_AFTER_LAST
  826. };
  827. static_assert (AFTER_LAST == 19, "incorrect number of artifact slots");
  828. ArtifactPosition(EArtifactPosition _num = PRE_FIRST) : num(_num)
  829. {}
  830. ID_LIKE_CLASS_COMMON(ArtifactPosition, EArtifactPosition)
  831. EArtifactPosition num;
  832. };
  833. ID_LIKE_OPERATORS(ArtifactPosition, ArtifactPosition::EArtifactPosition)
  834. class ArtifactID
  835. {
  836. public:
  837. enum EArtifactID
  838. {
  839. NONE = -1,
  840. SPELLBOOK = 0,
  841. SPELL_SCROLL = 1,
  842. GRAIL = 2,
  843. CATAPULT = 3,
  844. BALLISTA = 4,
  845. AMMO_CART = 5,
  846. FIRST_AID_TENT = 6,
  847. //CENTAUR_AXE = 7,
  848. //BLACKSHARD_OF_THE_DEAD_KNIGHT = 8,
  849. ARMAGEDDONS_BLADE = 128,
  850. TITANS_THUNDER = 135,
  851. //CORNUCOPIA = 140,
  852. //FIXME: the following is only true if WoG is enabled. Otherwise other mod artifacts will take these slots.
  853. ART_SELECTION = 144,
  854. ART_LOCK = 145, // FIXME: We must get rid of this one since it's conflict with artifact from mods. See issue 2455
  855. AXE_OF_SMASHING = 146,
  856. MITHRIL_MAIL = 147,
  857. SWORD_OF_SHARPNESS = 148,
  858. HELM_OF_IMMORTALITY = 149,
  859. PENDANT_OF_SORCERY = 150,
  860. BOOTS_OF_HASTE = 151,
  861. BOW_OF_SEEKING = 152,
  862. DRAGON_EYE_RING = 153
  863. //HARDENED_SHIELD = 154,
  864. //SLAVAS_RING_OF_POWER = 155
  865. };
  866. ArtifactID(EArtifactID _num = NONE) : num(_num)
  867. {}
  868. DLL_LINKAGE const CArtifact * toArtifact() const;
  869. DLL_LINKAGE const Artifact * toArtifact(const ArtifactService * service) const;
  870. ///json serialization helpers
  871. static si32 decode(const std::string & identifier);
  872. static std::string encode(const si32 index);
  873. ID_LIKE_CLASS_COMMON(ArtifactID, EArtifactID)
  874. EArtifactID num;
  875. };
  876. ID_LIKE_OPERATORS(ArtifactID, ArtifactID::EArtifactID)
  877. class CreatureID
  878. {
  879. public:
  880. enum ECreatureID
  881. {
  882. NONE = -1,
  883. ARCHER = 2,
  884. CAVALIER = 10,
  885. CHAMPION = 11,
  886. STONE_GOLEM = 32,
  887. IRON_GOLEM = 33,
  888. IMP = 42,
  889. SKELETON = 56,
  890. WALKING_DEAD = 58,
  891. WIGHTS = 60,
  892. LICHES = 64,
  893. BONE_DRAGON = 68,
  894. TROGLODYTES = 70,
  895. HYDRA = 110,
  896. CHAOS_HYDRA = 111,
  897. AIR_ELEMENTAL = 112,
  898. EARTH_ELEMENTAL = 113,
  899. FIRE_ELEMENTAL = 114,
  900. WATER_ELEMENTAL = 115,
  901. GOLD_GOLEM = 116,
  902. DIAMOND_GOLEM = 117,
  903. PSYCHIC_ELEMENTAL = 120,
  904. CATAPULT = 145,
  905. BALLISTA = 146,
  906. FIRST_AID_TENT = 147,
  907. AMMO_CART = 148,
  908. ARROW_TOWERS = 149
  909. };
  910. CreatureID(ECreatureID _num = NONE) : num(_num)
  911. {}
  912. DLL_LINKAGE const CCreature * toCreature() const;
  913. DLL_LINKAGE const Creature * toCreature(const CreatureService * creatures) const;
  914. ID_LIKE_CLASS_COMMON(CreatureID, ECreatureID)
  915. ECreatureID num;
  916. ///json serialization helpers
  917. static si32 decode(const std::string & identifier);
  918. static std::string encode(const si32 index);
  919. };
  920. ID_LIKE_OPERATORS(CreatureID, CreatureID::ECreatureID)
  921. class SpellID
  922. {
  923. public:
  924. enum ESpellID
  925. {
  926. PRESET = -2,
  927. NONE = -1,
  928. SUMMON_BOAT=0, SCUTTLE_BOAT=1, VISIONS=2, VIEW_EARTH=3, DISGUISE=4, VIEW_AIR=5,
  929. FLY=6, WATER_WALK=7, DIMENSION_DOOR=8, TOWN_PORTAL=9,
  930. QUICKSAND=10, LAND_MINE=11, FORCE_FIELD=12, FIRE_WALL=13, EARTHQUAKE=14,
  931. MAGIC_ARROW=15, ICE_BOLT=16, LIGHTNING_BOLT=17, IMPLOSION=18,
  932. CHAIN_LIGHTNING=19, FROST_RING=20, FIREBALL=21, INFERNO=22,
  933. METEOR_SHOWER=23, DEATH_RIPPLE=24, DESTROY_UNDEAD=25, ARMAGEDDON=26,
  934. SHIELD=27, AIR_SHIELD=28, FIRE_SHIELD=29, PROTECTION_FROM_AIR=30,
  935. PROTECTION_FROM_FIRE=31, PROTECTION_FROM_WATER=32,
  936. PROTECTION_FROM_EARTH=33, ANTI_MAGIC=34, DISPEL=35, MAGIC_MIRROR=36,
  937. CURE=37, RESURRECTION=38, ANIMATE_DEAD=39, SACRIFICE=40, BLESS=41,
  938. CURSE=42, BLOODLUST=43, PRECISION=44, WEAKNESS=45, STONE_SKIN=46,
  939. DISRUPTING_RAY=47, PRAYER=48, MIRTH=49, SORROW=50, FORTUNE=51,
  940. MISFORTUNE=52, HASTE=53, SLOW=54, SLAYER=55, FRENZY=56,
  941. TITANS_LIGHTNING_BOLT=57, COUNTERSTRIKE=58, BERSERK=59, HYPNOTIZE=60,
  942. FORGETFULNESS=61, BLIND=62, TELEPORT=63, REMOVE_OBSTACLE=64, CLONE=65,
  943. SUMMON_FIRE_ELEMENTAL=66, SUMMON_EARTH_ELEMENTAL=67, SUMMON_WATER_ELEMENTAL=68, SUMMON_AIR_ELEMENTAL=69,
  944. STONE_GAZE=70, POISON=71, BIND=72, DISEASE=73, PARALYZE=74, AGE=75, DEATH_CLOUD=76, THUNDERBOLT=77,
  945. DISPEL_HELPFUL_SPELLS=78, DEATH_STARE=79, ACID_BREATH_DEFENSE=80, ACID_BREATH_DAMAGE=81,
  946. FIRST_NON_SPELL = 70, AFTER_LAST = 82
  947. };
  948. SpellID(ESpellID _num = NONE) : num(_num)
  949. {}
  950. DLL_LINKAGE const CSpell * toSpell() const; //deprecated
  951. DLL_LINKAGE const spells::Spell * toSpell(const spells::Service * service) const;
  952. ID_LIKE_CLASS_COMMON(SpellID, ESpellID)
  953. ESpellID num;
  954. ///json serialization helpers
  955. static si32 decode(const std::string & identifier);
  956. static std::string encode(const si32 index);
  957. };
  958. ID_LIKE_OPERATORS(SpellID, SpellID::ESpellID)
  959. class BattleFieldInfo;
  960. class BattleField : public BaseForID<BattleField, si32>
  961. {
  962. INSTID_LIKE_CLASS_COMMON(BattleField, si32)
  963. DLL_LINKAGE static const BattleField NONE;
  964. DLL_LINKAGE friend bool operator==(const BattleField & l, const BattleField & r);
  965. DLL_LINKAGE friend bool operator!=(const BattleField & l, const BattleField & r);
  966. DLL_LINKAGE friend bool operator<(const BattleField & l, const BattleField & r);
  967. DLL_LINKAGE operator std::string() const;
  968. DLL_LINKAGE const BattleFieldInfo * getInfo() const;
  969. DLL_LINKAGE static BattleField fromString(std::string identifier);
  970. };
  971. class ObstacleInfo;
  972. class Obstacle : public BaseForID<Obstacle, si32>
  973. {
  974. INSTID_LIKE_CLASS_COMMON(Obstacle, si32)
  975. DLL_LINKAGE const ObstacleInfo * getInfo() const;
  976. DLL_LINKAGE operator std::string() const;
  977. DLL_LINKAGE static Obstacle fromString(std::string identifier);
  978. };
  979. enum class ESpellSchool: ui8
  980. {
  981. AIR = 0,
  982. FIRE = 1,
  983. WATER = 2,
  984. EARTH = 3
  985. };
  986. enum class EMetaclass: ui8
  987. {
  988. INVALID = 0,
  989. ARTIFACT,
  990. CREATURE,
  991. FACTION,
  992. EXPERIENCE,
  993. HERO,
  994. HEROCLASS,
  995. LUCK,
  996. MANA,
  997. MORALE,
  998. MOVEMENT,
  999. OBJECT,
  1000. PRIMARY_SKILL,
  1001. SECONDARY_SKILL,
  1002. SPELL,
  1003. RESOURCE
  1004. };
  1005. enum class EHealLevel: ui8
  1006. {
  1007. HEAL,
  1008. RESURRECT,
  1009. OVERHEAL
  1010. };
  1011. enum class EHealPower : ui8
  1012. {
  1013. ONE_BATTLE,
  1014. PERMANENT
  1015. };
  1016. // Typedef declarations
  1017. typedef ui8 TFaction;
  1018. typedef si64 TExpType;
  1019. typedef std::pair<si64, si64> TDmgRange;
  1020. typedef si32 TBonusSubtype;
  1021. typedef si32 TQuantity;
  1022. typedef int TRmgTemplateZoneId;
  1023. #undef ID_LIKE_CLASS_COMMON
  1024. #undef ID_LIKE_OPERATORS
  1025. #undef ID_LIKE_OPERATORS_INTERNAL
  1026. #undef INSTID_LIKE_CLASS_COMMON
  1027. #undef OP_DECL_INT