2008-12-27 03:01:59 +02:00
# ifndef __COBJECTHANDLER_H__
# define __COBJECTHANDLER_H__
# include "../global.h"
# include <string>
# include <vector>
# include <set>
# include <map>
2009-02-03 07:28:05 +02:00
# include <list>
2008-12-27 03:01:59 +02:00
# include "CCreatureHandler.h"
2009-02-04 15:40:54 +02:00
# include "../lib/HeroBonus.h"
2009-01-30 20:36:00 +02:00
# ifndef _MSC_VER
# include "CHeroHandler.h"
# include "CTownHandler.h"
# include "../lib/VCMI_Lib.h"
# endif
2008-12-27 03:01:59 +02:00
using boost : : logic : : tribool ;
class IGameCallback ;
struct BattleResult ;
class CCPPObjectScript ;
class CGObjectInstance ;
class CScript ;
class CObjectScript ;
class CGHeroInstance ;
class CTown ;
class CHero ;
class CBuilding ;
class CSpell ;
class CGTownInstance ;
class CArtifact ;
class CGDefInfo ;
class CSpecObjInfo ;
2009-02-12 16:44:58 +02:00
struct TerrainTile ;
2008-12-27 03:01:59 +02:00
class DLL_EXPORT CCastleEvent
{
public :
std : : string name , message ;
2008-12-31 11:33:46 +02:00
std : : vector < si32 > resources ; //gain / loss of resources
ui8 players ; //players for whom this event can be applied
ui8 forHuman , forComputer ;
ui32 firstShow ; //postpone of first encounter time in days
ui32 forEvery ; //every n days this event will occure
ui8 bytes [ 6 ] ; //build specific buildings (raw format, similar to town's)
si32 gen [ 7 ] ; //additional creatures in i-th level dwelling
2008-12-27 03:01:59 +02:00
bool operator < ( const CCastleEvent & drugie ) const
{
return firstShow < drugie . firstShow ;
}
2008-12-31 11:33:46 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & name & message & resources & players & forHuman & forComputer & firstShow
& forEvery & bytes & gen ;
}
2008-12-27 03:01:59 +02:00
} ;
class CQuest
{
public :
ui8 missionType ; //type of mission: 0 - no mission; 1 - reach level; 2 - reach main statistics values; 3 - win with a certain hero; 4 - win with a certain creature; 5 - collect some atifacts; 6 - have certain troops in army; 7 - collect resources; 8 - be a certain hero; 9 - be a certain playe
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
std : : vector < std : : pair < ui32 , ui32 > > m6creatures ; //pair[cre id, cre count]
std : : vector < ui32 > m7resources ;
std : : string firstVisitText , nextVisitText , completedText ;
2008-12-31 11:33:46 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & missionType & lastDay & m13489val & m2stats & m5arts & m6creatures & m7resources
& firstVisitText & nextVisitText & completedText ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT IObjectInterface
{
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
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGObjectInstance : protected IObjectInterface
{
protected :
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 ;
CSpecObjInfo * info ;
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-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)
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)
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)
bool operator < ( const CGObjectInstance & cmp ) const ; //screen printing priority comparing
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 ;
//////////////////////////////////////////////////////////////////////////
void initObj ( ) ;
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 )
{
h & hoverName & pos & ID & subID & id & animPhaseShift & tempOwner & blockVisit ;
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
} ;
2009-03-14 19:19:53 +02:00
class DLL_EXPORT CPlayersVisited : public CGObjectInstance
{
public :
std : : set < ui8 > players ;
bool hasVisited ( ui8 player ) const ;
void setPropertyDer ( ui8 what , ui32 val ) ; //synchr
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & players ;
}
} ;
2008-12-27 03:01:59 +02:00
class DLL_EXPORT CArmedInstance : public CGObjectInstance
{
public :
CCreatureSet army ; //army
virtual bool needsLastStack ( ) const ; //true if last stack cannot be taken
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 ) ;
2008-12-31 11:33:46 +02:00
h & army ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGHeroInstance : public CArmedInstance
{
public :
//////////////////////////////////////////////////////////////////////////
mutable int moveDir ; //format: 123
// 8 4
// 765
mutable ui8 isStanding , tacticFormationEnabled ;
//////////////////////////////////////////////////////////////////////////
CHero * type ;
ui32 exp ; //experience point
2008-12-31 11:33:46 +02:00
si32 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
si32 mana ; // remaining spell points
std : : vector < si32 > primSkills ; //0-attack, 1-defence, 2-spell power, 3-knowledge
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
2008-12-31 11:33:46 +02:00
si32 movement ; //remaining movement points
si32 identifier ; //from the map file
ui8 sex ;
ui8 inTownGarrison ; // if hero is in town garrison
2008-12-27 03:01:59 +02:00
CGTownInstance * visitedTown ; //set if hero is visiting town or in the town garrison
std : : vector < ui32 > artifacts ; //hero's artifacts from bag
std : : map < ui16 , ui32 > artifWorn ; //map<position,artifact_id>; positions: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
std : : set < ui32 > spells ; //known spells (spell IDs)
2009-02-03 07:28:05 +02:00
struct DLL_EXPORT Patrol
{
Patrol ( ) { patrolling = false ; patrolRadious = - 1 ; } ;
ui8 patrolling ;
si32 patrolRadious ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & patrolling & patrolRadious ;
}
} patrol ;
2009-02-04 15:40:54 +02:00
std : : list < HeroBonus > 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 ) ;
2008-12-31 11:33:46 +02:00
h & exp & level & name & biography & portrait & mana & primSkills & secSkills & movement
2009-02-03 07:28:05 +02:00
& identifier & sex & inTownGarrison & artifacts & artifWorn & spells & patrol & bonuses ;
2009-01-06 20:42:20 +02:00
ui8 standardType = ( VLC - > heroh - > heroes [ subID ] = = type ) ;
h & standardType ;
if ( ! standardType )
h & type ;
else if ( ! h . saving )
type = VLC - > heroh - > heroes [ subID ] ;
//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
//////////////////////////////////////////////////////////////////////////
int3 getSightCenter ( ) const ; //"center" tile from which the sight distance is calculated
int getSightRadious ( ) const ; //sight distance (should be used if player-owned structure)
2008-12-31 11:33:46 +02:00
//////////////////////////////////////////////////////////////////////////
2009-02-04 15:40:54 +02:00
const HeroBonus * getBonus ( int from , int id ) const ;
2009-04-04 01:34:31 +03:00
int valOfBonuses ( HeroBonus : : BonusType type ) const ;
2008-12-27 03:01:59 +02:00
const std : : string & getBiography ( ) const ;
bool needsLastStack ( ) const ;
2009-02-12 16:44:58 +02:00
unsigned int getTileCost ( const TerrainTile & dest , const TerrainTile & from ) const ; //move cost - applying pathfinding skill, road and terrain modifiers. NOT includes diagonal move penalty, last move levelling
2008-12-27 03:01:59 +02:00
unsigned int getLowestCreatureSpeed ( ) const ;
int3 getPosition ( bool h3m ) const ; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
2008-12-31 11:33:46 +02:00
si32 manaLimit ( ) const ; //maximum mana value for this hero (basically 10*knowledge)
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 ;
std : : vector < std : : pair < int , std : : string > > getCurrentLuckModifiers ( int stack = - 1 , bool town = false ) const ; //args as above
2009-02-03 07:28:05 +02:00
int getCurrentMorale ( int stack = - 1 , bool town = false ) const ; //if stack - position of creature, if -1 then morale for hero is calculated; town - if bonuses from town (tavern) should be considered
std : : vector < std : : pair < int , std : : string > > getCurrentMoraleModifiers ( int stack = - 1 , bool town = false ) const ; //args as above
2008-12-27 03:01:59 +02:00
int getPrimSkillLevel ( int id ) const ;
2008-12-31 11:33:46 +02:00
ui8 getSecSkillLevel ( const int & ID ) const ; //0 - no skill
2008-12-27 03:01:59 +02:00
int maxMovePoints ( bool onLand ) const ;
ui32 getArtAtPos ( ui16 pos ) const ; //-1 - no artifact
const CArtifact * getArt ( int pos ) const ;
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
static int3 convertPosition ( int3 src , bool toh3m ) ; //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest
2009-02-03 07:28:05 +02:00
2008-12-27 03:01:59 +02:00
//////////////////////////////////////////////////////////////////////////
void initHero ( ) ;
void initHero ( int SUBID ) ;
2009-02-01 16:11:41 +02:00
void initHeroDefInfo ( ) ;
2008-12-27 03:01:59 +02:00
CGHeroInstance ( ) ;
virtual ~ CGHeroInstance ( ) ;
//////////////////////////////////////////////////////////////////////////
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 ;
} ;
class DLL_EXPORT CGTownInstance : public CArmedInstance
{
public :
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
2008-12-27 03:01:59 +02:00
const 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 ;
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
struct StrInfo
{
std : : map < si32 , ui32 > creatures ; //level - available amount
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & creatures ;
}
} strInfo ;
std : : set < CCastleEvent > events ;
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 ) ;
2008-12-31 11:33:46 +02:00
h & name & builded & destroyed & identifier & alignment & forbiddenBuildings & builtBuildings
& possibleSpells & obligatorySpells & spells & strInfo & events ;
2009-01-06 20:42:20 +02:00
ui8 standardType = ( & VLC - > townh - > towns [ subID ] = = town ) ;
h & standardType ;
if ( ! standardType )
h & town ;
else if ( ! h . saving )
town = & VLC - > townh - > towns [ subID ] ;
//garrison/visiting hero pointers will be restored in the map serialization
2008-12-31 11:33:46 +02:00
}
//////////////////////////////////////////////////////////////////////////
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
//////////////////////////////////////////////////////////////////////////
2008-12-27 03:01:59 +02:00
bool needsLastStack ( ) const ;
int fortLevel ( ) const ; //0 - none, 1 - fort, 2 - citadel, 3 - castle
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
bool creatureDwelling ( const int & level , bool upgraded = false ) const ;
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 ;
bool hasFort ( ) const ;
bool hasCapitol ( ) const ;
int dailyIncome ( ) const ;
int spellsAtLevel ( int level , bool checkGuild ) const ; //levels are counted from 1 (1 - 5)
CGTownInstance ( ) ;
virtual ~ CGTownInstance ( ) ;
//////////////////////////////////////////////////////////////////////////
void onHeroVisit ( const CGHeroInstance * h ) const ;
void onHeroLeave ( const CGHeroInstance * h ) const ;
void initObj ( ) ;
} ;
class DLL_EXPORT CGVisitableOPH : public CGObjectInstance //objects visitable only once per hero
{
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 ;
2009-02-20 14:39:27 +02:00
void setPropertyDer ( ui8 what , ui32 val ) ; //synchr
2008-12-27 03:01:59 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
void onNAHeroVisit ( int heroID , bool alreadyVisited ) const ;
void initObj ( ) ;
void treeSelected ( int heroID , int resType , int resVal , int expVal , ui32 result ) const ; //handle player's anwer to the Tree of Knowledge dialog
2009-01-11 00:08:18 +02:00
void arenaSelected ( int heroID , int primSkill ) 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 & visitors & ttype ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGEvent : public CGObjectInstance //event objects
{
public :
CCreatureSet guarders ;
std : : string message ;
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-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 )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
h & guarders & message & gainedExp & manaDiff & moraleDiff & luckDiff & resources & primskills
& abilities & abilityLevels & artifacts & spells & creatures & availableFor
& computerActivate & humanActivate ;
}
2009-02-08 08:42:15 +02:00
void activated ( const CGHeroInstance * h ) const ;
void onHeroVisit ( const CGHeroInstance * h ) const ;
void endBattle ( BattleResult * result ) const ;
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGCreature : public CArmedInstance //creatures on map
{
public :
ui32 identifier ; //unique code for this monster (used in missions)
ui8 character ; //chracter of this set of creatures (0 - the most friendly, 4 - the most hostile)
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
void onHeroVisit ( const CGHeroInstance * h ) const ;
void endBattle ( BattleResult * result ) 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 ) ;
h & identifier & character & message & resources & gainedArtifact & neverFlees & notGrowingTeam ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGSignBottle : public CGObjectInstance //signs and ocean bottles
{
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
} ;
class DLL_EXPORT CGSeerHut : public CGObjectInstance , public CQuest
{
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
si32 rID ;
si32 rVal ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) & static_cast < CQuest & > ( * this ) ;
h & rewardType & rID & rVal ;
}
2008-12-27 03:01:59 +02:00
} ;
2009-03-14 19:19:53 +02:00
class DLL_EXPORT 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-03-14 19:19:53 +02:00
h & static_cast < CGObjectInstance & > ( * this ) & 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
} ;
class DLL_EXPORT CGScholar : public CGObjectInstance
{
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-04-08 22:55:50 +03:00
h & bonusType & id ;
2009-01-06 20:42:20 +02:00
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGGarrison : public CArmedInstance
{
public :
2009-01-06 20:42:20 +02:00
ui8 removableUnits ;
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
} ;
class DLL_EXPORT CGArtifact : public CArmedInstance
{
public :
std : : string message ;
ui32 spell ; //if it's spell scroll
void onHeroVisit ( const CGHeroInstance * h ) const ;
2009-02-03 07:28:05 +02:00
void fightForArt ( ui32 refusedFight , const CGHeroInstance * h ) const ;
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 ) ;
h & message & spell ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGResource : public CArmedInstance
{
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-01-12 22:05:56 +02:00
void fightForRes ( ui32 refusedFight , 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
} ;
class DLL_EXPORT CGPickable : public CGObjectInstance //campfire, treasure chest
{
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
} ;
2009-03-14 19:19:53 +02:00
class DLL_EXPORT 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-03-14 19:19:53 +02:00
h & static_cast < CGObjectInstance & > ( * this ) & static_cast < CPlayersVisited & > ( * this ) ; ;
2009-01-06 20:42:20 +02:00
h & spell ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGPandoraBox : public CArmedInstance
{
public :
std : : string message ;
//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
CCreatureSet creatures ; //gained creatures
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CArmedInstance & > ( * this ) ;
h & message & gainedExp & manaDiff & moraleDiff & luckDiff & resources & primskills
& abilities & abilityLevels & artifacts & spells & creatures ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGQuestGuard : public CGObjectInstance , public CQuest
{
public :
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CQuest & > ( * this ) & static_cast < CGObjectInstance & > ( * this ) ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGMine : public CArmedInstance
{
public :
void onHeroVisit ( const CGHeroInstance * h ) const ;
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 ) ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGVisitableOPW : public CGObjectInstance //objects visitable OPW
{
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
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
} ;
class DLL_EXPORT CGTeleport : public CGObjectInstance //teleports and subterranean gates
{
public :
static std : : map < int , std : : map < int , std : : vector < int > > > objs ; //map[ID][subID] => vector of ids
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 ) ;
}
2008-12-27 03:01:59 +02:00
} ;
2009-02-03 07:28:05 +02:00
class DLL_EXPORT CGDwelling : public CGObjectInstance //teleports and subterranean gates
{
public :
static std : : map < int , std : : map < int , std : : vector < int > > > objs ; //map[ID][subID] => vector of ids
void onHeroVisit ( const CGHeroInstance * h ) const ;
void initObj ( ) ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
}
} ;
2009-02-04 15:40:54 +02:00
class DLL_EXPORT CGBonusingObject : public CGObjectInstance //objects giving bonuses to luck/morale/movement
{
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 ) ;
}
} ;
2009-02-06 13:15:39 +02:00
class DLL_EXPORT CGMagicWell : public CGObjectInstance //objects giving bonuses to luck/morale/movement
{
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 ) ;
}
} ;
2009-03-14 13:25:25 +02:00
class DLL_EXPORT CGObservatory : public CGObjectInstance //Redwood observatory
{
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-02-03 07:28:05 +02:00
2008-12-27 03:01:59 +02:00
class DLL_EXPORT CObjectHandler
{
public :
2009-01-11 00:08:18 +02:00
std : : vector < si32 > cregens ; //type 17. dwelling subid -> creature ID
2008-12-27 03:01:59 +02:00
void loadObjects ( ) ;
2009-01-11 00:08:18 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & cregens ;
}
2008-12-27 03:01:59 +02:00
} ;
# endif // __COBJECTHANDLER_H__