CCallback.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. #ifndef __CCALLBACK_H__
  2. #define __CCALLBACK_H__
  3. #include "global.h"
  4. #ifdef _WIN32
  5. #include "tchar.h"
  6. #else
  7. #include "tchar_amigaos4.h" //XXX this is mingw header are we need this for something? for 'true'
  8. //support of unicode we should use ICU or some boost wraper areound it
  9. //(boost using this lib during compilation i dont know what for exactly)
  10. #endif
  11. #include "lib/CGameState.h"
  12. /*
  13. * CCallback.h, part of VCMI engine
  14. *
  15. * Authors: listed in file AUTHORS in main folder
  16. *
  17. * License: GNU General Public License v2.0 or later
  18. * Full text of license available in license.txt file, in main folder
  19. *
  20. */
  21. class CGHeroInstance;
  22. class CGameState;
  23. struct CPath;
  24. class CGObjectInstance;
  25. class CArmedInstance;
  26. class SComponent;
  27. class IChosen;
  28. class CSelectableComponent;
  29. struct BattleAction;
  30. class CGTownInstance;
  31. struct StartInfo;
  32. class CStack;
  33. struct lua_State;
  34. class CClient;
  35. struct TerrainTile;
  36. class CHeroClass;
  37. class IShipyard;
  38. struct CPackForServer;
  39. class CMapHeader;
  40. struct CGPathNode;
  41. struct CGPath;
  42. class CGGarrison;
  43. class CObstacleInstance;
  44. typedef std::vector<const CStack*> TStacks;
  45. struct InfoAboutTown
  46. {
  47. struct Details
  48. {
  49. int hallLevel, goldIncome;
  50. bool customRes;
  51. bool garrisonedHero;
  52. } *details;
  53. const CArmedInstance * obj;
  54. char fortLevel; //0 - none
  55. char owner;
  56. std::string name;
  57. CTown *tType;
  58. bool built;
  59. ArmyDescriptor army; //numbers of creatures are valid only if details
  60. InfoAboutTown();
  61. ~InfoAboutTown();
  62. void initFromTown(const CGTownInstance *t, bool detailed);
  63. void initFromGarrison(const CGGarrison *garr, bool detailed);
  64. };
  65. class IBattleCallback
  66. {
  67. public:
  68. ///describes why player cannot cast a specific spell
  69. enum EStackOwnership
  70. {
  71. ONLY_MINE, ONLY_ENEMY, MINE_AND_ENEMY
  72. };
  73. bool waitTillRealize; //if true, request functions will return after they are realized by server
  74. //battle
  75. virtual int battleGetBattlefieldType()=0; // 1. sand/shore 2. sand/mesas 3. dirt/birches 4. dirt/hills 5. dirt/pines 6. grass/hills 7. grass/pines 8. lava 9. magic plains 10. snow/mountains 11. snow/trees 12. subterranean 13. swamp/trees 14. fiery fields 15. rock lands 16. magic clouds 17. lucid pools 18. holy ground 19. clover field 20. evil fog 21. "favourable winds" text on magic plains background 22. cursed ground 23. rough 24. ship to ship 25. ship
  76. virtual int battleGetObstaclesAtTile(THex tile)=0; //returns bitfield
  77. virtual std::vector<CObstacleInstance> battleGetAllObstacles()=0; //returns all obstacles on the battlefield
  78. virtual const CStack * battleGetStackByID(int ID, bool onlyAlive = true)=0; //returns stack info by given ID
  79. virtual const CStack * battleGetStackByPos(THex pos, bool onlyAlive = true)=0; //returns stack info by given pos
  80. virtual THex battleGetPos(int stack)=0; //returns position (tile ID) of stack
  81. virtual int battleMakeAction(BattleAction* action)=0;//for casting spells by hero - DO NOT use it for moving active stack
  82. virtual TStacks battleGetStacks(EStackOwnership whose = MINE_AND_ENEMY, bool onlyAlive = true)=0; //returns stacks on battlefield
  83. virtual void getStackQueue( std::vector<const CStack *> &out, int howMany )=0; //returns vector of stack in order of their move sequence
  84. virtual std::vector<THex> battleGetAvailableHexes(const CStack * stack, bool addOccupiable)=0; //returns numbers of hexes reachable by creature with id ID
  85. virtual std::vector<int> battleGetDistances(const CStack * stack, THex hex = THex::INVALID, THex * predecessors = NULL)=0; //returns vector of distances to [dest hex number]
  86. virtual bool battleCanShoot(const CStack * stack, THex dest)=0; //returns true if unit with id ID can shoot to dest
  87. virtual bool battleCanCastSpell()=0; //returns true, if caller can cast a spell
  88. virtual SpellCasting::ESpellCastProblem battleCanCastThisSpell(const CSpell * spell)=0; //determines if given spell can be casted (and returns problem description)
  89. virtual bool battleCanFlee()=0; //returns true if caller can flee from the battle
  90. virtual const CGTownInstance * battleGetDefendedTown()=0; //returns defended town if current battle is a siege, NULL instead
  91. virtual ui8 battleGetWallState(int partOfWall)=0; //for determining state of a part of the wall; format: parameter [0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate; returned value: 1 - intact, 2 - damaged, 3 - destroyed; 0 - no battle
  92. virtual int battleGetWallUnderHex(THex hex)=0; //returns part of destructible wall / gate / keep under given hex or -1 if not found
  93. virtual TDmgRange battleEstimateDamage(const CStack * attacker, const CStack * defender, TDmgRange * retaliationDmg = NULL)=0; //estimates damage dealt by attacker to defender; it may be not precise especially when stack has randomly working bonuses; returns pair <min dmg, max dmg>
  94. virtual ui8 battleGetSiegeLevel()=0; //returns 0 when there is no siege, 1 if fort, 2 is citadel, 3 is castle
  95. virtual const CGHeroInstance * battleGetFightingHero(ui8 side) const =0; //returns hero corresponding to given side (0 - attacker, 1 - defender)
  96. virtual si8 battleHasDistancePenalty(const CStack * stack, THex destHex) =0; //checks if given stack has distance penalty
  97. virtual si8 battleHasWallPenalty(const CStack * stack, THex destHex) =0; //checks if given stack has wall penalty
  98. virtual si8 battleCanTeleportTo(const CStack * stack, THex destHex, int telportLevel) =0; //checks if teleportation of given stack to given position can take place
  99. virtual si8 battleGetTacticDist() =0; //returns tactic distance for calling player or 0 if player is not in tactic phase
  100. virtual ui8 battleGetMySide() =0; //return side of player in battle (attacker/defender)
  101. virtual bool battleMakeTacticAction(BattleAction * action) =0; // performs tactic phase actions
  102. //convienience methods using the ones above
  103. TStacks battleGetAllStacks() //returns all stacks, alive or dead or undead or mechanical :)
  104. {
  105. return battleGetStacks(MINE_AND_ENEMY, false);
  106. }
  107. };
  108. class ICallback : public virtual IBattleCallback
  109. {
  110. public:
  111. //hero
  112. virtual bool moveHero(const CGHeroInstance *h, int3 dst) =0; //dst must be free, neighbouring tile (this function can move hero only by one tile)
  113. virtual bool dismissHero(const CGHeroInstance * hero)=0; //dismisses given hero; true - successfuly, false - not successfuly
  114. //town
  115. virtual void recruitHero(const CGObjectInstance *townOrTavern, const CGHeroInstance *hero)=0;
  116. virtual bool buildBuilding(const CGTownInstance *town, si32 buildingID)=0;
  117. virtual void recruitCreatures(const CGObjectInstance *obj, ui32 ID, ui32 amount, si32 level=-1)=0;
  118. virtual bool upgradeCreature(const CArmedInstance *obj, int stackPos, int newID=-1)=0; //if newID==-1 then best possible upgrade will be made
  119. virtual void swapGarrisonHero(const CGTownInstance *town)=0;
  120. virtual void trade(const CGObjectInstance *market, int mode, int id1, int id2, int val1, const CGHeroInstance *hero = NULL)=0; //mode==0: sell val1 units of id1 resource for id2 resiurce
  121. virtual void selectionMade(int selection, int asker) =0;
  122. virtual int swapCreatures(const CArmedInstance *s1, const CArmedInstance *s2, int p1, int p2)=0;//swaps creatures between two posiibly different garrisons // TODO: AI-unsafe code - fix it!
  123. virtual int mergeStacks(const CArmedInstance *s1, const CArmedInstance *s2, int p1, int p2)=0;//joins first stack tothe second (creatures must be same type)
  124. virtual int splitStack(const CArmedInstance *s1, const CArmedInstance *s2, int p1, int p2, int val)=0;//split creatures from the first stack
  125. virtual bool swapArtifacts(const CGHeroInstance * hero1, ui16 pos1, const CGHeroInstance * hero2, ui16 pos2)=0; //swaps artifacts between two given heroes
  126. virtual bool assembleArtifacts(const CGHeroInstance * hero, ui16 artifactSlot, bool assemble, ui32 assembleTo)=0;
  127. virtual bool dismissCreature(const CArmedInstance *obj, int stackPos)=0;
  128. virtual void endTurn()=0;
  129. virtual void buyArtifact(const CGHeroInstance *hero, int aid)=0; //used to buy artifacts in towns (including spell book in the guild and war machines in blacksmith)
  130. virtual void setFormation(const CGHeroInstance * hero, bool tight)=0;
  131. virtual void setSelection(const CArmedInstance * obj)=0;
  132. virtual void save(const std::string &fname) = 0;
  133. virtual void sendMessage(const std::string &mess) = 0;
  134. virtual void buildBoat(const IShipyard *obj) = 0;
  135. //get info
  136. virtual bool verifyPath(CPath * path, bool blockSea)const =0;
  137. virtual int getDate(int mode=0)const =0; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
  138. virtual std::vector< std::vector< std::vector<unsigned char> > > & getVisibilityMap()const =0; //returns visibility map (TODO: make it const)
  139. virtual int getResourceAmount(int type)const =0;
  140. virtual bool isVisible(int3 pos)const =0;
  141. virtual int getMyColor()const =0;
  142. virtual int getHeroSerial(const CGHeroInstance * hero)const =0;
  143. virtual const StartInfo * getStartInfo()const =0;
  144. virtual const CMapHeader * getMapHeader()const =0;
  145. virtual int getSpellCost(const CSpell * sp, const CGHeroInstance * caster) const =0; //when called during battle, takes into account creatures' spell cost reduction
  146. virtual int estimateSpellDamage(const CSpell * sp, const CGHeroInstance * hero) const =0; //estimates damage of given spell; returns 0 if spell causes no dmg
  147. virtual void getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj)=0; //get thieves' guild info obtainable while visiting given object
  148. virtual int3 getGrailPos(float &outKnownRatio)=0;
  149. virtual int getPlayerStatus(int player) const = 0; //-1 if no such player
  150. //hero
  151. virtual int howManyHeroes(bool includeGarrisoned = true)const =0;
  152. virtual const CGHeroInstance * getHeroInfo(int val, int mode=2)const =0; //mode = 0 -> val = serial; mode = 1 -> val = ID
  153. virtual std::vector < const CGHeroInstance *> getHeroesInfo(bool onlyOur=true)const =0;
  154. virtual bool getHeroInfo(const CGObjectInstance *hero, InfoAboutHero &dest) const = 0;
  155. virtual bool getPath(int3 src, int3 dest, const CGHeroInstance * hero, CPath &ret)=0;
  156. virtual const CGPathNode *getPathInfo(int3 tile)=0; //uses main, client pathfinder info
  157. virtual bool getPath2(int3 dest, CGPath &ret)=0; //uses main, client pathfinder info
  158. virtual void calculatePaths(const CGHeroInstance *hero, CPathsInfo &out, int3 src = int3(-1,-1,-1), int movement = -1) =0;
  159. virtual void recalculatePaths()=0; //updates main, client pathfinder info (should be called when moving hero is over)
  160. virtual void dig(const CGObjectInstance *hero)=0;
  161. virtual void castSpell(const CGHeroInstance *hero, int spellID, const int3 &pos = int3(-1, -1, -1))=0; //cast adventure map spell
  162. //map
  163. virtual std::vector < const CGDwelling * > getMyDwellings() const =0; //returns all dwellings that belong to player
  164. virtual std::vector < const CGObjectInstance * > getMyObjects() const =0; //returns all objects flagged by belonging player
  165. virtual std::vector < const CGObjectInstance * > getBlockingObjs(int3 pos)const =0;
  166. virtual std::vector < const CGObjectInstance * > getVisitableObjs(int3 pos)const =0;
  167. virtual std::vector < const CGObjectInstance * > getFlaggableObjects(int3 pos) const =0;
  168. virtual std::vector < std::string > getObjDescriptions(int3 pos)const =0; //returns descriptions of objects at pos in order from the lowest to the highest
  169. //town
  170. virtual int howManyTowns()const =0;
  171. virtual const CGTownInstance * getTownInfo(int val, bool mode)const =0; //mode = 0 -> val = player town serial; mode = 1 -> val = object id (serial)
  172. virtual std::vector < const CGTownInstance *> getTownsInfo(bool onlyOur=true) const=0;
  173. virtual std::vector<const CGHeroInstance *> getAvailableHeroes(const CGObjectInstance * townOrTavern) const =0; //heroes that can be recruited
  174. virtual std::string getTavernGossip(const CGObjectInstance * townOrTavern) const =0;
  175. virtual int canBuildStructure(const CGTownInstance *t, int ID) =0;//// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
  176. virtual std::set<int> getBuildingRequiments(const CGTownInstance *t, int ID) =0;
  177. virtual bool getTownInfo(const CGObjectInstance *town, InfoAboutTown &dest) const = 0;
  178. virtual UpgradeInfo getUpgradeInfo(const CArmedInstance *obj, int stackPos)const =0;
  179. virtual const CCreatureSet* getGarrison(const CGObjectInstance *obj)const =0;
  180. virtual int3 getMapSize() const =0; //returns size of map - z is 1 for one - level map and 2 for two level map
  181. virtual const TerrainTile * getTileInfo(int3 tile) const = 0;
  182. virtual int getPlayerRelations(ui8 color1, ui8 color2) const =0;// 0 = enemy, 1 = ally, 2 = same player
  183. };
  184. class CBattleCallback : public virtual IBattleCallback
  185. {
  186. private:
  187. CGameState * gs;
  188. CBattleCallback(CGameState *GS, int Player, CClient *C);
  189. protected:
  190. template <typename T> void sendRequest(const T*request);
  191. CClient *cl;
  192. virtual bool hasAccess(int playerId) const;
  193. int player;
  194. public:
  195. //battle
  196. int battleGetBattlefieldType() OVERRIDE; // 1. sand/shore 2. sand/mesas 3. dirt/birches 4. dirt/hills 5. dirt/pines 6. grass/hills 7. grass/pines 8. lava 9. magic plains 10. snow/mountains 11. snow/trees 12. subterranean 13. swamp/trees 14. fiery fields 15. rock lands 16. magic clouds 17. lucid pools 18. holy ground 19. clover field 20. evil fog 21. "favourable winds" text on magic plains background 22. cursed ground 23. rough 24. ship to ship 25. ship
  197. int battleGetObstaclesAtTile(THex tile) OVERRIDE; //returns bitfield
  198. std::vector<CObstacleInstance> battleGetAllObstacles() OVERRIDE; //returns all obstacles on the battlefield
  199. const CStack * battleGetStackByID(int ID, bool onlyAlive = true) OVERRIDE; //returns stack info by given ID
  200. const CStack * battleGetStackByPos(THex pos, bool onlyAlive = true) OVERRIDE; //returns stack info by given pos
  201. THex battleGetPos(int stack) OVERRIDE; //returns position (tile ID) of stack
  202. int battleMakeAction(BattleAction* action) OVERRIDE;//for casting spells by hero - DO NOT use it for moving active stack
  203. TStacks battleGetStacks(EStackOwnership whose = MINE_AND_ENEMY, bool onlyAlive = true) OVERRIDE; //returns stacks on battlefield
  204. void getStackQueue( std::vector<const CStack *> &out, int howMany ) OVERRIDE; //returns vector of stack in order of their move sequence
  205. std::vector<THex> battleGetAvailableHexes(const CStack * stack, bool addOccupiable) OVERRIDE; //reutrns numbers of hexes reachable by creature with id ID
  206. std::vector<int> battleGetDistances(const CStack * stack, THex hex = THex::INVALID, THex * predecessors = NULL) OVERRIDE; //returns vector of distances to [dest hex number]; if predecessors is not null, it must point to BFIELD_SIZE * sizeof(int) of allocated memory
  207. bool battleCanShoot(const CStack * stack, THex dest) OVERRIDE; //returns true if unit with id ID can shoot to dest
  208. bool battleCanCastSpell() OVERRIDE; //returns true, if caller can cast a spell
  209. SpellCasting::ESpellCastProblem battleCanCastThisSpell(const CSpell * spell) OVERRIDE; //determines if given spell can be casted (and returns problem description)
  210. bool battleCanFlee() OVERRIDE; //returns true if caller can flee from the battle
  211. const CGTownInstance * battleGetDefendedTown() OVERRIDE; //returns defended town if current battle is a siege, NULL instead
  212. ui8 battleGetWallState(int partOfWall) OVERRIDE; //for determining state of a part of the wall; format: parameter [0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate; returned value: 1 - intact, 2 - damaged, 3 - destroyed; 0 - no battle
  213. int battleGetWallUnderHex(THex hex) OVERRIDE; //returns part of destructible wall / gate / keep under given hex or -1 if not found
  214. TDmgRange battleEstimateDamage(const CStack * attacker, const CStack * defender, TDmgRange * retaliationDmg = NULL) OVERRIDE; //estimates damage dealt by attacker to defender; it may be not precise especially when stack has randomly working bonuses; returns pair <min dmg, max dmg>
  215. ui8 battleGetSiegeLevel() OVERRIDE; //returns 0 when there is no siege, 1 if fort, 2 is citadel, 3 is castle
  216. const CGHeroInstance * battleGetFightingHero(ui8 side) const OVERRIDE; //returns hero corresponding ot given side (0 - attacker, 1 - defender)
  217. si8 battleHasDistancePenalty(const CStack * stack, THex destHex) OVERRIDE; //checks if given stack has distance penalty
  218. si8 battleHasWallPenalty(const CStack * stack, THex destHex) OVERRIDE; //checks if given stack has wall penalty
  219. si8 battleCanTeleportTo(const CStack * stack, THex destHex, int telportLevel) OVERRIDE; //checks if teleportation of given stack to given position can take place
  220. si8 battleGetTacticDist() OVERRIDE; //returns tactic distance for calling player or 0 if player is not in tactic phase
  221. ui8 battleGetMySide() OVERRIDE; //return side of player in battle (attacker/defender)
  222. bool battleMakeTacticAction(BattleAction * action) OVERRIDE; // performs tactic phase actions
  223. friend class CCallback;
  224. friend class CClient;
  225. };
  226. class CCallback : public ICallback, public CBattleCallback
  227. {
  228. private:
  229. CCallback(CGameState * GS, int Player, CClient *C);
  230. bool isVisible(int3 pos, int Player) const;
  231. bool isVisible(const CGObjectInstance *obj, int Player) const;
  232. protected:
  233. virtual bool hasAccess(int playerId) const OVERRIDE;
  234. public:
  235. //commands
  236. bool moveHero(const CGHeroInstance *h, int3 dst); //dst must be free, neighbouring tile (this function can move hero only by one tile)
  237. bool teleportHero(const CGHeroInstance *who, const CGTownInstance *where);
  238. void selectionMade(int selection, int asker);
  239. int swapCreatures(const CArmedInstance *s1, const CArmedInstance *s2, int p1, int p2);
  240. int mergeStacks(const CArmedInstance *s1, const CArmedInstance *s2, int p1, int p2); //first goes to the second
  241. int splitStack(const CArmedInstance *s1, const CArmedInstance *s2, int p1, int p2, int val);
  242. bool dismissHero(const CGHeroInstance * hero);
  243. bool swapArtifacts(const CGHeroInstance * hero1, ui16 pos1, const CGHeroInstance * hero2, ui16 pos2);
  244. bool assembleArtifacts(const CGHeroInstance * hero, ui16 artifactSlot, bool assemble, ui32 assembleTo);
  245. bool buildBuilding(const CGTownInstance *town, si32 buildingID);
  246. void recruitCreatures(const CGObjectInstance *obj, ui32 ID, ui32 amount, si32 level=-1);
  247. bool dismissCreature(const CArmedInstance *obj, int stackPos);
  248. bool upgradeCreature(const CArmedInstance *obj, int stackPos, int newID=-1);
  249. void endTurn();
  250. void swapGarrisonHero(const CGTownInstance *town);
  251. void buyArtifact(const CGHeroInstance *hero, int aid);
  252. void trade(const CGObjectInstance *market, int mode, int id1, int id2, int val1, const CGHeroInstance *hero = NULL);
  253. void setFormation(const CGHeroInstance * hero, bool tight);
  254. void setSelection(const CArmedInstance * obj);
  255. void recruitHero(const CGObjectInstance *townOrTavern, const CGHeroInstance *hero);
  256. void save(const std::string &fname);
  257. void sendMessage(const std::string &mess);
  258. void buildBoat(const IShipyard *obj);
  259. void dig(const CGObjectInstance *hero);
  260. void castSpell(const CGHeroInstance *hero, int spellID, const int3 &pos = int3(-1, -1, -1));
  261. //get info
  262. bool verifyPath(CPath * path, bool blockSea) const;
  263. int getDate(int mode=0) const; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
  264. std::vector< std::vector< std::vector<unsigned char> > > & getVisibilityMap() const; //returns visibility map (TODO: make it const)
  265. const CGHeroInstance * getHeroInfo(int val, int mode=2) const; //mode = 0 -> val = serial; mode = 1 -> val = hero type id (subID); mode = 2 -> val = global object serial id (id)
  266. const CGObjectInstance * getObjectInfo(int ID) const; //global object serial id (ID)
  267. int getResourceAmount(int type) const;
  268. std::vector<si32> getResourceAmount() const;
  269. int howManyHeroes(bool includeGarrisoned = true) const;
  270. const CGTownInstance * getTownInfo(int val, bool mode) const; //mode = 0 -> val = player town serial; mode = 1 -> val = object id (serial)
  271. std::vector < const CGTownInstance *> getTownsInfo(bool onlyOur=true) const;
  272. int howManyTowns()const;
  273. std::vector < std::string > getObjDescriptions(int3 pos) const; //returns descriptions of objects at pos in order from the lowest to the highest
  274. std::vector < const CGHeroInstance *> getHeroesInfo(bool onlyOur=true) const;
  275. bool isVisible(int3 pos) const;
  276. int getMyColor() const;
  277. int getHeroSerial(const CGHeroInstance * hero) const;
  278. //int getMySerial() const;
  279. const CCreatureSet* getGarrison(const CGObjectInstance *obj) const;
  280. UpgradeInfo getUpgradeInfo(const CArmedInstance *obj, int stackPos) const;
  281. const StartInfo * getStartInfo() const;
  282. const CMapHeader * getMapHeader()const ;
  283. int getSpellCost(const CSpell * sp, const CGHeroInstance * caster) const; //when called during battle, takes into account creatures' spell cost reduction
  284. int estimateSpellDamage(const CSpell * sp, const CGHeroInstance * hero) const; //estimates damage of given spell; returns 0 if spell causes no dmg
  285. void getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj); //get thieves' guild info obtainable while visiting given object
  286. int3 getGrailPos(float &outKnownRatio); //returns pos and (via arg) percent of discovered obelisks; TODO: relies on fairness of GUI/AI... :/
  287. std::vector < const CGDwelling * > getMyDwellings() const; //returns all dwellings that belong to player
  288. std::vector < const CGObjectInstance * > getMyObjects() const; //returns all objects flagged by belonging player
  289. std::vector < const CGObjectInstance * > getBlockingObjs(int3 pos) const;
  290. std::vector < const CGObjectInstance * > getVisitableObjs(int3 pos) const;
  291. std::vector < const CGObjectInstance * > getFlaggableObjects(int3 pos) const;
  292. int3 getMapSize() const; //returns size of map - z is 1 for one - level map and 2 for two level map
  293. std::vector<const CGHeroInstance *> getAvailableHeroes(const CGObjectInstance * townOrTavern) const; //heroes that can be recruited
  294. std::string getTavernGossip(const CGObjectInstance * townOrTavern) const;
  295. const TerrainTile * getTileInfo(int3 tile) const;
  296. int canBuildStructure(const CGTownInstance *t, int ID);//// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
  297. std::set<int> getBuildingRequiments(const CGTownInstance *t, int ID);
  298. bool getPath(int3 src, int3 dest, const CGHeroInstance * hero, CPath &ret);
  299. const CGPathNode *getPathInfo(int3 tile);
  300. bool getPath2(int3 dest, CGPath &ret);
  301. void calculatePaths(const CGHeroInstance *hero, CPathsInfo &out, int3 src = int3(-1,-1,-1), int movement = -1); //calculates possible paths for hero, by default uses current hero position and movement left;
  302. void recalculatePaths(); //updates pathfinder info (should be called when moving hero is over)
  303. bool getHeroInfo(const CGObjectInstance *hero, InfoAboutHero &dest) const;
  304. bool getTownInfo(const CGObjectInstance *town, InfoAboutTown &dest) const;
  305. int3 guardingCreaturePosition (int3 pos) const;
  306. int getPlayerStatus(int player) const;
  307. int getPlayerRelations(ui8 color1, ui8 color2) const;// 0 = enemy, 1 = ally, 2 = same player
  308. //XXX hmmm _tmain on _GNUC_ wtf?
  309. //friends
  310. friend class CClient;
  311. #ifndef __GNUC__
  312. friend int _tmain(int argc, _TCHAR* argv[]);
  313. #else
  314. friend int main(int argc, char** argv);
  315. #endif
  316. };
  317. #endif // __CCALLBACK_H__