CObjectHandler.h 40 KB

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