2011-12-14 00:23:17 +03:00
# pragma once
2009-01-30 20:36:00 +02:00
# ifndef _MSC_VER
# include "CHeroHandler.h"
# include "CTownHandler.h"
# include "../lib/VCMI_Lib.h"
# endif
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"
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 ;
2010-07-08 22:10:26 +03:00
struct UpdateHeroSpeciality ;
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
2012-07-08 11:42:03 +03:00
si32 qid ; //unique quets id for serialization / identification
2010-01-30 22:53:47 +02:00
ui8 missionType , 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 ;
CStackBasicDescriptor stackToKill ;
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
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
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
int state ( ) const ; //0 - can buid, 1 - there is already a boat at dest tile, 2 - dest tile is blocked, 3 - no water
2010-07-13 08:25:40 +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
2011-12-14 00:23:17 +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
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
{
protected :
2009-07-19 10:16:33 +03:00
void getNameVis ( std : : string & hname ) const ;
2010-05-02 21:20:26 +03:00
void giveDummyBonus ( int heroID , ui8 duration = Bonus : : ONE_DAY ) const ;
2008-12-27 03:01:59 +02:00
public :
mutable std : : string hoverName ;
int3 pos ; //h3m pos
2008-12-31 11:33:46 +02:00
si32 ID , subID ; //normal ID (this one from OH3 maps ;]) - eg. town=98; hero=34
2008-12-27 03:01:59 +02:00
si32 id ; //number of object in CObjectHandler's vector
CGDefInfo * defInfo ;
2008-12-31 11:33:46 +02:00
ui8 animPhaseShift ;
2008-12-27 03:01:59 +02:00
2008-12-31 11:33:46 +02:00
ui8 tempOwner ;
2008-12-27 03:01:59 +02:00
ui8 blockVisit ; //if non-zero then blocks the tile but is visitable from neighbouring tile
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
2008-12-27 03:01:59 +02:00
int getOwner ( ) const ;
void setOwner ( int ow ) ;
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
2008-12-27 03:01:59 +02:00
//////////////////////////////////////////////////////////////////////////
void initObj ( ) ;
2009-07-26 06:33:13 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
2009-02-20 14:39:27 +02:00
void setProperty ( ui8 what , ui32 val ) ; //synchr
virtual void setPropertyDer ( ui8 what , ui32 val ) ; //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
}
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 :
2009-05-07 20:20:41 +03:00
std : : set < ui8 > players ; //players that visited this object
2009-03-14 19:19:53 +02:00
2012-03-14 16:02:38 +03:00
bool wasVisited ( ui8 player ) const ;
2009-08-19 09:56:53 +03:00
virtual void setPropertyDer ( ui8 what , ui32 val ) ;
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 ( ) ;
void armyChanged ( ) OVERRIDE ;
2010-05-02 21:20:26 +03:00
//////////////////////////////////////////////////////////////////////////
2010-11-13 22:26:15 +02: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 :
2010-12-23 22:18:10 +02:00
enum SecondarySkill
{
PATHFINDING = 0 , ARCHERY , LOGISTICS , SCOUTING , DIPLOMACY , NAVIGATION , LEADERSHIP , WISDOM , MYSTICISM ,
LUCK , BALLISTICS , EAGLE_EYE , NECROMANCY , ESTATES , FIRE_MAGIC , AIR_MAGIC , WATER_MAGIC , EARTH_MAGIC ,
SCHOLAR , TACTICS , ARTILLERY , LEARNING , OFFENCE , ARMORER , INTELLIGENCE , SORCERY , RESISTANCE ,
FIRST_AID
} ;
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 ;
2009-10-27 22:40:11 +02:00
ui64 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
2008-12-27 03:01:59 +02:00
std : : vector < std : : pair < ui8 , ui8 > > secSkills ; //first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert); if hero has ability (-1, -1) it meansthat it should have default secondary abilities
2012-01-26 19:48:53 +03:00
ui32 movement ; //remaining movement points
2008-12-31 11:33:46 +02:00
ui8 sex ;
ui8 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
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 ; } ;
ui8 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
{
bool growthsWithLevel ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CBonusSystemNode & > ( * this ) ;
h & growthsWithLevel ;
}
} speciality ;
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
2012-04-22 20:38:36 +03:00
h & type & speciality & 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
//////////////////////////////////////////////////////////////////////////
2010-07-20 09:05:45 +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
2010-12-23 22:18:10 +02:00
ui8 getSecSkillLevel ( SecondarySkill skill ) const ; //0 - no skill
void setSecSkillLevel ( SecondarySkill which , int val , bool abs ) ; // abs == 0 - changes by value; 1 - sets to value
2010-07-31 16:55:05 +03:00
2008-12-27 03:01:59 +02:00
int maxMovePoints ( bool onLand ) const ;
2011-09-19 23:50:25 +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 ;
2011-02-12 20:48:11 +02:00
expType calculateXp ( expType 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 ;
2012-01-03 04:55:26 +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
//////////////////////////////////////////////////////////////////////////
void initHero ( ) ;
void initHero ( int SUBID ) ;
2010-08-28 17:52:20 +03:00
2010-12-30 16:41:46 +02:00
void putArtifact ( ui16 pos , CArtifactInstance * art ) ;
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 ( ) ;
2010-05-02 21:20:26 +03:00
void pushPrimSkill ( int which , int val ) ;
2010-07-13 22:55:13 +03:00
void UpdateSpeciality ( ) ;
2010-07-19 21:30:51 +03:00
void updateSkill ( int 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
//////////////////////////////////////////////////////////////////////////
//
ui8 bearerType ( ) const OVERRIDE ;
2008-12-27 03:01:59 +02:00
//////////////////////////////////////////////////////////////////////////
2009-02-20 14:39:27 +02:00
2011-02-22 11:47:25 +02:00
virtual CBonusSystemNode * whereShouldBeAttached ( CGameState * gs ) OVERRIDE ;
2010-12-12 01:11:26 +02:00
virtual std : : string nodeName ( ) const OVERRIDE ;
2011-02-04 16:58:14 +02:00
void deserializationFix ( ) ;
2009-02-20 14:39:27 +02:00
void setPropertyDer ( ui8 what , ui32 val ) ; //synchr
2008-12-27 03:01:59 +02:00
void initObj ( ) ;
void onHeroVisit ( const CGHeroInstance * h ) const ;
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CSpecObjInfo
2010-08-16 16:51:31 +03:00
{
public :
virtual ~ CSpecObjInfo ( ) { } ;
2012-05-11 22:03:40 +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 :
2012-01-13 17:18:32 +03:00
typedef std : : vector < std : : pair < ui32 , std : : vector < ui32 > > > TCreaturesSet ;
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 ;
}
void initObj ( ) ;
2009-10-26 11:11:10 +02:00
void setProperty ( ui8 what , ui32 val ) ;
2009-07-06 22:41:27 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
void newTurn ( ) const ;
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
const std : : string & getHoverText ( ) const ;
void setPropertyDer ( ui8 what , ui32 val ) ; //synchr
void onHeroVisit ( const CGHeroInstance * h ) const ;
void onNAHeroVisit ( int heroID , bool alreadyVisited ) const ;
void initObj ( ) ;
2012-03-14 16:02:38 +03:00
bool wasVisited ( const CGHeroInstance * h ) const ;
2010-07-13 22:55:13 +03:00
void treeSelected ( int heroID , int resType , int resVal , expType expVal , ui32 result ) const ; //handle player's anwer to the Tree of Knowledge dialog
2009-08-23 18:02:21 +03:00
void schoolSelected ( int heroID , ui32 which ) const ;
void arenaSelected ( int heroID , int primSkill ) const ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
h & visitors & ttype ;
}
} ;
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 ;
void setProperty ( ui8 what , ui32 val ) ;
void onHeroVisit ( const CGHeroInstance * h ) const ;
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 ;
void setProperty ( ui8 what , ui32 val ) ;
2009-08-23 18:02:21 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
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
2011-02-22 11:47:25 +02:00
virtual CBonusSystemNode * whatShouldBeAttached ( ) OVERRIDE ;
2011-02-04 16:58:14 +02:00
std : : string nodeName ( ) const OVERRIDE ;
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
2010-05-18 10:01:54 +03:00
int getMarketEfficiency ( ) const ; //=market count
2011-12-14 00:23:17 +03:00
bool allowsTrade ( EMarketMode : : EMarketMode mode ) const ;
std : : vector < int > availableItemsIds ( EMarketMode : : EMarketMode mode ) const ;
2009-09-21 12:00:33 +03:00
void setPropertyDer ( ui8 what , ui32 val ) ;
2009-10-06 10:55:39 +03:00
void newTurn ( ) const ;
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-01-03 04:55:26 +03:00
bool hasBuilt ( int buildingID ) 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)
2010-02-28 08:36:51 +02: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 ( ) ;
//////////////////////////////////////////////////////////////////////////
2009-08-22 16:59:15 +03:00
void fightOver ( const CGHeroInstance * h , BattleResult * result ) const ;
2008-12-27 03:01:59 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
void onHeroLeave ( const CGHeroInstance * h ) const ;
void initObj ( ) ;
} ;
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
std : : vector < si32 > resources ; //gained / lost resources
std : : vector < si32 > primskills ; //gained / lost resources
std : : vector < si32 > abilities ; //gained abilities
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
2009-08-17 05:26:56 +03:00
void initObj ( ) ;
2009-08-16 18:39:18 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
void open ( const CGHeroInstance * h , ui32 accept ) const ;
void endBattle ( const CGHeroInstance * h , BattleResult * result ) const ;
void giveContents ( const CGHeroInstance * h , bool afterBattle ) 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 ;
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
}
} ;
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 :
2011-03-08 15:27:32 +02:00
ui8 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
ui8 computerActivate ; //true if computre player can activate this event
ui8 humanActivate ; //true if human player can activate this event
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
}
2009-08-16 18:39:18 +03:00
2009-02-08 08:42:15 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
2009-08-16 18:39:18 +03:00
void activated ( const CGHeroInstance * h ) const ;
2009-04-21 01:57:07 +03:00
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
std : : vector < ui32 > resources ; //[res_id], resources given to hero that has won with monsters
si32 gainedArtifact ; //ID of artifact gained to hero, -1 if none
ui8 neverFlees ; //if true, the troops will never flee
ui8 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
void fight ( const CGHeroInstance * h ) const ;
2008-12-27 03:01:59 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
2010-06-28 16:33:05 +03:00
const std : : string & getHoverText ( ) const ;
2009-04-12 04:48:50 +03:00
void flee ( const CGHeroInstance * h ) const ;
2008-12-27 03:01:59 +02:00
void endBattle ( BattleResult * result ) const ;
2009-04-12 04:48:50 +03:00
void fleeDecision ( const CGHeroInstance * h , ui32 pursue ) const ;
void joinDecision ( const CGHeroInstance * h , int cost , ui32 accept ) const ;
2008-12-27 03:01:59 +02:00
void initObj ( ) ;
2010-06-26 15:57:16 +03:00
void newTurn ( ) const ;
void setPropertyDer ( ui8 what , ui32 val ) ;
2009-04-12 04:48:50 +03:00
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)
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
}
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
2009-03-19 16:17:19 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
void initObj ( ) ;
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
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGSeerHut : public CArmedInstance , public CQuest //army is used when giving reward
2008-12-27 03:01:59 +02:00
{
public :
2009-01-06 20:42:20 +02:00
ui8 rewardType ; //type of reward: 0 - no reward; 1 - experience; 2 - mana points; 3 - morale bonus; 4 - luck bonus; 5 - resources; 6 - main ability bonus (attak, defence etd.); 7 - secondary ability gain; 8 - artifact; 9 - spell; 10 - creature
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
2010-01-01 14:15:20 +02:00
void initObj ( ) ;
2009-12-30 22:49:10 +02:00
const std : : string & getHoverText ( ) const ;
2010-01-30 22:53:47 +02:00
void setPropertyDer ( ui8 what , ui32 val ) ;
2010-02-04 22:34:20 +02:00
int checkDirection ( ) const ; //calculates the region of map where monster is placed
2010-02-02 19:05:03 +02:00
void newTurn ( ) const ;
2010-01-01 14:15:20 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
2012-07-08 19:36:20 +03:00
void getRolloverText ( MetaString & text , bool onHover ) const ;
2012-07-08 09:33:41 +03:00
void getCompletionText ( MetaString & text , std : : vector < Component > & components , bool isCustom , const CGHeroInstance * h = NULL ) const ;
2010-02-02 19:05:03 +02:00
void finishQuest ( const CGHeroInstance * h , ui32 accept ) const ; //common for both objects
2010-01-30 22:53:47 +02:00
void completeQuest ( const CGHeroInstance * h ) const ;
2009-01-06 20:42:20 +02:00
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 ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2012-08-11 22:00:52 +03:00
h & static_cast < CArmedInstance & > ( * this ) & static_cast < CQuest & > ( * this ) ;
2012-08-11 20:01:39 +03:00
h & rewardType & rID & rVal & seerName ;
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 :
void initObj ( ) ;
void completeQuest ( const CGHeroInstance * h ) const ;
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 ;
2009-02-20 14:39:27 +02:00
const std : : string & getHoverText ( ) const ;
2009-01-11 00:08:18 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
void initObj ( ) ;
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 :
ui8 bonusType ; //255 - random, 0 - primary skill, 1 - secondary skill, 2 - spell
2009-04-08 22:55:50 +03:00
ui16 bonusID ; //ID of skill/spell
2008-12-27 03:01:59 +02:00
2009-04-08 22:55:50 +03:00
void giveAnyBonus ( const CGHeroInstance * h ) const ;
void onHeroVisit ( const CGHeroInstance * h ) const ;
void initObj ( ) ;
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 :
2009-01-06 20:42:20 +02:00
ui8 removableUnits ;
2009-12-20 19:14:14 +02:00
ui8 getPassableness ( ) const ;
2009-08-25 18:08:18 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
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
2008-12-27 03:01:59 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
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 ;
2008-12-27 03:01:59 +02:00
void initObj ( ) ;
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 ;
void onHeroVisit ( const CGHeroInstance * h ) const ;
2009-01-11 00:08:18 +02:00
void collectRes ( int player ) const ;
2008-12-27 03:01:59 +02:00
void initObj ( ) ;
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 ;
void onHeroVisit ( const CGHeroInstance * h ) const ;
void initObj ( ) ;
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
2009-03-14 13:25:25 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
void initObj ( ) ;
const std : : string & getHoverText ( ) const ;
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
{
public :
2010-07-31 03:26:34 +03:00
ui8 producedResource ;
ui32 producedQuantity ;
2009-04-12 03:58:41 +03:00
void offerLeavingGuards ( const CGHeroInstance * h ) const ;
2010-07-31 03:26:34 +03:00
void endBattle ( BattleResult * result , ui8 attackingPlayer ) const ;
void fight ( ui32 agreed , const CGHeroInstance * h ) const ;
2012-03-14 16:02:38 +03:00
2008-12-27 03:01:59 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
2010-07-31 03:26:34 +03:00
void flagMine ( ui8 player ) const ;
2008-12-27 03:01:59 +02:00
void newTurn ( ) const ;
void initObj ( ) ;
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
2009-02-20 14:39:27 +02:00
void setPropertyDer ( ui8 what , ui32 val ) ; //synchr
2012-03-14 16:02:38 +03:00
bool wasVisited ( ui8 player ) const ;
2008-12-27 03:01:59 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
void newTurn ( ) 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 & visited ;
}
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
2008-12-27 03:01:59 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
void initObj ( ) ;
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 ;
2009-02-04 15:40:54 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
const std : : string & getHoverText ( ) const ;
2009-07-19 10:16:33 +03:00
void initObj ( ) ;
2009-02-04 15:40:54 +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 CGMagicSpring : public CGVisitableOPW
2009-09-23 15:42:14 +03:00
{ ///unfortunatelly, this one is quite different than others
public :
void onHeroVisit ( const CGHeroInstance * h ) const ;
const std : : string & getHoverText ( ) const ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
h & visited ;
}
} ;
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 :
void onHeroVisit ( const CGHeroInstance * h ) const ;
const std : : string & getHoverText ( ) const ;
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 :
void onHeroVisit ( const CGHeroInstance * h ) const ;
const std : : string & getHoverText ( ) const ;
void initObj ( ) ;
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 :
void onHeroVisit ( const CGHeroInstance * h ) const ;
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
2009-08-11 10:50:29 +03:00
{
public :
static std : : map < ui8 , std : : set < ui8 > > playerKeyMap ; //[players][keysowned]
//SubID 0 - lightblue, 1 - green, 2 - red, 3 - darkblue, 4 - brown, 5 - purple, 6 - white, 7 - black
void setPropertyDer ( ui8 what , ui32 val ) ;
2012-07-08 19:36:20 +03:00
const std : : string getName ( ) const ; //depending on color
2009-08-11 10:50:29 +03:00
bool wasMyColorVisited ( int player ) const ;
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 CGKeymasterTent : public CGKeys
2009-08-11 10:50:29 +03:00
{
public :
2012-03-14 16:02:38 +03:00
bool wasVisited ( ui8 player ) const ;
2009-08-11 10:50:29 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
const std : : string & getHoverText ( ) const ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
}
} ;
2012-07-08 19:36:20 +03:00
class DLL_LINKAGE CGBorderGuard : public CGKeys , public CQuest
2009-08-11 10:50:29 +03:00
{
public :
void initObj ( ) ;
const std : : string & getHoverText ( ) const ;
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 ;
2009-08-11 10:50:29 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
void openGate ( const CGHeroInstance * h , ui32 accept ) const ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
2012-07-08 19:36:20 +03:00
h & static_cast < CQuest & > ( * 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 :
void onHeroVisit ( const CGHeroInstance * h ) const ;
2009-12-20 19:14:14 +02:00
ui8 getPassableness ( ) const ;
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
} ;
2011-12-14 00:23:17 +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
void initObj ( ) ;
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)
void onHeroVisit ( const CGHeroInstance * h ) const ;
const std : : string & getHoverText ( ) const ;
void initObj ( ) ;
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
void initObj ( ) ;
2009-09-17 17:27:28 +03:00
const std : : string & getHoverText ( ) const ;
2009-08-11 10:50:29 +03:00
void setPropertyDer ( ui8 what , ui32 val ) ;
2009-10-24 22:21:32 +03:00
void initialize ( ) const ;
void reset ( ui16 var1 ) ;
2009-08-23 18:02:21 +03:00
void newTurn ( ) const ;
2012-03-14 16:02:38 +03:00
bool wasVisited ( ui8 player ) const ;
2009-09-25 18:40:28 +03:00
virtual void onHeroVisit ( const CGHeroInstance * h ) const ;
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
}
} ;
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 ;
void initObj ( ) ;
2009-09-25 18:40:28 +03:00
const std : : string & getHoverText ( ) const ;
2009-09-24 20:54:02 +03:00
void newTurn ( ) const { } ; //empty, no reset
void onHeroVisit ( const CGHeroInstance * h ) const ;
void endBattle ( const CGHeroInstance * h , const BattleResult * result ) const ;
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 ( ) ;
void onHeroVisit ( const CGHeroInstance * h ) const ;
} ;
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
void initObj ( ) ;
void onHeroVisit ( const CGHeroInstance * h ) const ;
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
{
///behaviour varies depending on surface and floor
public :
void onHeroVisit ( const CGHeroInstance * h ) const ;
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
{
void onHeroVisit ( const CGHeroInstance * h ) const ;
} ;
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
void setPropertyDer ( ui8 what , ui32 val ) ;
void onHeroVisit ( const CGHeroInstance * h ) const ;
void initObj ( ) ;
const std : : string & getHoverText ( ) const ;
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
}
} ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGLighthouse : public CGObjectInstance
2010-02-10 04:56:00 +02:00
{
public :
void onHeroVisit ( const CGHeroInstance * h ) const ;
void initObj ( ) ;
const std : : string & getHoverText ( ) const ;
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 ( ) ;
void onHeroVisit ( const CGHeroInstance * h ) const ; //open trading window
int getMarketEfficiency ( ) const ;
2011-12-14 00:23:17 +03:00
bool allowsTrade ( EMarketMode : : EMarketMode mode ) const ;
int availableUnits ( EMarketMode : : EMarketMode mode , int marketItemSerial ) const ; //-1 if unlimited
std : : vector < int > availableItemsIds ( EMarketMode : : EMarketMode mode ) const ;
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
void newTurn ( ) const ; //reset artifacts for black market every month
2011-12-14 00:23:17 +03:00
std : : vector < int > availableItemsIds ( EMarketMode : : EMarketMode mode ) const ;
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
2011-12-14 00:23:17 +03:00
std : : vector < int > availableItemsIds ( EMarketMode : : EMarketMode mode ) const ;
2010-07-20 17:08:13 +03:00
void initObj ( ) ; //set skills for trade
void onHeroVisit ( const CGHeroInstance * h ) const ; //open window
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
2009-08-26 08:08:59 +03:00
std : : vector < std : : pair < ui16 , 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
2009-08-29 19:08:58 +03:00
std : : vector < std : : pair < ui16 , 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 :
2012-05-11 22:03:40 +03:00
std : : map < si32 , si32 > 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
}
} ;