2007-06-11 17:21:27 +00:00
# ifndef COBJECTHANDLER_H
# define COBJECTHANDLER_H
2008-06-17 17:48:32 +00:00
# include "../global.h"
2007-06-11 17:21:27 +00:00
# include <string>
# include <vector>
2008-01-09 17:21:31 +00:00
# include <set>
2008-06-08 00:58:29 +00:00
# include <map>
2007-06-12 20:09:23 +00:00
# include "CCreatureHandler.h"
2008-06-17 17:48:32 +00:00
2007-11-18 22:58:28 +00:00
using boost : : logic : : tribool ;
class CCPPObjectScript ;
class CGObjectInstance ;
2007-10-27 19:38:48 +00:00
class CScript ;
class CObjectScript ;
class CGHeroInstance ;
class CTown ;
class CHero ;
class CBuilding ;
class CSpell ;
2008-06-07 17:16:52 +00:00
class CGTownInstance ;
2008-06-08 00:58:29 +00:00
class CArtifact ;
2008-06-19 06:08:05 +00:00
class CGDefInfo ;
class CSpecObjInfo ;
2007-06-12 20:09:23 +00:00
2008-06-17 17:48:32 +00:00
class DLL_EXPORT CCastleEvent
2008-06-11 01:53:57 +00:00
{
public :
std : : string name , message ;
int wood , mercury , ore , sulfur , crystal , gems , gold ; //gain / loss of resources
unsigned char players ; //players for whom this event can be applied
bool forHuman , forComputer ;
int firstShow ; //postpone of first encounter time in days
int forEvery ; //every n days this event will occure
unsigned char bytes [ 6 ] ; //build specific buildings (raw format, similar to town's)
int gen [ 7 ] ; //additional creatures in i-th level dwelling
bool operator < ( const CCastleEvent & drugie ) const
{
return firstShow < drugie . firstShow ;
}
} ;
2007-06-15 16:50:02 +00:00
2008-06-17 17:48:32 +00:00
class DLL_EXPORT CGObjectInstance
2007-10-27 19:38:48 +00:00
{
public :
int3 pos ; //h3m pos
2008-05-31 20:37:54 +00:00
int ID , subID ; //normal ID (this one from OH3 maps ;]) - eg. town=98; hero=34
2008-07-28 12:44:08 +00:00
si32 id ; //number of object in CObjectHandler's vector
2007-10-27 19:38:48 +00:00
CGDefInfo * defInfo ;
2007-11-18 22:58:28 +00:00
CCPPObjectScript * state ;
2007-10-27 19:38:48 +00:00
CSpecObjInfo * info ;
2008-06-03 13:15:34 +00:00
unsigned char animPhaseShift ;
2008-07-30 17:51:19 +00:00
std : : string hoverName ;
2007-11-18 22:58:28 +00:00
2008-08-13 00:44:31 +00:00
ui8 tempOwner ; //uzywane dla szybkosci, skrypt ma obowiazek aktualizowac te zmienna
ui8 blockVisit ; //if non-zero then blocks the tile but is visitable from neighbouring tile
2008-08-02 15:08:03 +00:00
2007-10-27 19:38:48 +00:00
virtual bool isHero ( ) const ;
2008-08-02 15:08:03 +00:00
int getOwner ( ) const ;
void setOwner ( int ow ) ;
2007-10-27 19:38:48 +00:00
int getWidth ( ) const ; //returns width of object graphic in tiles
int getHeight ( ) const ; //returns height of object graphic in tiles
2008-09-26 14:16:01 +00:00
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)
2007-10-27 19:38:48 +00:00
bool operator < ( const CGObjectInstance & cmp ) const ; //screen printing priority comparing
CGObjectInstance ( ) ;
virtual ~ CGObjectInstance ( ) ;
CGObjectInstance ( const CGObjectInstance & right ) ;
CGObjectInstance & operator = ( const CGObjectInstance & right ) ;
} ;
2008-06-17 17:48:32 +00:00
class DLL_EXPORT CArmedInstance : public CGObjectInstance
2008-02-24 23:06:27 +00:00
{
public :
CCreatureSet army ; //army
} ;
2008-06-17 17:48:32 +00:00
class DLL_EXPORT CGHeroInstance : public CArmedInstance
2007-10-27 19:38:48 +00:00
{
public :
2008-08-25 21:14:00 +00:00
mutable int moveDir ; //format: 123
2008-02-15 18:40:58 +00:00
// 8 4
// 765
2008-09-19 08:16:19 +00:00
mutable ui8 isStanding , tacticFormationEnabled ;
2007-10-27 19:38:48 +00:00
CHero * type ;
2008-08-04 15:56:36 +00:00
ui32 exp ; //experience point
2007-10-27 19:38:48 +00:00
int level ; //current level of hero
std : : string name ; //may be custom
std : : string biography ; //may be custom
int portrait ; //may be custom
int mana ; // remaining spell points
std : : vector < int > primSkills ; //0-attack, 1-defence, 2-spell power, 3-knowledge
2008-09-29 11:03:30 +00:00
std : : vector < std : : pair < int , int > > 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
2007-10-27 19:38:48 +00:00
int movement ; //remaining movement points
2008-06-08 00:58:29 +00:00
int identifier ; //from the map file
bool sex ;
2008-05-31 20:37:54 +00:00
2008-06-17 17:48:32 +00:00
struct DLL_EXPORT Patrol
2008-06-11 01:53:57 +00:00
{
Patrol ( ) { patrolling = false ; patrolRadious = - 1 ; } ;
bool patrolling ;
int patrolRadious ;
} patrol ;
2007-10-27 19:38:48 +00:00
bool inTownGarrison ; // if hero is in town garrison
2008-05-31 20:37:54 +00:00
CGTownInstance * visitedTown ; //set if hero is visiting town or in the town garrison
2007-10-27 19:38:48 +00:00
2008-08-20 19:02:48 +00:00
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
2008-08-27 10:19:18 +00:00
std : : set < ui32 > spells ; //known spells (spell IDs)
2008-01-19 13:19:58 +00:00
2007-10-27 19:38:48 +00:00
virtual bool isHero ( ) const ;
2008-06-03 13:15:34 +00:00
unsigned int getTileCost ( const EterrainType & ttype , const Eroad & rdtype , const Eriver & rvtype ) const ;
2007-10-27 19:38:48 +00:00
unsigned int getLowestCreatureSpeed ( ) ;
2008-06-03 13:15:34 +00:00
unsigned int getAdditiveMoveBonus ( ) const ;
float getMultiplicativeMoveBonus ( ) const ;
2007-10-27 19:38:48 +00:00
static int3 convertPosition ( int3 src , bool toh3m ) ; //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest
int3 getPosition ( bool h3m ) const ; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
int getSightDistance ( ) const ; //returns sight distance of this hero
2008-10-18 11:41:24 +00:00
int manaLimit ( ) const ; //maximum mana value for this hero (basically 10*knowledge)
//void setPosition(int3 Pos, bool h3m); //as above, but sets position
2007-10-27 19:38:48 +00:00
bool canWalkOnSea ( ) const ;
int getCurrentLuck ( ) const ;
int getCurrentMorale ( ) const ;
2008-09-29 11:03:30 +00:00
int getPrimSkillLevel ( int id ) const ;
2008-09-28 13:29:37 +00:00
int getSecSkillLevel ( const int & ID ) const ; //0 - no skill
2008-08-20 19:02:48 +00:00
ui32 getArtAtPos ( ui16 pos ) const ; //-1 - no artifact
void setArtAtPos ( ui16 pos , int art ) ;
2008-09-28 13:29:37 +00:00
const CArtifact * getArt ( int pos ) const ;
2008-02-07 18:45:22 +00:00
CGHeroInstance ( ) ;
2007-10-27 19:38:48 +00:00
virtual ~ CGHeroInstance ( ) ;
} ;
2008-06-17 17:48:32 +00:00
class DLL_EXPORT CGTownInstance : public CArmedInstance
2007-10-27 19:38:48 +00:00
{
public :
CTown * town ;
std : : string name ; // name of town
int builded ; //how many buildings has been built this turn
int destroyed ; //how many buildings has been destroyed this turn
2008-06-11 01:53:57 +00:00
const CGHeroInstance * garrisonHero , * visitingHero ;
2008-06-08 00:58:29 +00:00
int identifier ; //special identifier from h3m (only > RoE maps)
int alignment ;
2008-08-01 11:21:15 +00:00
std : : set < si32 > forbiddenBuildings , builtBuildings ;
2008-08-20 06:57:53 +00:00
std : : vector < int > possibleSpells , obligatorySpells ;
std : : vector < std : : vector < ui32 > > spells ; //spells[level] -> vector of spells, first will be available in guild
2008-04-04 17:30:53 +00:00
struct StrInfo
{
2008-08-01 11:21:15 +00:00
std : : map < si32 , ui32 > creatures ; //level - available amount
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & creatures ;
}
2008-04-04 17:30:53 +00:00
} strInfo ;
2008-06-11 01:53:57 +00:00
std : : set < CCastleEvent > events ;
2007-10-27 19:38:48 +00:00
int getSightDistance ( ) const ; //returns sight distance
2008-02-18 21:14:28 +00:00
int fortLevel ( ) const ; //0 - none, 1 - fort, 2 - citadel, 3 - castle
int hallLevel ( ) const ; // -1 - none, 0 - village, 1 - town, 2 - city, 3 - capitol
2008-08-20 06:57:53 +00:00
int mageGuildLevel ( ) const ; // -1 - none, 0 - village, 1 - town, 2 - city, 3 - capitol
2008-06-03 13:15:34 +00:00
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 ;
2008-01-09 17:21:31 +00:00
bool hasFort ( ) const ;
2008-02-05 03:56:45 +00:00
bool hasCapitol ( ) const ;
2008-01-09 17:21:31 +00:00
int dailyIncome ( ) const ;
2008-09-12 08:51:46 +00:00
int spellsAtLevel ( int level , bool checkGuild ) const ; //levels are counted from 1 (1 - 5)
2008-01-09 17:21:31 +00:00
2007-10-27 19:38:48 +00:00
CGTownInstance ( ) ;
virtual ~ CGTownInstance ( ) ;
} ;
2008-06-17 17:48:32 +00:00
class DLL_EXPORT CObjectHandler
2007-06-11 17:21:27 +00:00
{
public :
2008-07-30 17:51:19 +00:00
std : : vector < std : : string > names ; //vector of objects; i-th object in vector has subnumber i
2008-02-05 03:56:45 +00:00
std : : vector < int > cregens ; //type 17. dwelling subid -> creature ID
2007-06-11 17:21:27 +00:00
void loadObjects ( ) ;
2007-11-18 22:58:28 +00:00
2008-02-29 22:14:53 +00:00
std : : vector < std : : string > creGens ; //names of creatures' generators
2007-11-18 22:58:28 +00:00
std : : vector < std : : string > advobtxt ;
std : : vector < std : : string > xtrainfo ;
2007-11-25 13:16:45 +00:00
std : : vector < std : : string > restypes ;
std : : vector < std : : pair < std : : string , std : : string > > mines ; //first - name; second - event description
2007-06-11 17:21:27 +00:00
} ;
2008-08-02 15:08:03 +00:00
# endif //COBJECTHANDLER_H