2007-06-11 17:21:27 +00:00
# ifndef COBJECTHANDLER_H
# define COBJECTHANDLER_H
# 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"
2007-11-18 22:58:28 +00:00
//#include "CHeroHandler.h"
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 ;
2007-06-11 17:21:27 +00:00
class CSpecObjInfo //class with object - specific info (eg. different information for creatures and heroes); use inheritance to make object - specific classes
{
} ;
2007-06-12 20:09:23 +00:00
class CEventObjInfo : public CSpecObjInfo
{
public :
bool areGuarders ; //true if there are
CCreatureSet guarders ;
bool isMessage ; //true if there is a message
std : : string message ;
unsigned int gainedExp ;
int manaDiff ; //amount of gained / lost mana
int moraleDiff ; //morale modifier
int luckDiff ; //luck modifier
int wood , mercury , ore , sulfur , crystal , gems , gold ; //gained / lost resources
unsigned int attack ; //added attack points
unsigned int defence ; //added defence points
unsigned int power ; //added power points
unsigned int knowledge ; //added knowledge points
2008-06-08 00:58:29 +00:00
std : : vector < int > abilities ; //gained abilities
2007-06-12 20:09:23 +00:00
std : : vector < int > abilityLevels ; //levels of gained abilities
2008-06-08 00:58:29 +00:00
std : : vector < int > artifacts ; //gained artifacts
std : : vector < int > spells ; //gained spells
2007-06-12 20:09:23 +00:00
CCreatureSet creatures ; //gained creatures
unsigned char availableFor ; //players whom this event is available for
bool computerActivate ; //true if computre player can activate this event
bool humanActivate ; //true if human player can activate this event
} ;
2008-06-11 01:53:57 +00:00
class CCastleEvent
{
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
class CCreatureObjInfo : public CSpecObjInfo
{
public :
unsigned char bytes [ 4 ] ; //mysterious bytes identifying creature
unsigned int number ; //number of units (0 - random)
unsigned char character ; //chracter of this set of creatures (0 - the most friendly, 4 - the most hostile)
std : : string message ; //message printed for attacking hero
int wood , mercury , ore , sulfur , crytal , gems , gold ; //resources gained to hero that has won with monsters
2008-06-08 00:58:29 +00:00
int gainedArtifact ; //ID of artifact gained to hero
2007-06-15 16:50:02 +00:00
bool neverFlees ; //if true, the troops will never flee
bool notGrowingTeam ; //if true, number of units won't grow
} ;
class CSignObjInfo : public CSpecObjInfo
{
public :
std : : string message ; //message
} ;
class CSeerHutObjInfo : public CSpecObjInfo
{
public :
2008-01-08 16:08:25 +00:00
unsigned char 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 player
2007-06-15 16:50:02 +00:00
bool isDayLimit ; //if true, there is a day limit
int lastDay ; //after this day (first day is 0) mission cannot be completed
2008-06-08 00:58:29 +00:00
int m1level ; //for mission 1
int m2attack , m2defence , m2power , m2knowledge ; //for mission 2
unsigned char m3bytes [ 4 ] ; //for mission 3
unsigned char m4bytes [ 4 ] ; //for mission 4
std : : vector < int > m5arts ; //for mission 5 - artifact ID
std : : vector < CCreature * > m6cre ; //for mission 6
2007-06-15 16:50:02 +00:00
std : : vector < int > m6number ;
2008-06-08 00:58:29 +00:00
int m7wood , m7mercury , m7ore , m7sulfur , m7crystal , m7gems , m7gold ; //for mission 7
2008-06-11 01:53:57 +00:00
int m8hero ; //for mission 8 - hero ID
2008-06-08 00:58:29 +00:00
int m9player ; //for mission 9 - number; from 0 to 7
2007-06-15 16:50:02 +00:00
std : : string firstVisitText , nextVisitText , completedText ;
2007-06-15 20:11:52 +00:00
char 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
//for reward 1
int r1exp ;
//for reward 2
int r2mana ;
//for reward 3
int r3morale ;
//for reward 4
int r4luck ;
//for reward 5
unsigned char r5type ; //0 - wood, 1 - mercury, 2 - ore, 3 - sulfur, 4 - crystal, 5 - gems, 6 - gold
int r5amount ;
//for reward 6
unsigned char r6type ; //0 - attack, 1 - defence, 2 - power, 3 - knowledge
int r6amount ;
//for reward 7
2008-06-08 00:58:29 +00:00
int r7ability ; //ability id
2007-06-15 20:11:52 +00:00
unsigned char r7level ; //1 - basic, 2 - advanced, 3 - expert
//for reward 8
2008-06-08 00:58:29 +00:00
int r8art ; //artifact id
2007-06-15 20:11:52 +00:00
//for reward 9
2008-06-08 00:58:29 +00:00
int r9spell ; //spell id
2007-06-15 20:11:52 +00:00
//for reward 10
2008-06-08 00:58:29 +00:00
int r10creature ; //creature id
2007-06-15 20:11:52 +00:00
int r10amount ;
} ;
class CWitchHutObjInfo : public CSpecObjInfo
{
public :
2008-06-08 00:58:29 +00:00
std : : vector < int > allowedAbilities ;
2007-06-15 20:11:52 +00:00
} ;
class CScholarObjInfo : public CSpecObjInfo
{
public :
unsigned char bonusType ; //255 - random, 0 - primary skill, 1 - secondary skill, 2 - spell
unsigned char r0type ;
2008-06-08 00:58:29 +00:00
int r1 ; //Ability ID
int r2 ; //Spell ID
2007-06-15 20:11:52 +00:00
} ;
class CGarrisonObjInfo : public CSpecObjInfo
{
public :
unsigned char player ; //255 - nobody; 0 - 7 - players
CCreatureSet units ;
bool movableUnits ; //if true, units can be moved
} ;
class CArtifactObjInfo : public CSpecObjInfo
{
public :
bool areGuards ;
std : : string message ;
CCreatureSet guards ;
} ;
class CResourceObjInfo : public CSpecObjInfo
{
public :
bool randomAmount ;
int amount ; //if not random
bool areGuards ;
CCreatureSet guards ;
std : : string message ;
2007-06-13 20:17:48 +00:00
} ;
2007-06-17 16:59:14 +00:00
class CPlayerOnlyObjInfo : public CSpecObjInfo
2007-06-16 20:12:08 +00:00
{
public :
unsigned char player ; //FF - nobody, 0 - 7
} ;
class CShrineObjInfo : public CSpecObjInfo
{
public :
unsigned char spell ; //number of spell or 255
} ;
2007-06-17 16:59:14 +00:00
class CSpellScrollObjinfo : public CSpecObjInfo
{
public :
std : : string message ;
2008-06-08 00:58:29 +00:00
int spell ;
2007-06-17 16:59:14 +00:00
bool areGuarders ;
CCreatureSet guarders ;
} ;
class CPandorasBoxObjInfo : public CSpecObjInfo
{
public :
std : : string message ;
bool areGuarders ;
CCreatureSet guarders ;
//gained things:
unsigned int gainedExp ;
int manaDiff ;
int moraleDiff ;
int luckDiff ;
int wood , mercury , ore , sulfur , crystal , gems , gold ;
int attack , defence , power , knowledge ;
2008-06-08 00:58:29 +00:00
std : : vector < int > abilities ;
2007-06-17 16:59:14 +00:00
std : : vector < int > abilityLevels ;
2008-06-08 00:58:29 +00:00
std : : vector < int > artifacts ;
std : : vector < int > spells ;
2007-06-17 16:59:14 +00:00
CCreatureSet creatures ;
} ;
class CGrailObjInfo : public CSpecObjInfo
{
public :
int radius ; //place grail at the distance lesser or equal radius from this place
} ;
class CCreGenObjInfo : public CSpecObjInfo
{
public :
unsigned char player ; //owner
bool asCastle ;
2008-02-05 03:56:45 +00:00
int identifier ;
2007-06-17 16:59:14 +00:00
unsigned char castles [ 2 ] ; //allowed castles
} ;
class CCreGen2ObjInfo : public CSpecObjInfo
{
public :
unsigned char player ; //owner
bool asCastle ;
2008-02-05 03:56:45 +00:00
int identifier ;
2007-06-17 16:59:14 +00:00
unsigned char castles [ 2 ] ; //allowed castles
unsigned char minLevel , maxLevel ; //minimal and maximal level of creature in dwelling: <0, 6>
} ;
class CCreGen3ObjInfo : public CSpecObjInfo
{
public :
unsigned char player ; //owner
unsigned char minLevel , maxLevel ; //minimal and maximal level of creature in dwelling: <0, 6>
} ;
class CBorderGuardObjInfo : public CSpecObjInfo //copied form seer huts, seems to be similar
{
public :
char 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 player
bool isDayLimit ; //if true, there is a day limit
int lastDay ; //after this day (first day is 0) mission cannot be completed
//for mission 1
int m1level ;
//for mission 2
int m2attack , m2defence , m2power , m2knowledge ;
//for mission 3
unsigned char m3bytes [ 4 ] ;
//for mission 4
unsigned char m4bytes [ 4 ] ;
//for mission 5
2008-06-08 00:58:29 +00:00
std : : vector < int > m5arts ; //artifacts id
2007-06-17 16:59:14 +00:00
//for mission 6
std : : vector < CCreature * > m6cre ;
std : : vector < int > m6number ;
//for mission 7
int m7wood , m7mercury , m7ore , m7sulfur , m7crystal , m7gems , m7gold ;
//for mission 8
2008-06-11 01:53:57 +00:00
int m8hero ; //hero id
2007-06-17 16:59:14 +00:00
//for mission 9
int m9player ; //number; from 0 to 7
std : : string firstVisitText , nextVisitText , completedText ;
} ;
2007-06-11 17:21:27 +00:00
class CObject //typical object that can be encountered on a map
{
public :
std : : string name ; //object's name
} ;
2008-02-05 03:56:45 +00:00
class CGDefInfo ;
2007-11-18 22:58:28 +00:00
2007-10-27 19:38:48 +00:00
class CGObjectInstance
{
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
2007-10-27 19:38:48 +00:00
int id ; //number of object in CObjectHandler's vector
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 ;
2007-11-18 22:58:28 +00:00
int tempOwner ; //uzywane dla szybkosci, skrypt ma obowiazek aktualizowac te zmienna
2007-11-23 22:33:55 +00:00
bool blockVisit ;
2007-10-27 19:38:48 +00:00
virtual bool isHero ( ) const ;
int getOwner ( ) const ;
2007-11-18 22:58:28 +00:00
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
bool visitableAt ( int x , int y ) const ; //returns true if ibject is visitable at 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 ( ) ;
CGObjectInstance ( const CGObjectInstance & right ) ;
CGObjectInstance & operator = ( const CGObjectInstance & right ) ;
} ;
2008-02-24 23:06:27 +00:00
class CArmedInstance : public CGObjectInstance
{
public :
CCreatureSet army ; //army
} ;
class CGHeroInstance : public CArmedInstance
2007-10-27 19:38:48 +00:00
{
public :
2008-02-15 18:40:58 +00:00
int moveDir ; //format: 123
// 8 4
// 765
2007-10-27 19:38:48 +00:00
bool isStanding ;
bool flagPrinted ;
CHero * type ;
int exp ; //experience point
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
std : : vector < std : : pair < int , int > > secSkills ; //first - ID of skill, second - level of skill (0 - basic, 1 - adv., 2 - expert)
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-11 01:53:57 +00:00
struct Patrol
{
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-06-08 00:58:29 +00:00
std : : vector < int > artifacts ; //hero's artifacts from bag
std : : map < int , int > 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 < int > 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
void setPosition ( int3 Pos , bool h3m ) ; //as above, but sets position
bool canWalkOnSea ( ) const ;
int getCurrentLuck ( ) const ;
int getCurrentMorale ( ) const ;
2008-06-03 13:15:34 +00:00
int getSecSkillLevel ( const int & ID ) const ; //-1 - no skill
2008-06-08 00:58:29 +00:00
const CArtifact * getArt ( int pos ) ;
2008-02-07 18:45:22 +00:00
CGHeroInstance ( ) ;
2007-10-27 19:38:48 +00:00
virtual ~ CGHeroInstance ( ) ;
} ;
2008-02-24 23:06:27 +00:00
class 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-06-11 01:53:57 +00:00
std : : set < int > forbiddenBuildings , builtBuildings ;
std : : vector < int > possibleSpells , obligatorySpells , availableSpells ;
2008-04-04 17:30:53 +00:00
struct StrInfo
{
std : : map < int , int > creatures ; //level - available amount
} 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-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 ;
2007-10-27 19:38:48 +00:00
CGTownInstance ( ) ;
virtual ~ CGTownInstance ( ) ;
} ;
2007-06-11 17:21:27 +00:00
class CObjectHandler
{
public :
std : : vector < CObject > objects ; //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
} ;
# endif //COBJECTHANDLER_H