CHeroHandler.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef CHEROHANDLER_H
  2. #define CHEROHANDLER_H
  3. #include <string>
  4. #include <vector>
  5. #include "CCreatureHandler.h"
  6. #include "SDL.h"
  7. #include "../int3.h"
  8. #include "CAmbarCendamo.h"
  9. #include "CGameInterface.h"
  10. class CHeroClass;
  11. class CObjectInstance;
  12. class CDefHandler;
  13. class CGameInfo;
  14. class CHero
  15. {
  16. public:
  17. std::string name;
  18. int ID;
  19. int low1stack, high1stack, low2stack, high2stack, low3stack, high3stack; //amount of units; described below
  20. std::string refType1stack, refType2stack, refType3stack; //reference names of units appearing in hero's army if he is recruited in tavern
  21. std::string bonusName, shortBonus, longBonus; //for special abilities
  22. std::string biography; //biography, of course
  23. bool isAllowed; //true if we can play with this hero (depends on map)
  24. CHeroClass * heroClass;
  25. EHeroClasses heroType; //hero class
  26. //bool operator<(CHero& drugi){if (ID < drugi.ID) return true; else return false;}
  27. SDL_Surface * portraitSmall; //48x32 px
  28. SDL_Surface * portraitLarge; //58x64 px
  29. };
  30. class CHeroClass
  31. {
  32. public:
  33. std::string name;
  34. float aggression;
  35. int initialAttack, initialDefence, initialPower, initialKnowledge;
  36. int proAttack[2]; //probability of gaining attack point on levels [0]: 2 - 9; [1]: 10+ (out of 100)
  37. int proDefence[2]; //probability of gaining defence point on levels [0]: 2 - 9; [1]: 10+ (out of 100)
  38. int proPower[2]; //probability of gaining power point on levels [0]: 2 - 9; [1]: 10+ (out of 100)
  39. int proKnowledge[2]; //probability of gaining knowledge point on levels [0]: 2 - 9; [1]: 10+ (out of 100)
  40. std::vector<int> proSec; //probabilities of gaining secondary skills (out of 112), in id order
  41. int selectionProbability[9]; //probability of selection in towns
  42. std::vector<int> terrCosts; //default costs of going through terrains: dirt, sand, grass, snow, swamp, rough, subterrain, lava, water, rock; -1 means terrain is imapassable
  43. CDefHandler * moveAnim; //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing
  44. };
  45. class CHeroInstance
  46. {
  47. public:
  48. int owner;
  49. CHero * type;
  50. CObjectInstance * ourObject;
  51. int exp; //experience point
  52. int level; //current level of hero
  53. std::string name; //may be custom
  54. std::string biography; //may be custom
  55. int portrait; //may be custom
  56. int3 pos; //position of object (hero pic is on the left)
  57. CCreatureSet army; //army
  58. int mana; // remaining spell points
  59. std::vector<int> primSkills; //0-attack, 1-defence, 2-spell power, 3-knowledge
  60. std::vector<std::pair<int,int> > secSkills; //first - ID of skill, second - level of skill (0 - basic, 1 - adv., 2 - expert)
  61. int movement; //remaining movement points
  62. bool inTownGarrison; // if hero is in town garrison
  63. unsigned int getTileCost(EterrainType & ttype, Eroad & rdtype, Eriver & rvtype);
  64. unsigned int getLowestCreatureSpeed();
  65. unsigned int getAdditiveMoveBonus();
  66. unsigned float getMultiplicativeMoveBonus();
  67. static int3 convertPosition(int3 src, bool toh3m); //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest
  68. int3 getPosition(bool h3m) const; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
  69. void setPosition(int3 Pos, bool h3m); //as above, but sets position
  70. bool canWalkOnSea() const;
  71. int getCurrentLuck() const;
  72. int getCurrentMorale() const;
  73. //TODO: artifacts, known spells, commander, blessings, curses, morale/luck special modifiers
  74. };
  75. class CHeroHandler
  76. {
  77. public:
  78. std::vector<CHeroInstance *> heroInstances;
  79. std::vector<CHero*> heroes; //by³o nodrze
  80. std::vector<CHeroClass *> heroClasses;
  81. std::vector<CDefHandler *> flags1, flags2, flags3, flags4; //flags blitted on heroes when
  82. unsigned int level(unsigned int experience);
  83. void loadHeroes();
  84. void loadSpecialAbilities();
  85. void loadBiographies();
  86. void loadHeroClasses();
  87. void loadPortraits();
  88. void initHeroClasses();
  89. ~CHeroHandler();
  90. void initTerrainCosts();
  91. friend void CAmbarCendamo::deh3m();
  92. friend void initGameState(CGameInfo * cgi);
  93. friend class CConsoleHandler;
  94. //friend void CPlayerInterface::heroMoved(const HeroMoveDetails & details); //TODO: wywalic, wstretne!!!
  95. };
  96. #endif //CHEROHANDLER_H