CObjectHandler.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. #ifndef COBJECTHANDLER_H
  2. #define COBJECTHANDLER_H
  3. #include <string>
  4. #include <vector>
  5. #include "CCreatureHandler.h"
  6. #include "CArtHandler.h"
  7. #include "CAbilityHandler.h"
  8. #include "CSpellHandler.h"
  9. #include "CHeroHandler.h"
  10. class CSpecObjInfo //class with object - specific info (eg. different information for creatures and heroes); use inheritance to make object - specific classes
  11. {
  12. };
  13. class CEventObjInfo : public CSpecObjInfo
  14. {
  15. public:
  16. bool areGuarders; //true if there are
  17. CCreatureSet guarders;
  18. bool isMessage; //true if there is a message
  19. std::string message;
  20. unsigned int gainedExp;
  21. int manaDiff; //amount of gained / lost mana
  22. int moraleDiff; //morale modifier
  23. int luckDiff; //luck modifier
  24. int wood, mercury, ore, sulfur, crystal, gems, gold; //gained / lost resources
  25. unsigned int attack; //added attack points
  26. unsigned int defence; //added defence points
  27. unsigned int power; //added power points
  28. unsigned int knowledge; //added knowledge points
  29. std::vector<CAbility *> abilities; //gained abilities
  30. std::vector<int> abilityLevels; //levels of gained abilities
  31. std::vector<CArtifact *> artifacts; //gained artifacts
  32. std::vector<CSpell *> spells; //gained spells
  33. CCreatureSet creatures; //gained creatures
  34. unsigned char availableFor; //players whom this event is available for
  35. bool computerActivate; //true if computre player can activate this event
  36. bool humanActivate; //true if human player can activate this event
  37. };
  38. class CHeroObjInfo : public CSpecObjInfo
  39. {
  40. public:
  41. unsigned char bytes[4]; //mysterius bytes identifying hero in a strange way
  42. int player;
  43. CHero * type;
  44. std::string name; //if nonstandard
  45. bool standardGarrison; //true if hero has standard garrison
  46. CCreatureSet garrison; //hero's army
  47. std::vector<CArtifact *> artifacts; //hero's artifacts from bag
  48. CArtifact * artHead, * artLRing, * artRRing, * artLHand, * artRhand, * artFeet, * artSpellBook, * artMach1, * artMach2, * artMach3, * artMach4, * artMisc1, * artMisc2, * artMisc3, * artMisc4, * artMisc5, * artTorso, * artNeck, * artShoulders; //working artifacts
  49. bool isGuarding;
  50. int guardRange; //range of hero's guard
  51. std::string biography; //if nonstandard
  52. bool sex; //if true, reverse hero's sex
  53. std::vector<CSpell *> spells; //hero's spells
  54. int attack, defence, power, knowledge; //main hero's attributes
  55. unsigned int experience; //hero's experience points
  56. std::vector<CAbility *> abilities; //hero's abilities
  57. std::vector<int> abilityLevels; //hero ability levels
  58. bool defaultMainStats; //if true attack, defence, power and knowledge are typical
  59. CHeroInstance * myInstance; //pointer to appropriate hero instance
  60. };
  61. class CCreatureObjInfo : public CSpecObjInfo
  62. {
  63. public:
  64. unsigned char bytes[4]; //mysterious bytes identifying creature
  65. unsigned int number; //number of units (0 - random)
  66. unsigned char character; //chracter of this set of creatures (0 - the most friendly, 4 - the most hostile)
  67. std::string message; //message printed for attacking hero
  68. int wood, mercury, ore, sulfur, crytal, gems, gold; //resources gained to hero that has won with monsters
  69. CArtifact * gainedArtifact; //artifact gained to hero
  70. bool neverFlees; //if true, the troops will never flee
  71. bool notGrowingTeam; //if true, number of units won't grow
  72. };
  73. class CSignObjInfo : public CSpecObjInfo
  74. {
  75. public:
  76. std::string message; //message
  77. };
  78. class CSeerHutObjInfo : public CSpecObjInfo
  79. {
  80. public:
  81. char missionType; //type of mission: 0 - no mission; 1 - reach level; 2 - reach main statistics values; 3 - win with a certain hero; 4 - win with a certain creature; 5 - collect some atifacts; 6 - have certain troops in army; 7 - collect resources; 8 - be a certain hero; 9 - be a certain player
  82. bool isDayLimit; //if true, there is a day limit
  83. int lastDay; //after this day (first day is 0) mission cannot be completed
  84. //for mission 1
  85. int m1level;
  86. //for mission 2
  87. int m2attack, m2defence, m2power, m2knowledge;
  88. //for mission 3
  89. unsigned char m3bytes[4];
  90. //for mission 4
  91. unsigned char m4bytes[4];
  92. //for mission 5
  93. std::vector<CArtifact *> m5arts;
  94. //for mission 6
  95. std::vector<CCreature *> m6cre;
  96. std::vector<int> m6number;
  97. //for mission 7
  98. int m7wood, m7mercury, m7ore, m7sulfur, m7crystal, m7gems, m7gold;
  99. //for mission 8
  100. CHero * m8hero;
  101. //for mission 9
  102. int m9player; //number; from 0 to 7
  103. std::string firstVisitText, nextVisitText, completedText;
  104. char rewardType; //type of reward: 0 - no reward; 1 - experience; 2 - mana points; 3 - morale bonus; 4 - luck bonus; 5 - resources; 6 - main ability bonus (attak, defence etd.); 7 - secondary ability gain; 8 - artifact; 9 - spell; 10 - creature
  105. //for reward 1
  106. int r1exp;
  107. //for reward 2
  108. int r2mana;
  109. //for reward 3
  110. int r3morale;
  111. //for reward 4
  112. int r4luck;
  113. //for reward 5
  114. unsigned char r5type; //0 - wood, 1 - mercury, 2 - ore, 3 - sulfur, 4 - crystal, 5 - gems, 6 - gold
  115. int r5amount;
  116. //for reward 6
  117. unsigned char r6type; //0 - attack, 1 - defence, 2 - power, 3 - knowledge
  118. int r6amount;
  119. //for reward 7
  120. CAbility * r7ability;
  121. unsigned char r7level; //1 - basic, 2 - advanced, 3 - expert
  122. //for reward 8
  123. CArtifact * r8art;
  124. //for reward 9
  125. CSpell * r9spell;
  126. //for reward 10
  127. CCreature * r10creature;
  128. int r10amount;
  129. };
  130. class CWitchHutObjInfo : public CSpecObjInfo
  131. {
  132. public:
  133. std::vector<CAbility *> allowedAbilities;
  134. };
  135. class CScholarObjInfo : public CSpecObjInfo
  136. {
  137. public:
  138. unsigned char bonusType; //255 - random, 0 - primary skill, 1 - secondary skill, 2 - spell
  139. unsigned char r0type;
  140. CAbility * r1;
  141. CSpell * r2;
  142. };
  143. class CGarrisonObjInfo : public CSpecObjInfo
  144. {
  145. public:
  146. unsigned char player; //255 - nobody; 0 - 7 - players
  147. CCreatureSet units;
  148. bool movableUnits; //if true, units can be moved
  149. };
  150. class CArtifactObjInfo : public CSpecObjInfo
  151. {
  152. public:
  153. bool areGuards;
  154. std::string message;
  155. CCreatureSet guards;
  156. };
  157. class CResourceObjInfo : public CSpecObjInfo
  158. {
  159. public:
  160. bool randomAmount;
  161. int amount; //if not random
  162. bool areGuards;
  163. CCreatureSet guards;
  164. std::string message;
  165. };
  166. class CPlayerOnlyObjInfo : public CSpecObjInfo
  167. {
  168. public:
  169. unsigned char player; //FF - nobody, 0 - 7
  170. };
  171. class CShrineObjInfo : public CSpecObjInfo
  172. {
  173. public:
  174. unsigned char spell; //number of spell or 255
  175. };
  176. class CSpellScrollObjinfo : public CSpecObjInfo
  177. {
  178. public:
  179. std::string message;
  180. CSpell * spell;
  181. bool areGuarders;
  182. CCreatureSet guarders;
  183. };
  184. class CPandorasBoxObjInfo : public CSpecObjInfo
  185. {
  186. public:
  187. std::string message;
  188. bool areGuarders;
  189. CCreatureSet guarders;
  190. //gained things:
  191. unsigned int gainedExp;
  192. int manaDiff;
  193. int moraleDiff;
  194. int luckDiff;
  195. int wood, mercury, ore, sulfur, crystal, gems, gold;
  196. int attack, defence, power, knowledge;
  197. std::vector<CAbility *> abilities;
  198. std::vector<int> abilityLevels;
  199. std::vector<CArtifact *> artifacts;
  200. std::vector<CSpell *> spells;
  201. CCreatureSet creatures;
  202. };
  203. class CGrailObjInfo : public CSpecObjInfo
  204. {
  205. public:
  206. int radius; //place grail at the distance lesser or equal radius from this place
  207. };
  208. class CCreGenObjInfo : public CSpecObjInfo
  209. {
  210. public:
  211. unsigned char player; //owner
  212. bool asCastle;
  213. unsigned char bytes[4]; //castle identifier
  214. unsigned char castles[2]; //allowed castles
  215. };
  216. class CCreGen2ObjInfo : public CSpecObjInfo
  217. {
  218. public:
  219. unsigned char player; //owner
  220. bool asCastle;
  221. unsigned char bytes[4]; //castle identifier
  222. unsigned char castles[2]; //allowed castles
  223. unsigned char minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6>
  224. };
  225. class CCreGen3ObjInfo : public CSpecObjInfo
  226. {
  227. public:
  228. unsigned char player; //owner
  229. unsigned char minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6>
  230. };
  231. class CBorderGuardObjInfo : public CSpecObjInfo //copied form seer huts, seems to be similar
  232. {
  233. public:
  234. char missionType; //type of mission: 0 - no mission; 1 - reach level; 2 - reach main statistics values; 3 - win with a certain hero; 4 - win with a certain creature; 5 - collect some atifacts; 6 - have certain troops in army; 7 - collect resources; 8 - be a certain hero; 9 - be a certain player
  235. bool isDayLimit; //if true, there is a day limit
  236. int lastDay; //after this day (first day is 0) mission cannot be completed
  237. //for mission 1
  238. int m1level;
  239. //for mission 2
  240. int m2attack, m2defence, m2power, m2knowledge;
  241. //for mission 3
  242. unsigned char m3bytes[4];
  243. //for mission 4
  244. unsigned char m4bytes[4];
  245. //for mission 5
  246. std::vector<CArtifact *> m5arts;
  247. //for mission 6
  248. std::vector<CCreature *> m6cre;
  249. std::vector<int> m6number;
  250. //for mission 7
  251. int m7wood, m7mercury, m7ore, m7sulfur, m7crystal, m7gems, m7gold;
  252. //for mission 8
  253. CHero * m8hero;
  254. //for mission 9
  255. int m9player; //number; from 0 to 7
  256. std::string firstVisitText, nextVisitText, completedText;
  257. };
  258. class CObject //typical object that can be encountered on a map
  259. {
  260. public:
  261. std::string name; //object's name
  262. };
  263. class CObjectInstance //instance of object
  264. {
  265. public:
  266. int defNumber; //specifies number of def file with animation of this object
  267. int defObjInfoNumber; //number of this object's def's additional informations in CDefObjInfo's vector
  268. int id; //number of object in CObjectHandler's vector //TODO: absolutnie wywalic i zastapic czyms sensownym
  269. int3 pos; // position
  270. CSpecObjInfo * info; //pointer to something with additional information
  271. bool isHero; //true if this is a hero
  272. unsigned char moveDir; //direction of hero movement (0 - default; 1 - lt; 2 - t; 3 - tr; 4 - r; 5 - br; 6 - b; 7 - bl; 8 - l)
  273. bool isStanding; //true if is standing, flase if is moving
  274. unsigned char flagPrinted; //true if flag has been printed //number of print hits
  275. unsigned char owner; //if 254, object cannot have owner; if it has, it equal to owner's ID (or 255, when no owner)
  276. int getWidth() const; //returns width of object graphic in tiles
  277. int getHeight() const; //returns height of object graphic in tiles
  278. bool visitableAt(int x, int y) const; //returns true if ibject is visitable at location (x, y) form left top tile of image (x, y in tiles)
  279. bool operator<(const CObjectInstance & cmp) const; //screen printing priority comparing
  280. };
  281. class CObjectHandler
  282. {
  283. public:
  284. std::vector<CObject> objects; //vector of objects; i-th object in vector has subnumber i
  285. std::vector<CObjectInstance*> objInstances; //vector with objects on map
  286. void loadObjects();
  287. };
  288. #endif //COBJECTHANDLER_H