CObjectHandler.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161
  1. #ifndef __COBJECTHANDLER_H__
  2. #define __COBJECTHANDLER_H__
  3. #include "../global.h"
  4. #include <string>
  5. #include <vector>
  6. #include <set>
  7. #include <map>
  8. #include <list>
  9. #include "CCreatureHandler.h"
  10. #include "../lib/HeroBonus.h"
  11. #ifndef _MSC_VER
  12. #include "CHeroHandler.h"
  13. #include "CTownHandler.h"
  14. #include "../lib/VCMI_Lib.h"
  15. #endif
  16. /*
  17. * CObjectHandler.h, part of VCMI engine
  18. *
  19. * Authors: listed in file AUTHORS in main folder
  20. *
  21. * License: GNU General Public License v2.0 or later
  22. * Full text of license available in license.txt file, in main folder
  23. *
  24. */
  25. class IGameCallback;
  26. struct BattleResult;
  27. class CCPPObjectScript;
  28. class CGObjectInstance;
  29. class CScript;
  30. class CObjectScript;
  31. class CGHeroInstance;
  32. class CTown;
  33. class CHero;
  34. class CBuilding;
  35. class CSpell;
  36. class CGTownInstance;
  37. class CGTownBuilding;
  38. class CArtifact;
  39. class CGDefInfo;
  40. class CSpecObjInfo;
  41. struct TerrainTile;
  42. struct InfoWindow;
  43. struct Component;
  44. struct BankConfig;
  45. class CGBoat;
  46. class DLL_EXPORT CCastleEvent
  47. {
  48. public:
  49. std::string name, message;
  50. std::vector<si32> resources; //gain / loss of resources
  51. ui8 players; //players for whom this event can be applied
  52. ui8 forHuman, forComputer;
  53. ui32 firstShow; //postpone of first encounter time in days
  54. ui32 forEvery; //every n days this event will occure
  55. ui8 bytes[6]; //build specific buildings (raw format, similar to town's)
  56. si32 gen[7]; //additional creatures in i-th level dwelling
  57. bool operator<(const CCastleEvent &drugie) const
  58. {
  59. return firstShow<drugie.firstShow;
  60. }
  61. template <typename Handler> void serialize(Handler &h, const int version)
  62. {
  63. h & name & message & resources & players & forHuman & forComputer & firstShow
  64. & forEvery & bytes & gen;
  65. }
  66. };
  67. class DLL_EXPORT CQuest
  68. {
  69. public:
  70. enum Emission {MISSION_NONE = 0, MISSION_LEVEL = 1, MISSION_PRIMARY_STAT = 2, MISSION_KILL_HERO = 3, MISSION_KILL_CREATURE = 4,
  71. MISSION_ART = 5, MISSION_ARMY = 6, MISSION_RESOURCES = 7, MISSION_HERO = 8, MISSION_PLAYER = 9};
  72. ui8 missionType, progress;
  73. si32 lastDay; //after this day (first day is 0) mission cannot be completed; if -1 - no limit
  74. ui32 m13489val;
  75. std::vector<ui32> m2stats;
  76. std::vector<ui16> m5arts; //artifacts id
  77. TSlots m6creatures; //pair[cre id, cre count], CreatureSet info irrelevant
  78. std::vector<ui32> m7resources;
  79. std::string firstVisitText, nextVisitText, completedText;
  80. bool checkQuest (const CGHeroInstance * h) const; //determines whether the quest is complete or not
  81. virtual void completeQuest (const CGHeroInstance * h) const {};
  82. template <typename Handler> void serialize(Handler &h, const int version)
  83. {
  84. h & missionType & progress & lastDay & m13489val & m2stats & m5arts & m6creatures & m7resources
  85. & firstVisitText & nextVisitText & completedText;
  86. }
  87. };
  88. class DLL_EXPORT IObjectInterface
  89. {
  90. public:
  91. static IGameCallback *cb;
  92. IObjectInterface();
  93. virtual ~IObjectInterface();
  94. virtual void onHeroVisit(const CGHeroInstance * h) const;
  95. virtual void onHeroLeave(const CGHeroInstance * h) const;
  96. virtual void newTurn() const;
  97. virtual void initObj(); //synchr
  98. virtual void setProperty(ui8 what, ui32 val);//synchr
  99. static void preInit(); //called before objs receive their initObj
  100. static void postInit();//caleed after objs receive their initObj
  101. };
  102. class DLL_EXPORT IShipyard
  103. {
  104. public:
  105. const CGObjectInstance *o;
  106. IShipyard(const CGObjectInstance *O);
  107. virtual void getBoatCost(std::vector<si32> &cost) const;
  108. virtual int getBoatType() const; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral
  109. virtual void getOutOffsets(std::vector<int3> &offsets) const =0; //offsets to obj pos when we boat can be placed
  110. //virtual bool validLocation() const; //returns true if there is a water tile near where boat can be placed
  111. int3 bestLocation() const; //returns location when the boat should be placed
  112. int state() const; //0 - can buid, 1 - there is already a boat at dest tile, 2 - dest tile is blocked, 3 - no water
  113. static const IShipyard *castFrom(const CGObjectInstance *obj);
  114. static IShipyard *castFrom(CGObjectInstance *obj);
  115. };
  116. class DLL_EXPORT CGObjectInstance : public IObjectInterface
  117. {
  118. protected:
  119. void getNameVis(std::string &hname) const;
  120. void giveDummyBonus(int heroID, ui8 duration = HeroBonus::ONE_DAY) const;
  121. public:
  122. mutable std::string hoverName;
  123. int3 pos; //h3m pos
  124. si32 ID, subID; //normal ID (this one from OH3 maps ;]) - eg. town=98; hero=34
  125. si32 id;//number of object in CObjectHandler's vector
  126. CGDefInfo * defInfo;
  127. CSpecObjInfo * info;
  128. ui8 animPhaseShift;
  129. ui8 tempOwner;
  130. ui8 blockVisit; //if non-zero then blocks the tile but is visitable from neighbouring tile
  131. virtual ui8 getPassableness() const; //bitmap - if the bit is set the corresponding player can pass through the visitable tiles of object, even if it's blockvis; if not set - default properties from definfo are used
  132. virtual int3 getSightCenter() const; //"center" tile from which the sight distance is calculated
  133. virtual int getSightRadious() const; //sight distance (should be used if player-owned structure)
  134. void getSightTiles(std::set<int3> &tiles) const; //returns reference to the set
  135. int getOwner() const;
  136. void setOwner(int ow);
  137. int getWidth() const; //returns width of object graphic in tiles
  138. int getHeight() const; //returns height of object graphic in tiles
  139. bool visitableAt(int x, int y) const; //returns true if object is visitable at location (x, y) form left top tile of image (x, y in tiles)
  140. int3 getVisitableOffset() const; //returns (x,y,0) offset to first visitable tile from bottom right obj tile (0,0,0) (h3m pos)
  141. bool blockingAt(int x, int y) const; //returns true if object is blocking location (x, y) form left top tile of image (x, y in tiles)
  142. bool coveringAt(int x, int y) const; //returns true if object covers with picture location (x, y) form left top tile of maximal possible image (8 x 6 tiles) (x, y in tiles)
  143. std::set<int3> getBlockedPos() const; //returns set of positions blocked by this object
  144. bool operator<(const CGObjectInstance & cmp) const; //screen printing priority comparing
  145. CGObjectInstance();
  146. virtual ~CGObjectInstance();
  147. //CGObjectInstance(const CGObjectInstance & right);
  148. //CGObjectInstance& operator=(const CGObjectInstance & right);
  149. virtual const std::string & getHoverText() const;
  150. //////////////////////////////////////////////////////////////////////////
  151. void initObj();
  152. void onHeroVisit(const CGHeroInstance * h) const;
  153. void setProperty(ui8 what, ui32 val);//synchr
  154. virtual void setPropertyDer(ui8 what, ui32 val);//synchr
  155. friend class CGameHandler;
  156. template <typename Handler> void serialize(Handler &h, const int version)
  157. {
  158. h & hoverName & pos & ID & subID & id & animPhaseShift & tempOwner & blockVisit;
  159. //definfo is handled by map serializer
  160. }
  161. };
  162. class CGHeroPlaceholder : public CGObjectInstance
  163. {
  164. public:
  165. //subID stores id of hero type. If it's 0xff then following field is used
  166. ui8 power;
  167. template <typename Handler> void serialize(Handler &h, const int version)
  168. {
  169. h & static_cast<CGObjectInstance&>(*this);
  170. h & power;
  171. }
  172. };
  173. class DLL_EXPORT CPlayersVisited: public CGObjectInstance
  174. {
  175. public:
  176. std::set<ui8> players; //players that visited this object
  177. bool hasVisited(ui8 player) const;
  178. virtual void setPropertyDer( ui8 what, ui32 val );
  179. template <typename Handler> void serialize(Handler &h, const int version)
  180. {
  181. h & static_cast<CGObjectInstance&>(*this);
  182. h & players;
  183. }
  184. };
  185. class DLL_EXPORT CArmedInstance: public CGObjectInstance
  186. {
  187. public:
  188. CCreatureSet army; //army
  189. virtual bool needsLastStack() const; //true if last stack cannot be taken
  190. int getArmyStrength() const; //sum of AI values of creatures
  191. ui64 getPower (TSlot slot) const; //value of specific stack
  192. std::string getRoughAmount (TSlot slot) const; //rought size of specific stack
  193. template <typename Handler> void serialize(Handler &h, const int version)
  194. {
  195. h & static_cast<CGObjectInstance&>(*this);
  196. h & army;
  197. }
  198. };
  199. class DLL_EXPORT CGHeroInstance : public CArmedInstance
  200. {
  201. public:
  202. //////////////////////////////////////////////////////////////////////////
  203. ui8 moveDir; //format: 123
  204. // 8 4
  205. // 765
  206. mutable ui8 isStanding, tacticFormationEnabled;
  207. //////////////////////////////////////////////////////////////////////////
  208. CHero * type;
  209. ui64 exp; //experience points
  210. si32 level; //current level of hero
  211. std::string name; //may be custom
  212. std::string biography; //if custom
  213. si32 portrait; //may be custom
  214. si32 mana; // remaining spell points
  215. std::vector<si32> primSkills; //0-attack, 1-defence, 2-spell power, 3-knowledge
  216. std::vector<std::pair<ui8,ui8> > secSkills; //first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert); if hero has ability (-1, -1) it meansthat it should have default secondary abilities
  217. si32 movement; //remaining movement points
  218. ui8 sex;
  219. ui8 inTownGarrison; // if hero is in town garrison
  220. CGTownInstance * visitedTown; //set if hero is visiting town or in the town garrison
  221. CGBoat *boat; //set to CGBoat when sailing
  222. std::vector<ui32> artifacts; //hero's artifacts from bag
  223. std::map<ui16,ui32> artifWorn; //map<position,artifact_id>; positions: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
  224. std::set<ui32> spells; //known spells (spell IDs)
  225. struct DLL_EXPORT Patrol
  226. {
  227. Patrol(){patrolling=false;patrolRadious=-1;};
  228. ui8 patrolling;
  229. si32 patrolRadious;
  230. template <typename Handler> void serialize(Handler &h, const int version)
  231. {
  232. h & patrolling & patrolRadious;
  233. }
  234. } patrol;
  235. BonusList bonuses;
  236. //////////////////////////////////////////////////////////////////////////
  237. template <typename Handler> void serialize(Handler &h, const int version)
  238. {
  239. h & static_cast<CArmedInstance&>(*this);
  240. h & exp & level & name & biography & portrait & mana & primSkills & secSkills & movement
  241. & sex & inTownGarrison & artifacts & artifWorn & spells & patrol & bonuses
  242. & moveDir;
  243. ui8 standardType = (VLC->heroh->heroes[subID] == type);
  244. h & standardType;
  245. if(!standardType)
  246. h & type;
  247. else if(!h.saving)
  248. type = VLC->heroh->heroes[subID];
  249. //visitied town pointer will be restored by map serialization method
  250. }
  251. //////////////////////////////////////////////////////////////////////////
  252. int3 getSightCenter() const; //"center" tile from which the sight distance is calculated
  253. int getSightRadious() const; //sight distance (should be used if player-owned structure)
  254. //////////////////////////////////////////////////////////////////////////
  255. const std::string &getBiography() const;
  256. bool needsLastStack()const;
  257. unsigned int getTileCost(const TerrainTile &dest, const TerrainTile &from) const; //move cost - applying pathfinding skill, road and terrain modifiers. NOT includes diagonal move penalty, last move levelling
  258. unsigned int getLowestCreatureSpeed() const;
  259. int3 getPosition(bool h3m) const; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
  260. si32 manaLimit() const; //maximum mana value for this hero (basically 10*knowledge)
  261. si32 manaRegain() const; //how many points of mana can hero regain "naturally" in one day
  262. bool canWalkOnSea() const;
  263. int getCurrentLuck(int stack=-1, bool town=false) const;
  264. const BonusList *ownerBonuses() const;
  265. const HeroBonus *getBonus(int from, int id) const;
  266. int valOfBonuses(HeroBonus::BonusType type, int subtype = -1) const; //subtype -> subtype of bonus, if -1 then any
  267. bool hasBonusOfType(HeroBonus::BonusType type, int subtype = -1) const; //determines if hero has a bonus of given type (and optionally subtype)
  268. void getModifiersWDescr(std::vector<std::pair<int,std::string> > &out, HeroBonus::BonusType type, int subtype = -1) const; //out: pairs<modifier value, modifier description>
  269. template<int N> void getModifiersWDescr(std::vector<std::pair<int,std::string> > &out, const HeroBonus::BonusType (&types)[N]) const //retreive array of types
  270. {
  271. for (int i = 0; i < N; i++)
  272. getModifiersWDescr(out, types[i]);
  273. }
  274. std::vector<std::pair<int,std::string> > getCurrentLuckModifiers(int stack=-1, bool town=false) const; //args as above
  275. int getCurrentMorale(int stack=-1, bool town=false) const; //if stack - position of creature, if -1 then morale for hero is calculated; town - if bonuses from town (tavern) should be considered
  276. std::vector<std::pair<int,std::string> > getCurrentMoraleModifiers(int stack=-1, bool town=false) const; //args as above
  277. int getPrimSkillLevel(int id) const; //0-attack, 1-defence, 2-spell power, 3-knowledge
  278. ui8 getSecSkillLevel(const int & ID) const; //0 - no skill
  279. int maxMovePoints(bool onLand) const;
  280. ui32 getArtAtPos(ui16 pos) const; //-1 - no artifact
  281. const CArtifact * getArt(int pos) const;
  282. si32 getArtPos(int aid) const; //looks for equipped artifact with given ID and returns its slot ID or -1 if none(if more than one such artifact lower ID is returned)
  283. bool hasArt(ui32 aid) const; //checks if hero possess artifact of given id (either in backack or worn)
  284. int getSpellSecLevel(int spell) const; //returns level of secondary ability (fire, water, earth, air magic) known to this hero and applicable to given spell; -1 if error
  285. static int3 convertPosition(int3 src, bool toh3m); //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest
  286. double getHeroStrength() const;
  287. int getTotalStrength() const;
  288. ui8 getSpellSchoolLevel(const CSpell * spell) const; //returns level on which given spell would be cast by this hero (0 - none, 1 - basic etc)
  289. bool canCastThisSpell(const CSpell * spell) const; //determines if this hero can cast given spell; takes into account existing spell in spellbook, existing spellbook and artifact bonuses
  290. std::pair<ui32, si32> calculateNecromancy (const BattleResult &battleResult) const;
  291. void showNecromancyDialog (std::pair<ui32, si32> raisedStack) const;
  292. //////////////////////////////////////////////////////////////////////////
  293. void initHero();
  294. void initHero(int SUBID);
  295. void recreateArtBonuses();
  296. void giveArtifact (ui32 aid);
  297. void initHeroDefInfo();
  298. CGHeroInstance();
  299. virtual ~CGHeroInstance();
  300. //////////////////////////////////////////////////////////////////////////
  301. void setPropertyDer(ui8 what, ui32 val);//synchr
  302. void initObj();
  303. void onHeroVisit(const CGHeroInstance * h) const;
  304. };
  305. class DLL_EXPORT CGDwelling : public CArmedInstance
  306. {
  307. public:
  308. std::vector<std::pair<ui32, std::vector<ui32> > > creatures; //creatures[level] -> <vector of alternative ids (base creature and upgrades, creatures amount>
  309. template <typename Handler> void serialize(Handler &h, const int version)
  310. {
  311. h & static_cast<CArmedInstance&>(*this) & creatures;
  312. }
  313. void initObj();
  314. void setProperty(ui8 what, ui32 val);
  315. void onHeroVisit(const CGHeroInstance * h) const;
  316. void newTurn() const;
  317. void heroAcceptsCreatures(const CGHeroInstance *h, ui32 answer) const;
  318. void fightOver(const CGHeroInstance *h, BattleResult *result) const;
  319. void wantsFight(const CGHeroInstance *h, ui32 answer) const;
  320. };
  321. class DLL_EXPORT CGVisitableOPH : public CGObjectInstance //objects visitable only once per hero
  322. {
  323. public:
  324. std::set<si32> visitors; //ids of heroes who have visited this obj
  325. si8 ttype; //tree type - used only by trees of knowledge: 0 - give level for free; 1 - take 2000 gold; 2 - take 10 gems
  326. const std::string & getHoverText() const;
  327. void setPropertyDer(ui8 what, ui32 val);//synchr
  328. void onHeroVisit(const CGHeroInstance * h) const;
  329. void onNAHeroVisit(int heroID, bool alreadyVisited) const;
  330. void initObj();
  331. void treeSelected(int heroID, int resType, int resVal, ui64 expVal, ui32 result) const; //handle player's anwer to the Tree of Knowledge dialog
  332. void schoolSelected(int heroID, ui32 which) const;
  333. void arenaSelected(int heroID, int primSkill) const;
  334. template <typename Handler> void serialize(Handler &h, const int version)
  335. {
  336. h & static_cast<CGObjectInstance&>(*this);
  337. h & visitors & ttype;
  338. }
  339. };
  340. class DLL_EXPORT CGTownBuilding : public IObjectInterface
  341. {
  342. ///basic class for town structures handled as map objects
  343. public:
  344. si32 ID; //from buildig list
  345. si32 id; //identifies its index on towns vector
  346. CGTownInstance *town;
  347. template <typename Handler> void serialize(Handler &h, const int version)
  348. {
  349. h & ID & id;
  350. }
  351. };
  352. class DLL_EXPORT COPWBonus : public CGTownBuilding
  353. {///used for OPW bonusing structures
  354. public:
  355. std::set<si32> visitors;
  356. void setProperty(ui8 what, ui32 val);
  357. void onHeroVisit (const CGHeroInstance * h) const;
  358. COPWBonus (int index, CGTownInstance *TOWN);
  359. COPWBonus (){ID = 0; town = NULL;};
  360. template <typename Handler> void serialize(Handler &h, const int version)
  361. {
  362. h & static_cast<CGTownBuilding&>(*this);
  363. h & visitors;
  364. }
  365. };
  366. class DLL_EXPORT CTownBonus : public CGTownBuilding
  367. {
  368. ///used for one-time bonusing structures
  369. ///feel free to merge inheritance tree
  370. public:
  371. std::set<si32> visitors;
  372. void setProperty(ui8 what, ui32 val);
  373. void onHeroVisit (const CGHeroInstance * h) const;
  374. CTownBonus (int index, CGTownInstance *TOWN);
  375. CTownBonus (){ID = 0; town = NULL;};
  376. template <typename Handler> void serialize(Handler &h, const int version)
  377. {
  378. h & static_cast<CGTownBuilding&>(*this);
  379. h & visitors;
  380. }
  381. };
  382. class DLL_EXPORT CGTownInstance : public CGDwelling, public IShipyard
  383. {
  384. public:
  385. CTown * town;
  386. std::string name; // name of town
  387. si32 builded; //how many buildings has been built this turn
  388. si32 destroyed; //how many buildings has been destroyed this turn
  389. const CGHeroInstance * garrisonHero, *visitingHero;
  390. ui32 identifier; //special identifier from h3m (only > RoE maps)
  391. si32 alignment;
  392. std::set<si32> forbiddenBuildings, builtBuildings;
  393. std::vector<CGTownBuilding*> bonusingBuildings;
  394. std::vector<ui32> possibleSpells, obligatorySpells;
  395. std::vector<std::vector<ui32> > spells; //spells[level] -> vector of spells, first will be available in guild
  396. std::set<CCastleEvent> events;
  397. std::pair<si32, si32> bonusValue;//var to store town bonuses (rampart = resources from mystic pond);
  398. //////////////////////////////////////////////////////////////////////////
  399. template <typename Handler> void serialize(Handler &h, const int version)
  400. {
  401. h & static_cast<CGDwelling&>(*this);
  402. h & name & builded & destroyed & identifier & alignment & forbiddenBuildings & builtBuildings & bonusValue
  403. & possibleSpells & obligatorySpells & spells & /*strInfo & */events & bonusingBuildings;
  404. for (std::vector<CGTownBuilding*>::iterator i = bonusingBuildings.begin(); i!=bonusingBuildings.end(); i++)
  405. (*i)->town = this;
  406. ui8 standardType = (&VLC->townh->towns[subID] == town);
  407. h & standardType;
  408. if(!standardType)
  409. h & town;
  410. else if(!h.saving)
  411. town = &VLC->townh->towns[subID];
  412. //garrison/visiting hero pointers will be restored in the map serialization
  413. }
  414. //////////////////////////////////////////////////////////////////////////
  415. ui8 getPassableness() const; //bitmap - if the bit is set the corresponding player can pass through the visitable tiles of object, even if it's blockvis; if not set - default properties from definfo are used
  416. int3 getSightCenter() const; //"center" tile from which the sight distance is calculated
  417. int getSightRadious() const; //returns sight distance
  418. int getBoatType() const; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral
  419. void getOutOffsets(std::vector<int3> &offsets) const; //offsets to obj pos when we boat can be placed
  420. void setPropertyDer(ui8 what, ui32 val);
  421. void newTurn() const;
  422. //////////////////////////////////////////////////////////////////////////
  423. bool needsLastStack() const;
  424. int fortLevel() const; //0 - none, 1 - fort, 2 - citadel, 3 - castle
  425. int hallLevel() const; // -1 - none, 0 - village, 1 - town, 2 - city, 3 - capitol
  426. int mageGuildLevel() const; // -1 - none, 0 - village, 1 - town, 2 - city, 3 - capitol
  427. bool creatureDwelling(const int & level, bool upgraded=false) const;
  428. int getHordeLevel(const int & HID) const; //HID - 0 or 1; returns creature level or -1 if that horde structure is not present
  429. int creatureGrowth(const int & level) const;
  430. bool hasFort() const;
  431. bool hasCapitol() const;
  432. int dailyIncome() const; //calculates daily income of this town
  433. int spellsAtLevel(int level, bool checkGuild) const; //levels are counted from 1 (1 - 5)
  434. void removeCapitols (ui8 owner, bool me) const;
  435. int defenceBonus(int type) const;//primary skills bonuses for defending hero
  436. CGTownInstance();
  437. virtual ~CGTownInstance();
  438. //////////////////////////////////////////////////////////////////////////
  439. void fightOver(const CGHeroInstance *h, BattleResult *result) const;
  440. void onHeroVisit(const CGHeroInstance * h) const;
  441. void onHeroLeave(const CGHeroInstance * h) const;
  442. void initObj();
  443. };
  444. class DLL_EXPORT CGPandoraBox : public CArmedInstance
  445. {
  446. public:
  447. std::string message;
  448. ui8 removeAfterVisit; //true if event is removed after occurring
  449. //gained things:
  450. ui32 gainedExp;
  451. si32 manaDiff; //amount of gained / lost mana
  452. si32 moraleDiff; //morale modifier
  453. si32 luckDiff; //luck modifier
  454. std::vector<si32> resources;//gained / lost resources
  455. std::vector<si32> primskills;//gained / lost resources
  456. std::vector<si32> abilities; //gained abilities
  457. std::vector<si32> abilityLevels; //levels of gained abilities
  458. std::vector<si32> artifacts; //gained artifacts
  459. std::vector<si32> spells; //gained spells
  460. CCreatureSet creatures; //gained creatures
  461. void initObj();
  462. void onHeroVisit(const CGHeroInstance * h) const;
  463. void open (const CGHeroInstance * h, ui32 accept) const;
  464. void endBattle(const CGHeroInstance *h, BattleResult *result) const;
  465. void giveContents(const CGHeroInstance *h, bool afterBattle) const;
  466. void getText( InfoWindow &iw, bool &afterBattle, int val, int negative, int positive, const CGHeroInstance * h ) const;
  467. void getText( InfoWindow &iw, bool &afterBattle, int text, const CGHeroInstance * h ) const;
  468. template <typename Handler> void serialize(Handler &h, const int version)
  469. {
  470. h & static_cast<CArmedInstance&>(*this);
  471. h & message & gainedExp & manaDiff & moraleDiff & luckDiff & resources & primskills
  472. & abilities & abilityLevels & artifacts & spells & creatures & army;
  473. }
  474. };
  475. class DLL_EXPORT CGEvent : public CGPandoraBox //event objects
  476. {
  477. public:
  478. ui8 availableFor; //players whom this event is available for
  479. ui8 computerActivate; //true if computre player can activate this event
  480. ui8 humanActivate; //true if human player can activate this event
  481. template <typename Handler> void serialize(Handler &h, const int version)
  482. {
  483. h & static_cast<CArmedInstance&>(*this);
  484. h & message & gainedExp & manaDiff & moraleDiff & luckDiff & resources & primskills
  485. & abilities & abilityLevels & artifacts & spells & creatures & availableFor
  486. & computerActivate & humanActivate & army;
  487. }
  488. void onHeroVisit(const CGHeroInstance * h) const;
  489. void activated(const CGHeroInstance * h) const;
  490. };
  491. class DLL_EXPORT CGCreature : public CArmedInstance //creatures on map
  492. {
  493. public:
  494. ui32 identifier; //unique code for this monster (used in missions)
  495. si8 character; //chracter of this set of creatures (0 - the most friendly, 4 - the most hostile) => on init changed to 0 (compliant) - 10 value (savage)
  496. std::string message; //message printed for attacking hero
  497. std::vector<ui32> resources; //[res_id], resources given to hero that has won with monsters
  498. si32 gainedArtifact; //ID of artifact gained to hero, -1 if none
  499. ui8 neverFlees; //if true, the troops will never flee
  500. ui8 notGrowingTeam; //if true, number of units won't grow
  501. void fight(const CGHeroInstance *h) const;
  502. void onHeroVisit(const CGHeroInstance * h) const;
  503. //const std::string & getHoverText() const;
  504. void flee( const CGHeroInstance * h ) const;
  505. void endBattle(BattleResult *result) const;
  506. void fleeDecision(const CGHeroInstance *h, ui32 pursue) const;
  507. void joinDecision(const CGHeroInstance *h, int cost, ui32 accept) const;
  508. void initObj();
  509. int takenAction(const CGHeroInstance *h, bool allowJoin=true) const; //action on confrontation: -2 - fight, -1 - flee, >=0 - will join for given value of gold (may be 0)
  510. template <typename Handler> void serialize(Handler &h, const int version)
  511. {
  512. h & static_cast<CArmedInstance&>(*this);
  513. h & identifier & character & message & resources & gainedArtifact & neverFlees & notGrowingTeam;
  514. }
  515. };
  516. class DLL_EXPORT CGSignBottle : public CGObjectInstance //signs and ocean bottles
  517. {
  518. public:
  519. std::string message;
  520. void onHeroVisit(const CGHeroInstance * h) const;
  521. void initObj();
  522. template <typename Handler> void serialize(Handler &h, const int version)
  523. {
  524. h & static_cast<CGObjectInstance&>(*this);
  525. h & message;
  526. }
  527. };
  528. class DLL_EXPORT CGSeerHut : public CGObjectInstance, public CQuest
  529. {
  530. public:
  531. ui8 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
  532. si32 rID; //reward ID
  533. si32 rVal; //reward value
  534. ui8 textOption; //store randomized mission write-ups rather than entire string (?)
  535. std::string seerName;
  536. void initObj();
  537. const std::string & getHoverText() const;
  538. void setPropertyDer (ui8 what, ui32 val);
  539. int checkDirection() const; //calculates the region of map where monster is placed
  540. void newTurn() const;
  541. void onHeroVisit (const CGHeroInstance * h) const;
  542. void finishQuest (const CGHeroInstance * h, ui32 accept) const; //common for both objects
  543. void completeQuest (const CGHeroInstance * h) const;
  544. template <typename Handler> void serialize(Handler &h, const int version)
  545. {
  546. h & static_cast<CGObjectInstance&>(*this) & static_cast<CQuest&>(*this);
  547. h & rewardType & rID & rVal & textOption & seerName;
  548. }
  549. };
  550. class DLL_EXPORT CGQuestGuard : public CGSeerHut
  551. {
  552. public:
  553. void initObj();
  554. void completeQuest (const CGHeroInstance * h) const;
  555. template <typename Handler> void serialize(Handler &h, const int version)
  556. {
  557. h & static_cast<CGSeerHut&>(*this);
  558. }
  559. };
  560. class DLL_EXPORT CGWitchHut : public CPlayersVisited
  561. {
  562. public:
  563. std::vector<si32> allowedAbilities;
  564. ui32 ability;
  565. const std::string & getHoverText() const;
  566. void onHeroVisit(const CGHeroInstance * h) const;
  567. void initObj();
  568. template <typename Handler> void serialize(Handler &h, const int version)
  569. {
  570. h & static_cast<CPlayersVisited&>(*this);
  571. h & allowedAbilities & ability;
  572. }
  573. };
  574. class DLL_EXPORT CGScholar : public CGObjectInstance
  575. {
  576. public:
  577. ui8 bonusType; //255 - random, 0 - primary skill, 1 - secondary skill, 2 - spell
  578. ui16 bonusID; //ID of skill/spell
  579. void giveAnyBonus(const CGHeroInstance * h) const;
  580. void onHeroVisit(const CGHeroInstance * h) const;
  581. void initObj();
  582. template <typename Handler> void serialize(Handler &h, const int version)
  583. {
  584. h & static_cast<CGObjectInstance&>(*this);
  585. h & bonusType & bonusID;
  586. }
  587. };
  588. class DLL_EXPORT CGGarrison : public CArmedInstance
  589. {
  590. public:
  591. ui8 removableUnits;
  592. ui8 getPassableness() const;
  593. void onHeroVisit (const CGHeroInstance *h) const;
  594. void fightOver (const CGHeroInstance *h, BattleResult *result) const;
  595. template <typename Handler> void serialize(Handler &h, const int version)
  596. {
  597. h & static_cast<CArmedInstance&>(*this);
  598. h & removableUnits;
  599. }
  600. };
  601. class DLL_EXPORT CGArtifact : public CArmedInstance
  602. {
  603. public:
  604. std::string message;
  605. ui32 spell; //if it's spell scroll
  606. void onHeroVisit(const CGHeroInstance * h) const;
  607. void fightForArt(ui32 agreed, const CGHeroInstance *h) const;
  608. void endBattle(BattleResult *result, const CGHeroInstance *h) const;
  609. void pick( const CGHeroInstance * h ) const;
  610. void initObj();
  611. template <typename Handler> void serialize(Handler &h, const int version)
  612. {
  613. h & static_cast<CArmedInstance&>(*this);
  614. h & message & spell;
  615. }
  616. };
  617. class DLL_EXPORT CGResource : public CArmedInstance
  618. {
  619. public:
  620. ui32 amount; //0 if random
  621. std::string message;
  622. void onHeroVisit(const CGHeroInstance * h) const;
  623. void collectRes(int player) const;
  624. void initObj();
  625. void fightForRes(ui32 agreed, const CGHeroInstance *h) const;
  626. void endBattle(BattleResult *result, const CGHeroInstance *h) const;
  627. template <typename Handler> void serialize(Handler &h, const int version)
  628. {
  629. h & static_cast<CArmedInstance&>(*this);
  630. h & amount & message;
  631. }
  632. };
  633. class DLL_EXPORT CGPickable : public CGObjectInstance //campfire, treasure chest, Flotsam, Shipwreck Survivor, Sea Chest
  634. {
  635. public:
  636. ui32 type, val1, val2;
  637. void onHeroVisit(const CGHeroInstance * h) const;
  638. void initObj();
  639. void chosen(int which, int heroID) const;
  640. template <typename Handler> void serialize(Handler &h, const int version)
  641. {
  642. h & static_cast<CGObjectInstance&>(*this);
  643. h & type & val1 & val2;
  644. }
  645. };
  646. class DLL_EXPORT CGShrine : public CPlayersVisited
  647. {
  648. public:
  649. ui8 spell; //number of spell or 255 if random
  650. void onHeroVisit(const CGHeroInstance * h) const;
  651. void initObj();
  652. const std::string & getHoverText() const;
  653. template <typename Handler> void serialize(Handler &h, const int version)
  654. {
  655. h & static_cast<CPlayersVisited&>(*this);;
  656. h & spell;
  657. }
  658. };
  659. class DLL_EXPORT CGMine : public CArmedInstance
  660. {
  661. public:
  662. void offerLeavingGuards(const CGHeroInstance *h) const;
  663. void onHeroVisit(const CGHeroInstance * h) const;
  664. void newTurn() const;
  665. void initObj();
  666. template <typename Handler> void serialize(Handler &h, const int version)
  667. {
  668. h & static_cast<CArmedInstance&>(*this);
  669. }
  670. };
  671. class DLL_EXPORT CGVisitableOPW : public CGObjectInstance //objects visitable OPW
  672. {
  673. public:
  674. ui8 visited; //true if object has been visited this week
  675. void setPropertyDer(ui8 what, ui32 val);//synchr
  676. void onHeroVisit(const CGHeroInstance * h) const;
  677. void newTurn() const;
  678. template <typename Handler> void serialize(Handler &h, const int version)
  679. {
  680. h & static_cast<CGObjectInstance&>(*this);
  681. h & visited;
  682. }
  683. };
  684. class DLL_EXPORT CGTeleport : public CGObjectInstance //teleports and subterranean gates
  685. {
  686. public:
  687. static std::map<int,std::map<int, std::vector<int> > > objs; //teleports: map[ID][subID] => vector of ids
  688. static std::vector<std::pair<int, int> > gates; //subterranean gates: pairs of ids
  689. void onHeroVisit(const CGHeroInstance * h) const;
  690. void initObj();
  691. static void postInit();
  692. template <typename Handler> void serialize(Handler &h, const int version)
  693. {
  694. h & static_cast<CGObjectInstance&>(*this);
  695. }
  696. };
  697. class DLL_EXPORT CGBonusingObject : public CGObjectInstance //objects giving bonuses to luck/morale/movement
  698. {
  699. public:
  700. void onHeroVisit(const CGHeroInstance * h) const;
  701. const std::string & getHoverText() const;
  702. void initObj();
  703. template <typename Handler> void serialize(Handler &h, const int version)
  704. {
  705. h & static_cast<CGObjectInstance&>(*this);
  706. }
  707. };
  708. class DLL_EXPORT CGMagicSpring : public CGVisitableOPW
  709. {///unfortunatelly, this one is quite different than others
  710. public:
  711. void onHeroVisit(const CGHeroInstance * h) const;
  712. const std::string & getHoverText() const;
  713. template <typename Handler> void serialize(Handler &h, const int version)
  714. {
  715. h & static_cast<CGObjectInstance&>(*this);
  716. h & visited;
  717. }
  718. };
  719. class DLL_EXPORT CGMagicWell : public CGObjectInstance //objects giving bonuses to luck/morale/movement
  720. {
  721. public:
  722. void onHeroVisit(const CGHeroInstance * h) const;
  723. const std::string & getHoverText() const;
  724. template <typename Handler> void serialize(Handler &h, const int version)
  725. {
  726. h & static_cast<CGObjectInstance&>(*this);
  727. }
  728. };
  729. class DLL_EXPORT CGSirens : public CGObjectInstance
  730. {
  731. public:
  732. void onHeroVisit(const CGHeroInstance * h) const;
  733. const std::string & getHoverText() const;
  734. void initObj();
  735. template <typename Handler> void serialize(Handler &h, const int version)
  736. {
  737. h & static_cast<CGObjectInstance&>(*this);
  738. }
  739. };
  740. class DLL_EXPORT CGObservatory : public CGObjectInstance //Redwood observatory
  741. {
  742. public:
  743. void onHeroVisit(const CGHeroInstance * h) const;
  744. template <typename Handler> void serialize(Handler &h, const int version)
  745. {
  746. h & static_cast<CGObjectInstance&>(*this);
  747. }
  748. };
  749. class DLL_EXPORT CGKeys : public CGObjectInstance //Base class for Keymaster and guards
  750. {
  751. public:
  752. static std::map <ui8, std::set <ui8> > playerKeyMap; //[players][keysowned]
  753. //SubID 0 - lightblue, 1 - green, 2 - red, 3 - darkblue, 4 - brown, 5 - purple, 6 - white, 7 - black
  754. void setPropertyDer (ui8 what, ui32 val);
  755. bool wasMyColorVisited (int player) const;
  756. template <typename Handler> void serialize(Handler &h, const int version)
  757. {
  758. h & static_cast<CGObjectInstance&>(*this);
  759. }
  760. };
  761. class DLL_EXPORT CGKeymasterTent : public CGKeys
  762. {
  763. public:
  764. void onHeroVisit(const CGHeroInstance * h) const;
  765. const std::string & getHoverText() const;
  766. template <typename Handler> void serialize(Handler &h, const int version)
  767. {
  768. h & static_cast<CGObjectInstance&>(*this);
  769. }
  770. };
  771. class DLL_EXPORT CGBorderGuard : public CGKeys
  772. {
  773. public:
  774. void initObj();
  775. const std::string & getHoverText() const;
  776. void onHeroVisit(const CGHeroInstance * h) const;
  777. void openGate(const CGHeroInstance *h, ui32 accept) const;
  778. template <typename Handler> void serialize(Handler &h, const int version)
  779. {
  780. h & static_cast<CGObjectInstance&>(*this);
  781. h & blockVisit;
  782. }
  783. };
  784. class DLL_EXPORT CGBorderGate : public CGBorderGuard //not fully imlemented, waiting for garrison
  785. {
  786. public:
  787. void onHeroVisit(const CGHeroInstance * h) const;
  788. ui8 getPassableness() const;
  789. };
  790. class DLL_EXPORT CGBoat : public CGObjectInstance
  791. {
  792. public:
  793. ui8 direction;
  794. const CGHeroInstance *hero; //hero on board
  795. void initObj();
  796. CGBoat()
  797. {
  798. hero = NULL;
  799. direction = 4;
  800. }
  801. template <typename Handler> void serialize(Handler &h, const int version)
  802. {
  803. h & static_cast<CGObjectInstance&>(*this) & direction;
  804. }
  805. };
  806. class DLL_EXPORT CGOnceVisitable : public CPlayersVisited
  807. ///wagon, corpse, lean to, warriors tomb
  808. {
  809. public:
  810. ui8 artOrRes; //0 - nothing; 1 - artifact; 2 - resource
  811. ui32 bonusType, //id of res or artifact
  812. bonusVal; //resource amount (or not used)
  813. void onHeroVisit(const CGHeroInstance * h) const;
  814. const std::string & getHoverText() const;
  815. void initObj();
  816. void searchTomb(const CGHeroInstance *h, ui32 accept) const;
  817. template <typename Handler> void serialize(Handler &h, const int version)
  818. {
  819. h & static_cast<CPlayersVisited&>(*this);;
  820. h & artOrRes & bonusType & bonusVal;
  821. }
  822. };
  823. class DLL_EXPORT CBank : public CArmedInstance
  824. {
  825. public:
  826. int index; //banks have unusal numbering - see ZCRBANK.txt and initObj()
  827. BankConfig *bc;
  828. float multiplier; //for improved banks script
  829. std::vector<ui32> artifacts; //fixed and deterministic
  830. ui32 daycounter;
  831. void initObj();
  832. const std::string & getHoverText() const;
  833. void setPropertyDer (ui8 what, ui32 val);
  834. void initialize() const;
  835. void reset(ui16 var1);
  836. void newTurn() const;
  837. virtual void onHeroVisit (const CGHeroInstance * h) const;
  838. virtual void fightGuards (const CGHeroInstance *h, ui32 accept) const;
  839. virtual void endBattle (const CGHeroInstance *h, const BattleResult *result) const;
  840. template <typename Handler> void serialize(Handler &h, const int version)
  841. {
  842. h & static_cast<CGObjectInstance&>(*this);
  843. h & index & multiplier & artifacts & daycounter & bc;
  844. }
  845. };
  846. class DLL_EXPORT CGPyramid : public CBank
  847. {
  848. public:
  849. static BankConfig pyramidConfig;
  850. ui16 spell;
  851. void initObj();
  852. const std::string & getHoverText() const;
  853. void newTurn() const {}; //empty, no reset
  854. void onHeroVisit (const CGHeroInstance * h) const;
  855. void endBattle (const CGHeroInstance *h, const BattleResult *result) const;
  856. template <typename Handler> void serialize(Handler &h, const int version)
  857. {
  858. h & static_cast<CBank&>(*this);
  859. h & spell;
  860. }
  861. };
  862. class CGShipyard : public CGObjectInstance, public IShipyard
  863. {
  864. public:
  865. void getOutOffsets(std::vector<int3> &offsets) const; //offsets to obj pos when we boat can be placed
  866. CGShipyard();
  867. void onHeroVisit(const CGHeroInstance * h) const;
  868. };
  869. class DLL_EXPORT CGMagi : public CGObjectInstance
  870. {
  871. public:
  872. static std::map <si32, std::vector<si32> > eyelist; //[subID][id], supports multiple sets as in H5
  873. void initObj();
  874. void onHeroVisit(const CGHeroInstance * h) const;
  875. template <typename Handler> void serialize(Handler &h, const int version)
  876. {
  877. h & static_cast<CGObjectInstance&>(*this);
  878. }
  879. };
  880. class DLL_EXPORT CCartographer : public CPlayersVisited
  881. {
  882. ///behaviour varies depending on surface and floor
  883. public:
  884. void onHeroVisit( const CGHeroInstance * h ) const;
  885. void buyMap (const CGHeroInstance *h, ui32 accept) const;
  886. template <typename Handler> void serialize(Handler &h, const int version)
  887. {
  888. h & static_cast<CPlayersVisited&>(*this);
  889. h & players;
  890. }
  891. };
  892. class DLL_EXPORT CShop : public CGObjectInstance
  893. {
  894. ///base class for university, art merchant, slave market etc.
  895. public:
  896. std::map<ui16, Component*> available;
  897. std::map<ui16, Component*> chosen, bought; //redundant?
  898. //keys are unique for all three maps
  899. std::map<ui16, ui32> price;
  900. void initObj() {};
  901. void setPropertyDer (ui8 what, ui32 val);
  902. void newTurn() const;
  903. virtual void reset (ui32 val) {}; //get new items for Black Market, Tavern, Refugee Camp
  904. virtual void onHeroVisit (const CGHeroInstance * h) const {};
  905. virtual void trade (const CGHeroInstance * h) const {};
  906. template <typename Handler> void serialize(Handler &h, const int version)
  907. {
  908. h & available & chosen & bought & price;
  909. }
  910. };
  911. class DLL_EXPORT CGArtMerchant : public CShop
  912. {
  913. public:
  914. void reset (ui32 val);
  915. void onHeroVisit (const CGHeroInstance * h) const {};
  916. };
  917. class DLL_EXPORT CGRefugeeCamp : public CShop
  918. {
  919. public:
  920. void reset (ui32 val);
  921. void onHeroVisit (const CGHeroInstance * h) const {};
  922. };
  923. class DLL_EXPORT CGDenOfthieves : public CGObjectInstance
  924. {
  925. void onHeroVisit (const CGHeroInstance * h) const;
  926. };
  927. class DLL_EXPORT CGObelisk : public CPlayersVisited
  928. {
  929. public:
  930. static ui8 obeliskCount; //how many obelisks are on map
  931. static std::map<ui8, ui8> visited; //map: color_id => how many obelisks has been visited
  932. void setPropertyDer (ui8 what, ui32 val);
  933. void onHeroVisit(const CGHeroInstance * h) const;
  934. void initObj();
  935. const std::string & getHoverText() const;
  936. template <typename Handler> void serialize(Handler &h, const int version)
  937. {
  938. h & static_cast<CPlayersVisited&>(*this);;
  939. }
  940. };
  941. class DLL_EXPORT CGLighthouse : public CGObjectInstance
  942. {
  943. public:
  944. void onHeroVisit(const CGHeroInstance * h) const;
  945. void initObj();
  946. const std::string & getHoverText() const;
  947. template <typename Handler> void serialize(Handler &h, const int version)
  948. {
  949. h & static_cast<CGObjectInstance&>(*this);;
  950. }
  951. void giveBonusTo( ui8 player ) const;
  952. };
  953. struct BankConfig
  954. {
  955. BankConfig() {level = chance = upgradeChance = combatValue = value = rewardDifficulty = easiest = 0; };
  956. ui8 level; //1 - 4, how hard the battle will be
  957. ui8 chance; //chance for this level being chosen
  958. ui8 upgradeChance; //chance for creatures to be in upgraded versions
  959. std::vector< std::pair <ui16, ui32> > guards; //creature ID, amount
  960. ui32 combatValue; //how hard are guards of this level
  961. std::vector<si32> resources; //resources given in case of victory
  962. std::vector< std::pair <ui16, ui32> > creatures; //creatures granted in case of victory (creature ID, amount)
  963. std::vector<ui16> artifacts; //number of artifacts given in case of victory [0] -> treasure, [1] -> minor [2] -> major [3] -> relic
  964. ui32 value; //overall value of given things
  965. ui32 rewardDifficulty; //proportion of reward value to difficulty of guards; how profitable is this creature Bank config
  966. ui16 easiest; //?!?
  967. template <typename Handler> void serialize(Handler &h, const int version)
  968. {
  969. h & level & chance & upgradeChance & guards & combatValue & resources & creatures & artifacts & value & rewardDifficulty & easiest;
  970. }
  971. };
  972. class DLL_EXPORT CObjectHandler
  973. {
  974. public:
  975. std::vector<si32> cregens; //type 17. dwelling subid -> creature ID
  976. std::map <ui32, std::vector <BankConfig*> > banksInfo; //[index][preset]
  977. std::map <ui32, std::string> creBanksNames; //[crebank index] -> name of this creature bank
  978. void loadObjects();
  979. template <typename Handler> void serialize(Handler &h, const int version)
  980. {
  981. h & cregens & banksInfo & creBanksNames;
  982. }
  983. };
  984. #endif // __COBJECTHANDLER_H__