CSpellHandler.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef __CSPELLHANDLER_H__
  2. #define __CSPELLHANDLER_H__
  3. #include <string>
  4. #include <vector>
  5. #include <set>
  6. #include "CSoundBase.h"
  7. //#include "map.h"
  8. /*
  9. * CSpellHandler.h, part of VCMI engine
  10. *
  11. * Authors: listed in file AUTHORS in main folder
  12. *
  13. * License: GNU General Public License v2.0 or later
  14. * Full text of license available in license.txt file, in main folder
  15. *
  16. */
  17. typedef ui16 spelltype;
  18. class DLL_EXPORT CSpell
  19. {
  20. public:
  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::set<ui16> rangeInHexes(unsigned int centralHex, ui8 schoolLvl ) const; //convert range to specific hexes
  41. si16 mainEffectAnim; //main spell effect animation, in AC format (or -1 when none)
  42. soundBase::soundID soundID; // spell sound id
  43. template <typename Handler> void serialize(Handler &h, const int version)
  44. {
  45. h & id & name & abbName & descriptions & level & earth & water & fire & air & power & costs
  46. & powers & probabilities & AIVals & attributes & combatSpell & creatureAbility & positiveness & range & mainEffectAnim;
  47. }
  48. };
  49. namespace Spells
  50. {
  51. enum {SUMMON_BOAT=0, SCUTTLE_BOAT, VISIONS, VIEW_EARTH, DISGUISE, VIEW_AIR, FLY, WATER_WALK, DIMENSION_DOOR, TOWN_PORTAL};
  52. }
  53. bool DLL_EXPORT isInScreenRange(const int3 &center, const int3 &pos); //for spells like Dimension Door
  54. class DLL_EXPORT CSpellHandler
  55. {
  56. public:
  57. CSpellHandler();
  58. std::vector<CSpell> spells;
  59. void loadSpells();
  60. template <typename Handler> void serialize(Handler &h, const int version)
  61. {
  62. h & spells;
  63. }
  64. };
  65. #endif // __CSPELLHANDLER_H__