EntityIdentifiers.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  1. /*
  2. * EntityIdentifiers.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 "NumericConstants.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class Artifact;
  14. class ArtifactService;
  15. class Creature;
  16. class CreatureService;
  17. namespace spells
  18. {
  19. class Spell;
  20. class Service;
  21. }
  22. class CArtifact;
  23. class CArtifactInstance;
  24. class CCreature;
  25. class CHero;
  26. class CSpell;
  27. class CSkill;
  28. class CGameInfoCallback;
  29. class CNonConstInfoCallback;
  30. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  31. class IdentifierBase
  32. {
  33. protected:
  34. constexpr IdentifierBase():
  35. num(-1)
  36. {}
  37. explicit constexpr IdentifierBase(int32_t value):
  38. num(value)
  39. {}
  40. ~IdentifierBase() = default;
  41. public:
  42. int32_t num;
  43. constexpr int32_t getNum() const
  44. {
  45. return num;
  46. }
  47. constexpr void setNum(int32_t value)
  48. {
  49. num = value;
  50. }
  51. struct hash
  52. {
  53. size_t operator()(const IdentifierBase & id) const
  54. {
  55. return std::hash<int>()(id.num);
  56. }
  57. };
  58. template <typename Handler> void serialize(Handler &h, const int version)
  59. {
  60. h & num;
  61. }
  62. constexpr void advance(int change)
  63. {
  64. num += change;
  65. }
  66. constexpr operator int32_t () const
  67. {
  68. return num;
  69. }
  70. friend std::ostream& operator<<(std::ostream& os, const IdentifierBase& dt)
  71. {
  72. return os << dt.num;
  73. }
  74. };
  75. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  76. // Note: use template to force different type, blocking any Identifier<A> <=> Identifier<B> comparisons
  77. template<typename FinalClass>
  78. class Identifier : public IdentifierBase
  79. {
  80. using BaseClass = IdentifierBase;
  81. public:
  82. constexpr Identifier()
  83. {}
  84. explicit constexpr Identifier(int32_t value):
  85. IdentifierBase(value)
  86. {}
  87. constexpr bool operator == (const Identifier & b) const { return BaseClass::num == b.num; }
  88. constexpr bool operator <= (const Identifier & b) const { return BaseClass::num <= b.num; }
  89. constexpr bool operator >= (const Identifier & b) const { return BaseClass::num >= b.num; }
  90. constexpr bool operator != (const Identifier & b) const { return BaseClass::num != b.num; }
  91. constexpr bool operator < (const Identifier & b) const { return BaseClass::num < b.num; }
  92. constexpr bool operator > (const Identifier & b) const { return BaseClass::num > b.num; }
  93. constexpr FinalClass & operator++()
  94. {
  95. ++BaseClass::num;
  96. return static_cast<FinalClass&>(*this);
  97. }
  98. constexpr FinalClass & operator--()
  99. {
  100. --BaseClass::num;
  101. return static_cast<FinalClass&>(*this);
  102. }
  103. constexpr FinalClass operator--(int)
  104. {
  105. FinalClass ret(num);
  106. --BaseClass::num;
  107. return ret;
  108. }
  109. constexpr FinalClass operator++(int)
  110. {
  111. FinalClass ret(num);
  112. ++BaseClass::num;
  113. return ret;
  114. }
  115. };
  116. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  117. template<typename FinalClass, typename BaseClass>
  118. class IdentifierWithEnum : public BaseClass
  119. {
  120. using EnumType = typename BaseClass::Type;
  121. static_assert(std::is_same_v<std::underlying_type_t<EnumType>, int32_t>, "Entity Identifier must use int32_t");
  122. public:
  123. constexpr EnumType toEnum() const
  124. {
  125. return static_cast<EnumType>(BaseClass::num);
  126. }
  127. constexpr IdentifierWithEnum(const EnumType & enumValue)
  128. {
  129. BaseClass::num = static_cast<int32_t>(enumValue);
  130. }
  131. constexpr IdentifierWithEnum(int32_t _num = -1)
  132. {
  133. BaseClass::num = _num;
  134. }
  135. constexpr bool operator == (const EnumType & b) const { return BaseClass::num == static_cast<int32_t>(b); }
  136. constexpr bool operator <= (const EnumType & b) const { return BaseClass::num <= static_cast<int32_t>(b); }
  137. constexpr bool operator >= (const EnumType & b) const { return BaseClass::num >= static_cast<int32_t>(b); }
  138. constexpr bool operator != (const EnumType & b) const { return BaseClass::num != static_cast<int32_t>(b); }
  139. constexpr bool operator < (const EnumType & b) const { return BaseClass::num < static_cast<int32_t>(b); }
  140. constexpr bool operator > (const EnumType & b) const { return BaseClass::num > static_cast<int32_t>(b); }
  141. constexpr bool operator == (const IdentifierWithEnum & b) const { return BaseClass::num == b.num; }
  142. constexpr bool operator <= (const IdentifierWithEnum & b) const { return BaseClass::num <= b.num; }
  143. constexpr bool operator >= (const IdentifierWithEnum & b) const { return BaseClass::num >= b.num; }
  144. constexpr bool operator != (const IdentifierWithEnum & b) const { return BaseClass::num != b.num; }
  145. constexpr bool operator < (const IdentifierWithEnum & b) const { return BaseClass::num < b.num; }
  146. constexpr bool operator > (const IdentifierWithEnum & b) const { return BaseClass::num > b.num; }
  147. constexpr FinalClass & operator++()
  148. {
  149. ++BaseClass::num;
  150. return static_cast<FinalClass&>(*this);
  151. }
  152. constexpr FinalClass operator++(int)
  153. {
  154. FinalClass ret(BaseClass::num);
  155. ++BaseClass::num;
  156. return ret;
  157. }
  158. };
  159. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  160. class ArtifactInstanceID : public Identifier<ArtifactInstanceID>
  161. {
  162. public:
  163. using Identifier<ArtifactInstanceID>::Identifier;
  164. };
  165. class QueryID : public Identifier<QueryID>
  166. {
  167. public:
  168. using Identifier<QueryID>::Identifier;
  169. DLL_LINKAGE static const QueryID NONE;
  170. };
  171. class BattleID : public Identifier<BattleID>
  172. {
  173. public:
  174. using Identifier<BattleID>::Identifier;
  175. DLL_LINKAGE static const BattleID NONE;
  176. };
  177. class ObjectInstanceID : public Identifier<ObjectInstanceID>
  178. {
  179. public:
  180. using Identifier<ObjectInstanceID>::Identifier;
  181. DLL_LINKAGE static const ObjectInstanceID NONE;
  182. };
  183. class HeroClassID : public Identifier<HeroClassID>
  184. {
  185. public:
  186. using Identifier<HeroClassID>::Identifier;
  187. };
  188. class HeroTypeID : public Identifier<HeroTypeID>
  189. {
  190. public:
  191. using Identifier<HeroTypeID>::Identifier;
  192. ///json serialization helpers
  193. DLL_LINKAGE static si32 decode(const std::string & identifier);
  194. DLL_LINKAGE static std::string encode(const si32 index);
  195. static std::string entityType();
  196. DLL_LINKAGE static const HeroTypeID NONE;
  197. DLL_LINKAGE static const HeroTypeID RANDOM;
  198. bool isValid() const
  199. {
  200. return getNum() >= 0;
  201. }
  202. };
  203. class SlotID : public Identifier<SlotID>
  204. {
  205. public:
  206. using Identifier<SlotID>::Identifier;
  207. DLL_LINKAGE static const SlotID COMMANDER_SLOT_PLACEHOLDER;
  208. DLL_LINKAGE static const SlotID SUMMONED_SLOT_PLACEHOLDER; ///<for all summoned creatures, only during battle
  209. DLL_LINKAGE static const SlotID WAR_MACHINES_SLOT; ///<for all war machines during battle
  210. DLL_LINKAGE static const SlotID ARROW_TOWERS_SLOT; ///<for all arrow towers during battle
  211. bool validSlot() const
  212. {
  213. return getNum() >= 0 && getNum() < GameConstants::ARMY_SIZE;
  214. }
  215. };
  216. class DLL_LINKAGE PlayerColor : public Identifier<PlayerColor>
  217. {
  218. public:
  219. using Identifier<PlayerColor>::Identifier;
  220. enum EPlayerColor
  221. {
  222. PLAYER_LIMIT_I = 8,
  223. };
  224. static const PlayerColor SPECTATOR; //252
  225. static const PlayerColor CANNOT_DETERMINE; //253
  226. static const PlayerColor UNFLAGGABLE; //254 - neutral objects (pandora, banks)
  227. static const PlayerColor NEUTRAL; //255
  228. static const PlayerColor PLAYER_LIMIT; //player limit per map
  229. bool isValidPlayer() const; //valid means < PLAYER_LIMIT (especially non-neutral)
  230. bool isSpectator() const;
  231. std::string toString() const;
  232. static si32 decode(const std::string& identifier);
  233. static std::string encode(const si32 index);
  234. static std::string entityType();
  235. };
  236. class TeamID : public Identifier<TeamID>
  237. {
  238. public:
  239. using Identifier<TeamID>::Identifier;
  240. DLL_LINKAGE static const TeamID NO_TEAM;
  241. };
  242. class TeleportChannelID : public Identifier<TeleportChannelID>
  243. {
  244. public:
  245. using Identifier<TeleportChannelID>::Identifier;
  246. };
  247. class SecondarySkillBase : public IdentifierBase
  248. {
  249. public:
  250. enum Type : int32_t
  251. {
  252. WRONG = -2,
  253. DEFAULT = -1,
  254. PATHFINDING = 0,
  255. ARCHERY,
  256. LOGISTICS,
  257. SCOUTING,
  258. DIPLOMACY,
  259. NAVIGATION,
  260. LEADERSHIP,
  261. WISDOM,
  262. MYSTICISM,
  263. LUCK,
  264. BALLISTICS,
  265. EAGLE_EYE,
  266. NECROMANCY,
  267. ESTATES,
  268. FIRE_MAGIC,
  269. AIR_MAGIC,
  270. WATER_MAGIC,
  271. EARTH_MAGIC,
  272. SCHOLAR,
  273. TACTICS,
  274. ARTILLERY,
  275. LEARNING,
  276. OFFENCE,
  277. ARMORER,
  278. INTELLIGENCE,
  279. SORCERY,
  280. RESISTANCE,
  281. FIRST_AID,
  282. SKILL_SIZE
  283. };
  284. static_assert(GameConstants::SKILL_QUANTITY == SKILL_SIZE, "Incorrect number of skills");
  285. };
  286. class SecondarySkill : public IdentifierWithEnum<SecondarySkill, SecondarySkillBase>
  287. {
  288. public:
  289. using IdentifierWithEnum<SecondarySkill, SecondarySkillBase>::IdentifierWithEnum;
  290. };
  291. class DLL_LINKAGE FactionID : public Identifier<FactionID>
  292. {
  293. public:
  294. using Identifier<FactionID>::Identifier;
  295. static const FactionID NONE;
  296. static const FactionID DEFAULT;
  297. static const FactionID RANDOM;
  298. static const FactionID ANY;
  299. static const FactionID CASTLE;
  300. static const FactionID RAMPART;
  301. static const FactionID TOWER;
  302. static const FactionID INFERNO;
  303. static const FactionID NECROPOLIS;
  304. static const FactionID DUNGEON;
  305. static const FactionID STRONGHOLD;
  306. static const FactionID FORTRESS;
  307. static const FactionID CONFLUX;
  308. static const FactionID NEUTRAL;
  309. static si32 decode(const std::string& identifier);
  310. static std::string encode(const si32 index);
  311. static std::string entityType();
  312. bool isValid() const
  313. {
  314. return getNum() >= 0;
  315. }
  316. };
  317. class BuildingIDBase : public IdentifierBase
  318. {
  319. public:
  320. //Quite useful as long as most of building mechanics hardcoded
  321. // NOTE: all building with completely configurable mechanics will be removed from list
  322. enum Type
  323. {
  324. DEFAULT = -50,
  325. HORDE_PLACEHOLDER7 = -36,
  326. HORDE_PLACEHOLDER6 = -35,
  327. HORDE_PLACEHOLDER5 = -34,
  328. HORDE_PLACEHOLDER4 = -33,
  329. HORDE_PLACEHOLDER3 = -32,
  330. HORDE_PLACEHOLDER2 = -31,
  331. HORDE_PLACEHOLDER1 = -30,
  332. NONE = -1,
  333. FIRST_REGULAR_ID = 0,
  334. MAGES_GUILD_1 = 0, MAGES_GUILD_2, MAGES_GUILD_3, MAGES_GUILD_4, MAGES_GUILD_5,
  335. TAVERN, SHIPYARD, FORT, CITADEL, CASTLE,
  336. VILLAGE_HALL, TOWN_HALL, CITY_HALL, CAPITOL, MARKETPLACE,
  337. RESOURCE_SILO, BLACKSMITH, SPECIAL_1, HORDE_1, HORDE_1_UPGR,
  338. SHIP, SPECIAL_2, SPECIAL_3, SPECIAL_4, HORDE_2,
  339. HORDE_2_UPGR, GRAIL, EXTRA_TOWN_HALL, EXTRA_CITY_HALL, EXTRA_CAPITOL,
  340. DWELL_FIRST=30, DWELL_LVL_2, DWELL_LVL_3, DWELL_LVL_4, DWELL_LVL_5, DWELL_LVL_6, DWELL_LAST=36,
  341. DWELL_UP_FIRST=37, DWELL_LVL_2_UP, DWELL_LVL_3_UP, DWELL_LVL_4_UP, DWELL_LVL_5_UP,
  342. DWELL_LVL_6_UP, DWELL_UP_LAST=43,
  343. DWELL_LVL_1 = DWELL_FIRST,
  344. DWELL_LVL_7 = DWELL_LAST,
  345. DWELL_LVL_1_UP = DWELL_UP_FIRST,
  346. DWELL_LVL_7_UP = DWELL_UP_LAST,
  347. DWELL_UP2_FIRST = DWELL_LVL_7_UP + 1,
  348. // //Special buildings for towns.
  349. CASTLE_GATE = SPECIAL_3, //Inferno
  350. FREELANCERS_GUILD = SPECIAL_2, //Stronghold
  351. ARTIFACT_MERCHANT = SPECIAL_1,
  352. };
  353. bool IsSpecialOrGrail() const
  354. {
  355. return num == SPECIAL_1 || num == SPECIAL_2 || num == SPECIAL_3 || num == SPECIAL_4 || num == GRAIL;
  356. }
  357. };
  358. class BuildingID : public IdentifierWithEnum<BuildingID, BuildingIDBase>
  359. {
  360. public:
  361. using IdentifierWithEnum<BuildingID, BuildingIDBase>::IdentifierWithEnum;
  362. };
  363. class ObjBase : public IdentifierBase
  364. {
  365. public:
  366. enum Type
  367. {
  368. NO_OBJ = -1,
  369. ALTAR_OF_SACRIFICE [[deprecated]] = 2,
  370. ANCHOR_POINT = 3,
  371. ARENA = 4,
  372. ARTIFACT = 5,
  373. PANDORAS_BOX = 6,
  374. BLACK_MARKET [[deprecated]] = 7,
  375. BOAT = 8,
  376. BORDERGUARD = 9,
  377. KEYMASTER = 10,
  378. BUOY = 11,
  379. CAMPFIRE = 12,
  380. CARTOGRAPHER = 13,
  381. SWAN_POND = 14,
  382. COVER_OF_DARKNESS = 15,
  383. CREATURE_BANK = 16,
  384. CREATURE_GENERATOR1 = 17,
  385. CREATURE_GENERATOR2 = 18,
  386. CREATURE_GENERATOR3 = 19,
  387. CREATURE_GENERATOR4 = 20,
  388. CURSED_GROUND1 = 21,
  389. CORPSE = 22,
  390. MARLETTO_TOWER = 23,
  391. DERELICT_SHIP = 24,
  392. DRAGON_UTOPIA = 25,
  393. EVENT = 26,
  394. EYE_OF_MAGI = 27,
  395. FAERIE_RING = 28,
  396. FLOTSAM = 29,
  397. FOUNTAIN_OF_FORTUNE = 30,
  398. FOUNTAIN_OF_YOUTH = 31,
  399. GARDEN_OF_REVELATION = 32,
  400. GARRISON = 33,
  401. HERO = 34,
  402. HILL_FORT = 35,
  403. GRAIL = 36,
  404. HUT_OF_MAGI = 37,
  405. IDOL_OF_FORTUNE = 38,
  406. LEAN_TO = 39,
  407. LIBRARY_OF_ENLIGHTENMENT = 41,
  408. LIGHTHOUSE = 42,
  409. MONOLITH_ONE_WAY_ENTRANCE = 43,
  410. MONOLITH_ONE_WAY_EXIT = 44,
  411. MONOLITH_TWO_WAY = 45,
  412. MAGIC_PLAINS1 = 46,
  413. SCHOOL_OF_MAGIC = 47,
  414. MAGIC_SPRING = 48,
  415. MAGIC_WELL = 49,
  416. MARKET_OF_TIME = 50,
  417. MERCENARY_CAMP = 51,
  418. MERMAID = 52,
  419. MINE = 53,
  420. MONSTER = 54,
  421. MYSTICAL_GARDEN = 55,
  422. OASIS = 56,
  423. OBELISK = 57,
  424. REDWOOD_OBSERVATORY = 58,
  425. OCEAN_BOTTLE = 59,
  426. PILLAR_OF_FIRE = 60,
  427. STAR_AXIS = 61,
  428. PRISON = 62,
  429. PYRAMID = 63,//subtype 0
  430. WOG_OBJECT = 63,//subtype > 0
  431. RALLY_FLAG = 64,
  432. RANDOM_ART = 65,
  433. RANDOM_TREASURE_ART = 66,
  434. RANDOM_MINOR_ART = 67,
  435. RANDOM_MAJOR_ART = 68,
  436. RANDOM_RELIC_ART = 69,
  437. RANDOM_HERO = 70,
  438. RANDOM_MONSTER = 71,
  439. RANDOM_MONSTER_L1 = 72,
  440. RANDOM_MONSTER_L2 = 73,
  441. RANDOM_MONSTER_L3 = 74,
  442. RANDOM_MONSTER_L4 = 75,
  443. RANDOM_RESOURCE = 76,
  444. RANDOM_TOWN = 77,
  445. REFUGEE_CAMP = 78,
  446. RESOURCE = 79,
  447. SANCTUARY = 80,
  448. SCHOLAR = 81,
  449. SEA_CHEST = 82,
  450. SEER_HUT = 83,
  451. CRYPT = 84,
  452. SHIPWRECK = 85,
  453. SHIPWRECK_SURVIVOR = 86,
  454. SHIPYARD = 87,
  455. SHRINE_OF_MAGIC_INCANTATION = 88,
  456. SHRINE_OF_MAGIC_GESTURE = 89,
  457. SHRINE_OF_MAGIC_THOUGHT = 90,
  458. SIGN = 91,
  459. SIRENS = 92,
  460. SPELL_SCROLL = 93,
  461. STABLES = 94,
  462. TAVERN = 95,
  463. TEMPLE = 96,
  464. DEN_OF_THIEVES = 97,
  465. TOWN = 98,
  466. TRADING_POST [[deprecated]] = 99,
  467. LEARNING_STONE = 100,
  468. TREASURE_CHEST = 101,
  469. TREE_OF_KNOWLEDGE = 102,
  470. SUBTERRANEAN_GATE = 103,
  471. UNIVERSITY [[deprecated]] = 104,
  472. WAGON = 105,
  473. WAR_MACHINE_FACTORY = 106,
  474. SCHOOL_OF_WAR = 107,
  475. WARRIORS_TOMB = 108,
  476. WATER_WHEEL = 109,
  477. WATERING_HOLE = 110,
  478. WHIRLPOOL = 111,
  479. WINDMILL = 112,
  480. WITCH_HUT = 113,
  481. HOLE = 124,
  482. RANDOM_MONSTER_L5 = 162,
  483. RANDOM_MONSTER_L6 = 163,
  484. RANDOM_MONSTER_L7 = 164,
  485. BORDER_GATE = 212,
  486. FREELANCERS_GUILD [[deprecated]] = 213,
  487. HERO_PLACEHOLDER = 214,
  488. QUEST_GUARD = 215,
  489. RANDOM_DWELLING = 216,
  490. RANDOM_DWELLING_LVL = 217, //subtype = creature level
  491. RANDOM_DWELLING_FACTION = 218, //subtype = faction
  492. GARRISON2 = 219,
  493. ABANDONED_MINE = 220,
  494. TRADING_POST_SNOW [[deprecated]] = 221,
  495. CLOVER_FIELD = 222,
  496. CURSED_GROUND2 = 223,
  497. EVIL_FOG = 224,
  498. FAVORABLE_WINDS = 225,
  499. FIERY_FIELDS = 226,
  500. HOLY_GROUNDS = 227,
  501. LUCID_POOLS = 228,
  502. MAGIC_CLOUDS = 229,
  503. MAGIC_PLAINS2 = 230,
  504. ROCKLANDS = 231,
  505. };
  506. };
  507. class Obj : public IdentifierWithEnum<Obj, ObjBase>
  508. {
  509. public:
  510. using IdentifierWithEnum<Obj, ObjBase>::IdentifierWithEnum;
  511. };
  512. class DLL_LINKAGE RoadId : public Identifier<RoadId>
  513. {
  514. public:
  515. using Identifier<RoadId>::Identifier;
  516. static const RoadId NO_ROAD;
  517. static const RoadId DIRT_ROAD;
  518. static const RoadId GRAVEL_ROAD;
  519. static const RoadId COBBLESTONE_ROAD;
  520. };
  521. class DLL_LINKAGE RiverId : public Identifier<RiverId>
  522. {
  523. public:
  524. using Identifier<RiverId>::Identifier;
  525. static const RiverId NO_RIVER;
  526. static const RiverId WATER_RIVER;
  527. static const RiverId ICY_RIVER;
  528. static const RiverId MUD_RIVER;
  529. static const RiverId LAVA_RIVER;
  530. };
  531. class DLL_LINKAGE EPathfindingLayerBase : public IdentifierBase
  532. {
  533. public:
  534. enum Type : int32_t
  535. {
  536. LAND = 0, SAIL = 1, WATER, AIR, NUM_LAYERS, WRONG, AUTO
  537. };
  538. };
  539. class EPathfindingLayer : public IdentifierWithEnum<EPathfindingLayer, EPathfindingLayerBase>
  540. {
  541. public:
  542. using IdentifierWithEnum<EPathfindingLayer, EPathfindingLayerBase>::IdentifierWithEnum;
  543. };
  544. class ArtifactPositionBase : public IdentifierBase
  545. {
  546. public:
  547. enum Type
  548. {
  549. TRANSITION_POS = -3,
  550. FIRST_AVAILABLE = -2,
  551. PRE_FIRST = -1, //sometimes used as error, sometimes as first free in backpack
  552. HEAD, SHOULDERS, NECK, RIGHT_HAND, LEFT_HAND, TORSO, //5
  553. RIGHT_RING, LEFT_RING, FEET, //8
  554. MISC1, MISC2, MISC3, MISC4, //12
  555. MACH1, MACH2, MACH3, MACH4, //16
  556. SPELLBOOK, MISC5, //18
  557. AFTER_LAST,
  558. //cres
  559. CREATURE_SLOT = 0,
  560. COMMANDER1 = 0, COMMANDER2, COMMANDER3, COMMANDER4, COMMANDER5, COMMANDER6, COMMANDER_AFTER_LAST,
  561. BACKPACK_START = 19
  562. };
  563. static_assert (AFTER_LAST == BACKPACK_START, "incorrect number of artifact slots");
  564. DLL_LINKAGE static si32 decode(const std::string & identifier);
  565. DLL_LINKAGE static std::string encode(const si32 index);
  566. };
  567. class ArtifactPosition : public IdentifierWithEnum<ArtifactPosition, ArtifactPositionBase>
  568. {
  569. public:
  570. using IdentifierWithEnum<ArtifactPosition, ArtifactPositionBase>::IdentifierWithEnum;
  571. };
  572. class ArtifactIDBase : public IdentifierBase
  573. {
  574. public:
  575. enum Type
  576. {
  577. NONE = -1,
  578. SPELLBOOK = 0,
  579. SPELL_SCROLL = 1,
  580. GRAIL = 2,
  581. CATAPULT = 3,
  582. BALLISTA = 4,
  583. AMMO_CART = 5,
  584. FIRST_AID_TENT = 6,
  585. VIAL_OF_DRAGON_BLOOD = 127,
  586. ARMAGEDDONS_BLADE = 128,
  587. TITANS_THUNDER = 135,
  588. ART_SELECTION = 144,
  589. ART_LOCK = 145, // FIXME: We must get rid of this one since it's conflict with artifact from mods. See issue 2455
  590. };
  591. DLL_LINKAGE const CArtifact * toArtifact() const;
  592. DLL_LINKAGE const Artifact * toArtifact(const ArtifactService * service) const;
  593. };
  594. class ArtifactID : public IdentifierWithEnum<ArtifactID, ArtifactIDBase>
  595. {
  596. public:
  597. using IdentifierWithEnum<ArtifactID, ArtifactIDBase>::IdentifierWithEnum;
  598. ///json serialization helpers
  599. DLL_LINKAGE static si32 decode(const std::string & identifier);
  600. DLL_LINKAGE static std::string encode(const si32 index);
  601. static std::string entityType();
  602. };
  603. class CreatureIDBase : public IdentifierBase
  604. {
  605. public:
  606. enum Type
  607. {
  608. NONE = -1,
  609. ARCHER = 2, // for debug / fallback
  610. IMP = 42, // for Deity of Fire
  611. SKELETON = 56, // for Skeleton Transformer
  612. BONE_DRAGON = 68, // for Skeleton Transformer
  613. TROGLODYTES = 70, // for Abandoned Mine
  614. MEDUSA = 76, // for Siege UI workaround
  615. HYDRA = 110, // for Skeleton Transformer
  616. CHAOS_HYDRA = 111, // for Skeleton Transformer
  617. AIR_ELEMENTAL = 112, // for tests
  618. FIRE_ELEMENTAL = 114, // for tests
  619. PSYCHIC_ELEMENTAL = 120, // for hardcoded ability
  620. MAGIC_ELEMENTAL = 121, // for hardcoded ability
  621. CATAPULT = 145,
  622. BALLISTA = 146,
  623. FIRST_AID_TENT = 147,
  624. AMMO_CART = 148,
  625. ARROW_TOWERS = 149
  626. };
  627. DLL_LINKAGE const CCreature * toCreature() const;
  628. DLL_LINKAGE const Creature * toCreature(const CreatureService * creatures) const;
  629. };
  630. class CreatureID : public IdentifierWithEnum<CreatureID, CreatureIDBase>
  631. {
  632. public:
  633. using IdentifierWithEnum<CreatureID, CreatureIDBase>::IdentifierWithEnum;
  634. ///json serialization helpers
  635. DLL_LINKAGE static si32 decode(const std::string & identifier);
  636. DLL_LINKAGE static std::string encode(const si32 index);
  637. static std::string entityType();
  638. };
  639. class SpellIDBase : public IdentifierBase
  640. {
  641. public:
  642. enum Type
  643. {
  644. // Special ID's
  645. SPELLBOOK_PRESET = -3,
  646. PRESET = -2,
  647. NONE = -1,
  648. // Adventure map spells
  649. SUMMON_BOAT = 0,
  650. SCUTTLE_BOAT = 1,
  651. VISIONS = 2,
  652. VIEW_EARTH = 3,
  653. DISGUISE = 4,
  654. VIEW_AIR = 5,
  655. FLY = 6,
  656. WATER_WALK = 7,
  657. DIMENSION_DOOR = 8,
  658. TOWN_PORTAL = 9,
  659. // Combar spells
  660. QUICKSAND = 10,
  661. LAND_MINE = 11,
  662. FORCE_FIELD = 12,
  663. FIRE_WALL = 13,
  664. EARTHQUAKE = 14,
  665. MAGIC_ARROW = 15,
  666. ICE_BOLT = 16,
  667. LIGHTNING_BOLT = 17,
  668. IMPLOSION = 18,
  669. CHAIN_LIGHTNING = 19,
  670. FROST_RING = 20,
  671. FIREBALL = 21,
  672. INFERNO = 22,
  673. METEOR_SHOWER = 23,
  674. DEATH_RIPPLE = 24,
  675. DESTROY_UNDEAD = 25,
  676. ARMAGEDDON = 26,
  677. SHIELD = 27,
  678. AIR_SHIELD = 28,
  679. FIRE_SHIELD = 29,
  680. PROTECTION_FROM_AIR = 30,
  681. PROTECTION_FROM_FIRE = 31,
  682. PROTECTION_FROM_WATER = 32,
  683. PROTECTION_FROM_EARTH = 33,
  684. ANTI_MAGIC = 34,
  685. DISPEL = 35,
  686. MAGIC_MIRROR = 36,
  687. CURE = 37,
  688. RESURRECTION = 38,
  689. ANIMATE_DEAD = 39,
  690. SACRIFICE = 40,
  691. BLESS = 41,
  692. CURSE = 42,
  693. BLOODLUST = 43,
  694. PRECISION = 44,
  695. WEAKNESS = 45,
  696. STONE_SKIN = 46,
  697. DISRUPTING_RAY = 47,
  698. PRAYER = 48,
  699. MIRTH = 49,
  700. SORROW = 50,
  701. FORTUNE = 51,
  702. MISFORTUNE = 52,
  703. HASTE = 53,
  704. SLOW = 54,
  705. SLAYER = 55,
  706. FRENZY = 56,
  707. TITANS_LIGHTNING_BOLT = 57,
  708. COUNTERSTRIKE = 58,
  709. BERSERK = 59,
  710. HYPNOTIZE = 60,
  711. FORGETFULNESS = 61,
  712. BLIND = 62,
  713. TELEPORT = 63,
  714. REMOVE_OBSTACLE = 64,
  715. CLONE = 65,
  716. SUMMON_FIRE_ELEMENTAL = 66,
  717. SUMMON_EARTH_ELEMENTAL = 67,
  718. SUMMON_WATER_ELEMENTAL = 68,
  719. SUMMON_AIR_ELEMENTAL = 69,
  720. // Creature abilities
  721. STONE_GAZE = 70,
  722. POISON = 71,
  723. BIND = 72,
  724. DISEASE = 73,
  725. PARALYZE = 74,
  726. AGE = 75,
  727. DEATH_CLOUD = 76,
  728. THUNDERBOLT = 77,
  729. DISPEL_HELPFUL_SPELLS = 78,
  730. DEATH_STARE = 79,
  731. ACID_BREATH_DEFENSE = 80,
  732. ACID_BREATH_DAMAGE = 81,
  733. // Special ID's
  734. FIRST_NON_SPELL = 70,
  735. AFTER_LAST = 82
  736. };
  737. DLL_LINKAGE const CSpell * toSpell() const; //deprecated
  738. DLL_LINKAGE const spells::Spell * toSpell(const spells::Service * service) const;
  739. };
  740. class SpellID : public IdentifierWithEnum<SpellID, SpellIDBase>
  741. {
  742. public:
  743. using IdentifierWithEnum<SpellID, SpellIDBase>::IdentifierWithEnum;
  744. ///json serialization helpers
  745. DLL_LINKAGE static si32 decode(const std::string & identifier);
  746. DLL_LINKAGE static std::string encode(const si32 index);
  747. static std::string entityType();
  748. };
  749. class BattleFieldInfo;
  750. class BattleField : public Identifier<BattleField>
  751. {
  752. public:
  753. using Identifier<BattleField>::Identifier;
  754. DLL_LINKAGE static const BattleField NONE;
  755. DLL_LINKAGE const BattleFieldInfo * getInfo() const;
  756. };
  757. class DLL_LINKAGE BoatId : public Identifier<BoatId>
  758. {
  759. public:
  760. using Identifier<BoatId>::Identifier;
  761. static const BoatId NONE;
  762. static const BoatId NECROPOLIS;
  763. static const BoatId CASTLE;
  764. static const BoatId FORTRESS;
  765. };
  766. class TerrainIdBase : public IdentifierBase
  767. {
  768. public:
  769. enum Type : int32_t
  770. {
  771. NATIVE_TERRAIN = -4,
  772. ANY_TERRAIN = -3,
  773. NONE = -1,
  774. FIRST_REGULAR_TERRAIN = 0,
  775. DIRT = 0,
  776. SAND,
  777. GRASS,
  778. SNOW,
  779. SWAMP,
  780. ROUGH,
  781. SUBTERRANEAN,
  782. LAVA,
  783. WATER,
  784. ROCK,
  785. ORIGINAL_REGULAR_TERRAIN_COUNT = ROCK
  786. };
  787. };
  788. class TerrainId : public IdentifierWithEnum<TerrainId, TerrainIdBase>
  789. {
  790. public:
  791. using IdentifierWithEnum<TerrainId, TerrainIdBase>::IdentifierWithEnum;
  792. DLL_LINKAGE static si32 decode(const std::string & identifier);
  793. DLL_LINKAGE static std::string encode(const si32 index);
  794. static std::string entityType();
  795. };
  796. class ObstacleInfo;
  797. class Obstacle : public Identifier<Obstacle>
  798. {
  799. public:
  800. using Identifier<Obstacle>::Identifier;
  801. DLL_LINKAGE const ObstacleInfo * getInfo() const;
  802. };
  803. class DLL_LINKAGE SpellSchool : public Identifier<SpellSchool>
  804. {
  805. public:
  806. using Identifier<SpellSchool>::Identifier;
  807. static const SpellSchool ANY;
  808. static const SpellSchool AIR;
  809. static const SpellSchool FIRE;
  810. static const SpellSchool WATER;
  811. static const SpellSchool EARTH;
  812. };
  813. class GameResIDBase : public IdentifierBase
  814. {
  815. public:
  816. enum Type : int32_t
  817. {
  818. WOOD = 0,
  819. MERCURY,
  820. ORE,
  821. SULFUR,
  822. CRYSTAL,
  823. GEMS,
  824. GOLD,
  825. MITHRIL,
  826. COUNT,
  827. WOOD_AND_ORE = 127, // special case for town bonus resource
  828. INVALID = -1
  829. };
  830. };
  831. class GameResID : public IdentifierWithEnum<GameResID, GameResIDBase>
  832. {
  833. public:
  834. using IdentifierWithEnum<GameResID, GameResIDBase>::IdentifierWithEnum;
  835. };
  836. // Deprecated
  837. // TODO: remove
  838. using ESpellSchool = SpellSchool;
  839. using ETownType = FactionID;
  840. using EGameResID = GameResID;
  841. using River = RiverId;
  842. using Road = RoadId;
  843. using ETerrainId = TerrainId;
  844. VCMI_LIB_NAMESPACE_END