CSpellHandler.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef __CSPELLHANDLER_H__
  2. #define __CSPELLHANDLER_H__
  3. #include <string>
  4. #include <vector>
  5. #include <set>
  6. #include "CSoundBase.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. ui32 id;
  20. std::string name;
  21. std::string abbName; //abbreviated name
  22. std::vector<std::string> descriptions; //descriptions of spell for skill levels: 0 - none, 1 - basic, etc
  23. si32 level;
  24. bool earth;
  25. bool water;
  26. bool fire;
  27. bool air;
  28. si32 power; //spell's power
  29. std::vector<si32> costs; //per skill level: 0 - none, 1 - basic, etc
  30. std::vector<si32> powers; //[er skill level: 0 - none, 1 - basic, etc
  31. std::vector<si32> probabilities; //% chance to gain for castles
  32. std::vector<si32> AIVals; //AI values: per skill level: 0 - none, 1 - basic, etc
  33. std::string attributes; //reference only attributes
  34. bool combatSpell; //is this spell combat (true) or adventure (false)
  35. bool creatureAbility; //if true, only creatures can use this spell
  36. si8 positiveness; //1 if spell is positive for influenced stacks, 0 if it is indifferent, -1 if it's negative
  37. std::vector<std::string> range; //description of spell's range in SRSL by magic school level
  38. std::set<ui16> rangeInHexes(unsigned int centralHex, ui8 schoolLvl ) const; //convert range to specific hexes
  39. si16 mainEffectAnim; //main spell effect animation, in AC format (or -1 when none)
  40. soundBase::soundID soundID; // spell sound id
  41. template <typename Handler> void serialize(Handler &h, const int version)
  42. {
  43. h & id & name & abbName & descriptions & level & earth & water & fire & air & power & costs
  44. & powers & probabilities & AIVals & attributes & combatSpell & creatureAbility & positiveness & range & mainEffectAnim;
  45. }
  46. };
  47. class DLL_EXPORT CSpellHandler
  48. {
  49. public:
  50. std::vector<CSpell> spells;
  51. void loadSpells();
  52. template <typename Handler> void serialize(Handler &h, const int version)
  53. {
  54. h & spells;
  55. }
  56. };
  57. #endif // __CSPELLHANDLER_H__