CSpellHandler.h 3.9 KB

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