2011-12-14 00:23:17 +03:00
# pragma once
2010-05-02 21:20:26 +03:00
# include "../lib/CCreatureSet.h"
2011-06-24 20:43:02 +03:00
# include "CArtHandler.h"
2010-12-19 16:39:56 +02:00
# include "../lib/ConstTransitivePtr.h"
2011-12-14 00:23:17 +03:00
# include "int3.h"
# include "GameConstants.h"
2013-02-04 22:43:16 +03:00
# include "ResourceSet.h"
2008-12-27 03:01:59 +02:00
2009-04-15 17:03:31 +03:00
/*
* CObjectHandler . h , part of VCMI engine
*
* Authors : listed in file AUTHORS in main folder
*
* License : GNU General Public License v2 .0 or later
* Full text of license available in license . txt file , in main folder
*
*/
2011-02-22 11:47:25 +02:00
class CGameState ;
2010-12-17 20:47:07 +02:00
class CArtifactInstance ;
2010-07-13 08:25:40 +03:00
struct MetaString ;
2010-10-31 00:53:41 +03:00
struct BattleInfo ;
2012-05-16 20:29:05 +03:00
struct QuestInfo ;
2008-12-27 03:01:59 +02:00
class IGameCallback ;
struct BattleResult ;
class CCPPObjectScript ;
class CGObjectInstance ;
class CScript ;
class CObjectScript ;
class CGHeroInstance ;
class CTown ;
class CHero ;
class CBuilding ;
class CSpell ;
class CGTownInstance ;
2009-08-23 18:02:21 +03:00
class CGTownBuilding ;
2008-12-27 03:01:59 +02:00
class CArtifact ;
class CGDefInfo ;
class CSpecObjInfo ;
2010-08-18 17:24:30 +03:00
class CCastleEvent ;
2009-02-12 16:44:58 +02:00
struct TerrainTile ;
2009-04-21 01:57:07 +03:00
struct InfoWindow ;
2009-09-21 12:00:33 +03:00
struct Component ;
2009-08-11 10:50:29 +03:00
struct BankConfig ;
2013-01-17 21:15:00 +03:00
struct UpdateHerospecialty ;
2010-11-10 02:06:25 +02:00
struct NewArtifact ;
2009-07-19 04:00:19 +03:00
class CGBoat ;
2011-06-24 20:43:02 +03:00
class CArtifactSet ;
2012-04-04 20:41:55 +03:00
class CCommanderInstance ;
2008-12-27 03:01:59 +02:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CQuest
2008-12-27 03:01:59 +02:00
{
public :
2009-12-30 22:49:10 +02:00
enum Emission { MISSION_NONE = 0 , MISSION_LEVEL = 1 , MISSION_PRIMARY_STAT = 2 , MISSION_KILL_HERO = 3 , MISSION_KILL_CREATURE = 4 ,
2012-07-08 19:36:20 +03:00
MISSION_ART = 5 , MISSION_ARMY = 6 , MISSION_RESOURCES = 7 , MISSION_HERO = 8 , MISSION_PLAYER = 9 , MISSION_KEYMASTER = 10 } ;
2012-07-18 13:10:14 +03:00
enum Eprogress { NOT_ACTIVE , IN_PROGRESS , COMPLETE } ;
2009-12-30 22:49:10 +02:00
2013-02-02 22:28:39 +03:00
si32 qid ; //unique quest id for serialization / identification
2012-07-08 11:42:03 +03:00
2013-02-02 01:04:25 +03:00
Emission missionType ;
Eprogress progress ;
2008-12-27 03:01:59 +02:00
si32 lastDay ; //after this day (first day is 0) mission cannot be completed; if -1 - no limit
ui32 m13489val ;
std : : vector < ui32 > m2stats ;
std : : vector < ui16 > m5arts ; //artifacts id
2010-11-22 02:34:46 +02:00
std : : vector < CStackBasicDescriptor > m6creatures ; //pair[cre id, cre count], CreatureSet info irrelevant
2012-07-18 13:10:14 +03:00
std : : vector < ui32 > m7resources ; //TODO: use resourceset?
2008-12-27 03:01:59 +02:00
2012-07-08 09:33:41 +03:00
//following field are used only for kill creature/hero missions, the original objects became inaccessible after their removal, so we need to store info needed for messages / hover text
ui8 textOption ;
2013-01-12 13:32:03 +03:00
CStackBasicDescriptor stackToKill ;
2012-07-08 09:33:41 +03:00
ui8 stackDirection ;
std : : string heroName ; //backup of hero name
si32 heroPortrait ;
2008-12-27 03:01:59 +02:00
std : : string firstVisitText , nextVisitText , completedText ;
2011-10-16 22:24:05 +03:00
bool isCustomFirst , isCustomNext , isCustomComplete ;
2008-12-31 11:33:46 +02:00
2013-02-02 01:04:25 +03:00
CQuest ( ) { missionType = MISSION_NONE ; } ; //default constructor
2012-09-28 18:46:09 +03:00
2012-07-19 12:10:55 +03:00
virtual bool checkQuest ( const CGHeroInstance * h ) const ; //determines whether the quest is complete or not
2012-07-08 09:33:41 +03:00
virtual void getVisitText ( MetaString & text , std : : vector < Component > & components , bool isCustom , bool FirstVisit , const CGHeroInstance * h = NULL ) const ;
virtual void getCompletionText ( MetaString & text , std : : vector < Component > & components , bool isCustom , const CGHeroInstance * h = NULL ) const ;
virtual void getRolloverText ( MetaString & text , bool onHover ) const ; //hover or quest log entry
2010-01-30 22:53:47 +02:00
virtual void completeQuest ( const CGHeroInstance * h ) const { } ;
2012-07-08 09:33:41 +03:00
virtual void addReplacements ( MetaString & out , const std : : string & base ) const ;
2009-12-31 13:43:37 +02:00
2012-09-28 18:46:09 +03:00
bool operator = = ( const CQuest & quest ) const
{
return ( quest . qid = = qid ) ;
}
2008-12-31 11:33:46 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2012-07-08 11:42:03 +03:00
h & qid & missionType & progress & lastDay & m13489val & m2stats & m5arts & m6creatures & m7resources
2012-07-08 09:33:41 +03:00
& textOption & stackToKill & stackDirection & heroName & heroPortrait
2011-10-16 22:24:05 +03:00
& firstVisitText & nextVisitText & completedText & isCustomFirst & isCustomNext & isCustomComplete ;
2008-12-31 11:33:46 +02:00
}
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE IObjectInterface
2008-12-27 03:01:59 +02:00
{
public :
static IGameCallback * cb ;
IObjectInterface ( ) ;
virtual ~ IObjectInterface ( ) ;
virtual void onHeroVisit ( const CGHeroInstance * h ) const ;
virtual void onHeroLeave ( const CGHeroInstance * h ) const ;
virtual void newTurn ( ) const ;
2009-02-20 14:39:27 +02:00
virtual void initObj ( ) ; //synchr
virtual void setProperty ( ui8 what , ui32 val ) ; //synchr
2012-03-14 16:02:38 +03:00
//unified interface, AI helpers
virtual bool wasVisited ( ui8 player ) const ;
virtual bool wasVisited ( const CGHeroInstance * h ) const ;
2009-09-07 05:29:44 +03:00
static void preInit ( ) ; //called before objs receive their initObj
static void postInit ( ) ; //caleed after objs receive their initObj
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE IBoatGenerator
2009-07-26 06:33:13 +03:00
{
public :
const CGObjectInstance * o ;
2010-03-11 01:16:30 +02:00
IBoatGenerator ( const CGObjectInstance * O ) ;
2010-02-13 06:47:31 +02:00
virtual int getBoatType ( ) const ; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral
2009-07-26 06:33:13 +03:00
virtual void getOutOffsets ( std : : vector < int3 > & offsets ) const = 0 ; //offsets to obj pos when we boat can be placed
int3 bestLocation ( ) const ; //returns location when the boat should be placed
2012-09-23 21:01:04 +03:00
enum EGeneratorState { GOOD , BOAT_ALREADY_BUILT , TILE_BLOCKED , NO_WATER } ;
EGeneratorState state ( ) const ; //0 - can buid, 1 - there is already a boat at dest tile, 2 - dest tile is blocked, 3 - no water
2013-01-12 13:32:03 +03:00
void getProblemText ( MetaString & out , const CGHeroInstance * visitor = NULL ) const ;
2010-03-11 01:16:30 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE IShipyard : public IBoatGenerator
2010-03-11 01:16:30 +02:00
{
public :
IShipyard ( const CGObjectInstance * O ) ;
virtual void getBoatCost ( std : : vector < si32 > & cost ) const ;
2009-07-26 06:33:13 +03:00
static const IShipyard * castFrom ( const CGObjectInstance * obj ) ;
static IShipyard * castFrom ( CGObjectInstance * obj ) ;
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE IMarket
2010-05-18 10:01:54 +03:00
{
public :
const CGObjectInstance * o ;
IMarket ( const CGObjectInstance * O ) ;
2012-01-03 04:55:26 +03:00
virtual int getMarketEfficiency ( ) const = 0 ;
2011-12-14 00:23:17 +03:00
virtual bool allowsTrade ( EMarketMode : : EMarketMode mode ) const ;
virtual int availableUnits ( EMarketMode : : EMarketMode mode , int marketItemSerial ) const ; //-1 if unlimited
virtual std : : vector < int > availableItemsIds ( EMarketMode : : EMarketMode mode ) const ;
2010-05-18 10:01:54 +03:00
2013-01-12 13:32:03 +03:00
bool getOffer ( int id1 , int id2 , int & val1 , int & val2 , EMarketMode : : EMarketMode mode ) const ; //val1 - how many units of id1 player has to give to receive val2 units
2011-12-14 00:23:17 +03:00
std : : vector < EMarketMode : : EMarketMode > availableModes ( ) const ;
2010-05-18 10:01:54 +03:00
2012-02-14 21:04:45 +03:00
static const IMarket * castFrom ( const CGObjectInstance * obj , bool verbose = true ) ;
2010-05-18 10:01:54 +03:00
} ;
2010-05-08 01:10:32 +03:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGObjectInstance : public IObjectInterface
2008-12-27 03:01:59 +02:00
{
public :
mutable std : : string hoverName ;
int3 pos ; //h3m pos
2013-02-07 20:34:50 +03:00
Obj : : Obj ID ;
si32 subID ; //normal subID (this one from OH3 maps ;])
2013-01-15 17:20:48 +03:00
si32 id ; //number of object in map's vector
2008-12-27 03:01:59 +02:00
CGDefInfo * defInfo ;
2008-12-31 11:33:46 +02:00
ui8 animPhaseShift ;
2008-12-27 03:01:59 +02:00
2013-02-02 22:28:39 +03:00
TPlayerColor tempOwner ;
bool blockVisit ; //if non-zero then blocks the tile but is visitable from neighbouring tile
2008-12-27 03:01:59 +02:00
2009-12-20 19:14:14 +02:00
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
2009-03-12 01:25:59 +02:00
virtual int3 getSightCenter ( ) const ; //"center" tile from which the sight distance is calculated
virtual int getSightRadious ( ) const ; //sight distance (should be used if player-owned structure)
2011-01-20 19:25:15 +02:00
void getSightTiles ( boost : : unordered_set < int3 , ShashInt3 > & tiles ) const ; //returns reference to the set
2012-09-24 21:52:30 +03:00
int getOwner ( ) const ;
void setOwner ( int ow ) ;
2008-12-27 03:01:59 +02:00
int getWidth ( ) const ; //returns width of object graphic in tiles
int getHeight ( ) const ; //returns height of object graphic in tiles
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)
2009-07-14 19:20:15 +03:00
int3 getVisitableOffset ( ) const ; //returns (x,y,0) offset to first visitable tile from bottom right obj tile (0,0,0) (h3m pos)
2010-05-15 11:33:32 +03:00
int3 visitablePos ( ) const ;
2008-12-27 03:01:59 +02:00
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)
2009-07-01 18:58:20 +03:00
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)
2010-02-21 20:07:24 +02:00
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)
2009-07-30 15:49:45 +03:00
std : : set < int3 > getBlockedPos ( ) const ; //returns set of positions blocked by this object
2011-02-24 17:05:21 +02:00
bool isVisitable ( ) const ; //returns true if object is visitable
2008-12-27 03:01:59 +02:00
bool operator < ( const CGObjectInstance & cmp ) const ; //screen printing priority comparing
2010-06-19 12:13:10 +03:00
void hideTiles ( int ourplayer , int radius ) const ;
2008-12-27 03:01:59 +02:00
CGObjectInstance ( ) ;
virtual ~ CGObjectInstance ( ) ;
2008-12-31 11:33:46 +02:00
//CGObjectInstance(const CGObjectInstance & right);
//CGObjectInstance& operator=(const CGObjectInstance & right);
2008-12-27 03:01:59 +02:00
virtual const std : : string & getHoverText ( ) const ;
2012-03-14 16:02:38 +03:00
2013-01-13 15:40:24 +03:00
///IObjectInterface
void initObj ( ) override ;
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void setProperty ( ui8 what , ui32 val ) override ; //synchr
2008-12-27 03:01:59 +02:00
friend class CGameHandler ;
2008-12-31 11:33:46 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2010-07-28 13:46:36 +03:00
h & hoverName & pos & ID & subID & id & animPhaseShift & tempOwner & blockVisit & defInfo ;
2009-01-06 20:42:20 +02:00
//definfo is handled by map serializer
2008-12-31 11:33:46 +02:00
}
2013-01-13 15:40:24 +03:00
protected :
virtual void setPropertyDer ( ui8 what , ui32 val ) ; //synchr
void getNameVis ( std : : string & hname ) const ;
void giveDummyBonus ( int heroID , ui8 duration = Bonus : : ONE_DAY ) const ;
2008-12-27 03:01:59 +02:00
} ;
2010-02-01 19:07:46 +02:00
class CGHeroPlaceholder : public CGObjectInstance
{
public :
//subID stores id of hero type. If it's 0xff then following field is used
ui8 power ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
h & power ;
}
} ;
2008-12-27 03:01:59 +02:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CPlayersVisited : public CGObjectInstance
2009-03-14 19:19:53 +02:00
{
public :
2013-02-02 22:28:39 +03:00
std : : set < TPlayerColor > players ; //players that visited this object
2009-03-14 19:19:53 +02:00
2013-02-02 22:28:39 +03:00
bool wasVisited ( TPlayerColor player ) const ;
2013-01-13 15:40:24 +03:00
void setPropertyDer ( ui8 what , ui32 val ) override ;
2009-03-14 19:19:53 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-11-14 22:14:15 +02:00
h & static_cast < CGObjectInstance & > ( * this ) ;
2009-03-14 19:19:53 +02:00
h & players ;
}
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CArmedInstance : public CGObjectInstance , public CBonusSystemNode , public CCreatureSet
2008-12-27 03:01:59 +02:00
{
public :
2010-05-02 21:20:26 +03:00
BattleInfo * battle ; //set to the current battle, if engaged
void randomizeArmy ( int type ) ;
2011-02-04 16:58:14 +02:00
void updateMoraleBonusFromArmy ( ) ;
2013-01-13 15:40:24 +03:00
void armyChanged ( ) override ;
2010-05-02 21:20:26 +03:00
//////////////////////////////////////////////////////////////////////////
2013-01-13 15:40:24 +03:00
// int valOfGlobalBonuses(CSelector selector) const; //used only for castle interface ???
2011-02-22 11:47:25 +02:00
virtual CBonusSystemNode * whereShouldBeAttached ( CGameState * gs ) ;
virtual CBonusSystemNode * whatShouldBeAttached ( ) ;
2010-05-02 21:20:26 +03:00
//////////////////////////////////////////////////////////////////////////
CArmedInstance ( ) ;
2008-12-31 11:33:46 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-01-06 20:42:20 +02:00
h & static_cast < CGObjectInstance & > ( * this ) ;
2010-05-02 21:20:26 +03:00
h & static_cast < CBonusSystemNode & > ( * this ) ;
h & static_cast < CCreatureSet & > ( * this ) ;
2008-12-31 11:33:46 +02:00
}
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGHeroInstance : public CArmedInstance , public IBoatGenerator , public CArtifactSet
2008-12-27 03:01:59 +02:00
{
public :
2012-01-03 04:55:26 +03:00
enum ECanDig
{
CAN_DIG , LACK_OF_MOVEMENT , WRONG_TERRAIN , TILE_OCCUPIED
} ;
2008-12-27 03:01:59 +02:00
//////////////////////////////////////////////////////////////////////////
2009-07-18 06:13:13 +03:00
ui8 moveDir ; //format: 123
2008-12-27 03:01:59 +02:00
// 8 4
// 765
mutable ui8 isStanding , tacticFormationEnabled ;
//////////////////////////////////////////////////////////////////////////
2011-02-11 14:27:38 +02:00
ConstTransitivePtr < CHero > type ;
2012-09-23 21:01:04 +03:00
TExpType exp ; //experience points
2012-01-26 19:48:53 +03:00
ui32 level ; //current level of hero
2008-12-27 03:01:59 +02:00
std : : string name ; //may be custom
std : : string biography ; //if custom
2008-12-31 11:33:46 +02:00
si32 portrait ; //may be custom
2012-02-20 19:26:14 +03:00
si32 mana ; // remaining spell points
2013-02-04 22:43:16 +03:00
std : : vector < std : : pair < SecondarySkill : : SecondarySkill , 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
2012-01-26 19:48:53 +03:00
ui32 movement ; //remaining movement points
2008-12-31 11:33:46 +02:00
ui8 sex ;
2013-02-02 22:28:39 +03:00
bool inTownGarrison ; // if hero is in town garrison
2011-02-22 11:47:25 +02:00
ConstTransitivePtr < CGTownInstance > visitedTown ; //set if hero is visiting town or in the town garrison
2012-04-04 20:41:55 +03:00
ConstTransitivePtr < CCommanderInstance > commander ;
2010-07-20 21:34:32 +03:00
const CGBoat * boat ; //set to CGBoat when sailing
2013-01-12 13:32:03 +03:00
2010-12-17 20:47:07 +02:00
2011-01-18 20:56:14 +02:00
//std::vector<const CArtifact*> artifacts; //hero's artifacts from bag
//std::map<ui16, const CArtifact*> 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
2008-12-27 03:01:59 +02:00
std : : set < ui32 > spells ; //known spells (spell IDs)
2010-12-26 16:34:11 +02:00
2011-12-14 00:23:17 +03:00
struct DLL_LINKAGE Patrol
2009-02-03 07:28:05 +02:00
{
Patrol ( ) { patrolling = false ; patrolRadious = - 1 ; } ;
2013-02-02 22:28:39 +03:00
bool patrolling ;
2012-01-26 19:48:53 +03:00
ui32 patrolRadious ;
2009-02-03 07:28:05 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & patrolling & patrolRadious ;
}
} patrol ;
2010-12-26 16:34:11 +02:00
2011-12-14 00:23:17 +03:00
struct DLL_LINKAGE HeroSpecial : CBonusSystemNode
2010-06-28 08:07:21 +03:00
{
2013-02-02 22:28:39 +03:00
bool growsWithLevel ;
2013-01-17 21:15:00 +03:00
HeroSpecial ( ) { growsWithLevel = false ; } ;
2010-06-28 08:07:21 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CBonusSystemNode & > ( * this ) ;
2013-01-17 21:15:00 +03:00
h & growsWithLevel ;
2010-06-28 08:07:21 +03:00
}
2013-01-17 21:15:00 +03:00
} ;
std : : vector < HeroSpecial * > specialty ;
2009-02-03 07:28:05 +02:00
2010-04-03 06:33:46 +03:00
//BonusList bonuses;
2008-12-27 03:01:59 +02:00
//////////////////////////////////////////////////////////////////////////
2008-12-31 11:33:46 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-01-06 20:42:20 +02:00
h & static_cast < CArmedInstance & > ( * this ) ;
2010-12-26 16:34:11 +02:00
h & static_cast < CArtifactSet & > ( * this ) ;
2010-05-02 21:20:26 +03:00
h & exp & level & name & biography & portrait & mana & secSkills & movement
2011-01-18 20:56:14 +02:00
& sex & inTownGarrison & /*artifacts & artifWorn & */ spells & patrol & moveDir ;
2009-01-06 20:42:20 +02:00
2013-01-17 21:15:00 +03:00
h & type & specialty & commander ;
2011-02-22 11:47:25 +02:00
BONUS_TREE_DESERIALIZATION_FIX
2009-01-06 20:42:20 +02:00
//visitied town pointer will be restored by map serialization method
2008-12-31 11:33:46 +02:00
}
2009-03-12 01:25:59 +02:00
//////////////////////////////////////////////////////////////////////////
2010-11-13 22:26:15 +02:00
// void getParents(TCNodes &out, const CBonusSystemNode *root = NULL) const;
// void getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root = NULL) const;
2010-05-02 21:20:26 +03:00
//////////////////////////////////////////////////////////////////////////
2009-03-12 01:25:59 +02:00
int3 getSightCenter ( ) const ; //"center" tile from which the sight distance is calculated
int getSightRadious ( ) const ; //sight distance (should be used if player-owned structure)
2010-03-11 01:16:30 +02:00
//////////////////////////////////////////////////////////////////////////
int getBoatType ( ) const ; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral
void getOutOffsets ( std : : vector < int3 > & offsets ) const ; //offsets to obj pos when we boat can be placed
2008-12-31 11:33:46 +02:00
//////////////////////////////////////////////////////////////////////////
2013-01-12 13:32:03 +03:00
2011-01-18 20:56:14 +02:00
bool hasSpellbook ( ) const ;
2011-12-14 00:23:17 +03:00
EAlignment : : EAlignment getAlignment ( ) const ;
2008-12-27 03:01:59 +02:00
const std : : string & getBiography ( ) const ;
bool needsLastStack ( ) const ;
2011-12-14 00:23:17 +03:00
ui32 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
ui32 getLowestCreatureSpeed ( ) const ;
2010-02-24 15:03:36 +02:00
int3 getPosition ( bool h3m = false ) const ; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
2009-04-04 01:34:31 +03:00
si32 manaRegain ( ) const ; //how many points of mana can hero regain "naturally" in one day
2008-12-27 03:01:59 +02:00
bool canWalkOnSea ( ) const ;
2009-02-04 15:40:54 +02:00
int getCurrentLuck ( int stack = - 1 , bool town = false ) const ;
2010-03-11 01:16:30 +02:00
int getSpellCost ( const CSpell * sp ) const ; //do not use during battles -> bonuses from army would be ignored
2010-02-10 04:56:00 +02:00
2013-02-04 22:43:16 +03:00
ui8 getSecSkillLevel ( SecondarySkill : : SecondarySkill skill ) const ; //0 - no skill
void setSecSkillLevel ( SecondarySkill : : SecondarySkill which , int val , bool abs ) ; // abs == 0 - changes by value; 1 - sets to value
2012-12-18 14:24:13 +03:00
bool canLearnSkill ( ) const ; ///true if hero has free secondary skill slot
2013-01-12 13:32:03 +03:00
2008-12-27 03:01:59 +02:00
int maxMovePoints ( bool onLand ) const ;
2013-01-12 13:32:03 +03:00
int movementPointsAfterEmbark ( int MPsBefore , int basicCost , bool disembark = false ) const ;
2010-01-29 22:52:45 +02:00
2010-12-29 23:04:22 +02:00
// const CArtifact* getArtAtPos(ui16 pos) const; //NULL - no artifact
// const CArtifact * getArt(int pos) const;
// 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)
// bool hasArt(ui32 aid) const; //checks if hero possess artifact of given id (either in backack or worn)
2010-01-29 22:52:45 +02:00
2010-07-28 13:09:15 +03:00
//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
2008-12-27 03:01:59 +02:00
static int3 convertPosition ( int3 src , bool toh3m ) ; //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest
2009-04-12 04:48:50 +03:00
double getHeroStrength ( ) const ;
2011-06-21 12:31:08 +03:00
ui64 getTotalStrength ( ) const ;
2012-09-23 21:01:04 +03:00
TExpType calculateXp ( TExpType exp ) const ; //apply learning skill
2010-07-21 13:09:29 +03:00
ui8 getSpellSchoolLevel ( const CSpell * spell , int * outSelectedSchool = NULL ) const ; //returns level on which given spell would be cast by this hero (0 - none, 1 - basic etc); optionally returns number of selected school by arg - 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic,
* support for new hero bonuses (BLOCK_MORALE, SECONDARY_SKILL_PREMY (archery), AIR_SPELL_DMG_PREMY, EARTH_SPELL_DMG_PREMY, FIRE_SPELL_DMG_PREMY, WATER_SPELL_DMG_PREMY, BLOCK_SPELLS_ABOVE_LEVEL, SPELL_IMMUNITY, BLOCK_MORALE, FIRE_SPELLS, AIR_SPELLS, WATER_SPELLS, EARTH_SPELLS, SPELL, SPELLS_OF_LEVEL). It means that following artifacts are now supported:
- Orb of the Firmament
- Orb of Silt
- Orb of Tempestuous Fire
- Orb of Driving Rain
- Bow of Elven Cherrywood
- Bowstring of the Unicorn's Mane
- Angel Feather Arrows
- Tome of Fire Magic
- Tome of Air Magic
- Tome of Water Magic
- Tome of Earth Magic
- Recanter's Cloak
- Orb of Inhibition
- Pendant of Dispassion
- Pendant of Second Sight
- Pendant of Holiness
- Pendant of Life
- Pendant of Death
- Pendant of Free Will
- Pendant of Negativity
- Pendant of Total Recall
- Spellbinder's Hat
- Spirit of Oppression
- Sphere of Permanence
I hope I listed them all here :). Please try them and report if something's wrong.
2009-05-03 19:14:16 +03:00
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
2010-11-22 02:34:46 +02:00
CStackBasicDescriptor calculateNecromancy ( const BattleResult & battleResult ) const ;
void showNecromancyDialog ( const CStackBasicDescriptor & raisedStack ) const ;
2013-01-12 13:32:03 +03:00
ECanDig diggingStatus ( ) const ; //0 - can dig; 1 - lack of movement; 2 -
2009-02-03 07:28:05 +02:00
2008-12-27 03:01:59 +02:00
//////////////////////////////////////////////////////////////////////////
2013-01-12 13:32:03 +03:00
void initHero ( ) ;
void initHero ( int SUBID ) ;
2010-08-28 17:52:20 +03:00
2013-02-07 02:24:43 +03:00
void putArtifact ( ArtifactPosition : : ArtifactPosition pos , CArtifactInstance * art ) ;
2010-12-30 16:41:46 +02:00
void putInBackpack ( CArtifactInstance * art ) ;
2010-08-28 17:52:20 +03:00
void initExp ( ) ;
2011-01-28 04:11:58 +02:00
void initArmy ( IArmyDescriptor * dst = NULL ) ;
2012-02-17 22:30:40 +03:00
//void giveArtifact (ui32 aid);
2009-02-01 16:11:41 +02:00
void initHeroDefInfo ( ) ;
2013-02-04 22:43:16 +03:00
void pushPrimSkill ( PrimarySkill : : PrimarySkill which , int val ) ;
2013-01-17 21:15:00 +03:00
void Updatespecialty ( ) ;
2013-02-04 22:43:16 +03:00
void updateSkill ( SecondarySkill : : SecondarySkill which , int val ) ;
2010-01-29 22:52:45 +02:00
2008-12-27 03:01:59 +02:00
CGHeroInstance ( ) ;
virtual ~ CGHeroInstance ( ) ;
2012-04-14 05:20:22 +03:00
//////////////////////////////////////////////////////////////////////////
//
2013-02-07 20:34:50 +03:00
ArtBearer : : ArtBearer bearerType ( ) const override ;
2008-12-27 03:01:59 +02:00
//////////////////////////////////////////////////////////////////////////
2009-02-20 14:39:27 +02:00
2013-01-13 15:40:24 +03:00
CBonusSystemNode * whereShouldBeAttached ( CGameState * gs ) override ;
std : : string nodeName ( ) const override ;
2011-02-04 16:58:14 +02:00
void deserializationFix ( ) ;
2013-01-13 15:40:24 +03:00
void initObj ( ) override ;
void onHeroVisit ( const CGHeroInstance * h ) const override ;
protected :
void setPropertyDer ( ui8 what , ui32 val ) override ; //synchr
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CSpecObjInfo
2010-08-16 16:51:31 +03:00
{
public :
virtual ~ CSpecObjInfo ( ) { } ;
2012-09-24 21:52:30 +03:00
ui8 player ; //owner
2010-08-16 16:51:31 +03:00
} ;
2012-05-11 22:03:40 +03:00
class DLL_LINKAGE CCreGenAsCastleInfo : public virtual CSpecObjInfo
2010-08-16 16:51:31 +03:00
{
public :
bool asCastle ;
ui32 identifier ;
2011-12-14 00:23:17 +03:00
ui8 castles [ 2 ] ; //allowed castles
2010-08-16 16:51:31 +03:00
} ;
2012-05-11 22:03:40 +03:00
class DLL_LINKAGE CCreGenLeveledInfo : public virtual CSpecObjInfo
2010-08-16 16:51:31 +03:00
{
public :
2011-12-14 00:23:17 +03:00
ui8 minLevel , maxLevel ; //minimal and maximal level of creature in dwelling: <0, 6>
2010-08-16 16:51:31 +03:00
} ;
2012-05-11 22:03:40 +03:00
class DLL_LINKAGE CCreGenLeveledCastleInfo : public CCreGenAsCastleInfo , public CCreGenLeveledInfo
2010-08-16 16:51:31 +03:00
{
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGDwelling : public CArmedInstance
2009-07-06 22:41:27 +03:00
{
public :
2013-02-07 20:34:50 +03:00
typedef std : : vector < std : : pair < ui32 , std : : vector < CreatureID : : CreatureID > > > TCreaturesSet ;
2012-01-13 17:18:32 +03:00
2010-02-21 20:07:24 +02:00
CSpecObjInfo * info ; //h3m info about dewlling
2012-01-13 17:18:32 +03:00
TCreaturesSet creatures ; //creatures[level] -> <vector of alternative ids (base creature and upgrades, creatures amount>
2009-07-06 22:41:27 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CArmedInstance & > ( * this ) & creatures ;
}
2013-01-13 15:40:24 +03:00
void initObj ( ) override ;
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void newTurn ( ) const override ;
2013-01-22 00:34:30 +03:00
void setProperty ( ui8 what , ui32 val ) override ;
2013-01-13 15:40:24 +03:00
private :
2009-07-09 22:15:22 +03:00
void heroAcceptsCreatures ( const CGHeroInstance * h , ui32 answer ) const ;
void fightOver ( const CGHeroInstance * h , BattleResult * result ) const ;
void wantsFight ( const CGHeroInstance * h , ui32 answer ) const ;
2009-07-06 22:41:27 +03:00
} ;
2009-08-23 18:02:21 +03:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGVisitableOPH : public CGObjectInstance //objects visitable only once per hero
2009-08-23 18:02:21 +03:00
{
public :
std : : set < si32 > visitors ; //ids of heroes who have visited this obj
si8 ttype ; //tree type - used only by trees of knowledge: 0 - give level for free; 1 - take 2000 gold; 2 - take 10 gems
2013-01-13 15:40:24 +03:00
const std : : string & getHoverText ( ) const override ;
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void initObj ( ) override ;
bool wasVisited ( const CGHeroInstance * h ) const override ;
2009-08-23 18:02:21 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
h & visitors & ttype ;
}
2013-01-13 15:40:24 +03:00
protected :
void setPropertyDer ( ui8 what , ui32 val ) override ; //synchr
private :
void onNAHeroVisit ( int heroID , bool alreadyVisited ) const ;
///dialog callbacks
void treeSelected ( int heroID , int resType , int resVal , TExpType expVal , ui32 result ) const ;
void schoolSelected ( int heroID , ui32 which ) const ;
void arenaSelected ( int heroID , int primSkill ) const ;
2009-08-23 18:02:21 +03:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGTownBuilding : public IObjectInterface
2009-08-23 18:02:21 +03:00
{
///basic class for town structures handled as map objects
public :
2009-09-21 12:00:33 +03:00
si32 ID ; //from buildig list
si32 id ; //identifies its index on towns vector
2009-08-23 18:02:21 +03:00
CGTownInstance * town ;
2009-09-21 12:00:33 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & ID & id ;
}
2009-08-23 18:02:21 +03:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE COPWBonus : public CGTownBuilding
2009-10-05 19:38:54 +03:00
{ ///used for OPW bonusing structures
public :
std : : set < si32 > visitors ;
2013-01-13 15:40:24 +03:00
void setProperty ( ui8 what , ui32 val ) override ;
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2009-10-05 19:38:54 +03:00
COPWBonus ( int index , CGTownInstance * TOWN ) ;
COPWBonus ( ) { ID = 0 ; town = NULL ; } ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGTownBuilding & > ( * this ) ;
h & visitors ;
}
} ;
2010-05-18 10:01:54 +03:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CTownBonus : public CGTownBuilding
2009-08-23 18:02:21 +03:00
{
///used for one-time bonusing structures
2009-09-21 12:00:33 +03:00
///feel free to merge inheritance tree
2009-08-23 18:02:21 +03:00
public :
2009-09-21 12:00:33 +03:00
std : : set < si32 > visitors ;
2013-01-13 15:40:24 +03:00
void setProperty ( ui8 what , ui32 val ) override ;
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2009-08-23 18:02:21 +03:00
CTownBonus ( int index , CGTownInstance * TOWN ) ;
CTownBonus ( ) { ID = 0 ; town = NULL ; } ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-09-21 12:00:33 +03:00
h & static_cast < CGTownBuilding & > ( * this ) ;
2009-08-26 08:08:59 +03:00
h & visitors ;
2009-08-23 18:02:21 +03:00
}
} ;
2010-05-18 10:01:54 +03:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CTownAndVisitingHero : public CBonusSystemNode
2011-02-04 16:58:14 +02:00
{
2011-08-26 23:32:05 +03:00
public :
CTownAndVisitingHero ( ) ;
} ;
2011-12-14 00:23:17 +03:00
struct DLL_LINKAGE GrowthInfo
2011-08-26 23:32:05 +03:00
{
struct Entry
{
int count ;
std : : string description ;
Entry ( const std : : string & format , int _count ) ;
2011-12-14 00:23:17 +03:00
Entry ( int subID , EBuilding : : EBuilding building , int _count ) ;
2011-08-26 23:32:05 +03:00
} ;
std : : vector < Entry > entries ;
int totalGrowth ( ) const ;
2011-02-04 16:58:14 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGTownInstance : public CGDwelling , public IShipyard , public IMarket
2008-12-27 03:01:59 +02:00
{
public :
2012-03-04 13:43:46 +03:00
enum EFortLevel { NONE = 0 , FORT = 1 , CITADEL = 2 , CASTLE = 3 } ;
2011-02-04 16:58:14 +02:00
CTownAndVisitingHero townAndVis ;
2008-12-27 03:01:59 +02:00
CTown * town ;
std : : string name ; // name of town
2008-12-31 11:33:46 +02:00
si32 builded ; //how many buildings has been built this turn
si32 destroyed ; //how many buildings has been destroyed this turn
2011-02-04 16:58:14 +02:00
ConstTransitivePtr < CGHeroInstance > garrisonHero , visitingHero ;
2008-12-31 11:33:46 +02:00
ui32 identifier ; //special identifier from h3m (only > RoE maps)
si32 alignment ;
2008-12-27 03:01:59 +02:00
std : : set < si32 > forbiddenBuildings , builtBuildings ;
2009-08-24 17:59:24 +03:00
std : : vector < CGTownBuilding * > bonusingBuildings ;
2008-12-31 11:33:46 +02:00
std : : vector < ui32 > possibleSpells , obligatorySpells ;
2008-12-27 03:01:59 +02:00
std : : vector < std : : vector < ui32 > > spells ; //spells[level] -> vector of spells, first will be available in guild
2010-08-18 17:24:30 +03:00
std : : list < CCastleEvent * > events ;
2010-01-28 18:15:46 +02:00
std : : pair < si32 , si32 > bonusValue ; //var to store town bonuses (rampart = resources from mystic pond);
2008-12-27 03:01:59 +02:00
2008-12-31 11:33:46 +02:00
//////////////////////////////////////////////////////////////////////////
2010-06-26 19:02:10 +03:00
static std : : vector < const CArtifact * > merchantArtifacts ; //vector of artifacts available at Artifact merchant, NULLs possible (for making empty space when artifact is bought)
2010-07-20 17:08:13 +03:00
static std : : vector < int > universitySkills ; //skills for university of magic
2008-12-31 11:33:46 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-07-16 01:46:00 +03:00
h & static_cast < CGDwelling & > ( * this ) ;
2010-01-28 18:15:46 +02:00
h & name & builded & destroyed & identifier & alignment & forbiddenBuildings & builtBuildings & bonusValue
2009-12-01 23:05:57 +02:00
& possibleSpells & obligatorySpells & spells & /*strInfo & */ events & bonusingBuildings ;
for ( std : : vector < CGTownBuilding * > : : iterator i = bonusingBuildings . begin ( ) ; i ! = bonusingBuildings . end ( ) ; i + + )
( * i ) - > town = this ;
2011-02-04 16:58:14 +02:00
h & town & townAndVis ;
2011-02-22 11:47:25 +02:00
BONUS_TREE_DESERIALIZATION_FIX
2009-01-06 20:42:20 +02:00
//garrison/visiting hero pointers will be restored in the map serialization
2008-12-31 11:33:46 +02:00
}
2010-05-02 21:20:26 +03:00
//////////////////////////////////////////////////////////////////////////
2011-02-04 16:58:14 +02:00
2013-01-13 15:40:24 +03:00
CBonusSystemNode * whatShouldBeAttached ( ) override ;
std : : string nodeName ( ) const override ;
2011-02-04 16:58:14 +02:00
void deserializationFix ( ) ;
void recreateBuildingsBonuses ( ) ;
2012-03-06 19:59:55 +03:00
bool addBonusIfBuilt ( int building , int type , int val , TPropagatorPtr prop , int subtype = - 1 ) ; //returns true if building is built and bonus has been added
2011-02-21 06:13:00 +02:00
bool addBonusIfBuilt ( int building , int type , int val , int subtype = - 1 ) ; //convienence version of above
2011-02-04 16:58:14 +02:00
void setVisitingHero ( CGHeroInstance * h ) ;
void setGarrisonedHero ( CGHeroInstance * h ) ;
2011-02-25 19:57:30 +02:00
const CArmedInstance * getUpperArmy ( ) const ; //garrisoned hero if present or the town itself
2010-11-13 22:26:15 +02:00
// void getParents(TCNodes &out, const CBonusSystemNode *root = NULL) const;
// void getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root = NULL) const;
2008-12-31 11:33:46 +02:00
//////////////////////////////////////////////////////////////////////////
2010-02-01 19:07:46 +02:00
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
2009-03-12 01:25:59 +02:00
int3 getSightCenter ( ) const ; //"center" tile from which the sight distance is calculated
int getSightRadious ( ) const ; //returns sight distance
2010-02-13 06:47:31 +02:00
int getBoatType ( ) const ; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral
2009-07-26 06:33:13 +03:00
void getOutOffsets ( std : : vector < int3 > & offsets ) const ; //offsets to obj pos when we boat can be placed
2013-01-13 15:40:24 +03:00
int getMarketEfficiency ( ) const override ; //=market count
2011-12-14 00:23:17 +03:00
bool allowsTrade ( EMarketMode : : EMarketMode mode ) const ;
std : : vector < int > availableItemsIds ( EMarketMode : : EMarketMode mode ) const ;
2013-01-13 15:40:24 +03:00
2009-03-12 01:25:59 +02:00
//////////////////////////////////////////////////////////////////////////
2008-12-27 03:01:59 +02:00
bool needsLastStack ( ) const ;
2012-03-04 13:43:46 +03:00
CGTownInstance : : EFortLevel fortLevel ( ) const ;
2008-12-27 03:01:59 +02:00
int hallLevel ( ) const ; // -1 - none, 0 - village, 1 - town, 2 - city, 3 - capitol
int mageGuildLevel ( ) const ; // -1 - none, 0 - village, 1 - town, 2 - city, 3 - capitol
2012-08-08 00:46:24 +03:00
int creatureDwellingLevel ( int dwelling ) const ;
2008-12-27 03:01:59 +02:00
int getHordeLevel ( const int & HID ) const ; //HID - 0 or 1; returns creature level or -1 if that horde structure is not present
int creatureGrowth ( const int & level ) const ;
2011-08-26 23:32:05 +03:00
GrowthInfo getGrowthInfo ( int level ) const ;
2008-12-27 03:01:59 +02:00
bool hasFort ( ) const ;
bool hasCapitol ( ) const ;
2012-09-05 15:49:23 +03:00
//checks if building is constructed and town has same subID
2012-01-03 04:55:26 +03:00
bool hasBuilt ( int buildingID ) const ;
2012-09-05 15:49:23 +03:00
bool hasBuilt ( int buildingID , int townID ) const ;
2009-05-07 20:20:41 +03:00
int dailyIncome ( ) const ; //calculates daily income of this town
2008-12-27 03:01:59 +02:00
int spellsAtLevel ( int level , bool checkGuild ) const ; //levels are counted from 1 (1 - 5)
2012-09-24 21:52:30 +03:00
void removeCapitols ( ui8 owner ) const ;
2011-02-21 06:13:00 +02:00
bool armedGarrison ( ) const ; //true if town has creatures in garrison or garrisoned hero
2008-12-27 03:01:59 +02:00
CGTownInstance ( ) ;
virtual ~ CGTownInstance ( ) ;
2013-01-13 15:40:24 +03:00
///IObjectInterface overrides
void newTurn ( ) const override ;
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void onHeroLeave ( const CGHeroInstance * h ) const override ;
void initObj ( ) override ;
protected :
void setPropertyDer ( ui8 what , ui32 val ) override ;
private :
///dialog callbacks
2009-08-22 16:59:15 +03:00
void fightOver ( const CGHeroInstance * h , BattleResult * result ) const ;
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGPandoraBox : public CArmedInstance
2008-12-27 03:01:59 +02:00
{
public :
std : : string message ;
2009-08-16 18:39:18 +03:00
//gained things:
2009-01-06 20:42:20 +02:00
ui32 gainedExp ;
si32 manaDiff ; //amount of gained / lost mana
si32 moraleDiff ; //morale modifier
si32 luckDiff ; //luck modifier
2013-02-05 00:58:42 +03:00
TResources resources ; //gained / lost resources
2013-02-04 22:43:16 +03:00
std : : vector < si32 > primskills ; //gained / lost prim skills
std : : vector < SecondarySkill : : SecondarySkill > abilities ; //gained abilities
2009-01-06 20:42:20 +02:00
std : : vector < si32 > abilityLevels ; //levels of gained abilities
std : : vector < si32 > artifacts ; //gained artifacts
std : : vector < si32 > spells ; //gained spells
2008-12-27 03:01:59 +02:00
CCreatureSet creatures ; //gained creatures
2009-08-16 18:39:18 +03:00
2013-01-13 15:40:24 +03:00
void initObj ( ) override ;
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2009-08-16 18:39:18 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CArmedInstance & > ( * this ) ;
h & message & gainedExp & manaDiff & moraleDiff & luckDiff & resources & primskills
2010-05-02 21:20:26 +03:00
& abilities & abilityLevels & artifacts & spells & creatures ;
2009-08-16 18:39:18 +03:00
}
2013-01-13 15:40:24 +03:00
protected :
void endBattle ( const CGHeroInstance * h , BattleResult * result ) const ;
void giveContents ( const CGHeroInstance * h , bool afterBattle ) const ;
private :
void open ( const CGHeroInstance * h , ui32 accept ) const ;
void getText ( InfoWindow & iw , bool & afterBattle , int val , int negative , int positive , const CGHeroInstance * h ) const ;
void getText ( InfoWindow & iw , bool & afterBattle , int text , const CGHeroInstance * h ) const ;
2009-08-16 18:39:18 +03:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGEvent : public CGPandoraBox //event objects
2009-08-16 18:39:18 +03:00
{
public :
2013-02-02 22:28:39 +03:00
bool removeAfterVisit ; //true if event is removed after occurring
2009-01-06 20:42:20 +02:00
ui8 availableFor ; //players whom this event is available for
2013-02-02 22:28:39 +03:00
bool computerActivate ; //true if computer player can activate this event
bool humanActivate ; //true if human player can activate this event
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2011-03-08 15:27:32 +02:00
h & static_cast < CGPandoraBox & > ( * this ) ;
h & removeAfterVisit & availableFor & computerActivate & humanActivate ;
2009-01-06 20:42:20 +02:00
}
2013-01-12 13:32:03 +03:00
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
private :
2009-08-16 18:39:18 +03:00
void activated ( const CGHeroInstance * h ) const ;
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGCreature : public CArmedInstance //creatures on map
2008-12-27 03:01:59 +02:00
{
public :
ui32 identifier ; //unique code for this monster (used in missions)
2012-01-19 17:33:22 +03:00
si8 character ; //character of this set of creatures (0 - the most friendly, 4 - the most hostile) => on init changed to -4 (compliant) ... 10 value (savage)
2008-12-27 03:01:59 +02:00
std : : string message ; //message printed for attacking hero
2013-02-05 00:58:42 +03:00
TResources resources ; // resources given to hero that has won with monsters
2013-02-07 20:34:50 +03:00
ArtifactID : : ArtifactID gainedArtifact ; //ID of artifact gained to hero, -1 if none
2013-02-02 22:28:39 +03:00
bool neverFlees ; //if true, the troops will never flee
bool notGrowingTeam ; //if true, number of units won't grow
2010-09-30 16:15:18 +03:00
ui64 temppower ; //used to handle fractional stack growth for tiny stacks
2008-12-27 03:01:59 +02:00
2009-04-12 04:48:50 +03:00
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
const std : : string & getHoverText ( ) const override ;
void initObj ( ) override ;
void newTurn ( ) const override ;
2009-01-06 20:42:20 +02:00
2011-12-14 00:23:17 +03:00
struct DLL_LINKAGE RestoredCreature // info about merging stacks after battle back into one
2011-04-14 10:58:19 +03:00
{
si32 basicType ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & basicType ;
}
} restore ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CArmedInstance & > ( * this ) ;
2011-04-14 10:58:19 +03:00
h & identifier & character & message & resources & gainedArtifact & neverFlees & notGrowingTeam & temppower & restore ;
2009-01-06 20:42:20 +02:00
}
2013-01-13 15:40:24 +03:00
protected :
void setPropertyDer ( ui8 what , ui32 val ) override ;
private :
void fight ( const CGHeroInstance * h ) const ;
void flee ( const CGHeroInstance * h ) const ;
void endBattle ( BattleResult * result ) const ;
void fleeDecision ( const CGHeroInstance * h , ui32 pursue ) const ;
void joinDecision ( const CGHeroInstance * h , int cost , ui32 accept ) const ;
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)
2013-01-12 13:32:03 +03:00
} ;
2008-12-27 03:01:59 +02:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGSignBottle : public CGObjectInstance //signs and ocean bottles
2008-12-27 03:01:59 +02:00
{
public :
std : : string message ;
2009-01-06 20:42:20 +02:00
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void initObj ( ) override ;
2009-03-19 16:17:19 +02:00
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
h & message ;
}
2008-12-27 03:01:59 +02:00
} ;
2012-09-16 16:34:01 +03:00
class DLL_LINKAGE IQuestObject
{
public :
2012-10-03 17:49:29 +03:00
CQuest * quest ;
2012-09-16 16:34:01 +03:00
2012-10-03 17:49:29 +03:00
IQuestObject ( ) { quest = new CQuest ; } ;
2012-09-16 16:34:01 +03:00
virtual void getVisitText ( MetaString & text , std : : vector < Component > & components , bool isCustom , bool FirstVisit , const CGHeroInstance * h = NULL ) const ;
virtual bool checkQuest ( const CGHeroInstance * h ) const ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & quest ;
}
} ;
class DLL_LINKAGE CGSeerHut : public CArmedInstance , public IQuestObject //army is used when giving reward
2008-12-27 03:01:59 +02:00
{
public :
2013-02-02 01:04:25 +03:00
enum ERewardType { NOTHING , EXPERIENCE , MANA_POINTS , MORALE_BONUS , LUCK_BONUS , RESOURCES , PRIMARY_SKILL , SECONDARY_SKILL , ARTIFACT , SPELL , CREATURE } ;
ERewardType rewardType ;
2009-05-07 20:20:41 +03:00
si32 rID ; //reward ID
si32 rVal ; //reward value
2010-01-27 07:11:31 +02:00
std : : string seerName ;
2009-12-30 22:49:10 +02:00
2012-10-03 17:49:29 +03:00
CGSeerHut ( ) : IQuestObject ( ) { } ;
2013-01-13 15:40:24 +03:00
void initObj ( ) override ;
const std : : string & getHoverText ( ) const override ;
void newTurn ( ) const override ;
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2009-01-06 20:42:20 +02:00
2012-09-16 16:34:01 +03:00
int checkDirection ( ) const ; //calculates the region of map where monster is placed
2012-07-19 12:10:55 +03:00
void setObjToKill ( ) ; //remember creatures / heroes to kill after they are initialized
2011-02-11 14:27:38 +02:00
const CGHeroInstance * getHeroToKill ( bool allowNull = false ) const ;
const CGCreature * getCreatureToKill ( bool allowNull = false ) const ;
2012-09-16 16:34:01 +03:00
void getRolloverText ( MetaString & text , bool onHover ) const ;
void getCompletionText ( MetaString & text , std : : vector < Component > & components , bool isCustom , const CGHeroInstance * h = NULL ) const ;
void finishQuest ( const CGHeroInstance * h , ui32 accept ) const ; //common for both objects
void completeQuest ( const CGHeroInstance * h ) const ;
2011-02-11 14:27:38 +02:00
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2012-09-16 16:34:01 +03:00
h & static_cast < CArmedInstance & > ( * this ) & static_cast < IQuestObject & > ( * this ) ;
2012-08-11 20:01:39 +03:00
h & rewardType & rID & rVal & seerName ;
2010-01-30 22:53:47 +02:00
}
2013-01-13 15:40:24 +03:00
protected :
void setPropertyDer ( ui8 what , ui32 val ) override ;
2010-01-30 22:53:47 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGQuestGuard : public CGSeerHut
2010-01-30 22:53:47 +02:00
{
public :
2012-10-03 17:49:29 +03:00
CGQuestGuard ( ) : CGSeerHut ( ) { } ;
2013-01-13 15:40:24 +03:00
void initObj ( ) override ;
2010-01-30 22:53:47 +02:00
void completeQuest ( const CGHeroInstance * h ) const ;
2013-01-12 13:32:03 +03:00
2010-01-30 22:53:47 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGSeerHut & > ( * this ) ;
2009-01-06 20:42:20 +02:00
}
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGWitchHut : public CPlayersVisited
2008-12-27 03:01:59 +02:00
{
public :
2009-01-06 20:42:20 +02:00
std : : vector < si32 > allowedAbilities ;
2009-01-11 00:08:18 +02:00
ui32 ability ;
2013-01-13 15:40:24 +03:00
const std : : string & getHoverText ( ) const override ;
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void initObj ( ) override ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-11-21 00:35:18 +02:00
h & static_cast < CPlayersVisited & > ( * this ) ;
2009-01-11 00:08:18 +02:00
h & allowedAbilities & ability ;
2009-01-06 20:42:20 +02:00
}
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGScholar : public CGObjectInstance
2008-12-27 03:01:59 +02:00
{
public :
2013-02-02 01:04:25 +03:00
enum EBonusType { PRIM_SKILL , SECONDARY_SKILL , SPELL , RANDOM = 255 } ;
EBonusType bonusType ;
2009-04-08 22:55:50 +03:00
ui16 bonusID ; //ID of skill/spell
2008-12-27 03:01:59 +02:00
2013-01-13 15:40:24 +03:00
// void giveAnyBonus(const CGHeroInstance * h) const; //TODO: remove
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void initObj ( ) override ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
2009-05-30 19:00:26 +03:00
h & bonusType & bonusID ;
2009-01-06 20:42:20 +02:00
}
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGGarrison : public CArmedInstance
2008-12-27 03:01:59 +02:00
{
public :
2013-02-02 22:28:39 +03:00
bool removableUnits ;
2009-01-06 20:42:20 +02:00
2009-12-20 19:14:14 +02:00
ui8 getPassableness ( ) const ;
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2009-08-25 18:08:18 +03:00
void fightOver ( const CGHeroInstance * h , BattleResult * result ) const ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CArmedInstance & > ( * this ) ;
h & removableUnits ;
}
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGArtifact : public CArmedInstance
2008-12-27 03:01:59 +02:00
{
public :
2010-12-26 16:34:11 +02:00
CArtifactInstance * storedArtifact ;
2008-12-27 03:01:59 +02:00
std : : string message ;
2010-12-26 16:34:11 +02:00
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2009-04-11 04:32:50 +03:00
void fightForArt ( ui32 agreed , const CGHeroInstance * h ) const ;
2009-02-03 07:28:05 +02:00
void endBattle ( BattleResult * result , const CGHeroInstance * h ) const ;
void pick ( const CGHeroInstance * h ) const ;
2013-01-13 15:40:24 +03:00
void initObj ( ) override ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CArmedInstance & > ( * this ) ;
2010-12-26 16:34:11 +02:00
h & message & storedArtifact ;
2009-01-06 20:42:20 +02:00
}
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGResource : public CArmedInstance
2008-12-27 03:01:59 +02:00
{
public :
2009-01-06 20:42:20 +02:00
ui32 amount ; //0 if random
2008-12-27 03:01:59 +02:00
std : : string message ;
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void initObj ( ) override ;
2009-01-11 00:08:18 +02:00
void collectRes ( int player ) const ;
2009-04-11 04:32:50 +03:00
void fightForRes ( ui32 agreed , const CGHeroInstance * h ) const ;
2009-01-11 00:08:18 +02:00
void endBattle ( BattleResult * result , const CGHeroInstance * h ) const ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CArmedInstance & > ( * this ) ;
h & amount & message ;
}
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGPickable : public CGObjectInstance //campfire, treasure chest, Flotsam, Shipwreck Survivor, Sea Chest
2008-12-27 03:01:59 +02:00
{
2009-01-06 20:42:20 +02:00
public :
2008-12-27 03:01:59 +02:00
ui32 type , val1 , val2 ;
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void initObj ( ) override ;
2008-12-27 03:01:59 +02:00
void chosen ( int which , int heroID ) const ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
h & type & val1 & val2 ;
}
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGShrine : public CPlayersVisited
2008-12-27 03:01:59 +02:00
{
public :
2009-01-06 20:42:20 +02:00
ui8 spell ; //number of spell or 255 if random
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void initObj ( ) override ;
const std : : string & getHoverText ( ) const override ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-11-21 00:35:18 +02:00
h & static_cast < CPlayersVisited & > ( * this ) ; ;
2009-01-06 20:42:20 +02:00
h & spell ;
}
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGMine : public CArmedInstance
2008-12-27 03:01:59 +02:00
{
2013-01-12 13:32:03 +03:00
public :
2013-02-04 22:43:16 +03:00
Res : : ERes producedResource ;
2010-07-31 03:26:34 +03:00
ui32 producedQuantity ;
2009-04-12 03:58:41 +03:00
void offerLeavingGuards ( const CGHeroInstance * h ) const ;
2013-02-04 22:43:16 +03:00
void endBattle ( BattleResult * result , TPlayerColor attackingPlayer ) const ;
2010-07-31 03:26:34 +03:00
void fight ( ui32 agreed , const CGHeroInstance * h ) const ;
2013-01-12 13:32:03 +03:00
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2010-07-31 03:26:34 +03:00
2013-02-04 22:43:16 +03:00
void flagMine ( TPlayerColor player ) const ;
2013-01-13 15:40:24 +03:00
void newTurn ( ) const override ;
void initObj ( ) override ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CArmedInstance & > ( * this ) ;
2010-07-31 03:26:34 +03:00
h & producedResource & producedQuantity ;
2009-01-06 20:42:20 +02:00
}
2010-07-31 03:26:34 +03:00
ui32 defaultResProduction ( ) ;
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGVisitableOPW : public CGObjectInstance //objects visitable OPW
2008-12-27 03:01:59 +02:00
{
public :
ui8 visited ; //true if object has been visited this week
2013-02-02 22:28:39 +03:00
bool wasVisited ( TPlayerColor player ) const ;
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void newTurn ( ) const override ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
h & visited ;
}
2013-01-13 15:40:24 +03:00
protected :
void setPropertyDer ( ui8 what , ui32 val ) override ;
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGTeleport : public CGObjectInstance //teleports and subterranean gates
2008-12-27 03:01:59 +02:00
{
public :
2009-09-07 05:29:44 +03:00
static std : : map < int , std : : map < int , std : : vector < int > > > objs ; //teleports: map[ID][subID] => vector of ids
static std : : vector < std : : pair < int , int > > gates ; //subterranean gates: pairs of ids
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void initObj ( ) override ;
2009-09-07 05:29:44 +03:00
static void postInit ( ) ;
2011-09-19 23:50:25 +03:00
static int getMatchingGate ( int id ) ; //receives id of one subterranean gate and returns id of the paired one, -1 if none
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
2009-02-03 07:28:05 +02:00
{
h & static_cast < CGObjectInstance & > ( * this ) ;
}
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGBonusingObject : public CGObjectInstance //objects giving bonuses to luck/morale/movement
2009-02-04 15:40:54 +02:00
{
public :
2012-03-14 16:02:38 +03:00
bool wasVisited ( const CGHeroInstance * h ) const ;
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
const std : : string & getHoverText ( ) const override ;
void initObj ( ) override ;
2009-02-04 15:40:54 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
}
} ;
2013-01-12 13:32:03 +03:00
class DLL_LINKAGE CGMagicSpring : public CGVisitableOPW
2013-02-02 22:28:39 +03:00
{ ///unfortunately, this one is quite different than others
2013-01-12 13:32:03 +03:00
public :
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
const std : : string & getHoverText ( ) const override ;
2009-09-23 15:42:14 +03:00
2013-01-12 13:32:03 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
h & visited ;
}
} ;
2009-09-23 15:42:14 +03:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGMagicWell : public CGObjectInstance //objects giving bonuses to luck/morale/movement
2009-02-06 13:15:39 +02:00
{
public :
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
const std : : string & getHoverText ( ) const override ;
2009-02-06 13:15:39 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
}
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGSirens : public CGObjectInstance
2009-07-19 10:16:33 +03:00
{
public :
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
const std : : string & getHoverText ( ) const override ;
void initObj ( ) override ;
2009-07-19 10:16:33 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
}
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGObservatory : public CGObjectInstance //Redwood observatory
2009-03-14 13:25:25 +02:00
{
public :
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2009-03-14 13:25:25 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
}
} ;
2009-02-06 13:15:39 +02:00
2009-08-11 10:50:29 +03:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGKeys : public CGObjectInstance //Base class for Keymaster and guards
2013-01-12 13:32:03 +03:00
{
2009-08-11 10:50:29 +03:00
public :
2013-02-02 22:28:39 +03:00
static std : : map < TPlayerColor , std : : set < ui8 > > playerKeyMap ; //[players][keysowned]
2009-08-11 10:50:29 +03:00
//SubID 0 - lightblue, 1 - green, 2 - red, 3 - darkblue, 4 - brown, 5 - purple, 6 - white, 7 - black
2012-07-08 19:36:20 +03:00
const std : : string getName ( ) const ; //depending on color
2013-02-02 22:28:39 +03:00
bool wasMyColorVisited ( TPlayerColor player ) const ;
2013-01-13 15:40:24 +03:00
const std : : string & getHoverText ( ) const override ;
2009-08-11 10:50:29 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
}
2013-01-13 15:40:24 +03:00
protected :
void setPropertyDer ( ui8 what , ui32 val ) override ;
2009-08-11 10:50:29 +03:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGKeymasterTent : public CGKeys
2009-08-11 10:50:29 +03:00
{
public :
2013-02-02 22:28:39 +03:00
bool wasVisited ( TPlayerColor player ) const ;
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2009-08-11 10:50:29 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
}
} ;
2012-09-16 16:34:01 +03:00
class DLL_LINKAGE CGBorderGuard : public CGKeys , public IQuestObject
2009-08-11 10:50:29 +03:00
{
public :
2012-10-03 17:49:29 +03:00
CGBorderGuard ( ) : IQuestObject ( ) { } ;
2013-01-13 15:40:24 +03:00
void initObj ( ) override ;
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2012-07-08 19:36:20 +03:00
void getVisitText ( MetaString & text , std : : vector < Component > & components , bool isCustom , bool FirstVisit , const CGHeroInstance * h = NULL ) const ;
void getRolloverText ( MetaString & text , bool onHover ) const ;
2012-07-19 12:10:55 +03:00
bool checkQuest ( const CGHeroInstance * h ) const ;
2013-01-13 15:40:24 +03:00
2009-08-11 10:50:29 +03:00
void openGate ( const CGHeroInstance * h , ui32 accept ) const ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
2012-09-16 16:34:01 +03:00
h & static_cast < IQuestObject & > ( * this ) ;
2009-08-11 10:50:29 +03:00
h & static_cast < CGObjectInstance & > ( * this ) ;
h & blockVisit ;
}
} ;
2012-07-29 21:18:55 +03:00
class DLL_LINKAGE CGBorderGate : public CGBorderGuard
2009-08-11 10:50:29 +03:00
{
public :
2012-10-03 17:49:29 +03:00
CGBorderGate ( ) : CGBorderGuard ( ) { } ;
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
ui8 getPassableness ( ) const override ;
2012-07-29 21:18:55 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGBorderGuard & > ( * this ) ; //need to serialize or object will be empty
}
2009-08-11 10:50:29 +03:00
} ;
2013-01-12 13:32:03 +03:00
class DLL_LINKAGE CGBoat : public CGObjectInstance
2009-07-19 04:00:19 +03:00
{
public :
ui8 direction ;
const CGHeroInstance * hero ; //hero on board
2013-01-13 15:40:24 +03:00
void initObj ( ) override ;
2009-07-19 04:00:19 +03:00
CGBoat ( )
{
2009-08-01 13:08:16 +03:00
hero = NULL ;
2009-07-19 04:00:19 +03:00
direction = 4 ;
}
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) & direction ;
}
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGOnceVisitable : public CPlayersVisited
2009-09-01 17:36:48 +03:00
///wagon, corpse, lean to, warriors tomb
2009-04-16 03:28:54 +03:00
{
public :
ui8 artOrRes ; //0 - nothing; 1 - artifact; 2 - resource
ui32 bonusType , //id of res or artifact
bonusVal ; //resource amount (or not used)
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
const std : : string & getHoverText ( ) const override ;
void initObj ( ) override ;
2009-04-16 03:28:54 +03:00
void searchTomb ( const CGHeroInstance * h , ui32 accept ) const ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-11-21 00:35:18 +02:00
h & static_cast < CPlayersVisited & > ( * this ) ; ;
2009-12-01 13:47:52 +02:00
h & artOrRes & bonusType & bonusVal ;
2009-04-16 03:28:54 +03:00
}
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CBank : public CArmedInstance
2009-08-11 10:50:29 +03:00
{
public :
int index ; //banks have unusal numbering - see ZCRBANK.txt and initObj()
BankConfig * bc ;
2011-12-14 00:23:17 +03:00
double multiplier ; //for improved banks script
2009-08-26 08:08:59 +03:00
std : : vector < ui32 > artifacts ; //fixed and deterministic
2009-08-14 09:01:08 +03:00
ui32 daycounter ;
2009-08-11 10:50:29 +03:00
2013-01-13 15:40:24 +03:00
void initObj ( ) override ;
const std : : string & getHoverText ( ) const override ;
2009-10-24 22:21:32 +03:00
void initialize ( ) const ;
void reset ( ui16 var1 ) ;
2013-01-13 15:40:24 +03:00
void newTurn ( ) const override ;
bool wasVisited ( ui8 player ) const override ;
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2009-09-25 18:40:28 +03:00
virtual void fightGuards ( const CGHeroInstance * h , ui32 accept ) const ;
virtual void endBattle ( const CGHeroInstance * h , const BattleResult * result ) const ;
2009-08-11 10:50:29 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2010-10-02 10:10:38 +03:00
h & static_cast < CArmedInstance & > ( * this ) ;
2009-12-29 03:07:17 +02:00
h & index & multiplier & artifacts & daycounter & bc ;
2009-08-11 10:50:29 +03:00
}
2013-01-13 15:40:24 +03:00
protected :
void setPropertyDer ( ui8 what , ui32 val ) override ;
2009-08-11 10:50:29 +03:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGPyramid : public CBank
2009-09-24 20:54:02 +03:00
{
public :
ui16 spell ;
2013-01-13 15:40:24 +03:00
void initObj ( ) override ;
const std : : string & getHoverText ( ) const override ;
void newTurn ( ) const override { } ; //empty, no reset
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void endBattle ( const CGHeroInstance * h , const BattleResult * result ) const override ;
2009-09-24 20:54:02 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-12-29 19:15:03 +02:00
h & static_cast < CBank & > ( * this ) ;
2009-09-24 20:54:02 +03:00
h & spell ;
}
} ;
2009-08-11 10:50:29 +03:00
2009-07-26 06:33:13 +03:00
class CGShipyard : public CGObjectInstance , public IShipyard
{
public :
void getOutOffsets ( std : : vector < int3 > & offsets ) const ; //offsets to obj pos when we boat can be placed
CGShipyard ( ) ;
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2009-07-26 06:33:13 +03:00
} ;
2009-02-03 07:28:05 +02:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGMagi : public CGObjectInstance
2008-12-27 03:01:59 +02:00
{
public :
2009-08-13 04:03:11 +03:00
static std : : map < si32 , std : : vector < si32 > > eyelist ; //[subID][id], supports multiple sets as in H5
2013-01-13 15:40:24 +03:00
void initObj ( ) override ;
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2009-01-11 00:08:18 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-08-13 04:03:11 +03:00
h & static_cast < CGObjectInstance & > ( * this ) ;
2009-01-11 00:08:18 +02:00
}
2008-12-27 03:01:59 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CCartographer : public CPlayersVisited
2009-08-19 09:56:53 +03:00
{
2013-01-12 13:32:03 +03:00
///behaviour varies depending on surface and floor
2009-08-19 09:56:53 +03:00
public :
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2009-08-19 09:56:53 +03:00
void buyMap ( const CGHeroInstance * h , ui32 accept ) const ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-11-14 22:14:15 +02:00
h & static_cast < CPlayersVisited & > ( * this ) ;
2009-08-19 09:56:53 +03:00
}
2009-09-21 12:00:33 +03:00
} ;
2010-02-06 15:49:14 +02:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGDenOfthieves : public CGObjectInstance
2010-02-06 15:49:14 +02:00
{
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2010-02-06 15:49:14 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGObelisk : public CPlayersVisited
2010-02-10 04:56:00 +02:00
{
public :
static ui8 obeliskCount ; //how many obelisks are on map
2010-08-06 16:14:10 +03:00
static std : : map < ui8 , ui8 > visited ; //map: team_id => how many obelisks has been visited
2010-02-10 04:56:00 +02:00
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void initObj ( ) override ;
const std : : string & getHoverText ( ) const override ;
2010-02-10 04:56:00 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2010-05-18 10:01:54 +03:00
h & static_cast < CPlayersVisited & > ( * this ) ;
2010-02-10 04:56:00 +02:00
}
2013-01-13 15:40:24 +03:00
protected :
void setPropertyDer ( ui8 what , ui32 val ) override ;
2010-02-10 04:56:00 +02:00
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGLighthouse : public CGObjectInstance
2010-02-10 04:56:00 +02:00
{
public :
2013-01-13 15:40:24 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
void initObj ( ) override ;
const std : : string & getHoverText ( ) const override ;
2010-02-10 04:56:00 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2010-05-18 10:01:54 +03:00
h & static_cast < CGObjectInstance & > ( * this ) ;
2010-02-10 04:56:00 +02:00
}
void giveBonusTo ( ui8 player ) const ;
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGMarket : public CGObjectInstance , public IMarket
2010-05-18 10:01:54 +03:00
{
public :
CGMarket ( ) ;
2013-01-13 15:40:24 +03:00
///IObjectIntercae
void onHeroVisit ( const CGHeroInstance * h ) const override ; //open trading window
2013-01-12 13:32:03 +03:00
2013-01-13 15:40:24 +03:00
///IMarket
int getMarketEfficiency ( ) const override ;
bool allowsTrade ( EMarketMode : : EMarketMode mode ) const override ;
int availableUnits ( EMarketMode : : EMarketMode mode , int marketItemSerial ) const override ; //-1 if unlimited
std : : vector < int > availableItemsIds ( EMarketMode : : EMarketMode mode ) const override ;
2013-01-12 13:32:03 +03:00
2010-05-18 10:01:54 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
}
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGBlackMarket : public CGMarket
2010-06-26 19:02:10 +03:00
{
public :
std : : vector < const CArtifact * > artifacts ; //available artifacts
2013-01-13 15:40:24 +03:00
void newTurn ( ) const override ; //reset artifacts for black market every month
std : : vector < int > availableItemsIds ( EMarketMode : : EMarketMode mode ) const override ;
2013-01-12 13:32:03 +03:00
2010-06-26 19:02:10 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGMarket & > ( * this ) ;
2010-06-27 19:03:01 +03:00
h & artifacts ;
2010-06-26 19:02:10 +03:00
}
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGUniversity : public CGMarket
2010-07-20 17:08:13 +03:00
{
public :
std : : vector < int > skills ; //available skills
2013-01-12 13:32:03 +03:00
2011-12-14 00:23:17 +03:00
std : : vector < int > availableItemsIds ( EMarketMode : : EMarketMode mode ) const ;
2013-01-13 15:40:24 +03:00
void initObj ( ) override ; //set skills for trade
void onHeroVisit ( const CGHeroInstance * h ) const override ; //open window
2013-01-12 13:32:03 +03:00
2010-07-20 17:08:13 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGMarket & > ( * this ) ;
h & skills ;
}
} ;
2009-08-13 04:03:11 +03:00
struct BankConfig
{
2009-08-20 13:07:23 +03:00
BankConfig ( ) { level = chance = upgradeChance = combatValue = value = rewardDifficulty = easiest = 0 ; } ;
ui8 level ; //1 - 4, how hard the battle will be
ui8 chance ; //chance for this level being chosen
ui8 upgradeChance ; //chance for creatures to be in upgraded versions
2013-02-07 20:34:50 +03:00
std : : vector < std : : pair < CreatureID : : CreatureID , ui32 > > guards ; //creature ID, amount
2009-08-20 13:07:23 +03:00
ui32 combatValue ; //how hard are guards of this level
std : : vector < si32 > resources ; //resources given in case of victory
2013-02-07 20:34:50 +03:00
std : : vector < std : : pair < CreatureID : : CreatureID , ui32 > > creatures ; //creatures granted in case of victory (creature ID, amount)
2009-08-20 13:07:23 +03:00
std : : vector < ui16 > artifacts ; //number of artifacts given in case of victory [0] -> treasure, [1] -> minor [2] -> major [3] -> relic
ui32 value ; //overall value of given things
ui32 rewardDifficulty ; //proportion of reward value to difficulty of guards; how profitable is this creature Bank config
ui16 easiest ; //?!?
2009-08-13 04:03:11 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-09-01 17:36:48 +03:00
h & level & chance & upgradeChance & guards & combatValue & resources & creatures & artifacts & value & rewardDifficulty & easiest ;
2009-08-13 04:03:11 +03:00
}
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CObjectHandler
2009-08-11 10:50:29 +03:00
{
public :
2013-02-07 20:34:50 +03:00
std : : map < si32 , CreatureID : : CreatureID > cregens ; //type 17. dwelling subid -> creature ID
2010-12-19 16:39:56 +02:00
std : : map < ui32 , std : : vector < ConstTransitivePtr < BankConfig > > > banksInfo ; //[index][preset]
2009-09-17 14:05:50 +03:00
std : : map < ui32 , std : : string > creBanksNames ; //[crebank index] -> name of this creature bank
2010-05-18 10:01:54 +03:00
std : : vector < ui32 > resVals ; //default values of resources in gold
2009-08-11 10:50:29 +03:00
2009-08-13 04:03:11 +03:00
void loadObjects ( ) ;
2012-03-03 13:08:01 +03:00
int bankObjToIndex ( const CGObjectInstance * obj ) ;
2009-08-11 10:50:29 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2010-05-18 10:01:54 +03:00
h & cregens & banksInfo & creBanksNames & resVals ;
2009-08-11 10:50:29 +03:00
}
} ;