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>
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"
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
*
*/
2010-07-13 08:25:40 +03:00
struct MetaString ;
2010-05-02 21:20:26 +03:00
class BattleInfo ;
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 ;
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 ;
2009-07-19 04:00:19 +03:00
class CGBoat ;
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
} ;
2010-02-10 04:56:00 +02:00
class DLL_EXPORT 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 ,
MISSION_ART = 5 , MISSION_ARMY = 6 , MISSION_RESOURCES = 7 , MISSION_HERO = 8 , MISSION_PLAYER = 9 } ;
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-01-01 14:15:20 +02:00
TSlots m6creatures ; //pair[cre id, cre count], CreatureSet info irrelevant
2008-12-27 03:01:59 +02:00
std : : vector < ui32 > m7resources ;
std : : string firstVisitText , nextVisitText , completedText ;
2010-05-03 09:25:19 +03:00
bool isCustom ;
2008-12-31 11:33:46 +02:00
2010-01-01 14:15:20 +02:00
bool checkQuest ( const CGHeroInstance * h ) const ; //determines whether the quest is complete or not
2010-01-30 22:53:47 +02:00
virtual void completeQuest ( const CGHeroInstance * h ) 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 )
{
2010-01-30 22:53:47 +02:00
h & missionType & progress & lastDay & m13489val & m2stats & m5arts & m6creatures & m7resources
2010-05-03 09:25:19 +03:00
& firstVisitText & nextVisitText & completedText & isCustom ;
2008-12-31 11:33:46 +02:00
}
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
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
} ;
2010-03-11 01:16:30 +02:00
class DLL_EXPORT 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
} ;
class DLL_EXPORT IShipyard : public IBoatGenerator
{
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 ) ;
} ;
2010-05-18 10:01:54 +03:00
class DLL_EXPORT IMarket
{
virtual int getMarketEfficiency ( ) const = 0 ;
public :
const CGObjectInstance * o ;
IMarket ( const CGObjectInstance * O ) ;
virtual bool allowsTrade ( EMarketMode mode ) const ;
virtual int availableUnits ( EMarketMode mode , int marketItemSerial ) const ; //-1 if unlimited
virtual std : : vector < int > availableItemsIds ( EMarketMode mode ) const ;
bool getOffer ( int id1 , int id2 , int & val1 , int & val2 , EMarketMode mode ) const ; //val1 - how many units of id1 player has to give to receive val2 units
std : : vector < EMarketMode > availableModes ( ) const ;
static const IMarket * castFrom ( const CGObjectInstance * obj ) ;
} ;
2010-05-08 01:10:32 +03:00
2009-09-07 05:29:44 +03:00
class DLL_EXPORT 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)
2009-11-11 19:45:03 +02:00
void getSightTiles ( std : : set < int3 > & 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
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 ;
//////////////////////////////////////////////////////////////////////////
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
2009-03-14 19:19:53 +02:00
class DLL_EXPORT CPlayersVisited : public CGObjectInstance
{
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
bool hasVisited ( 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 ;
}
} ;
2010-05-02 21:20:26 +03:00
class DLL_EXPORT 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 setArmy ( const CCreatureSet & src ) ;
CCreatureSet getArmy ( ) const ;
void randomizeArmy ( int type ) ;
//////////////////////////////////////////////////////////////////////////
void getParents ( TCNodes & out , const CBonusSystemNode * root = NULL ) const ;
void getBonuses ( BonusList & out , const CSelector & selector , const CBonusSystemNode * root = NULL ) const ;
//////////////////////////////////////////////////////////////////////////
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
} ;
2010-05-02 21:20:26 +03:00
class DLL_EXPORT CGHeroInstance : public CArmedInstance , public IBoatGenerator
2008-12-27 03:01:59 +02:00
{
public :
//////////////////////////////////////////////////////////////////////////
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 ;
//////////////////////////////////////////////////////////////////////////
2010-07-20 21:34:32 +03:00
const CHero * type ;
2009-10-27 22:40:11 +02:00
ui64 exp ; //experience points
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
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
ui8 sex ;
ui8 inTownGarrison ; // if hero is in town garrison
2010-07-20 21:34:32 +03:00
const CGTownInstance * visitedTown ; //set if hero is visiting town or in the town garrison
const CGBoat * boat ; //set to CGBoat when sailing
2008-12-27 03:01:59 +02: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
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 ;
2010-06-28 08:07:21 +03:00
struct DLL_EXPORT HeroSpecial : CBonusSystemNode
{
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-05-02 21:20:26 +03:00
h & exp & level & name & biography & portrait & mana & secSkills & movement
2010-05-30 14:48:24 +03:00
& sex & inTownGarrison & artifacts & artifWorn & spells & patrol & moveDir ;
2009-01-06 20:42:20 +02:00
2010-06-28 08:07:21 +03:00
h & type & speciality ;
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-05-02 21:20:26 +03:00
void getParents ( TCNodes & out , const CBonusSystemNode * root = NULL ) const ;
void getBonuses ( BonusList & out , const CSelector & selector , const CBonusSystemNode * root = NULL ) const ;
//////////////////////////////////////////////////////////////////////////
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
EAlignment getAlignment ( ) 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 ;
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'
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 ;
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-05-02 21:20:26 +03:00
TModDescr 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
2010-05-02 21:20:26 +03:00
TModDescr getCurrentMoraleModifiers ( int stack = - 1 , bool town = false ) const ; //args as above
2010-02-06 15:49:14 +02:00
int getPrimSkillLevel ( int id ) const ; //0-attack, 1-defence, 2-spell power, 3-knowledge
2008-12-31 11:33:46 +02:00
ui8 getSecSkillLevel ( const int & ID ) const ; //0 - no skill
2010-07-31 16:55:05 +03:00
void setSecSkillLevel ( int which , int val , bool abs ) ; // abs == 0 - changes by value; 1 - sets to value
2008-12-27 03:01:59 +02:00
int maxMovePoints ( bool onLand ) const ;
2010-01-29 22:52:45 +02:00
2008-12-27 03:01:59 +02:00
ui32 getArtAtPos ( ui16 pos ) const ; //-1 - no artifact
const CArtifact * getArt ( int pos ) const ;
2009-05-22 02:50:45 +03:00
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)
2010-01-29 22:52:45 +02:00
bool hasArt ( ui32 aid ) const ; //checks if hero possess artifact of given id (either in backack or worn)
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 ;
int getTotalStrength ( ) const ;
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-04-02 05:07:40 +03:00
CStackInstance calculateNecromancy ( const BattleResult & battleResult ) const ;
void showNecromancyDialog ( const CStackInstance & raisedStack ) const ;
2009-02-03 07:28:05 +02:00
2008-12-27 03:01:59 +02:00
//////////////////////////////////////////////////////////////////////////
void initHero ( ) ;
void initHero ( int SUBID ) ;
2010-07-08 08:52:11 +03:00
void initArmy ( CCreatureSet * dst = NULL ) ;
2010-01-29 22:52:45 +02: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 ( ) ;
//////////////////////////////////////////////////////////////////////////
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 ;
} ;
2010-08-16 16:51:31 +03:00
class DLL_EXPORT CSpecObjInfo
{
public :
virtual ~ CSpecObjInfo ( ) { } ;
} ;
class DLL_EXPORT CCreGenObjInfo : public CSpecObjInfo
{
public :
unsigned char player ; //owner
bool asCastle ;
ui32 identifier ;
unsigned char castles [ 2 ] ; //allowed castles
} ;
class DLL_EXPORT CCreGen2ObjInfo : public CSpecObjInfo
{
public :
unsigned char player ; //owner
bool asCastle ;
ui32 identifier ;
unsigned char castles [ 2 ] ; //allowed castles
unsigned char minLevel , maxLevel ; //minimal and maximal level of creature in dwelling: <0, 6>
} ;
class DLL_EXPORT CCreGen3ObjInfo : public CSpecObjInfo
{
public :
unsigned char player ; //owner
unsigned char minLevel , maxLevel ; //minimal and maximal level of creature in dwelling: <0, 6>
} ;
2009-07-06 22:41:27 +03:00
class DLL_EXPORT CGDwelling : public CArmedInstance
{
public :
2010-02-21 20:07:24 +02:00
CSpecObjInfo * info ; //h3m info about dewlling
2009-07-06 22:41:27 +03:00
std : : vector < std : : pair < ui32 , std : : vector < ui32 > > > creatures ; //creatures[level] -> <vector of alternative ids (base creature and upgrades, creatures amount>
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
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 ;
void setPropertyDer ( ui8 what , ui32 val ) ; //synchr
void onHeroVisit ( const CGHeroInstance * h ) const ;
void onNAHeroVisit ( int heroID , bool alreadyVisited ) const ;
void initObj ( ) ;
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 ;
}
} ;
2009-09-21 12:00:33 +03:00
class DLL_EXPORT 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
} ;
2009-10-05 19:38:54 +03:00
class DLL_EXPORT COPWBonus : public CGTownBuilding
{ ///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
2009-09-21 12:00:33 +03:00
class DLL_EXPORT 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
class DLL_EXPORT CGTownInstance : public CGDwelling , public IShipyard , public IMarket
2008-12-27 03:01:59 +02:00
{
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 ;
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-01-29 18:19:12 +02:00
std : : set < 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 ;
2010-02-26 13:18:09 +02:00
h & town ;
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
//////////////////////////////////////////////////////////////////////////
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
bool allowsTrade ( EMarketMode mode ) const ;
2010-06-27 19:03:01 +03:00
std : : vector < int > availableItemsIds ( 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 ;
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 ;
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 ;
2010-02-13 17:56:34 +02:00
int defenceBonus ( int type ) const ; //primary skills bonuses for defending 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 ( ) ;
} ;
2009-08-16 18:39:18 +03:00
class DLL_EXPORT CGPandoraBox : public CArmedInstance
2008-12-27 03:01:59 +02:00
{
public :
std : : string message ;
2009-08-16 18:39:18 +03:00
ui8 removeAfterVisit ; //true if event is removed after occurring
//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
}
} ;
class DLL_EXPORT CGEvent : public CGPandoraBox //event objects
{
public :
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 )
{
2009-04-21 01:57:07 +03:00
h & static_cast < CArmedInstance & > ( * this ) ;
h & message & gainedExp & manaDiff & moraleDiff & luckDiff & resources & primskills
2009-01-06 20:42:20 +02:00
& abilities & abilityLevels & artifacts & spells & creatures & availableFor
2010-05-02 21:20:26 +03:00
& 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
} ;
class DLL_EXPORT CGCreature : public CArmedInstance //creatures on map
{
public :
ui32 identifier ; //unique code for this monster (used in missions)
2009-04-12 04:48:50 +03:00
si8 character ; //chracter of this set of creatures (0 - the most friendly, 4 - the most hostile) => on init changed to 0 (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-06-26 15:57:16 +03:00
ui32 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
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CArmedInstance & > ( * this ) ;
2010-06-26 15:57:16 +03:00
h & identifier & character & message & resources & gainedArtifact & neverFlees & notGrowingTeam & temppower ;
2009-01-06 20:42:20 +02:00
}
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
2009-05-07 20:20:41 +03:00
si32 rID ; //reward ID
si32 rVal ; //reward value
2010-01-01 14:15:20 +02:00
ui8 textOption ; //store randomized mission write-ups rather than entire string (?)
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 ;
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
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) & static_cast < CQuest & > ( * this ) ;
2010-01-30 22:53:47 +02:00
h & rewardType & rID & rVal & textOption & seerName ;
}
} ;
class DLL_EXPORT CGQuestGuard : public CGSeerHut
{
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
} ;
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-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
} ;
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-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
} ;
class DLL_EXPORT CGGarrison : public CArmedInstance
{
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
} ;
class DLL_EXPORT CGArtifact : public CArmedInstance
{
public :
std : : string message ;
ui32 spell ; //if it's spell scroll
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 ) ;
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-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
} ;
2009-07-19 06:10:24 +03:00
class DLL_EXPORT 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
} ;
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-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
} ;
class DLL_EXPORT CGMine : public CArmedInstance
{
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 ;
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
} ;
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 :
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 ( ) ;
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 ) ;
}
} ;
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 ;
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 ) ;
}
} ;
2009-09-23 15:42:14 +03:00
class DLL_EXPORT CGMagicSpring : public CGVisitableOPW
{ ///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 ;
}
} ;
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-07-19 10:16:33 +03:00
class DLL_EXPORT CGSirens : public CGObjectInstance
{
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 ) ;
}
} ;
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-08-11 10:50:29 +03:00
2009-12-30 22:49:10 +02:00
class DLL_EXPORT 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 ) ;
bool wasMyColorVisited ( int player ) const ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
}
} ;
class DLL_EXPORT CGKeymasterTent : public CGKeys
{
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 ) ;
}
} ;
class DLL_EXPORT CGBorderGuard : public CGKeys
{
public :
void initObj ( ) ;
const std : : string & getHoverText ( ) const ;
void onHeroVisit ( const CGHeroInstance * h ) const ;
void openGate ( const CGHeroInstance * h , ui32 accept ) const ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
h & blockVisit ;
}
} ;
class DLL_EXPORT CGBorderGate : public CGBorderGuard //not fully imlemented, waiting for garrison
{
public :
void onHeroVisit ( const CGHeroInstance * h ) const ;
2009-12-20 19:14:14 +02:00
ui8 getPassableness ( ) const ;
2009-08-11 10:50:29 +03:00
} ;
2009-07-19 04:00:19 +03:00
class DLL_EXPORT CGBoat : public CGObjectInstance
{
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 ;
}
} ;
2009-09-01 17:36:48 +03:00
class DLL_EXPORT CGOnceVisitable : public CPlayersVisited
///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
}
} ;
2009-08-11 10:50:29 +03:00
class DLL_EXPORT CBank : public CArmedInstance
{
public :
int index ; //banks have unusal numbering - see ZCRBANK.txt and initObj()
BankConfig * bc ;
2009-08-26 08:08:59 +03:00
float multiplier ; //for improved banks script
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 ;
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 )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
2009-12-29 03:07:17 +02:00
h & index & multiplier & artifacts & daycounter & bc ;
2009-08-11 10:50:29 +03:00
}
} ;
2009-09-24 20:54:02 +03:00
class DLL_EXPORT CGPyramid : public CBank
{
public :
static BankConfig pyramidConfig ;
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
2009-08-13 04:03:11 +03:00
class DLL_EXPORT 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 ;
2010-08-17 19:26:48 +03:00
void showEyes ( const CGHeroInstance * h , ui32 accept ) 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
} ;
2009-08-19 09:56:53 +03:00
class DLL_EXPORT CCartographer : public CPlayersVisited
{
///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
h & players ;
}
2009-09-21 12:00:33 +03:00
} ;
2010-02-06 15:49:14 +02:00
class DLL_EXPORT CGDenOfthieves : public CGObjectInstance
{
void onHeroVisit ( const CGHeroInstance * h ) const ;
} ;
2010-02-10 04:56:00 +02:00
class DLL_EXPORT CGObelisk : public CPlayersVisited
{
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
}
} ;
class DLL_EXPORT CGLighthouse : public CGObjectInstance
{
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 ;
} ;
2010-05-18 10:01:54 +03:00
class DLL_EXPORT CGMarket : public CGObjectInstance , public IMarket
{
public :
CGMarket ( ) ;
void onHeroVisit ( const CGHeroInstance * h ) const ; //open trading window
int getMarketEfficiency ( ) const ;
bool allowsTrade ( EMarketMode mode ) const ;
int availableUnits ( EMarketMode mode , int marketItemSerial ) const ; //-1 if unlimited
std : : vector < int > availableItemsIds ( EMarketMode mode ) const ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
}
} ;
2010-06-26 19:02:10 +03:00
class DLL_EXPORT CGBlackMarket : public CGMarket
{
public :
std : : vector < const CArtifact * > artifacts ; //available artifacts
void newTurn ( ) const ; //reset artifacts for black market every month
std : : vector < int > availableItemsIds ( EMarketMode mode ) const ;
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
}
} ;
2010-07-20 17:08:13 +03:00
class DLL_EXPORT CGUniversity : public CGMarket
{
public :
std : : vector < int > skills ; //available skills
std : : vector < int > availableItemsIds ( EMarketMode mode ) const ;
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
}
} ;
class DLL_EXPORT CObjectHandler
2009-08-11 10:50:29 +03:00
{
public :
2009-08-13 04:03:11 +03:00
std : : vector < si32 > cregens ; //type 17. dwelling subid -> creature ID
2009-12-29 03:07:17 +02:00
std : : map < ui32 , std : : vector < 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 ( ) ;
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
}
} ;
2009-08-13 04:03:11 +03:00
2008-12-27 03:01:59 +02:00
# endif // __COBJECTHANDLER_H__