GameConstants.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. #pragma once
  2. /*
  3. * GameConstants.h, part of VCMI engine
  4. *
  5. * Authors: listed in file AUTHORS in main folder
  6. *
  7. * License: GNU General Public License v2.0 or later
  8. * Full text of license available in license.txt file, in main folder
  9. *
  10. */
  11. namespace GameConstants
  12. {
  13. const std::string VCMI_VERSION = "VCMI 0.89b";
  14. /*
  15. * DATA_DIR contains the game data (Data/, MP3/, ...).
  16. * BIN_DIR is where the vcmiclient/vcmiserver binaries reside
  17. * LIB_DIR is where the AI libraries reside (linux only)
  18. */
  19. #ifdef _WIN32
  20. const std::string DATA_DIR = ".";
  21. const std::string BIN_DIR = ".";
  22. const std::string LIB_DIR = ".";
  23. const std::string SERVER_NAME = "VCMI_server.exe";
  24. const std::string LIB_EXT = "dll";
  25. const std::string PATH_SEPARATOR = "\\";
  26. #else
  27. #ifndef M_DATA_DIR
  28. #error M_DATA_DIR undefined.
  29. #else
  30. const std::string DATA_DIR = M_DATA_DIR;
  31. #endif
  32. #ifndef M_BIN_DIR
  33. #error M_BIN_DIR undefined.
  34. #else
  35. const std::string BIN_DIR = M_BIN_DIR;
  36. #endif
  37. #ifndef M_LIB_DIR
  38. #error M_LIB_DIR undefined.
  39. #else
  40. const std::string LIB_DIR = M_LIB_DIR;
  41. #endif
  42. const std::string SERVER_NAME = "vcmiserver";
  43. const std::string LIB_EXT = "so";
  44. const std::string PATH_SEPARATOR = "/";
  45. #endif
  46. const int BFIELD_WIDTH = 17;
  47. const int BFIELD_HEIGHT = 11;
  48. const int BFIELD_SIZE = BFIELD_WIDTH * BFIELD_HEIGHT;
  49. const int ARMY_SIZE = 7;
  50. const int BOATI_TYPE = 8;
  51. const int HEROI_TYPE = 34;
  52. const int TOWNI_TYPE = 98;
  53. const int SUBTERRANEAN_GATE_TYPE = 103;
  54. const int CREI_TYPE = 54;
  55. const int EVENTI_TYPE = 26;
  56. const int CREATURES_COUNT = 197;
  57. const int CRE_LEVELS = 10;
  58. const int F_NUMBER = 9; //factions (town types) quantity
  59. const int PLAYER_LIMIT = 8; //player limit per map
  60. const int MAX_HEROES_PER_PLAYER = 8;
  61. const int ALL_PLAYERS = 255; //bitfield
  62. const int HEROES_PER_TYPE=8; //amount of heroes of each type
  63. const int SKILL_QUANTITY=28;
  64. const int SKILL_PER_HERO=8;
  65. const int ARTIFACTS_QUANTITY=171;
  66. const int HEROES_QUANTITY=156;
  67. const int SPELLS_QUANTITY=70;
  68. const int RESOURCE_QUANTITY=8;
  69. const int TERRAIN_TYPES=10;
  70. const int PRIMARY_SKILLS=4;
  71. const int NEUTRAL_PLAYER=255;
  72. const int NAMES_PER_TOWN=16;
  73. const int CREATURES_PER_TOWN = 7; //without upgrades
  74. const int MAX_BUILDING_PER_TURN = 1;
  75. const int SPELL_LEVELS = 5;
  76. const int AVAILABLE_HEROES_PER_PLAYER = 2;
  77. const int SPELLBOOK_GOLD_COST = 500;
  78. const ui16 BACKPACK_START = 19;
  79. const int ID_CATAPULT = 3, ID_LOCK = 145;
  80. }
  81. // Enum declarations
  82. namespace PrimarySkill
  83. {
  84. enum { ATTACK, DEFENSE, SPELL_POWER, KNOWLEDGE};
  85. }
  86. namespace EVictoryConditionType
  87. {
  88. enum EVictoryConditionType { ARTIFACT, GATHERTROOP, GATHERRESOURCE, BUILDCITY, BUILDGRAIL, BEATHERO,
  89. CAPTURECITY, BEATMONSTER, TAKEDWELLINGS, TAKEMINES, TRANSPORTITEM, WINSTANDARD = 255 };
  90. }
  91. namespace ELossConditionType
  92. {
  93. enum ELossConditionType { LOSSCASTLE, LOSSHERO, TIMEEXPIRES, LOSSSTANDARD = 255 };
  94. }
  95. namespace EAlignment
  96. {
  97. enum EAlignment { GOOD, EVIL, NEUTRAL };
  98. }
  99. namespace EBuilding
  100. {
  101. //Quite useful as long as most of building mechanics hardcoded
  102. enum EBuilding
  103. {
  104. MAGES_GUILD_1, MAGES_GUILD_2, MAGES_GUILD_3, MAGES_GUILD_4, MAGES_GUILD_5,
  105. TAVERN, SHIPYARD, FORT, CITADEL, CASTLE,
  106. VILLAGE_HALL, TOWN_HALL, CITY_HALL, CAPITOL, MARKETPLACE,
  107. RESOURCE_SILO, BLACKSMITH, SPECIAL_1, HORDE_1, HORDE_1_UPGR,
  108. SHIP, SPECIAL_2, SPECIAL_3, SPECIAL_4, HORDE_2,
  109. HORDE_2_UPGR, GRAIL, EXTRA_CITY_HALL, EXTRA_TOWN_HALL, EXTRA_CAPITOL,
  110. DWELL_FIRST=30, DWELL_LAST=36, DWELL_UP_FIRST=37, DWELL_UP_LAST=43
  111. };
  112. }
  113. namespace EBuildingState
  114. {
  115. enum EBuildingState
  116. {
  117. HAVE_CAPITAL, NO_WATER, FORBIDDEN, ADD_MAGES_GUILD, ALREADY_PRESENT, CANT_BUILD_TODAY,
  118. NO_RESOURCES, ALLOWED, PREREQUIRES, BUILDING_ERROR
  119. };
  120. }
  121. namespace ESpellCastProblem
  122. {
  123. enum ESpellCastProblem
  124. {
  125. OK, NO_HERO_TO_CAST_SPELL, ALREADY_CASTED_THIS_TURN, NO_SPELLBOOK, ANOTHER_ELEMENTAL_SUMMONED,
  126. HERO_DOESNT_KNOW_SPELL, NOT_ENOUGH_MANA, ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL,
  127. SECOND_HEROS_SPELL_IMMUNITY, SPELL_LEVEL_LIMIT_EXCEEDED, NO_SPELLS_TO_DISPEL,
  128. NO_APPROPRIATE_TARGET, STACK_IMMUNE_TO_SPELL, WRONG_SPELL_TARGET, ONGOING_TACTIC_PHASE,
  129. MAGIC_IS_BLOCKED, //For Orb of Inhibition and similar - no casting at all
  130. INVALID
  131. };
  132. }
  133. namespace ECastingMode
  134. {
  135. enum ECastingMode {HERO_CASTING, AFTER_ATTACK_CASTING, //also includes cast before attack
  136. MAGIC_MIRROR, CREATURE_ACTIVE_CASTING, ENCHANTER_CASTING};
  137. }
  138. namespace EMarketMode
  139. {
  140. enum EMarketMode
  141. {
  142. RESOURCE_RESOURCE, RESOURCE_PLAYER, CREATURE_RESOURCE, RESOURCE_ARTIFACT,
  143. ARTIFACT_RESOURCE, ARTIFACT_EXP, CREATURE_EXP, CREATURE_UNDEAD, RESOURCE_SKILL,
  144. MARTKET_AFTER_LAST_PLACEHOLDER
  145. };
  146. }
  147. namespace EBattleStackState
  148. {
  149. enum EBattleStackState{ALIVE = 180, SUMMONED, CLONED, HAD_MORALE, WAITING, MOVED, DEFENDING, FEAR,
  150. DRAINED_MANA /*remember to drain mana only once per turn*/};
  151. }
  152. namespace ECommander
  153. {
  154. enum SecondarySkills {ATTACK, DEFENSE, HEALTH, DAMAGE, SPEED, SPELL_POWER, CASTS, RESISTANCE};
  155. const int MAX_SKILL_LEVEL = 5;
  156. }
  157. namespace EWallParts
  158. {
  159. enum EWallParts
  160. {
  161. INDESTRUCTIBLE_PART = -2, INVALID = -1,
  162. KEEP = 0, BOTTOM_TOWER, BOTTOM_WALL, BELOW_GATE, OVER_GATE, UPPER_WAL, UPPER_TOWER, GATE,
  163. PARTS_COUNT
  164. };
  165. }
  166. namespace EWallState
  167. {
  168. enum
  169. {
  170. NONE, //no wall
  171. INTACT,
  172. DAMAGED,
  173. DESTROYED
  174. };
  175. }
  176. namespace Obj
  177. {
  178. enum
  179. {
  180. ARTIFACT = 5,
  181. BOAT = 8,
  182. BORDERGUARD = 9,
  183. KEYMASTER = 10,
  184. CREATURE_BANK = 16,
  185. CREATURE_GENERATOR1 = 17,
  186. CURSED_GROUND1 = 21,
  187. DERELICT_SHIP = 24,
  188. DRAGON_UTOPIA = 25,
  189. GARRISON = 33,
  190. HILL_FORT = 35,
  191. LIBRARY_OF_ENLIGHTENMENT = 41,
  192. MONOLITH1 = 43,
  193. MONOLITH2 = 44,
  194. MONOLITH3 = 45,
  195. MAGIC_PLAINS1 = 46,
  196. SCHOOL_OF_MAGIC = 47,
  197. MAGIC_WELL = 49,
  198. MINE = 53,
  199. MONSTER = 54,
  200. OBELISK = 57,
  201. PRISON = 62,
  202. PYRAMID = 63,
  203. SEER_HUT = 83,
  204. CRYPT = 84,
  205. SHIPWRECK = 85,
  206. STABLES = 94,
  207. TRADING_POST = 99,
  208. TREE_OF_KNOWLEDGE = 102,
  209. SUBTERRANEAN_GATE = 103,
  210. UNIVERSITY = 104,
  211. SCHOOL_OF_WAR = 107,
  212. WHIRLPOOL = 111,
  213. BORDER_GATE = 212,
  214. QUEST_GUARD = 215,
  215. GARRISON2 = 219,
  216. ABANDONED_MINE = 220,
  217. CLOVER_FIELD = 222,
  218. CURSED_GROUND2 = 223,
  219. EVIL_FOG = 224,
  220. FAVORABLE_WINDS = 225,
  221. FIERY_FIELDS = 226,
  222. HOLY_GROUNDS = 227,
  223. LUCID_POOLS = 228,
  224. MAGIC_CLOUDS = 229,
  225. MAGIC_PLAINS2 = 230,
  226. ROCKLANDS = 231,
  227. };
  228. }
  229. namespace SecSkillLevel
  230. {
  231. enum SecSkillLevel
  232. {
  233. NONE,
  234. BASIC,
  235. ADVANCED,
  236. EXPERT
  237. };
  238. }
  239. //follows ERM BI (battle image) format
  240. namespace BattlefieldBI
  241. {
  242. enum
  243. {
  244. NONE = -1,
  245. COASTAL,
  246. //Discrepency from ERM BI description - we have magic plains and cursed gronds swapped
  247. MAGIC_PLAINS,
  248. CURSED_GROUND,
  249. //
  250. HOLY_GROUND,
  251. EVIL_FOG,
  252. CLOVER_FIELD,
  253. LUCID_POOLS,
  254. FIERY_FIELDS,
  255. ROCKLANDS,
  256. MAGIC_CLOUDS,
  257. };
  258. }
  259. // Typedef declarations
  260. typedef si64 expType;
  261. typedef ui32 TSpell;
  262. typedef std::pair<ui32, ui32> TDmgRange;
  263. typedef ui8 TBonusType;
  264. typedef si32 TBonusSubtype;
  265. typedef si32 TSlot;
  266. typedef si32 TQuantity;
  267. typedef ui32 TCreature; //creature id