CObjectHandler.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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 defaultMianStats; //if true attack, defence, power and knowledge are typical
  59. };
  60. class CCreatureObjInfo : public CSpecObjInfo
  61. {
  62. public:
  63. unsigned char bytes[4]; //mysterious bytes identifying creature
  64. unsigned int number; //number of units (0 - random)
  65. unsigned char character; //chracter of this set of creatures (0 - the most friendly, 4 - the most hostile)
  66. std::string message; //message printed for attacking hero
  67. int wood, mercury, ore, sulfur, crytal, gems, gold; //resources gained to hero that has won with monsters
  68. CArtifact * gainedArtifact; //artifact gained to hero
  69. bool neverFlees; //if true, the troops will never flee
  70. bool notGrowingTeam; //if true, number of units won't grow
  71. };
  72. class CSignObjInfo : public CSpecObjInfo
  73. {
  74. public:
  75. std::string message; //message
  76. };
  77. class CSeerHutObjInfo : public CSpecObjInfo
  78. {
  79. public:
  80. 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
  81. bool isDayLimit; //if true, there is a day limit
  82. int lastDay; //after this day (first day is 0) mission cannot be completed
  83. //for mission 1
  84. int m1level;
  85. //for mission 2
  86. int m2attack, m2defence, m2power, m2knowledge;
  87. //for mission 3
  88. unsigned char m3bytes[4];
  89. //for mission 4
  90. unsigned char m4bytes[4];
  91. //for mission 5
  92. std::vector<CArtifact *> m5arts;
  93. //for mission 6
  94. std::vector<CCreature *> m6cre;
  95. std::vector<int> m6number;
  96. //for mission 7
  97. int m7wood, m7mercury, m7ore, m7sulfur, m7crystal, m7gems, m7gold;
  98. //for mission 8
  99. CHero * m8hero;
  100. //for mission 9
  101. int m9player; //number; from 0 to 7
  102. std::string firstVisitText, nextVisitText, completedText;
  103. 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
  104. //for reward 1
  105. int r1exp;
  106. //for reward 2
  107. int r2mana;
  108. //for reward 3
  109. int r3morale;
  110. //for reward 4
  111. int r4luck;
  112. //for reward 5
  113. unsigned char r5type; //0 - wood, 1 - mercury, 2 - ore, 3 - sulfur, 4 - crystal, 5 - gems, 6 - gold
  114. int r5amount;
  115. //for reward 6
  116. unsigned char r6type; //0 - attack, 1 - defence, 2 - power, 3 - knowledge
  117. int r6amount;
  118. //for reward 7
  119. CAbility * r7ability;
  120. unsigned char r7level; //1 - basic, 2 - advanced, 3 - expert
  121. //for reward 8
  122. CArtifact * r8art;
  123. //for reward 9
  124. CSpell * r9spell;
  125. //for reward 10
  126. CCreature * r10creature;
  127. int r10amount;
  128. };
  129. class CWitchHutObjInfo : public CSpecObjInfo
  130. {
  131. public:
  132. std::vector<CAbility *> allowedAbilities;
  133. };
  134. class CScholarObjInfo : public CSpecObjInfo
  135. {
  136. public:
  137. unsigned char bonusType; //255 - random, 0 - primary skill, 1 - secondary skill, 2 - spell
  138. unsigned char r0type;
  139. CAbility * r1;
  140. CSpell * r2;
  141. };
  142. class CGarrisonObjInfo : public CSpecObjInfo
  143. {
  144. public:
  145. unsigned char player; //255 - nobody; 0 - 7 - players
  146. CCreatureSet units;
  147. bool movableUnits; //if true, units can be moved
  148. };
  149. class CArtifactObjInfo : public CSpecObjInfo
  150. {
  151. public:
  152. bool areGuards;
  153. std::string message;
  154. CCreatureSet guards;
  155. };
  156. class CResourceObjInfo : public CSpecObjInfo
  157. {
  158. public:
  159. bool randomAmount;
  160. int amount; //if not random
  161. bool areGuards;
  162. CCreatureSet guards;
  163. std::string message;
  164. };
  165. class CPlayerOnlyObjInfo : public CSpecObjInfo
  166. {
  167. public:
  168. unsigned char player; //FF - nobody, 0 - 7
  169. };
  170. class CShrineObjInfo : public CSpecObjInfo
  171. {
  172. public:
  173. unsigned char spell; //number of spell or 255
  174. };
  175. class CSpellScrollObjinfo : public CSpecObjInfo
  176. {
  177. public:
  178. std::string message;
  179. CSpell * spell;
  180. bool areGuarders;
  181. CCreatureSet guarders;
  182. };
  183. class CPandorasBoxObjInfo : public CSpecObjInfo
  184. {
  185. public:
  186. std::string message;
  187. bool areGuarders;
  188. CCreatureSet guarders;
  189. //gained things:
  190. unsigned int gainedExp;
  191. int manaDiff;
  192. int moraleDiff;
  193. int luckDiff;
  194. int wood, mercury, ore, sulfur, crystal, gems, gold;
  195. int attack, defence, power, knowledge;
  196. std::vector<CAbility *> abilities;
  197. std::vector<int> abilityLevels;
  198. std::vector<CArtifact *> artifacts;
  199. std::vector<CSpell *> spells;
  200. CCreatureSet creatures;
  201. };
  202. class CGrailObjInfo : public CSpecObjInfo
  203. {
  204. public:
  205. int radius; //place grail at the distance lesser or equal radius from this place
  206. };
  207. class CCreGenObjInfo : public CSpecObjInfo
  208. {
  209. public:
  210. unsigned char player; //owner
  211. bool asCastle;
  212. unsigned char bytes[4]; //castle identifier
  213. unsigned char castles[2]; //allowed castles
  214. };
  215. class CCreGen2ObjInfo : public CSpecObjInfo
  216. {
  217. public:
  218. unsigned char player; //owner
  219. bool asCastle;
  220. unsigned char bytes[4]; //castle identifier
  221. unsigned char castles[2]; //allowed castles
  222. unsigned char minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6>
  223. };
  224. class CCreGen3ObjInfo : public CSpecObjInfo
  225. {
  226. public:
  227. unsigned char player; //owner
  228. unsigned char minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6>
  229. };
  230. class CBorderGuardObjInfo : public CSpecObjInfo //copied form seer huts, seems to be similar
  231. {
  232. public:
  233. 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
  234. bool isDayLimit; //if true, there is a day limit
  235. int lastDay; //after this day (first day is 0) mission cannot be completed
  236. //for mission 1
  237. int m1level;
  238. //for mission 2
  239. int m2attack, m2defence, m2power, m2knowledge;
  240. //for mission 3
  241. unsigned char m3bytes[4];
  242. //for mission 4
  243. unsigned char m4bytes[4];
  244. //for mission 5
  245. std::vector<CArtifact *> m5arts;
  246. //for mission 6
  247. std::vector<CCreature *> m6cre;
  248. std::vector<int> m6number;
  249. //for mission 7
  250. int m7wood, m7mercury, m7ore, m7sulfur, m7crystal, m7gems, m7gold;
  251. //for mission 8
  252. CHero * m8hero;
  253. //for mission 9
  254. int m9player; //number; from 0 to 7
  255. std::string firstVisitText, nextVisitText, completedText;
  256. };
  257. class CObject //typical object that can be encountered on a map
  258. {
  259. public:
  260. std::string name; //object's name
  261. };
  262. class CObjectInstance //instance of object
  263. {
  264. public:
  265. int defNumber; //specifies number of def file with animation of this object
  266. int id; //number of object in CObjectHandler's vector
  267. int x, y, z; // position
  268. CSpecObjInfo * info; //pointer to something with additional information
  269. };
  270. class CObjectHandler
  271. {
  272. public:
  273. std::vector<CObject> objects; //vector of objects; i-th object in vector has subnumber i
  274. std::vector<CObjectInstance> objInstances; //vector with objects on map
  275. void loadObjects();
  276. };
  277. #endif //COBJECTHANDLER_H