HeroBonus.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include "../global.h"
  3. #include <string>
  4. struct DLL_EXPORT HeroBonus
  5. {
  6. enum BonusType
  7. {
  8. //handled
  9. NONE,
  10. MOVEMENT, //both water/land
  11. LAND_MOVEMENT,
  12. SEA_MOVEMENT,
  13. MORALE,
  14. LUCK,
  15. MORALE_AND_LUCK,
  16. PRIMARY_SKILL, //uses subtype to pick skill
  17. SIGHT_RADIOUS,
  18. MANA_REGENERATION, //points per turn apart from normal (1 + mysticism)
  19. //not handled yet:
  20. MAGIC_RESISTANCE, // %
  21. SECONDARY_SKILL_PREMY, //%
  22. SURRENDER_DISCOUNT, //%
  23. STACKS_SPEED,
  24. FLYING_MOVEMENT, SPELL_DURATION, AIR_SPELL_DMG_PREMY, EARTH_SPELL_DMG_PREMY, FIRE_SPELL_DMG_PREMY,
  25. WATER_SPELL_DMG_PREMY, BLOCK_SPELLS_ABOVE_LEVEL, WATER_WALKING, NO_SHOTING_PENALTY, DISPEL_IMMUNITY,
  26. NEGATE_ALL_NATURAL_IMMUNITIES, STACK_HEALTH, SPELL_IMMUNITY, BLOCK_MORALE, BLOCK_LUCK, FIRE_SPELLS,
  27. AIR_SPELLS, WATER_SPELLS, EARTH_SPELLS,
  28. GENERATE_RESOURCE, //daily value, uses subtype (resource type)
  29. CREATURE_GROWTH, //for legion artifacts: value - week growth bonus, subtype - monster level
  30. WHIRLPOOL_PROTECTION, //hero won't lose army when teleporting through whirlpool
  31. SPELL, //hero knows spell, val - skill level (0 - 3), subtype - spell id
  32. SPELLS_OF_LEVEL, //hero knows all spells of given level, val - skill level; subtype - level
  33. ENEMY_CANT_ESCAPE //for shackles of war
  34. };
  35. enum BonusDuration{PERMANENT, ONE_BATTLE, ONE_DAY, ONE_WEEK};
  36. enum BonusSource{ARTIFACT, OBJECT};
  37. ui8 duration; //uses BonusDuration values
  38. ui8 type; //uses BonusType values - says to what is this bonus
  39. si32 subtype; //-1 if not applicable
  40. ui8 source;//uses BonusSource values - what gave that bonus
  41. si32 val;//for morale/luck [-3,+3], others any
  42. ui32 id; //id of object/artifact
  43. std::string description;
  44. HeroBonus(ui8 Dur, ui8 Type, ui8 Src, si32 Val, ui32 ID, std::string Desc, si32 Subtype=-1)
  45. :duration(Dur), type(Type), source(Src), val(Val), id(ID), description(Desc), subtype(Subtype)
  46. {}
  47. HeroBonus(ui8 Dur, ui8 Type, ui8 Src, si32 Val, ui32 ID, si32 Subtype=-1)
  48. :duration(Dur), type(Type), source(Src), val(Val), id(ID), subtype(Subtype)
  49. {}
  50. HeroBonus()
  51. {
  52. subtype = -1;
  53. }
  54. template <typename Handler> void serialize(Handler &h, const int version)
  55. {
  56. h & duration & type & source & val & id & description;
  57. }
  58. static bool OneDay(const HeroBonus &hb)
  59. {
  60. return hb.duration==HeroBonus::ONE_DAY;
  61. }
  62. static bool OneWeek(const HeroBonus &hb)
  63. {
  64. return hb.duration==HeroBonus::ONE_WEEK;
  65. }
  66. static bool OneBattle(const HeroBonus &hb)
  67. {
  68. return hb.duration==HeroBonus::ONE_BATTLE;
  69. }
  70. static bool IsFrom(const HeroBonus &hb, ui8 source, ui32 id) //if id==0xffffff then id doesn't matter
  71. {
  72. return hb.source==source && (id==0xffffff || hb.id==id);
  73. }
  74. };