2022-06-20 16:39:50 +02:00
/*
2014-06-05 20:26:50 +03:00
* CGHeroInstance . h , part of VCMI engine
2014-06-05 19:52:14 +03:00
*
* 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
*
*/
2017-07-13 10:26:03 +02:00
# pragma once
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
# include <vcmi/spells/Caster.h>
2017-07-13 10:26:03 +02:00
# include "CArmedInstance.h"
2024-08-24 22:42:19 +02:00
# include "IOwnableObject.h"
2017-07-13 10:26:03 +02:00
# include "../CArtHandler.h" // For CArtifactSet
2014-06-05 19:52:14 +03:00
2022-07-26 15:07:42 +02:00
VCMI_LIB_NAMESPACE_BEGIN
2014-06-05 19:52:14 +03:00
class CHero ;
class CGBoat ;
2014-06-25 17:11:07 +03:00
class CGTownInstance ;
2016-01-27 12:47:42 +02:00
class CMap ;
2014-08-11 21:17:17 +03:00
struct TerrainTile ;
2015-11-10 13:26:45 +02:00
struct TurnInfo ;
2024-02-05 21:27:55 +02:00
enum class EHeroGender : int8_t ;
2014-06-05 19:52:14 +03:00
2023-10-16 22:24:12 +02:00
class DLL_LINKAGE CGHeroPlaceholder : public CGObjectInstance
2014-06-05 19:52:14 +03:00
{
public :
2024-01-01 16:37:48 +02:00
using CGObjectInstance : : CGObjectInstance ;
2023-06-26 15:25:34 +02:00
/// if this is placeholder by power, then power rank of desired hero
std : : optional < ui8 > powerRank ;
/// if this is placeholder by type, then hero type of desired hero
std : : optional < HeroTypeID > heroType ;
2014-06-05 19:52:14 +03:00
2024-01-20 20:34:51 +02:00
template < typename Handler > void serialize ( Handler & h )
2014-06-05 19:52:14 +03:00
{
h & static_cast < CGObjectInstance & > ( * this ) ;
2023-06-26 15:25:34 +02:00
h & powerRank ;
h & heroType ;
2014-06-05 19:52:14 +03:00
}
2023-10-16 22:24:12 +02:00
protected :
void serializeJsonOptions ( JsonSerializeFormat & handler ) override ;
2014-06-05 19:52:14 +03:00
} ;
2024-08-24 22:42:19 +02:00
class DLL_LINKAGE CGHeroInstance : public CArmedInstance , public IBoatGenerator , public CArtifactSet , public spells : : Caster , public AFactionMember , public ICreatureUpgrader , public IOwnableObject
2014-06-05 19:52:14 +03:00
{
2018-01-05 19:21:07 +02:00
// We serialize heroes into JSON for crossover
2023-06-25 20:16:03 +02:00
friend class CampaignState ;
2018-12-20 23:42:31 +02:00
friend class CMapLoaderH3M ;
2023-01-02 13:27:03 +02:00
friend class CMapFormatJson ;
2018-12-20 23:42:31 +02:00
private :
std : : set < SpellID > spells ; //known spells (spell IDs)
2023-03-11 22:09:16 +02:00
mutable int lowestCreatureSpeed ;
2023-06-21 19:38:26 +02:00
ui32 movement ; //remaining movement points
2018-12-20 23:42:31 +02:00
2014-06-05 19:52:14 +03:00
public :
2023-01-02 13:27:03 +02:00
2014-06-05 19:52:14 +03:00
//////////////////////////////////////////////////////////////////////////
2023-02-12 22:39:17 +02:00
//format: 123
// 8 4
// 765
ui8 moveDir ;
mutable ui8 tacticFormationEnabled ;
2014-06-05 19:52:14 +03:00
//////////////////////////////////////////////////////////////////////////
TExpType exp ; //experience points
ui32 level ; //current level of hero
2023-09-28 18:43:04 +02:00
/// If not NONE - then hero should use portrait from referenced hero type
HeroTypeID customPortraitSource ;
2014-06-05 19:52:14 +03:00
si32 mana ; // remaining spell points
std : : vector < std : : pair < SecondarySkill , 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
2023-04-02 18:56:10 +02:00
EHeroGender gender ;
2023-01-02 13:27:03 +02:00
2023-09-28 00:00:32 +02:00
std : : string nameCustomTextId ;
std : : string biographyCustomTextId ;
2023-01-02 13:27:03 +02:00
2014-06-05 19:52:14 +03:00
bool inTownGarrison ; // if hero is in town garrison
ConstTransitivePtr < CGTownInstance > visitedTown ; //set if hero is visiting town or in the town garrison
ConstTransitivePtr < CCommanderInstance > commander ;
2023-02-12 22:39:17 +02:00
const CGBoat * boat = nullptr ; //set to CGBoat when sailing
2014-06-05 19:52:14 +03:00
2023-02-12 22:39:17 +02:00
static constexpr si32 UNINITIALIZED_MANA = - 1 ;
static constexpr ui32 UNINITIALIZED_MOVEMENT = - 1 ;
2024-01-17 15:59:41 +02:00
static constexpr auto UNINITIALIZED_EXPERIENCE = std : : numeric_limits < TExpType > : : max ( ) ;
2014-06-05 19:52:14 +03:00
//std::vector<const CArtifact*> artifacts; //hero's artifacts from bag
//std::map<ui16, const CArtifact*> 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 < ObjectInstanceID > visitedObjects ;
struct DLL_LINKAGE Patrol
{
2016-01-31 17:01:58 +02:00
Patrol ( ) { patrolling = false ; initialPos = int3 ( ) ; patrolRadius = - 1 ; } ;
2014-06-05 19:52:14 +03:00
bool patrolling ;
2015-11-27 10:04:01 +02:00
int3 initialPos ;
2016-01-31 17:01:58 +02:00
ui32 patrolRadius ;
2024-01-20 20:34:51 +02:00
template < typename Handler > void serialize ( Handler & h )
2014-06-05 19:52:14 +03:00
{
2015-11-28 16:58:59 +02:00
h & patrolling ;
2022-06-20 16:39:50 +02:00
h & initialPos ;
2016-01-31 17:01:58 +02:00
h & patrolRadius ;
2014-06-05 19:52:14 +03:00
}
} patrol ;
struct DLL_LINKAGE SecondarySkillsInfo
{
ui8 magicSchoolCounter ;
ui8 wisdomCounter ;
2016-08-18 17:53:28 +02:00
SecondarySkillsInfo ( ) ;
2014-06-05 19:52:14 +03:00
void resetMagicSchoolCounter ( ) ;
void resetWisdomCounter ( ) ;
2024-01-20 20:34:51 +02:00
template < typename Handler > void serialize ( Handler & h )
2014-06-05 19:52:14 +03:00
{
2017-07-31 15:35:42 +02:00
h & magicSchoolCounter ;
h & wisdomCounter ;
2014-06-05 19:52:14 +03:00
}
} skillsInfo ;
2016-01-26 21:24:38 +02:00
inline bool isInitialized ( ) const
{ // has this hero been on the map at least once?
2016-01-27 08:44:04 +02:00
return movement ! = UNINITIALIZED_MOVEMENT & & mana ! = UNINITIALIZED_MANA ;
2016-01-26 21:24:38 +02:00
}
2014-06-24 02:26:36 +03:00
//int3 getSightCenter() const; //"center" tile from which the sight distance is calculated
2016-01-31 17:01:58 +02:00
int getSightRadius ( ) const override ; //sight distance (should be used if player-owned structure)
2014-06-05 19:52:14 +03:00
//////////////////////////////////////////////////////////////////////////
2023-04-20 19:20:51 +02:00
BoatId getBoatType ( ) const override ; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral
2015-10-12 15:47:10 +02:00
void getOutOffsets ( std : : vector < int3 > & offsets ) const override ; //offsets to obj pos when we boat can be placed
2023-06-07 00:55:21 +02:00
const IObjectInterface * getObject ( ) const override ;
2014-06-05 19:52:14 +03:00
//////////////////////////////////////////////////////////////////////////
2023-02-24 13:40:06 +02:00
std : : string getBiographyTranslated ( ) const ;
2024-04-08 17:21:40 +02:00
std : : string getBiographyTextID ( ) const ;
std : : string getNameTextID ( ) const ;
2023-01-02 13:27:03 +02:00
std : : string getNameTranslated ( ) const ;
2023-09-28 18:43:04 +02:00
HeroTypeID getPortraitSource ( ) const ;
int32_t getIconIndex ( ) const ;
2024-01-30 23:34:27 +02:00
std : : string getClassNameTranslated ( ) const ;
std : : string getClassNameTextID ( ) const ;
2014-06-05 19:52:14 +03:00
bool hasSpellbook ( ) const ;
2017-08-26 10:49:29 +02:00
int maxSpellLevel ( ) const ;
2023-02-12 22:39:17 +02:00
void addSpellToSpellbook ( const SpellID & spell ) ;
void removeSpellFromSpellbook ( const SpellID & spell ) ;
bool spellbookContainsSpell ( const SpellID & spell ) const ;
2018-12-20 23:42:31 +02:00
void removeSpellbook ( ) ;
const std : : set < SpellID > & getSpellsInSpellbook ( ) const ;
2023-04-04 12:36:42 +02:00
EAlignment getAlignment ( ) const ;
2015-10-12 15:47:10 +02:00
bool needsLastStack ( ) const override ;
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
2024-08-24 22:42:19 +02:00
ResourceSet dailyIncome ( ) const override ;
2024-08-25 17:04:44 +02:00
std : : vector < CreatureID > providedCreatures ( ) const override ;
2024-08-24 22:42:19 +02:00
const IOwnableObject * asOwnable ( ) const final ;
2023-04-09 03:03:47 +02:00
//INativeTerrainProvider
2024-10-05 21:37:52 +02:00
FactionID getFactionID ( ) const override ;
2023-04-05 17:56:28 +02:00
TerrainId getNativeTerrain ( ) const override ;
2023-03-11 22:09:16 +02:00
int getLowestCreatureSpeed ( ) const ;
2014-06-05 19:52:14 +03:00
si32 manaRegain ( ) const ; //how many points of mana can hero regain "naturally" in one day
2016-01-30 09:20:49 +02:00
si32 getManaNewTurn ( ) const ; //calculate how much mana this hero is going to have the next day
2014-06-05 19:52:14 +03:00
int getCurrentLuck ( int stack = - 1 , bool town = false ) const ;
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
int32_t getSpellCost ( const spells : : Spell * sp ) const ; //do not use during battles -> bonuses from army would be ignored
2023-10-18 16:38:40 +02:00
bool canLearnSpell ( const spells : : Spell * spell , bool allowBanned = false ) const ;
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
bool canCastThisSpell ( const spells : : Spell * spell ) const ; //determines if this hero can cast given spell; takes into account existing spell in spellbook, existing spellbook and artifact bonuses
2014-06-05 19:52:14 +03:00
2022-12-09 14:42:47 +02:00
/// convert given position between map position (CGObjectInstance::pos) and visitable position used for hero interactions
int3 convertToVisitablePos ( const int3 & position ) const ;
int3 convertFromVisitablePos ( const int3 & position ) const ;
2016-10-09 12:38:54 +02:00
2014-06-05 19:52:14 +03:00
// ----- primary and secondary skill, experience, level handling -----
/// Returns true if hero has lower level than should upon his experience.
bool gainsLevel ( ) const ;
/// Returns the next primary skill on level up. Can only be called if hero can gain a level up.
2024-06-01 17:28:17 +02:00
PrimarySkill nextPrimarySkill ( vstd : : RNG & rand ) const ;
2014-06-05 19:52:14 +03:00
/// Returns the next secondary skill randomly on level up. Can only be called if hero can gain a level up.
2024-06-01 17:28:17 +02:00
std : : optional < SecondarySkill > nextSecondarySkill ( vstd : : RNG & rand ) const ;
2014-06-05 19:52:14 +03:00
/// Gets 0, 1 or 2 secondary skills which are proposed on hero level up.
2024-06-01 17:28:17 +02:00
std : : vector < SecondarySkill > getLevelUpProposedSecondarySkills ( vstd : : RNG & rand ) const ;
2014-06-05 19:52:14 +03:00
2023-02-12 22:39:17 +02:00
ui8 getSecSkillLevel ( const SecondarySkill & skill ) const ; //0 - no skill
2014-06-05 19:52:14 +03:00
/// Returns true if hero has free secondary skill slot.
bool canLearnSkill ( ) const ;
2023-02-12 22:39:17 +02:00
bool canLearnSkill ( const SecondarySkill & which ) const ;
2014-06-05 19:52:14 +03:00
2023-08-19 20:43:50 +02:00
void setPrimarySkill ( PrimarySkill primarySkill , si64 value , ui8 abs ) ;
2023-02-12 22:39:17 +02:00
void setSecSkillLevel ( const SecondarySkill & which , int val , bool abs ) ; // abs == 0 - changes by value; 1 - sets to value
void levelUp ( const std : : vector < SecondarySkill > & skills ) ;
2014-06-05 19:52:14 +03:00
2023-06-21 19:38:26 +02:00
/// returns base movement cost for movement between specific tiles. Does not accounts for diagonal movement or last tile exception
ui32 getTileMovementCost ( const TerrainTile & dest , const TerrainTile & from , const TurnInfo * ti ) const ;
void setMovementPoints ( int points ) ;
int movementPointsRemaining ( ) const ;
int movementPointsLimit ( bool onLand ) const ;
2019-01-15 07:52:55 +02:00
//cached version is much faster, TurnInfo construction is costly
2023-06-21 19:38:26 +02:00
int movementPointsLimitCached ( bool onLand , const TurnInfo * ti ) const ;
2023-02-18 20:01:32 +02:00
//update army movement bonus
void updateArmyMovementBonus ( bool onLand , const TurnInfo * ti ) const ;
2019-01-15 07:52:55 +02:00
2015-11-12 13:04:33 +02:00
int movementPointsAfterEmbark ( int MPsBefore , int basicCost , bool disembark = false , const TurnInfo * ti = nullptr ) const ;
2014-06-05 19:52:14 +03:00
double getFightingStrength ( ) const ; // takes attack / defense skill into account
double getMagicStrength ( ) const ; // takes knowledge / spell power skill into account
double getHeroStrength ( ) const ; // includes fighting and magic strength
ui64 getTotalStrength ( ) const ; // includes fighting strength and army strength
TExpType calculateXp ( TExpType exp ) const ; //apply learning skill
2016-01-24 01:27:14 +02:00
2014-06-05 19:52:14 +03:00
CStackBasicDescriptor calculateNecromancy ( const BattleResult & battleResult ) const ;
2024-06-01 17:28:17 +02:00
void showNecromancyDialog ( const CStackBasicDescriptor & raisedStack , vstd : : RNG & rand ) const ;
2015-11-29 11:32:06 +02:00
EDiggingStatus diggingStatus ( ) const ;
2014-06-05 19:52:14 +03:00
//////////////////////////////////////////////////////////////////////////
2024-10-05 21:37:52 +02:00
const CHeroClass * getHeroClass ( ) const ;
HeroClassID getHeroClassID ( ) const ;
const CHero * getHeroType ( ) const ;
HeroTypeID getHeroTypeID ( ) const ;
2023-10-28 11:27:10 +02:00
void setHeroType ( HeroTypeID type ) ;
2014-06-05 19:52:14 +03:00
2024-06-01 17:28:17 +02:00
void initHero ( vstd : : RNG & rand ) ;
void initHero ( vstd : : RNG & rand , const HeroTypeID & SUBID ) ;
2014-06-05 19:52:14 +03:00
2024-09-19 15:51:59 +02:00
ArtPlacementMap putArtifact ( const ArtifactPosition & pos , CArtifactInstance * art ) override ;
void removeArtifact ( const ArtifactPosition & pos ) override ;
2024-06-01 17:28:17 +02:00
void initExp ( vstd : : RNG & rand ) ;
void initArmy ( vstd : : RNG & rand , IArmyDescriptor * dst = nullptr ) ;
2023-08-19 20:43:50 +02:00
void pushPrimSkill ( PrimarySkill which , int val ) ;
2014-06-05 19:52:14 +03:00
ui8 maxlevelsToMagicSchool ( ) const ;
ui8 maxlevelsToWisdom ( ) const ;
void recreateSecondarySkillsBonuses ( ) ;
2023-02-12 22:39:17 +02:00
void updateSkillBonus ( const SecondarySkill & which , int val ) ;
2016-01-24 01:27:14 +02:00
2023-06-06 18:19:30 +02:00
void fillUpgradeInfo ( UpgradeInfo & info , const CStackInstance & stack ) const override ;
2023-10-21 13:50:42 +02:00
bool hasVisions ( const CGObjectInstance * target , BonusSubtypeID masteryLevel ) const ;
2016-01-27 12:47:42 +02:00
/// If this hero perishes, the scenario is failed
bool isMissionCritical ( ) const ;
2014-06-05 19:52:14 +03:00
2024-01-01 16:37:48 +02:00
CGHeroInstance ( IGameCallback * cb ) ;
2014-06-05 19:52:14 +03:00
virtual ~ CGHeroInstance ( ) ;
2016-01-24 01:27:14 +02:00
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
PlayerColor getOwner ( ) const override ;
2015-03-18 21:22:52 +02:00
///ArtBearer
2014-06-05 19:52:14 +03:00
ArtBearer : : ArtBearer bearerType ( ) const override ;
2015-03-18 21:22:52 +02:00
///IBonusBearer
2022-11-06 01:26:13 +02:00
CBonusSystemNode & whereShouldBeAttached ( CGameState * gs ) override ;
2014-06-05 19:52:14 +03:00
std : : string nodeName ( ) const override ;
2023-02-19 23:09:06 +02:00
si32 manaLimit ( ) const override ;
2016-01-24 01:27:14 +02:00
2023-04-09 03:03:47 +02:00
///IConstBonusProvider
2023-04-05 17:56:28 +02:00
const IBonusBearer * getBonusBearer ( ) const override ;
2021-03-23 16:47:07 +02:00
CBonusSystemNode * whereShouldBeAttachedOnSiege ( const bool isBattleOutsideTown ) const ;
CBonusSystemNode * whereShouldBeAttachedOnSiege ( CGameState * gs ) ;
2017-07-20 06:08:49 +02:00
///spells::Caster
2018-03-04 10:13:07 +02:00
int32_t getCasterUnitId ( ) const override ;
2023-11-05 18:58:07 +02:00
int32_t getSpellSchoolLevel ( const spells : : Spell * spell , SpellSchool * outSelectedSchool = nullptr ) const override ;
2017-07-20 06:08:49 +02:00
int64_t getSpellBonus ( const spells : : Spell * spell , int64_t base , const battle : : Unit * affectedStack ) const override ;
int64_t getSpecificSpellBonus ( const spells : : Spell * spell , int64_t base ) const override ;
2016-01-24 01:27:14 +02:00
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
int32_t getEffectLevel ( const spells : : Spell * spell ) const override ;
int32_t getEffectPower ( const spells : : Spell * spell ) const override ;
int32_t getEnchantPower ( const spells : : Spell * spell ) const override ;
2017-07-20 06:08:49 +02:00
int64_t getEffectValue ( const spells : : Spell * spell ) const override ;
2016-01-24 01:27:14 +02:00
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
PlayerColor getCasterOwner ( ) const override ;
2023-04-09 23:31:41 +02:00
const CGHeroInstance * getHeroCaster ( ) const override ;
2016-01-24 01:27:14 +02:00
2016-09-10 17:23:55 +02:00
void getCasterName ( MetaString & text ) const override ;
2017-07-20 06:08:49 +02:00
void getCastDescription ( const spells : : Spell * spell , const std : : vector < const battle : : Unit * > & attacked , MetaString & text ) const override ;
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
void spendMana ( ServerCallback * server , const int spellCost ) const override ;
2016-09-10 17:23:55 +02:00
2023-08-01 18:51:33 +02:00
void attachToBoat ( CGBoat * newBoat ) ;
2023-06-19 21:01:18 +02:00
void boatDeserializationFix ( ) ;
2014-06-05 19:52:14 +03:00
void deserializationFix ( ) ;
2024-06-01 17:28:17 +02:00
void pickRandomObject ( vstd : : RNG & rand ) override ;
2014-06-05 19:52:14 +03:00
void onHeroVisit ( const CGHeroInstance * h ) const override ;
2014-06-24 20:39:36 +03:00
std : : string getObjectName ( ) const override ;
2024-09-17 21:38:28 +02:00
std : : string getHoverText ( PlayerColor player ) const override ;
std : : string getMovementPointsTextIfOwner ( PlayerColor player ) const ;
2017-05-28 15:23:42 +02:00
void afterAddToMap ( CMap * map ) override ;
2022-09-17 13:04:01 +02:00
void afterRemoveFromMap ( CMap * map ) override ;
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
void updateFrom ( const JsonNode & data ) override ;
2022-07-09 18:00:03 +02:00
2023-06-21 15:49:44 +02:00
bool isCoastVisitable ( ) const override ;
2023-12-09 15:59:09 +02:00
bool isBlockedVisitable ( ) const override ;
2022-07-09 18:00:03 +02:00
BattleField getBattlefield ( ) const override ;
2024-01-30 23:33:58 +02:00
bool isCampaignYog ( ) const ;
bool isCampaignGem ( ) const ;
2014-06-05 19:52:14 +03:00
protected :
2023-11-06 18:27:16 +02:00
void setPropertyDer ( ObjProperty what , ObjPropertyID identifier ) override ; //synchr
2016-11-13 12:38:42 +02:00
///common part of hero instance and hero definition
void serializeCommonOptions ( JsonSerializeFormat & handler ) ;
2016-02-22 01:37:19 +02:00
void serializeJsonOptions ( JsonSerializeFormat & handler ) override ;
2014-06-05 19:52:14 +03:00
private :
2024-06-01 17:28:17 +02:00
void levelUpAutomatically ( vstd : : RNG & rand ) ;
2014-06-05 19:52:14 +03:00
public :
2016-11-13 12:38:42 +02:00
std : : string getHeroTypeName ( ) const ;
void setHeroTypeName ( const std : : string & identifier ) ;
void serializeJsonDefinition ( JsonSerializeFormat & handler ) ;
2024-01-20 20:34:51 +02:00
template < typename Handler > void serialize ( Handler & h )
2014-06-05 19:52:14 +03:00
{
h & static_cast < CArmedInstance & > ( * this ) ;
h & static_cast < CArtifactSet & > ( * this ) ;
2017-07-31 15:35:42 +02:00
h & exp ;
h & level ;
2023-09-28 00:00:32 +02:00
h & nameCustomTextId ;
h & biographyCustomTextId ;
2023-09-28 18:43:04 +02:00
h & customPortraitSource ;
2017-07-31 15:35:42 +02:00
h & mana ;
h & secSkills ;
h & movement ;
2023-04-02 18:56:10 +02:00
h & gender ;
2017-07-31 15:35:42 +02:00
h & inTownGarrison ;
h & spells ;
h & patrol ;
h & moveDir ;
h & skillsInfo ;
h & visitedTown ;
h & boat ;
2024-10-05 21:37:52 +02:00
if ( h . version < Handler : : Version : : REMOVE_TOWN_PTR )
{
CHero * type = nullptr ;
h & type ;
}
2017-07-31 15:35:42 +02:00
h & commander ;
h & visitedObjects ;
2014-06-05 19:52:14 +03:00
BONUS_TREE_DESERIALIZATION_FIX
}
} ;
2022-07-26 15:07:42 +02:00
VCMI_LIB_NAMESPACE_END