CObjectHandler.h 40 KB

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