2007-06-11 20:21:27 +03:00
|
|
|
#ifndef COBJECTHANDLER_H
|
|
|
|
#define COBJECTHANDLER_H
|
2008-06-17 20:48:32 +03:00
|
|
|
#include "../global.h"
|
2007-06-11 20:21:27 +03:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2008-01-09 19:21:31 +02:00
|
|
|
#include <set>
|
2008-06-08 03:58:29 +03:00
|
|
|
#include <map>
|
2007-06-12 23:09:23 +03:00
|
|
|
#include "CCreatureHandler.h"
|
2008-06-17 20:48:32 +03:00
|
|
|
|
2007-11-19 00:58:28 +02:00
|
|
|
using boost::logic::tribool;
|
|
|
|
class CCPPObjectScript;
|
|
|
|
class CGObjectInstance;
|
2007-10-27 22:38:48 +03:00
|
|
|
class CScript;
|
|
|
|
class CObjectScript;
|
|
|
|
class CGHeroInstance;
|
|
|
|
class CTown;
|
|
|
|
class CHero;
|
|
|
|
class CBuilding;
|
|
|
|
class CSpell;
|
2008-06-07 20:16:52 +03:00
|
|
|
class CGTownInstance;
|
2008-06-08 03:58:29 +03:00
|
|
|
class CArtifact;
|
2008-06-19 09:08:05 +03:00
|
|
|
class CGDefInfo;
|
|
|
|
class CSpecObjInfo;
|
2007-06-12 23:09:23 +03:00
|
|
|
|
2008-06-17 20:48:32 +03:00
|
|
|
class DLL_EXPORT CCastleEvent
|
2008-06-11 04:53:57 +03: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 19:50:02 +03:00
|
|
|
|
2008-06-17 20:48:32 +03:00
|
|
|
class DLL_EXPORT CGObjectInstance
|
2007-10-27 22:38:48 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
int3 pos; //h3m pos
|
2008-05-31 23:37:54 +03:00
|
|
|
int ID, subID; //normal ID (this one from OH3 maps ;]) - eg. town=98; hero=34
|
2008-07-28 15:44:08 +03:00
|
|
|
si32 id;//number of object in CObjectHandler's vector
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * defInfo;
|
2007-11-19 00:58:28 +02:00
|
|
|
CCPPObjectScript * state;
|
2007-10-27 22:38:48 +03:00
|
|
|
CSpecObjInfo * info;
|
2008-06-03 16:15:34 +03:00
|
|
|
unsigned char animPhaseShift;
|
2008-07-30 20:51:19 +03:00
|
|
|
std::string hoverName;
|
2007-11-19 00:58:28 +02:00
|
|
|
|
2008-08-13 03:44:31 +03: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 18:08:03 +03:00
|
|
|
|
2007-10-27 22:38:48 +03:00
|
|
|
virtual bool isHero() const;
|
2008-08-02 18:08:03 +03:00
|
|
|
int getOwner() const;
|
|
|
|
void setOwner(int ow);
|
2007-10-27 22:38:48 +03: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-06-17 20:48:32 +03:00
|
|
|
class DLL_EXPORT CArmedInstance: public CGObjectInstance
|
2008-02-25 01:06:27 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CCreatureSet army; //army
|
|
|
|
};
|
|
|
|
|
2008-06-17 20:48:32 +03:00
|
|
|
class DLL_EXPORT CGHeroInstance : public CArmedInstance
|
2007-10-27 22:38:48 +03:00
|
|
|
{
|
|
|
|
public:
|
2008-08-26 00:14:00 +03:00
|
|
|
mutable int moveDir; //format: 123
|
2008-02-15 20:40:58 +02:00
|
|
|
// 8 4
|
|
|
|
// 765
|
2008-08-27 13:19:18 +03:00
|
|
|
mutable bool isStanding, tacticFormationEnabled;
|
2007-10-27 22:38:48 +03:00
|
|
|
CHero * type;
|
2008-08-04 18:56:36 +03:00
|
|
|
ui32 exp; //experience point
|
2007-10-27 22:38:48 +03: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
|
|
|
|
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 03:58:29 +03:00
|
|
|
int identifier; //from the map file
|
|
|
|
bool sex;
|
2008-05-31 23:37:54 +03:00
|
|
|
|
2008-06-17 20:48:32 +03:00
|
|
|
struct DLL_EXPORT Patrol
|
2008-06-11 04:53:57 +03:00
|
|
|
{
|
|
|
|
Patrol(){patrolling=false;patrolRadious=-1;};
|
|
|
|
bool patrolling;
|
|
|
|
int patrolRadious;
|
|
|
|
} patrol;
|
|
|
|
|
|
|
|
|
2007-10-27 22:38:48 +03:00
|
|
|
bool inTownGarrison; // if hero is in town garrison
|
2008-05-31 23:37:54 +03:00
|
|
|
CGTownInstance * visitedTown; //set if hero is visiting town or in the town garrison
|
2007-10-27 22:38:48 +03:00
|
|
|
|
2008-08-20 22:02:48 +03: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 13:19:18 +03:00
|
|
|
std::set<ui32> spells; //known spells (spell IDs)
|
2008-01-19 15:19:58 +02:00
|
|
|
|
2007-10-27 22:38:48 +03:00
|
|
|
virtual bool isHero() const;
|
2008-06-03 16:15:34 +03:00
|
|
|
unsigned int getTileCost(const EterrainType & ttype, const Eroad & rdtype, const Eriver & rvtype) const;
|
2007-10-27 22:38:48 +03:00
|
|
|
unsigned int getLowestCreatureSpeed();
|
2008-06-03 16:15:34 +03:00
|
|
|
unsigned int getAdditiveMoveBonus() const;
|
|
|
|
float getMultiplicativeMoveBonus() const;
|
2007-10-27 22:38:48 +03: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 16:15:34 +03:00
|
|
|
int getSecSkillLevel(const int & ID) const; //-1 - no skill
|
2008-08-20 22:02:48 +03:00
|
|
|
ui32 getArtAtPos(ui16 pos) const; //-1 - no artifact
|
|
|
|
void setArtAtPos(ui16 pos, int art);
|
2008-06-08 03:58:29 +03:00
|
|
|
const CArtifact * getArt(int pos);
|
2008-02-07 20:45:22 +02:00
|
|
|
CGHeroInstance();
|
2007-10-27 22:38:48 +03:00
|
|
|
virtual ~CGHeroInstance();
|
|
|
|
};
|
|
|
|
|
2008-06-17 20:48:32 +03:00
|
|
|
class DLL_EXPORT CGTownInstance : public CArmedInstance
|
2007-10-27 22:38:48 +03: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 04:53:57 +03:00
|
|
|
const CGHeroInstance * garrisonHero, *visitingHero;
|
2008-06-08 03:58:29 +03:00
|
|
|
int identifier; //special identifier from h3m (only > RoE maps)
|
|
|
|
int alignment;
|
2008-08-01 14:21:15 +03:00
|
|
|
std::set<si32> forbiddenBuildings, builtBuildings;
|
2008-08-20 09:57:53 +03: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 20:30:53 +03:00
|
|
|
|
|
|
|
struct StrInfo
|
|
|
|
{
|
2008-08-01 14:21:15 +03:00
|
|
|
std::map<si32,ui32> creatures; //level - available amount
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & creatures;
|
|
|
|
}
|
2008-04-04 20:30:53 +03:00
|
|
|
} strInfo;
|
2008-06-11 04:53:57 +03:00
|
|
|
std::set<CCastleEvent> events;
|
2007-10-27 22:38:48 +03:00
|
|
|
|
|
|
|
|
|
|
|
int getSightDistance() const; //returns sight distance
|
2008-02-18 23:14:28 +02: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 09:57:53 +03:00
|
|
|
int mageGuildLevel() const; // -1 - none, 0 - village, 1 - town, 2 - city, 3 - capitol
|
2008-06-03 16:15:34 +03: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 19:21:31 +02:00
|
|
|
bool hasFort() const;
|
2008-02-05 05:56:45 +02:00
|
|
|
bool hasCapitol() const;
|
2008-01-09 19:21:31 +02:00
|
|
|
int dailyIncome() const;
|
|
|
|
|
2007-10-27 22:38:48 +03:00
|
|
|
CGTownInstance();
|
|
|
|
virtual ~CGTownInstance();
|
|
|
|
};
|
|
|
|
|
2008-06-17 20:48:32 +03:00
|
|
|
class DLL_EXPORT CObjectHandler
|
2007-06-11 20:21:27 +03:00
|
|
|
{
|
|
|
|
public:
|
2008-07-30 20:51:19 +03:00
|
|
|
std::vector<std::string> names; //vector of objects; i-th object in vector has subnumber i
|
2008-02-05 05:56:45 +02:00
|
|
|
std::vector<int> cregens; //type 17. dwelling subid -> creature ID
|
2007-06-11 20:21:27 +03:00
|
|
|
void loadObjects();
|
2007-11-19 00:58:28 +02:00
|
|
|
|
2008-03-01 00:14:53 +02:00
|
|
|
std::vector<std::string> creGens; //names of creatures' generators
|
2007-11-19 00:58:28 +02:00
|
|
|
std::vector<std::string> advobtxt;
|
|
|
|
std::vector<std::string> xtrainfo;
|
2007-11-25 15:16:45 +02:00
|
|
|
std::vector<std::string> restypes;
|
|
|
|
std::vector<std::pair<std::string,std::string> > mines; //first - name; second - event description
|
2007-06-11 20:21:27 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-08-02 18:08:03 +03:00
|
|
|
#endif //COBJECTHANDLER_H
|