2009-04-15 17:03:31 +03:00
/*
* CHeroHandler . 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
*
*/
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/HeroClass.h>
# include <vcmi/HeroClassService.h>
# include <vcmi/HeroType.h>
# include <vcmi/HeroTypeService.h>
2017-07-13 10:26:03 +02:00
# include "../lib/ConstTransitivePtr.h"
# include "GameConstants.h"
2023-05-01 19:29:53 +02:00
# include "bonuses/Bonus.h"
2023-04-30 19:34:25 +02:00
# include "bonuses/BonusList.h"
2017-07-13 10:26:03 +02:00
# include "IHandlerBase.h"
2012-12-16 16:47:53 +03:00
2022-07-26 15:07:42 +02:00
VCMI_LIB_NAMESPACE_BEGIN
2009-02-09 16:50:32 +02:00
class CHeroClass ;
class CGHeroInstance ;
2012-04-23 22:56:37 +03:00
struct BattleHex ;
2012-12-14 18:32:53 +03:00
class JsonNode ;
2014-04-10 20:11:09 +03:00
class CRandomGenerator ;
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
class JsonSerializeFormat ;
2022-06-22 10:41:02 +02:00
class BattleField ;
2010-08-17 17:58:13 +03:00
2023-04-02 18:56:10 +02:00
enum class EHeroGender : uint8_t
{
MALE = 0 ,
FEMALE = 1 ,
DEFAULT = 0xff // from h3m, instance has same gender as hero type
} ;
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
class DLL_LINKAGE CHero : public HeroType
2009-02-09 16:50:32 +02:00
{
2023-01-02 13:27:03 +02:00
friend class CHeroHandler ;
HeroTypeID ID ;
std : : string identifier ;
std : : string modScope ;
2009-02-09 16:50:32 +02:00
public :
2012-12-03 19:00:17 +03:00
struct InitialArmyStack
{
ui32 minAmount ;
ui32 maxAmount ;
2013-02-11 02:24:57 +03:00
CreatureID creature ;
2012-12-03 19:00:17 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2017-07-31 15:35:42 +02:00
h & minAmount ;
h & maxAmount ;
h & creature ;
2012-12-03 19:00:17 +03:00
}
} ;
2023-03-13 23:26:44 +02:00
si32 imageIndex = 0 ;
2012-12-03 19:00:17 +03:00
2012-12-16 16:47:53 +03:00
std : : vector < InitialArmyStack > initialArmy ;
2012-12-03 19:00:17 +03:00
2023-03-13 23:26:44 +02:00
CHeroClass * heroClass { } ;
2013-02-12 22:49:40 +03:00
std : : vector < std : : pair < SecondarySkill , ui8 > > secSkillsInit ; //initial secondary skills; first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert)
2017-09-10 04:10:50 +02:00
BonusList specialty ;
2013-02-11 02:24:57 +03:00
std : : set < SpellID > spells ;
2023-03-13 23:26:44 +02:00
bool haveSpellBook = false ;
bool special = false ; // hero is special and won't be placed in game (unless preset on map), e.g. campaign heroes
2023-07-09 11:16:36 +02:00
bool onlyOnWaterMap ; // hero will be placed only if the map contains water
bool onlyOnMapWithoutWater ; // hero will be placed only if the map does not contain water
2023-04-02 18:56:10 +02:00
EHeroGender gender = EHeroGender : : MALE ; // default sex: 0=male, 1=female
2009-02-09 16:50:32 +02:00
2012-12-16 16:47:53 +03:00
/// Graphics
std : : string iconSpecSmall ;
std : : string iconSpecLarge ;
std : : string portraitSmall ;
std : : string portraitLarge ;
2018-08-27 08:42:36 +02:00
std : : string battleImage ;
2009-07-03 21:40:36 +03: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
CHero ( ) ;
virtual ~ CHero ( ) ;
int32_t getIndex ( ) const override ;
int32_t getIconIndex ( ) const override ;
2023-01-18 23:56:01 +02:00
std : : string getJsonKey ( ) 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
HeroTypeID getId ( ) const override ;
void registerIcons ( const IconRegistar & cb ) const override ;
2023-01-02 13:27:03 +02:00
std : : string getNameTranslated ( ) const override ;
std : : string getBiographyTranslated ( ) const override ;
std : : string getSpecialtyNameTranslated ( ) const override ;
std : : string getSpecialtyDescriptionTranslated ( ) const override ;
std : : string getSpecialtyTooltipTranslated ( ) const override ;
std : : string getNameTextID ( ) const override ;
std : : string getBiographyTextID ( ) const override ;
std : : string getSpecialtyNameTextID ( ) const override ;
std : : string getSpecialtyDescriptionTextID ( ) const override ;
std : : string getSpecialtyTooltipTextID ( ) 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 updateFrom ( const JsonNode & data ) ;
void serializeJson ( JsonSerializeFormat & handler ) ;
2009-02-09 16:50:32 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2017-07-31 15:35:42 +02:00
h & ID ;
h & imageIndex ;
h & initialArmy ;
h & heroClass ;
h & secSkillsInit ;
2022-06-20 16:39:50 +02:00
h & specialty ;
2017-07-31 15:35:42 +02:00
h & spells ;
h & haveSpellBook ;
2023-04-02 18:56:10 +02:00
h & gender ;
2017-07-31 15:35:42 +02:00
h & special ;
2023-07-09 11:16:36 +02:00
h & onlyOnWaterMap ;
h & onlyOnMapWithoutWater ;
2017-07-31 15:35:42 +02:00
h & iconSpecSmall ;
h & iconSpecLarge ;
h & portraitSmall ;
h & portraitLarge ;
2022-06-20 16:39:50 +02:00
h & identifier ;
2023-01-18 23:56:01 +02:00
h & modScope ;
2022-06-20 16:39:50 +02:00
h & battleImage ;
2009-02-09 16:50:32 +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
class DLL_LINKAGE CHeroClass : public HeroClass
2009-02-09 16:50:32 +02:00
{
2023-01-02 13:27:03 +02:00
friend class CHeroClassHandler ;
HeroClassID id ; // use getId instead
std : : string modScope ;
std : : string identifier ; // use getJsonKey instead
2009-02-09 16:50:32 +02:00
public :
2013-12-13 21:27:54 +03:00
enum EClassAffinity
{
MIGHT ,
MAGIC
} ;
2013-03-12 17:56:23 +03:00
//double aggression; // not used in vcmi.
2023-04-09 17:26:32 +02:00
FactionID faction ;
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
ui8 affinity ; // affinity, using EClassAffinity enum
2012-12-14 18:32:53 +03:00
2013-11-03 15:07:23 +03:00
// default chance for hero of specific class to appear in tavern, if field "tavern" was not set
// resulting chance = sqrt(town.chance * heroClass.chance)
ui32 defaultTavernChance ;
2013-12-13 21:27:54 +03:00
CCreature * commander ;
2012-12-14 18:32:53 +03:00
std : : vector < int > primarySkillInitial ; // initial primary skills
std : : vector < int > primarySkillLowLevel ; // probability (%) of getting point of primary skill when getting level
std : : vector < int > primarySkillHighLevel ; // same for high levels (> 10)
std : : vector < int > secSkillProbability ; //probabilities of gaining secondary skills (out of 112), in id order
2023-04-09 17:26:32 +02:00
std : : map < FactionID , int > selectionProbability ; //probability of selection in towns
2009-02-09 16:50:32 +02:00
2012-12-16 16:47:53 +03:00
std : : string imageBattleMale ;
std : : string imageBattleFemale ;
std : : string imageMapMale ;
std : : string imageMapFemale ;
2014-01-06 20:45:21 +03:00
CHeroClass ( ) ;
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 getIndex ( ) const override ;
int32_t getIconIndex ( ) const override ;
2023-01-18 23:56:01 +02:00
std : : string getJsonKey ( ) 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
HeroClassID getId ( ) const override ;
void registerIcons ( const IconRegistar & cb ) const override ;
2023-01-02 13:27:03 +02:00
std : : string getNameTranslated ( ) const override ;
std : : string getNameTextID ( ) const override ;
2013-09-09 18:23:59 +03:00
bool isMagicHero ( ) const ;
2014-04-10 20:11:09 +03:00
SecondarySkill chooseSecSkill ( const std : : set < SecondarySkill > & possibles , CRandomGenerator & rand ) const ; //picks secondary skill out from given possibilities
2009-02-09 16:50:32 +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
void updateFrom ( const JsonNode & data ) ;
void serializeJson ( JsonSerializeFormat & handler ) ;
template < typename Handler > void serialize ( Handler & h , const int version )
2009-02-09 16:50:32 +02:00
{
2023-01-02 13:27:03 +02:00
h & modScope ;
2017-07-31 15:35:42 +02:00
h & identifier ;
h & faction ;
2022-06-20 16:39:50 +02:00
h & id ;
2017-07-31 15:35:42 +02:00
h & defaultTavernChance ;
h & primarySkillInitial ;
h & primarySkillLowLevel ;
h & primarySkillHighLevel ;
h & secSkillProbability ;
h & selectionProbability ;
h & affinity ;
h & commander ;
h & imageBattleMale ;
h & imageBattleFemale ;
h & imageMapMale ;
h & imageMapFemale ;
2020-10-19 21:39:57 +02:00
if ( ! h . saving )
{
2023-04-17 23:11:16 +02:00
for ( int & i : secSkillProbability )
vstd : : amax ( i , 0 ) ;
}
2009-02-09 16:50:32 +02:00
}
2023-04-04 12:36:42 +02:00
EAlignment getAlignment ( ) const ;
2009-02-09 16:50:32 +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
class DLL_LINKAGE CHeroClassHandler : public CHandlerBase < HeroClassID , HeroClass , CHeroClass , HeroClassService >
2012-12-14 18:32:53 +03:00
{
2023-03-13 23:26:44 +02:00
void fillPrimarySkillData ( const JsonNode & node , CHeroClass * heroClass , PrimarySkill : : PrimarySkill pSkill ) const ;
2012-12-14 18:32:53 +03:00
public :
2023-03-15 21:34:29 +02:00
std : : vector < JsonNode > loadLegacyData ( ) override ;
2012-12-14 18:32:53 +03:00
2015-10-12 15:47:10 +02:00
void afterLoadFinalization ( ) override ;
2013-11-03 15:07:23 +03:00
2015-10-12 15:47:10 +02:00
std : : vector < bool > getDefaultAllowed ( ) const override ;
2012-12-14 18:32:53 +03:00
~ CHeroClassHandler ( ) ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
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
h & objects ;
2012-12-14 18:32:53 +03: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
protected :
const std : : vector < std : : string > & getTypeNames ( ) const override ;
CHeroClass * loadFromJson ( const std : : string & scope , const JsonNode & node , const std : : string & identifier , size_t index ) override ;
2012-12-14 18:32:53 +03: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
class DLL_LINKAGE CHeroHandler : public CHandlerBase < HeroTypeID , HeroType , CHero , HeroTypeService >
2009-02-09 16:50:32 +02:00
{
2012-12-15 16:40:22 +03:00
/// expPerLEvel[i] is amount of exp needed to reach level i;
/// consists of 201 values. Any higher levels require experience larger that ui64 can hold
std : : vector < ui64 > expPerLevel ;
2012-12-14 18:32:53 +03:00
2013-03-03 21:00:37 +03:00
/// helpers for loading to avoid huge load functions
2023-03-13 23:26:44 +02:00
void loadHeroArmy ( CHero * hero , const JsonNode & node ) const ;
void loadHeroSkills ( CHero * hero , const JsonNode & node ) const ;
2023-03-28 16:09:54 +02:00
void loadHeroSpecialty ( CHero * hero , const JsonNode & node ) ;
2013-04-21 15:49:26 +03:00
void loadExperience ( ) ;
2023-03-28 16:09:54 +02:00
std : : vector < std : : function < void ( ) > > callAfterLoadFinalization ;
2009-02-09 16:50:32 +02:00
public :
2012-12-14 18:32:53 +03:00
CHeroClassHandler classes ;
2011-12-14 00:23:17 +03:00
ui32 level ( ui64 experience ) const ; //calculates level corresponding to given experience amount
ui64 reqExp ( ui32 level ) const ; //calculates experience required for given level
2009-02-09 16:50:32 +02:00
2023-03-15 21:34:29 +02:00
std : : vector < JsonNode > loadLegacyData ( ) override ;
2012-12-15 11:47:02 +03:00
2019-01-19 12:52:02 +02:00
void beforeValidate ( JsonNode & object ) override ;
2013-04-21 15:49:26 +03:00
void loadObject ( std : : string scope , std : : string name , const JsonNode & data ) override ;
void loadObject ( std : : string scope , std : : string name , const JsonNode & data , size_t index ) override ;
2017-09-12 14:59:50 +02:00
void afterLoadFinalization ( ) override ;
2012-12-15 11:47:02 +03:00
2017-07-17 23:04:00 +02:00
CHeroHandler ( ) ;
~ CHeroHandler ( ) ;
2009-02-09 16:50:32 +02:00
2015-10-12 15:47:10 +02:00
std : : vector < bool > getDefaultAllowed ( ) const override ;
2012-11-20 20:53:45 +03:00
2009-02-09 16:50:32 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2017-07-31 15:35:42 +02:00
h & classes ;
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
h & objects ;
2017-07-31 15:35:42 +02:00
h & expPerLevel ;
2009-02-09 16:50:32 +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
protected :
const std : : vector < std : : string > & getTypeNames ( ) const override ;
CHero * loadFromJson ( const std : : string & scope , const JsonNode & node , const std : : string & identifier , size_t index ) override ;
2009-02-09 16:50:32 +02:00
} ;
2022-07-26 15:07:42 +02:00
VCMI_LIB_NAMESPACE_END