2008-12-27 03:01:59 +02:00
# ifndef __COBJECTHANDLER_H__
# define __COBJECTHANDLER_H__
# include "../global.h"
# include <string>
# include <vector>
# include <set>
# include <map>
2009-02-03 07:28:05 +02:00
# include <list>
2008-12-27 03:01:59 +02:00
# include "CCreatureHandler.h"
2009-02-04 15:40:54 +02:00
# include "../lib/HeroBonus.h"
2009-01-30 20:36:00 +02:00
# ifndef _MSC_VER
# include "CHeroHandler.h"
# include "CTownHandler.h"
# include "../lib/VCMI_Lib.h"
# endif
2008-12-27 03:01:59 +02:00
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
*
*/
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 ;
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
} ;
class CQuest
{
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 } ;
ui8 missionType ;
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 ;
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
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 )
{
h & missionType & lastDay & m13489val & m2stats & m5arts & m6creatures & m7resources
& firstVisitText & nextVisitText & completedText ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT IObjectInterface
{
public :
static IGameCallback * cb ;
IObjectInterface ( ) ;
virtual ~ IObjectInterface ( ) ;
virtual void onHeroVisit ( const CGHeroInstance * h ) const ;
virtual void onHeroLeave ( const CGHeroInstance * h ) const ;
virtual void newTurn ( ) const ;
2009-02-20 14:39:27 +02:00
virtual void initObj ( ) ; //synchr
virtual void setProperty ( ui8 what , ui32 val ) ; //synchr
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
} ;
2009-07-26 06:33:13 +03:00
class DLL_EXPORT IShipyard
{
public :
const CGObjectInstance * o ;
IShipyard ( const CGObjectInstance * O ) ;
void getBoatCost ( std : : vector < si32 > & cost ) const ;
virtual void getOutOffsets ( std : : vector < int3 > & offsets ) const = 0 ; //offsets to obj pos when we boat can be placed
//virtual bool validLocation() const; //returns true if there is a water tile near where 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
static const IShipyard * castFrom ( const CGObjectInstance * obj ) ;
static IShipyard * castFrom ( CGObjectInstance * obj ) ;
} ;
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 ;
void giveDummyBonus ( int heroID , ui8 duration = HeroBonus : : 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 ;
CSpecObjInfo * info ;
2008-12-31 11:33:46 +02:00
ui8 animPhaseShift ;
2008-12-27 03:01:59 +02:00
2008-12-31 11:33:46 +02:00
ui8 tempOwner ;
2008-12-27 03:01:59 +02:00
ui8 blockVisit ; //if non-zero then blocks the tile but is visitable from neighbouring tile
2009-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)
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)
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
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 )
{
h & hoverName & pos & ID & subID & id & animPhaseShift & tempOwner & blockVisit ;
2009-01-06 20:42:20 +02:00
//definfo is handled by map serializer
2008-12-31 11:33:46 +02:00
}
2008-12-27 03:01:59 +02:00
} ;
2009-03-14 19:19:53 +02:00
class DLL_EXPORT CPlayersVisited : public CGObjectInstance
{
public :
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 ;
}
} ;
2009-08-11 10:50:29 +03:00
class DLL_EXPORT CArmedInstance : public CGObjectInstance
2008-12-27 03:01:59 +02:00
{
public :
CCreatureSet army ; //army
virtual bool needsLastStack ( ) const ; //true if last stack cannot be taken
2009-04-12 04:48:50 +03:00
int getArmyStrength ( ) const ; //sum of AI values of creatures
2009-10-03 22:31:50 +03:00
ui64 getPower ( TSlot slot ) const ; //value of specific stack
std : : string getRoughAmount ( TSlot slot ) const ; //rought size of specific stack
2008-12-31 11:33:46 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-01-06 20:42:20 +02:00
h & static_cast < CGObjectInstance & > ( * this ) ;
2008-12-31 11:33:46 +02:00
h & army ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGHeroInstance : public CArmedInstance
{
public :
//////////////////////////////////////////////////////////////////////////
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 ;
//////////////////////////////////////////////////////////////////////////
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
std : : vector < si32 > primSkills ; //0-attack, 1-defence, 2-spell power, 3-knowledge
2008-12-27 03:01:59 +02:00
std : : vector < std : : pair < ui8 , ui8 > > secSkills ; //first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert); if hero has ability (-1, -1) it meansthat it should have default secondary abilities
2008-12-31 11:33:46 +02:00
si32 movement ; //remaining movement points
si32 identifier ; //from the map file
ui8 sex ;
ui8 inTownGarrison ; // if hero is in town garrison
2008-12-27 03:01:59 +02:00
CGTownInstance * visitedTown ; //set if hero is visiting town or in the town garrison
2009-07-19 04:00:19 +03:00
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 ;
2009-02-04 15:40:54 +02:00
std : : list < HeroBonus > bonuses ;
2008-12-27 03:01:59 +02:00
//////////////////////////////////////////////////////////////////////////
2008-12-31 11:33:46 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-01-06 20:42:20 +02:00
h & static_cast < CArmedInstance & > ( * this ) ;
2008-12-31 11:33:46 +02:00
h & exp & level & name & biography & portrait & mana & primSkills & secSkills & movement
2009-07-18 06:13:13 +03:00
& identifier & sex & inTownGarrison & artifacts & artifWorn & spells & patrol & bonuses
& moveDir ;
2009-01-06 20:42:20 +02:00
ui8 standardType = ( VLC - > heroh - > heroes [ subID ] = = type ) ;
h & standardType ;
if ( ! standardType )
h & type ;
else if ( ! h . saving )
type = VLC - > heroh - > heroes [ subID ] ;
//visitied town pointer will be restored by map serialization method
2008-12-31 11:33:46 +02:00
}
2009-03-12 01:25:59 +02:00
//////////////////////////////////////////////////////////////////////////
int3 getSightCenter ( ) const ; //"center" tile from which the sight distance is calculated
int getSightRadious ( ) const ; //sight distance (should be used if player-owned structure)
2008-12-31 11:33:46 +02:00
//////////////////////////////////////////////////////////////////////////
2009-02-04 15:40:54 +02:00
const HeroBonus * getBonus ( int from , int id ) const ;
* 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
int valOfBonuses ( HeroBonus : : BonusType type , int subtype = - 1 ) const ; //subtype -> subtype of bonus, if -1 then any
bool hasBonusOfType ( HeroBonus : : BonusType type , int subtype = - 1 ) const ; //determines if hero has a bonus of given type (and optionally subtype)
2008-12-27 03:01:59 +02:00
const std : : string & getBiography ( ) const ;
bool needsLastStack ( ) const ;
2009-02-12 16:44:58 +02:00
unsigned int getTileCost ( const TerrainTile & dest , const TerrainTile & from ) const ; //move cost - applying pathfinding skill, road and terrain modifiers. NOT includes diagonal move penalty, last move levelling
2008-12-27 03:01:59 +02:00
unsigned int getLowestCreatureSpeed ( ) const ;
int3 getPosition ( bool h3m ) const ; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
2008-12-31 11:33:46 +02:00
si32 manaLimit ( ) const ; //maximum mana value for this hero (basically 10*knowledge)
2009-04-04 01:34:31 +03:00
si32 manaRegain ( ) const ; //how many points of mana can hero regain "naturally" in one day
2008-12-27 03:01:59 +02:00
bool canWalkOnSea ( ) const ;
2009-02-04 15:40:54 +02:00
int getCurrentLuck ( int stack = - 1 , bool town = false ) const ;
std : : vector < std : : pair < int , std : : string > > getCurrentLuckModifiers ( int stack = - 1 , bool town = false ) const ; //args as above
2009-02-03 07:28:05 +02:00
int getCurrentMorale ( int stack = - 1 , bool town = false ) const ; //if stack - position of creature, if -1 then morale for hero is calculated; town - if bonuses from town (tavern) should be considered
std : : vector < std : : pair < int , std : : string > > getCurrentMoraleModifiers ( int stack = - 1 , bool town = false ) const ; //args as above
2008-12-27 03:01:59 +02:00
int getPrimSkillLevel ( int id ) const ;
2008-12-31 11:33:46 +02:00
ui8 getSecSkillLevel ( const int & ID ) const ; //0 - no skill
2008-12-27 03:01:59 +02:00
int maxMovePoints ( bool onLand ) const ;
ui32 getArtAtPos ( ui16 pos ) const ; //-1 - no artifact
const CArtifact * getArt ( int pos ) const ;
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)
2009-12-30 17:33:28 +02:00
void giveArtifact ( ui32 aid ) ;
2008-12-27 03:01:59 +02: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
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 ;
2009-05-12 06:35:51 +03:00
ui8 getSpellSchoolLevel ( const CSpell * spell ) const ; //returns level on which given spell would be cast by this hero
* 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
2009-09-28 17:21:48 +03:00
std : : pair < ui32 , si32 > calculateNecromancy ( const BattleResult & battleResult ) const ;
2009-09-01 01:04:00 +03:00
void showNecromancyDialog ( std : : pair < ui32 , si32 > raisedStack ) const ;
2009-02-03 07:28:05 +02:00
2008-12-27 03:01:59 +02:00
//////////////////////////////////////////////////////////////////////////
void initHero ( ) ;
void initHero ( int SUBID ) ;
2009-07-11 02:40:10 +03:00
void recreateArtBonuses ( ) ;
2009-02-01 16:11:41 +02:00
void initHeroDefInfo ( ) ;
2008-12-27 03:01:59 +02:00
CGHeroInstance ( ) ;
virtual ~ CGHeroInstance ( ) ;
//////////////////////////////////////////////////////////////////////////
2009-02-20 14:39:27 +02:00
void setPropertyDer ( ui8 what , ui32 val ) ; //synchr
2008-12-27 03:01:59 +02:00
void initObj ( ) ;
void onHeroVisit ( const CGHeroInstance * h ) const ;
} ;
2009-07-06 22:41:27 +03:00
class DLL_EXPORT CGDwelling : public CArmedInstance
{
public :
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 ( ) ;
void treeSelected ( int heroID , int resType , int resVal , ui64 expVal , ui32 result ) const ; //handle player's anwer to the Tree of Knowledge dialog
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 ;
}
} ;
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
}
} ;
2009-07-26 06:33:13 +03:00
class DLL_EXPORT CGTownInstance : public CGDwelling , public IShipyard
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
std : : set < CCastleEvent > events ;
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 ) ;
2008-12-31 11:33:46 +02:00
h & name & builded & destroyed & identifier & alignment & forbiddenBuildings & builtBuildings
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 ;
2009-01-06 20:42:20 +02:00
ui8 standardType = ( & VLC - > townh - > towns [ subID ] = = town ) ;
h & standardType ;
if ( ! standardType )
h & town ;
else if ( ! h . saving )
town = & VLC - > townh - > towns [ subID ] ;
//garrison/visiting hero pointers will be restored in the map serialization
2008-12-31 11:33:46 +02:00
}
//////////////////////////////////////////////////////////////////////////
2009-03-12 01:25:59 +02:00
int3 getSightCenter ( ) const ; //"center" tile from which the sight distance is calculated
int getSightRadious ( ) const ; //returns sight distance
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
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)
2009-09-23 15:42:14 +03:00
void removeCapitols ( ui8 owner , bool me ) const ;
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
& abilities & abilityLevels & artifacts & spells & creatures & army ;
}
} ;
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
2009-08-16 18:39:18 +03:00
& computerActivate & humanActivate & army ;
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
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 ;
2009-08-11 10:50:29 +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 ( ) ;
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 ) ;
h & identifier & character & message & resources & gainedArtifact & neverFlees & notGrowingTeam ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGSignBottle : public CGObjectInstance //signs and ocean bottles
{
public :
std : : string message ;
2009-01-06 20:42:20 +02:00
2009-03-19 16:17:19 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
void initObj ( ) ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
h & message ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGSeerHut : public CGObjectInstance , public CQuest
{
public :
2009-01-06 20:42:20 +02:00
ui8 rewardType ; //type of reward: 0 - no reward; 1 - experience; 2 - mana points; 3 - morale bonus; 4 - luck bonus; 5 - resources; 6 - main ability bonus (attak, defence etd.); 7 - secondary ability gain; 8 - artifact; 9 - spell; 10 - creature
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-01 14:15:20 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
2009-12-30 22:49:10 +02:00
void finishQuest ( 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-01 14:15:20 +02:00
h & rewardType & rID & rVal & textOption & seerName ;
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 CGQuestGuard : public CGObjectInstance , public CQuest
{
public :
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CQuest & > ( * this ) & static_cast < CGObjectInstance & > ( * this ) ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGMine : public CArmedInstance
{
public :
2009-04-12 03:58:41 +03:00
void offerLeavingGuards ( const CGHeroInstance * h ) const ;
2008-12-27 03:01:59 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
void newTurn ( ) const ;
void initObj ( ) ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CArmedInstance & > ( * this ) ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGVisitableOPW : public CGObjectInstance //objects visitable OPW
{
public :
ui8 visited ; //true if object has been visited this week
2009-02-20 14:39:27 +02:00
void setPropertyDer ( ui8 what , ui32 val ) ; //synchr
2008-12-27 03:01:59 +02:00
void onHeroVisit ( const CGHeroInstance * h ) const ;
void newTurn ( ) const ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & static_cast < CGObjectInstance & > ( * this ) ;
h & visited ;
}
2008-12-27 03:01:59 +02:00
} ;
class DLL_EXPORT CGTeleport : public CGObjectInstance //teleports and subterranean gates
{
public :
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 ;
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-08-20 13:07:23 +03:00
2009-09-21 12:00:33 +03:00
class DLL_EXPORT CShop : public CGObjectInstance
{
///base class for university, art merchant, slave market etc.
public :
2009-09-25 07:05:01 +03:00
std : : map < ui16 , Component * > available ;
2009-09-21 12:00:33 +03:00
std : : map < ui16 , Component * > chosen , bought ; //redundant?
//keys are unique for all three maps
std : : map < ui16 , ui32 > price ;
void initObj ( ) { } ;
void setPropertyDer ( ui8 what , ui32 val ) ;
2009-09-23 15:42:14 +03:00
void newTurn ( ) const ;
virtual void reset ( ui32 val ) { } ; //get new items for Black Market, Tavern, Refugee Camp
2009-10-03 14:16:42 +03:00
virtual void onHeroVisit ( const CGHeroInstance * h ) const { } ;
2009-09-21 12:00:33 +03:00
virtual void trade ( const CGHeroInstance * h ) const { } ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
2009-09-25 07:05:01 +03:00
h & available & chosen & bought & price ;
2009-09-21 12:00:33 +03:00
}
} ;
class DLL_EXPORT CGArtMerchant : public CShop
{
2009-10-03 14:16:42 +03:00
public :
void reset ( ui32 val ) ;
void onHeroVisit ( const CGHeroInstance * h ) const { } ;
} ;
class DLL_EXPORT CGRefugeeCamp : public CShop
{
public :
2009-09-21 12:00:33 +03:00
void reset ( ui32 val ) ;
2009-10-03 14:16:42 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const { } ;
2009-09-21 12:00:33 +03:00
} ;
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
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 )
{
2009-11-21 17:45:37 +02:00
h & cregens & banksInfo & creBanksNames ;
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__