CHeroHandler.h 4.6 KB

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