BonusEnum.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. /*
  2. * BonusEnum.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. VCMI_LIB_NAMESPACE_BEGIN
  12. class JsonNode;
  13. #define BONUS_LIST \
  14. BONUS_NAME(NONE) \
  15. BONUS_NAME(ARTIFACT_GROWING) \
  16. BONUS_NAME(ARTIFACT_CHARGE) \
  17. BONUS_NAME(MOVEMENT) /*Subtype is 1 - land, 0 - sea*/ \
  18. BONUS_NAME(MORALE) \
  19. BONUS_NAME(LUCK) \
  20. BONUS_NAME(PRIMARY_SKILL) /*uses subtype to pick skill; additional info if set: 1 - only melee, 2 - only distance*/ \
  21. BONUS_NAME(SIGHT_RADIUS) \
  22. BONUS_NAME(MANA_REGENERATION) /*points per turn*/ \
  23. BONUS_NAME(MANA_PERCENTAGE_REGENERATION) /*all mana points are replenished every day*/ \
  24. BONUS_NAME(NONEVIL_ALIGNMENT_MIX) /*good and neutral creatures can be mixed without morale penalty*/ \
  25. BONUS_NAME(SURRENDER_DISCOUNT) /*%*/ \
  26. BONUS_NAME(STACKS_SPEED) /*additional info - percent of speed bonus applied after direct bonuses; >0 - added, <0 - subtracted to this part*/ \
  27. BONUS_NAME(FLYING_MOVEMENT) /*value - penalty percentage*/ \
  28. BONUS_NAME(SPELL_DURATION) \
  29. BONUS_NAME(WATER_WALKING) /*value - penalty percentage*/ \
  30. BONUS_NAME(NEGATE_ALL_NATURAL_IMMUNITIES) \
  31. BONUS_NAME(STACK_HEALTH) \
  32. BONUS_NAME(GENERATE_RESOURCE) /*daily value, uses subtype (resource type)*/ \
  33. BONUS_NAME(CREATURE_GROWTH) /*for legion artifacts: value - week growth bonus, subtype - monster level if applicable*/ \
  34. BONUS_NAME(WHIRLPOOL_PROTECTION) /*hero won't lose army when teleporting through whirlpool*/ \
  35. BONUS_NAME(SPELL) /*hero knows spell, val - skill level (0 - 3), subtype - spell id*/ \
  36. BONUS_NAME(SPELLS_OF_LEVEL) /*hero knows all spells of given level, val - skill level; subtype - level*/ \
  37. BONUS_NAME(SPELLS_OF_SCHOOL) /*hero knows all spells of given school, subtype - spell school; 0 - air, 1 - fire, 2 - water, 3 - earth*/ \
  38. BONUS_NAME(BATTLE_NO_FLEEING) /*for shackles of war*/ \
  39. BONUS_NAME(MAGIC_SCHOOL_SKILL) /* //eg. for magic plains terrain, subtype: school of magic (0 - all, 1 - fire, 2 - air, 4 - water, 8 - earth), value - level*/ \
  40. BONUS_NAME(FREE_SHOOTING) /*stacks can shoot even if otherwise blocked (sharpshooter's bow effect)*/ \
  41. BONUS_NAME(OPENING_BATTLE_SPELL) /*casts a spell at expert level at beginning of battle, val - spell power, subtype - spell id*/ \
  42. BONUS_NAME(IMPROVED_NECROMANCY) /* raise more powerful creatures: subtype - creature type raised, addInfo - [required necromancy level, required stack level], val - necromancy level for this purpose */ \
  43. BONUS_NAME(CREATURE_GROWTH_PERCENT) /*increases growth of all units in all towns, val - percentage*/ \
  44. BONUS_NAME(FREE_SHIP_BOARDING) /*movement points preserved with ship boarding and landing*/ \
  45. BONUS_NAME(FLYING) \
  46. BONUS_NAME(SHOOTER) \
  47. BONUS_NAME(CHARGE_IMMUNITY) \
  48. BONUS_NAME(ADDITIONAL_ATTACK) /*val: number of additional attacks to perform*/ \
  49. BONUS_NAME(UNLIMITED_RETALIATIONS) \
  50. BONUS_NAME(NO_MELEE_PENALTY) \
  51. BONUS_NAME(JOUSTING) /*for champions*/ \
  52. BONUS_NAME(HATE) /*eg. angels hate devils, subtype - ID of hated creature, val - damage bonus percent */ \
  53. BONUS_NAME(KING) /* val - required slayer bonus val to affect */\
  54. BONUS_NAME(MAGIC_RESISTANCE) /*in % (value)*/ \
  55. BONUS_NAME(CHANGES_SPELL_COST_FOR_ALLY) /*in mana points (value) , eg. mage*/ \
  56. BONUS_NAME(CHANGES_SPELL_COST_FOR_ENEMY) /*in mana points (value) , eg. pegasus */ \
  57. BONUS_NAME(SPELL_AFTER_ATTACK) /* subtype - spell id, value - chance %, addInfo[0] - level, addInfo[1] -> [0 - all attacks, 1 - shot only, 2 - melee only], addInfo[2] -> spell layer for multiple SPELL_AFTER_ATTACK bonuses (default none [-1]) */ \
  58. BONUS_NAME(SPELL_BEFORE_ATTACK) /* subtype - spell id, value - chance %, addInfo[0] - level, addInfo[1] -> [0 - all attacks, 1 - shot only, 2 - melee only], addInfo[2] -> spell layer for multiple SPELL_BEFORE_ATTACK bonuses (default none [-1]) */ \
  59. BONUS_NAME(SPELL_RESISTANCE_AURA) /*eg. unicorns, value - resistance bonus in % for adjacent creatures*/ \
  60. BONUS_NAME(LEVEL_SPELL_IMMUNITY) /*creature is immune to all spell with level below or equal to value of this bonus */ \
  61. BONUS_NAME(BLOCK_MAGIC_ABOVE) /*blocks casting spells of the level > value */ \
  62. BONUS_NAME(BLOCK_ALL_MAGIC) /*blocks casting spells*/ \
  63. BONUS_NAME(TWO_HEX_ATTACK_BREATH) /*eg. dragons*/ \
  64. BONUS_NAME(SPELL_DAMAGE_REDUCTION) /*eg. golems; value - reduction in %, subtype - spell school; -1 - all, 0 - air, 1 - fire, 2 - water, 3 - earth*/ \
  65. BONUS_NAME(NO_WALL_PENALTY) \
  66. BONUS_NAME(NON_LIVING) /*eg. golems, cannot be rised or healed, only neutral morale */ \
  67. BONUS_NAME(RANDOM_SPELLCASTER) /*eg. master genie, val - level*/ \
  68. BONUS_NAME(BLOCKS_RETALIATION) /*eg. naga*/ \
  69. BONUS_NAME(SPELL_IMMUNITY) /*subid - spell id*/ \
  70. BONUS_NAME(MANA_CHANNELING) /*value in %, eg. familiar*/ \
  71. BONUS_NAME(SPELL_LIKE_ATTACK) /*subtype - spell, value - spell level; range is taken from spell, but damage from creature; eg. magog*/ \
  72. BONUS_NAME(THREE_HEADED_ATTACK) /*eg. cerberus*/ \
  73. BONUS_NAME(GENERAL_DAMAGE_PREMY) \
  74. BONUS_NAME(MIND_IMMUNITY) \
  75. BONUS_NAME(FIRE_SHIELD) \
  76. BONUS_NAME(UNDEAD) \
  77. BONUS_NAME(HP_REGENERATION) /*creature regenerates val HP every new round*/ \
  78. BONUS_NAME(MANA_DRAIN) /*value - spell points per turn*/ \
  79. BONUS_NAME(LIFE_DRAIN) \
  80. BONUS_NAME(DOUBLE_DAMAGE_CHANCE) /*value in %, eg. dread knight*/ \
  81. BONUS_NAME(RETURN_AFTER_STRIKE) \
  82. BONUS_NAME(SPELLCASTER) /*subtype - spell id, value - level of school, additional info - weighted chance. use SPECIFIC_SPELL_POWER, CREATURE_SPELL_POWER or CREATURE_ENCHANT_POWER for calculating the power*/ \
  83. BONUS_NAME(CATAPULT) \
  84. BONUS_NAME(ENEMY_DEFENCE_REDUCTION) /*in % (value) eg. behemots*/ \
  85. BONUS_NAME(GENERAL_DAMAGE_REDUCTION) /* shield / air shield effect, also armorer skill/petrify effect for subtype -1*/ \
  86. BONUS_NAME(GENERAL_ATTACK_REDUCTION) /*eg. while stoned or blinded - in %,// subtype not used, use ONLY_MELEE_FIGHT / DISTANCE_FIGHT*/ \
  87. BONUS_NAME(DEFENSIVE_STANCE) /* val - bonus to defense while defending */ \
  88. BONUS_NAME(ATTACKS_ALL_ADJACENT) /*eg. hydra*/ \
  89. BONUS_NAME(MORE_DAMAGE_FROM_SPELL) /*value - damage increase in %, subtype - spell id*/ \
  90. BONUS_NAME(FEARFUL) \
  91. BONUS_NAME(LIVING) \
  92. BONUS_NAME(NO_DISTANCE_PENALTY) \
  93. BONUS_NAME(ENCHANTER)/* for Enchanter spells, val - skill level, subtype - spell id, additionalInfo - cooldown */ \
  94. BONUS_NAME(HEALER) \
  95. BONUS_NAME(SIEGE_WEAPON) \
  96. BONUS_NAME(HYPNOTIZED) \
  97. BONUS_NAME(NO_RETALIATION) /*temporary bonus for basilisk, unicorn and scorpicore paralyze*/\
  98. BONUS_NAME(ADDITIONAL_RETALIATION) /*value - number of additional retaliations*/ \
  99. BONUS_NAME(MAGIC_MIRROR) /* value - chance of redirecting in %*/ \
  100. BONUS_NAME(ALWAYS_MINIMUM_DAMAGE) /*unit does its minimum damage from range; subtype: -1 - any attack, 0 - melee, 1 - ranged, value: additional damage penalty (it'll subtracted from dmg), additional info - multiplicative anti-bonus for dmg in % [eg 20 means that creature will inflict 80% of normal minimal dmg]*/ \
  101. BONUS_NAME(ALWAYS_MAXIMUM_DAMAGE) /*eg. bless effect, subtype: -1 - any attack, 0 - melee, 1 - ranged, value: additional damage, additional info - multiplicative bonus for dmg in %*/ \
  102. BONUS_NAME(ATTACKS_NEAREST_CREATURE) /*while in berserk*/ \
  103. BONUS_NAME(IN_FRENZY) /*value - level*/ \
  104. BONUS_NAME(SLAYER) /*value - level*/ \
  105. BONUS_NAME(FORGETFULL) /*forgetfulness spell effect, value - level*/ \
  106. BONUS_NAME(NOT_ACTIVE) /* subtype - spell ID (paralyze, blind, stone gaze) for graphical effect*/ \
  107. BONUS_NAME(NO_LUCK) /*eg. when fighting on cursed ground*/ \
  108. BONUS_NAME(NO_MORALE) /*eg. when fighting on cursed ground*/ \
  109. BONUS_NAME(DARKNESS) /*val = radius */ \
  110. BONUS_NAME(SPECIAL_SPELL_LEV) /*subtype = id, val = value per level in percent*/\
  111. BONUS_NAME(SPELL_DAMAGE) /*val = value, now works for sorcery, subtype - spell school; -1 - all, 0 - air, 1 - fire, 2 - water, 3 - earth*/\
  112. BONUS_NAME(SPECIFIC_SPELL_DAMAGE) /*subtype = id of spell, val = value*/\
  113. BONUS_NAME(SPECIAL_PECULIAR_ENCHANT) /*blesses and curses with id = val dependent on unit's level, subtype = 0 or 1 for Coronius*/\
  114. BONUS_NAME(SPECIAL_UPGRADE) /*subtype = base, additionalInfo = target */\
  115. BONUS_NAME(DRAGON_NATURE) \
  116. BONUS_NAME(CREATURE_DAMAGE)/*subtype 0 = both, 1 = min, 2 = max*/\
  117. BONUS_NAME(SHOTS)\
  118. BONUS_NAME(DEATH_STARE) /*subtype 0 - gorgon, 1 - commander*/\
  119. BONUS_NAME(POISON) /*val - max health penalty from poison possible*/\
  120. BONUS_NAME(BIND_EFFECT) /*doesn't do anything particular, works as a marker)*/\
  121. BONUS_NAME(ACID_BREATH) /*additional val damage per creature after attack, additional info - chance in percent*/\
  122. BONUS_NAME(RECEPTIVE) /*accepts friendly spells even with immunity*/\
  123. BONUS_NAME(CASTS) /*how many times creature can cast activated spell*/ \
  124. BONUS_NAME(SPECIFIC_SPELL_POWER) /* value used for Thunderbolt and Resurrection cast by units, subtype - spell id */\
  125. BONUS_NAME(CREATURE_SPELL_POWER) /* value per unit, divided by 100 (so faerie Dragons have 800)*/ \
  126. BONUS_NAME(CREATURE_ENCHANT_POWER) /* total duration of spells cast by creature */ \
  127. BONUS_NAME(ENCHANTED) /* permanently enchanted with spell subID of level = val, if val > 3 then spell is mass and has level of val-3*/ \
  128. BONUS_NAME(REBIRTH) /* val - percent of life restored, subtype = 0 - regular, 1 - at least one unit (sacred Phoenix) */\
  129. BONUS_NAME(DISGUISED) /* subtype - spell level */\
  130. BONUS_NAME(VISIONS) /* subtype - spell level */\
  131. BONUS_NAME(NO_TERRAIN_PENALTY) /* subtype - terrain type */\
  132. BONUS_NAME(SOUL_STEAL) /*val - number of units gained per enemy killed, subtype = 0 - gained units survive after battle, 1 - they do not*/ \
  133. BONUS_NAME(TRANSMUTATION) /*val - chance to trigger in %, subtype = 0 - resurrection based on HP, 1 - based on unit count, additional info - target creature ID (attacker default)*/\
  134. BONUS_NAME(SUMMON_GUARDIANS) /*val - amount in % of stack count, subtype = creature ID*/\
  135. BONUS_NAME(CATAPULT_EXTRA_SHOTS) /*val - power of catapult effect, requires CATAPULT bonus to work*/\
  136. BONUS_NAME(RANGED_RETALIATION) /*allows shooters to perform ranged retaliation*/\
  137. BONUS_NAME(BLOCKS_RANGED_RETALIATION) /*disallows ranged retaliation for shooter unit, BLOCKS_RETALIATION bonus is for melee retaliation only*/\
  138. BONUS_NAME(MANUAL_CONTROL) /* manually control warmachine with id = subtype, chance = val */ \
  139. BONUS_NAME(WIDE_BREATH) /* initial desigh: dragon breath affecting multiple nearby hexes */\
  140. BONUS_NAME(FIRST_STRIKE) /* first counterattack, then attack if possible */\
  141. BONUS_NAME(VULNERABLE_FROM_BACK) /*bonus damage for attacks from behind*/\
  142. BONUS_NAME(SHOOTS_ALL_ADJACENT) /* H4 Cyclops-like shoot (attacks all hexes neighbouring with target) without spell-like mechanics */\
  143. BONUS_NAME(BLOCK_MAGIC_BELOW) /*blocks casting spells of the level < value */ \
  144. BONUS_NAME(DESTRUCTION) /*kills extra units after hit, subtype = 0 - kill percentage of units, 1 - kill amount, val = chance in percent to trigger, additional info - amount/percentage to kill*/ \
  145. BONUS_NAME(SPECIAL_CRYSTAL_GENERATION) /*crystal dragon crystal generation*/ \
  146. BONUS_NAME(NO_SPELLCAST_BY_DEFAULT) /*spellcast will not be default attack option for this creature*/ \
  147. BONUS_NAME(SKELETON_TRANSFORMER_TARGET) /* for skeleton transformer */ \
  148. BONUS_NAME(SPECIAL_ADD_VALUE_ENCHANT) /*specialty spell like Aenin has, increased effect of spell, additionalInfo = value to add*/\
  149. BONUS_NAME(SPECIAL_FIXED_VALUE_ENCHANT) /*specialty spell like Melody has, constant spell effect (i.e. 3 luck), additionalInfo = value to fix.*/\
  150. BONUS_NAME(THIEVES_GUILD_ACCESS) \
  151. BONUS_NAME(LIMITED_SHOOTING_RANGE) /*limits range of shooting creatures, doesn't adjust any other mechanics (half vs full damage etc). val - range in hexes, additional info - optional new range for broken arrow mechanic */\
  152. BONUS_NAME(LEARN_BATTLE_SPELL_CHANCE) /*skill-agnostic eagle eye chance. subtype = 0 - from enemy, 1 - TODO: from entire battlefield*/\
  153. BONUS_NAME(LEARN_BATTLE_SPELL_LEVEL_LIMIT) /*skill-agnostic eagle eye limit, subtype - school (-1 for all), others TODO*/\
  154. BONUS_NAME(PERCENTAGE_DAMAGE_BOOST) /*skill-agnostic archery and offence, subtype is 0 for offence and 1 for archery*/\
  155. BONUS_NAME(LEARN_MEETING_SPELL_LIMIT) /*skill-agnostic scholar, subtype is -1 for all, TODO for others (> 0)*/\
  156. BONUS_NAME(ROUGH_TERRAIN_DISCOUNT) /*skill-agnostic pathfinding*/\
  157. BONUS_NAME(WANDERING_CREATURES_JOIN_BONUS) /*skill-agnostic diplomacy*/\
  158. BONUS_NAME(BEFORE_BATTLE_REPOSITION) /*skill-agnostic tactics, bonus for allowing tactics*/\
  159. BONUS_NAME(BEFORE_BATTLE_REPOSITION_BLOCK) /*skill-agnostic tactics, bonus for blocking opposite tactics. For now donble side tactics is TODO.*/\
  160. BONUS_NAME(HERO_EXPERIENCE_GAIN_PERCENT) /*skill-agnostic learning, and we can use it as a global effect also*/\
  161. BONUS_NAME(UNDEAD_RAISE_PERCENTAGE) /*Percentage of killed enemy creatures to be raised after battle as undead*/\
  162. BONUS_NAME(MANA_PER_KNOWLEDGE_PERCENTAGE) /*Percentage rate of translating hero knowledge to 10 mana, used to intelligence and global bonus*/\
  163. BONUS_NAME(HERO_GRANTS_ATTACKS) /*If hero can grant additional attacks to creature, value is number of attacks, subtype is creatureID*/\
  164. BONUS_NAME(BONUS_DAMAGE_PERCENTAGE) /*If hero can grant conditional damage to creature, value is percentage, subtype is creatureID*/\
  165. BONUS_NAME(BONUS_DAMAGE_CHANCE) /*If hero can grant additional damage to creature, value is chance, subtype is creatureID*/\
  166. BONUS_NAME(MAX_LEARNABLE_SPELL_LEVEL) /*This can work as wisdom before. val = max learnable spell level*/\
  167. BONUS_NAME(SPELL_SCHOOL_IMMUNITY) /*This bonus will work as spell school immunity for all spells, subtype - spell school: 0 - air, 1 - fire, 2 - water, 3 - earth. Any is not handled for reducing overlap from LEVEL_SPELL_IMMUNITY*/\
  168. BONUS_NAME(NEGATIVE_EFFECTS_IMMUNITY) /*This bonus will work as spell school immunity for negative effects from spells of school, subtype - spell school: -1 - any, 0 - air, 1 - fire, 2 - water, 3 - earth*/\
  169. BONUS_NAME(TERRAIN_NATIVE) \
  170. BONUS_NAME(UNLIMITED_MOVEMENT) /*cheat bonus*/ \
  171. BONUS_NAME(MAX_MORALE) /*cheat bonus*/ \
  172. BONUS_NAME(MAX_LUCK) /*cheat bonus*/ \
  173. BONUS_NAME(FEROCITY) /*extra attacks, only if at least some creatures killed while attacking target unit, val = amount of additional attacks, additional info = amount of creatures killed to trigger (default 1)*/ \
  174. BONUS_NAME(ENEMY_ATTACK_REDUCTION) /*in % (value) eg. Nix (HotA)*/ \
  175. BONUS_NAME(REVENGE) /*additional damage based on how many units in stack died - formula: sqrt((number of creatures at battle start + 1) * creature health) / (total health now + 1 creature health) - 1) * 100% */ \
  176. BONUS_NAME(RESOURCES_CONSTANT_BOOST) /*Bonus that does not account for propagation and gives extra resources per day. val - resource amount, subtype - resource type*/ \
  177. BONUS_NAME(RESOURCES_TOWN_MULTIPLYING_BOOST) /*Bonus that does not account for propagation and gives extra resources per day with amount multiplied by number of owned towns. val - base resource amount to be multiplied times number of owned towns, subtype - resource type*/ \
  178. BONUS_NAME(DISINTEGRATE) /* after death no corpse remains */ \
  179. BONUS_NAME(INVINCIBLE) /* cannot be target of attacks or spells */ \
  180. BONUS_NAME(MECHANICAL) /*eg. factory creatures, cannot be rised or healed, only neutral morale, repairable by engineer */ \
  181. BONUS_NAME(PRISM_HEX_ATTACK_BREATH) /*eg. dragons*/ \
  182. BONUS_NAME(BASE_TILE_MOVEMENT_COST) /*minimal cost for moving offroad*/ \
  183. BONUS_NAME(HERO_SPELL_CASTS_PER_COMBAT_TURN) /**/ \
  184. BONUS_NAME(MULTIHEX_UNIT_ATTACK) /*eg. dragons*/ \
  185. BONUS_NAME(MULTIHEX_ENEMY_ATTACK) /*eg. dragons*/ \
  186. BONUS_NAME(MULTIHEX_ANIMATION) /*eg. dragons*/ \
  187. BONUS_NAME(STACK_EXPERIENCE_GAIN_PERCENT) /*modifies all stack experience gains*/\
  188. BONUS_NAME(FULL_MAP_SCOUTING) /*Skyship*/\
  189. BONUS_NAME(FULL_MAP_DARKNESS) /*opposite to Skyship*/\
  190. BONUS_NAME(TRANSMUTATION_IMMUNITY) /*blocks TRANSMUTATION bonus*/\
  191. BONUS_NAME(COMBAT_MANA_BONUS) /* Additional mana per combat */ \
  192. BONUS_NAME(SPECIFIC_SPELL_RANGE) /* value used for allowed spell range, subtype - spell id */\
  193. /* end of list */
  194. #define BONUS_SOURCE_LIST \
  195. BONUS_SOURCE(ARTIFACT)\
  196. BONUS_SOURCE(ARTIFACT_INSTANCE)\
  197. BONUS_SOURCE(OBJECT_TYPE)\
  198. BONUS_SOURCE(OBJECT_INSTANCE)\
  199. BONUS_SOURCE(CREATURE_ABILITY)\
  200. BONUS_SOURCE(TERRAIN_NATIVE)\
  201. BONUS_SOURCE(TERRAIN_OVERLAY)\
  202. BONUS_SOURCE(SPELL_EFFECT)\
  203. BONUS_SOURCE(TOWN_STRUCTURE)\
  204. BONUS_SOURCE(HERO_BASE_SKILL)\
  205. BONUS_SOURCE(SECONDARY_SKILL)\
  206. BONUS_SOURCE(HERO_SPECIAL)\
  207. BONUS_SOURCE(ARMY)\
  208. BONUS_SOURCE(CAMPAIGN_BONUS)\
  209. BONUS_SOURCE(STACK_EXPERIENCE)\
  210. BONUS_SOURCE(COMMANDER) /*TODO: consider using simply STACK_INSTANCE */\
  211. BONUS_SOURCE(GLOBAL) /*used for base bonuses which all heroes or all stacks should have*/\
  212. BONUS_SOURCE(OTHER) /*used for defensive stance and default value of spell level limit*/
  213. #define BONUS_VALUE_LIST \
  214. BONUS_VALUE(ADDITIVE_VALUE)\
  215. BONUS_VALUE(BASE_NUMBER)\
  216. BONUS_VALUE(PERCENT_TO_ALL)\
  217. BONUS_VALUE(PERCENT_TO_BASE)\
  218. BONUS_VALUE(PERCENT_TO_SOURCE) /*Adds value only to bonuses with same source*/\
  219. BONUS_VALUE(PERCENT_TO_TARGET_TYPE) /*Adds value only to bonuses with SourceType target*/\
  220. BONUS_VALUE(INDEPENDENT_MAX) /*used for SPELL bonus */\
  221. BONUS_VALUE(INDEPENDENT_MIN) //used for SECONDARY_SKILL_PREMY bonus
  222. enum class BonusType : uint16_t
  223. {
  224. #define BONUS_NAME(x) x,
  225. BONUS_LIST
  226. #undef BONUS_NAME
  227. BUILTIN_BONUSES_COUNT
  228. };
  229. namespace BonusDuration //when bonus is automatically removed
  230. {
  231. // We use uint16_t directly because std::bitset<11> eats whole 8 byte word.
  232. using Type = uint16_t;
  233. constexpr size_t Size = 11;
  234. enum BonusDuration : Type {
  235. PERMANENT = 1 << 0,
  236. ONE_BATTLE = 1 << 1, //at the end of battle
  237. ONE_DAY = 1 << 2, //at the end of day
  238. ONE_WEEK = 1 << 3, //at the end of week (bonus lasts till the end of week, thats NOT 7 days
  239. N_TURNS = 1 << 4, //used during battles, after battle bonus is always removed
  240. N_DAYS = 1 << 5,
  241. UNTIL_BEING_ATTACKED = 1 << 6, /*removed after attack and counterattacks are performed*/
  242. UNTIL_ATTACK = 1 << 7, /*removed after attack and counterattacks are performed*/
  243. STACK_GETS_TURN = 1 << 8, /*removed when stack gets its turn - used for defensive stance*/
  244. COMMANDER_KILLED = 1 << 9,
  245. UNTIL_OWN_ATTACK = 1 << 10 /*removed after attack is performed (not counterattack)*/,
  246. };
  247. extern JsonNode toJson(const Type & duration);
  248. };
  249. enum class BonusSource : uint8_t
  250. {
  251. #define BONUS_SOURCE(x) x,
  252. BONUS_SOURCE_LIST
  253. #undef BONUS_SOURCE
  254. NUM_BONUS_SOURCE /*This is a dummy value, which will be always last*/
  255. };
  256. enum class BonusLimitEffect : uint8_t
  257. {
  258. NO_LIMIT = 0,
  259. ONLY_DISTANCE_FIGHT=1, ONLY_MELEE_FIGHT, //used to mark bonuses for attack/defense primary skills from spells like Precision (distance only)
  260. };
  261. enum class BonusValueType : uint8_t
  262. {
  263. #define BONUS_VALUE(x) x,
  264. BONUS_VALUE_LIST
  265. #undef BONUS_VALUE
  266. };
  267. enum class BonusNodeType
  268. {
  269. NONE = -1,
  270. UNKNOWN,
  271. STACK_INSTANCE,
  272. STACK_BATTLE,
  273. ARMY,
  274. ARTIFACT,
  275. CREATURE,
  276. ARTIFACT_INSTANCE,
  277. HERO,
  278. PLAYER,
  279. TEAM,
  280. TOWN_AND_VISITOR,
  281. BATTLE_WIDE,
  282. COMMANDER,
  283. GLOBAL_EFFECTS,
  284. BOAT,
  285. TOWN
  286. };
  287. extern DLL_LINKAGE const std::map<std::string, BonusValueType> bonusValueMap;
  288. extern DLL_LINKAGE const std::map<std::string, BonusSource> bonusSourceMap;
  289. extern DLL_LINKAGE const std::map<std::string, BonusDuration::Type> bonusDurationMap;
  290. extern DLL_LINKAGE const std::map<std::string, BonusLimitEffect> bonusLimitEffect;
  291. VCMI_LIB_NAMESPACE_END