CSpellHandler.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #pragma once
  2. #include "../lib/ConstTransitivePtr.h"
  3. #include "int3.h"
  4. #include "GameConstants.h"
  5. /*
  6. * CSpellHandler.h, part of VCMI engine
  7. *
  8. * Authors: listed in file AUTHORS in main folder
  9. *
  10. * License: GNU General Public License v2.0 or later
  11. * Full text of license available in license.txt file, in main folder
  12. *
  13. */
  14. class CLegacyConfigParser;
  15. struct BattleHex;
  16. class DLL_LINKAGE CSpell
  17. {
  18. public:
  19. enum ETargetType {NO_TARGET, CREATURE, CREATURE_EXPERT_MASSIVE, OBSTACLE};
  20. enum ESpellPositiveness {NEGATIVE = -1, NEUTRAL = 0, POSITIVE = 1};
  21. ui32 id;
  22. std::string name;
  23. std::string abbName; //abbreviated name
  24. std::vector<std::string> descriptions; //descriptions of spell for skill levels: 0 - none, 1 - basic, etc
  25. si32 level;
  26. bool earth;
  27. bool water;
  28. bool fire;
  29. bool air;
  30. si32 power; //spell's power
  31. std::vector<si32> costs; //per skill level: 0 - none, 1 - basic, etc
  32. std::vector<si32> powers; //[er skill level: 0 - none, 1 - basic, etc
  33. std::vector<si32> probabilities; //% chance to gain for castles
  34. std::vector<si32> AIVals; //AI values: per skill level: 0 - none, 1 - basic, etc
  35. std::string attributes; //reference only attributes
  36. bool combatSpell; //is this spell combat (true) or adventure (false)
  37. bool creatureAbility; //if true, only creatures can use this spell
  38. si8 positiveness; //1 if spell is positive for influenced stacks, 0 if it is indifferent, -1 if it's negative
  39. std::vector<std::string> range; //description of spell's range in SRSL by magic school level
  40. std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool *outDroppedHexes = NULL ) const; //convert range to specific hexes; last optional out parameter is set to true, if spell would cover unavailable hexes (that are not included in ret)
  41. si16 mainEffectAnim; //main spell effect animation, in AC format (or -1 when none)
  42. ETargetType getTargetType() const;
  43. bool isPositive() const;
  44. bool isNegative() const;
  45. bool isRisingSpell() const;
  46. template <typename Handler> void serialize(Handler &h, const int version)
  47. {
  48. h & id & name & abbName & descriptions & level & earth & water & fire & air & power & costs
  49. & powers & probabilities & AIVals & attributes & combatSpell & creatureAbility & positiveness & range & mainEffectAnim;
  50. }
  51. };
  52. namespace Spells
  53. {
  54. enum
  55. {
  56. SUMMON_BOAT=0, SCUTTLE_BOAT=1, VISIONS=2, VIEW_EARTH=3, DISGUISE=4, VIEW_AIR=5,
  57. FLY=6, WATER_WALK=7, DIMENSION_DOOR=8, TOWN_PORTAL=9,
  58. QUICKSAND=10, LAND_MINE=11, FORCE_FIELD=12, FIRE_WALL=13, EARTHQUAKE=14,
  59. MAGIC_ARROW=15, ICE_BOLT=16, LIGHTNING_BOLT=17, IMPLOSION=18,
  60. CHAIN_LIGHTNING=19, FROST_RING=20, FIREBALL=21, INFERNO=22,
  61. METEOR_SHOWER=23, DEATH_RIPPLE=24, DESTROY_UNDEAD=25, ARMAGEDDON=26,
  62. SHIELD=27, AIR_SHIELD=28, FIRE_SHIELD=29, PROTECTION_FROM_AIR=30,
  63. PROTECTION_FROM_FIRE=31, PROTECTION_FROM_WATER=32,
  64. PROTECTION_FROM_EARTH=33, ANTI_MAGIC=34, DISPEL=35, MAGIC_MIRROR=36,
  65. CURE=37, RESURRECTION=38, ANIMATE_DEAD=39, SACRIFICE=40, BLESS=41,
  66. CURSE=42, BLOODLUST=43, PRECISION=44, WEAKNESS=45, STONE_SKIN=46,
  67. DISRUPTING_RAY=47, PRAYER=48, MIRTH=49, SORROW=50, FORTUNE=51,
  68. MISFORTUNE=52, HASTE=53, SLOW=54, SLAYER=55, FRENZY=56,
  69. TITANS_LIGHTNING_BOLT=57, COUNTERSTRIKE=58, BERSERK=59, HYPNOTIZE=60,
  70. FORGETFULNESS=61, BLIND=62, TELEPORT=63, REMOVE_OBSTACLE=64, CLONE=65,
  71. SUMMON_FIRE_ELEMENTAL=66, SUMMON_EARTH_ELEMENTAL=67, SUMMON_WATER_ELEMENTAL=68, SUMMON_AIR_ELEMENTAL=69,
  72. STONE_GAZE=70, POISON=71, BIND=72, DISEASE=73, PARALYZE=74, AGE=75, DEATH_CLOUD=76, THUNDERBOLT=77,
  73. DISPEL_HELPFUL_SPELLS=78, DEATH_STARE=79, ACID_BREATH_DEFENSE=80, ACID_BREATH_DAMAGE=81
  74. };
  75. }
  76. bool DLL_LINKAGE isInScreenRange(const int3 &center, const int3 &pos); //for spells like Dimension Door
  77. class DLL_LINKAGE CSpellHandler
  78. {
  79. CSpell * loadSpell(CLegacyConfigParser & parser);
  80. public:
  81. CSpellHandler();
  82. std::vector< ConstTransitivePtr<CSpell> > spells;
  83. std::set<TSpell> damageSpells; //they inflict damage and require particular threatment
  84. std::set<TSpell> risingSpells; //they affect dead stacks and need special target selection
  85. std::set<TSpell> mindSpells;
  86. void loadSpells();
  87. template <typename Handler> void serialize(Handler &h, const int version)
  88. {
  89. h & spells & damageSpells & risingSpells & mindSpells;
  90. }
  91. };