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"
# include "HeroBonus.h"
# include "IHandlerBase.h"
2022-08-09 07:54:32 +02:00
# include "Terrain.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
struct SSpecialtyInfo
2010-07-06 10:32:40 +03:00
{ si32 type ;
si32 val ;
si32 subtype ;
si32 additionalinfo ;
2010-12-25 21:23:30 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2017-07-31 15:35:42 +02:00
h & type ;
h & val ;
h & subtype ;
h & additionalinfo ;
2010-12-25 21:23:30 +02:00
}
2010-07-06 10:32:40 +03:00
} ;
2010-08-17 17:58:13 +03:00
2013-01-19 20:38:37 +03:00
struct SSpecialtyBonus
/// temporary hold
{
ui8 growsWithLevel ;
BonusList bonuses ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
2017-07-31 15:35:42 +02:00
h & growsWithLevel ;
h & bonuses ;
2013-01-19 20:38:37 +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 CHero : public HeroType
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
}
} ;
2015-08-24 10:55:45 +02:00
std : : string identifier ;
2013-05-19 01:30:48 +03:00
HeroTypeID ID ;
2012-12-16 16:47:53 +03:00
si32 imageIndex ;
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
2009-02-09 16:50:32 +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
std : : vector < SSpecialtyInfo > specDeprecated ;
std : : vector < SSpecialtyBonus > specialtyDeprecated ;
BonusList specialty ;
2013-02-11 02:24:57 +03:00
std : : set < SpellID > spells ;
2013-03-02 19:55:51 +03:00
bool haveSpellBook ;
bool special ; // hero is special and won't be placed in game (unless preset on map), e.g. campaign heroes
2010-08-25 17:57:58 +03:00
ui8 sex ; // default sex: 0=male, 1=female
2009-02-09 16:50:32 +02:00
2012-12-16 16:47:53 +03:00
/// Localized texts
std : : string name ; //name of hero
std : : string biography ;
std : : string specName ;
std : : string specDescr ;
std : : string specTooltip ;
/// 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 ;
const std : : string & getName ( ) const override ;
const std : : string & getJsonKey ( ) const override ;
HeroTypeID getId ( ) const override ;
void registerIcons ( const IconRegistar & cb ) const override ;
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 ;
h & sex ;
h & special ;
h & name ;
h & biography ;
h & specName ;
h & specDescr ;
h & specTooltip ;
h & iconSpecSmall ;
h & iconSpecLarge ;
h & portraitSmall ;
h & portraitLarge ;
2022-06-20 16:39:50 +02:00
h & identifier ;
h & battleImage ;
2009-02-09 16:50:32 +02:00
}
} ;
2017-09-10 04:10:50 +02:00
// convert deprecated format
2018-10-30 21:58:22 +02:00
std : : vector < std : : shared_ptr < Bonus > > SpecialtyInfoToBonuses ( const SSpecialtyInfo & spec , int sid = 0 ) ;
std : : vector < std : : shared_ptr < Bonus > > SpecialtyBonusToBonuses ( const SSpecialtyBonus & spec , int sid = 0 ) ;
2017-09-10 04:10:50 +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
{
public :
2013-12-13 21:27:54 +03:00
enum EClassAffinity
{
MIGHT ,
MAGIC
} ;
2012-12-14 18:32:53 +03:00
std : : string identifier ;
std : : string name ; // translatable
2013-03-12 17:56:23 +03:00
//double aggression; // not used in vcmi.
2012-12-14 18:32:53 +03:00
TFaction 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
HeroClassID id ;
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
2012-10-06 11:47:13 +03:00
std : : map < TFaction , 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 ;
const std : : string & getName ( ) const override ;
const std : : string & getJsonKey ( ) const override ;
HeroClassID getId ( ) const override ;
void registerIcons ( const IconRegistar & cb ) 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
{
2017-07-31 15:35:42 +02:00
h & identifier ;
h & name ;
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 )
{
for ( auto i = 0 ; i < secSkillProbability . size ( ) ; i + + )
if ( secSkillProbability [ i ] < 0 )
secSkillProbability [ i ] = 0 ;
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
}
2009-02-09 16:50:32 +02:00
}
2012-09-23 21:01:04 +03:00
EAlignment : : 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
{
2021-02-12 23:24:14 +02:00
void fillPrimarySkillData ( const JsonNode & node , CHeroClass * heroClass , PrimarySkill : : PrimarySkill pSkill ) ;
2012-12-14 18:32:53 +03:00
public :
2013-04-21 15:49:26 +03:00
std : : vector < JsonNode > loadLegacyData ( size_t dataSize ) 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
void loadHeroArmy ( CHero * hero , const JsonNode & node ) ;
void loadHeroSkills ( CHero * hero , const JsonNode & node ) ;
void loadHeroSpecialty ( CHero * hero , const JsonNode & node ) ;
2013-04-21 15:49:26 +03:00
void loadExperience ( ) ;
void loadBallistics ( ) ;
void loadTerrains ( ) ;
2009-02-09 16:50:32 +02:00
public :
2012-12-14 18:32:53 +03:00
CHeroClassHandler classes ;
2012-12-15 11:47:02 +03:00
//default costs of going through terrains. -1 means terrain is impassable
2022-06-20 16:39:50 +02:00
std : : map < Terrain , int > terrCosts ;
2013-02-05 00:58:42 +03:00
2009-02-09 16:50:32 +02:00
struct SBallisticsLevelInfo
{
ui8 keep , tower , gate , wall ; //chance to hit in percent (eg. 87 is 87%)
ui8 shots ; //how many shots we have
ui8 noDmg , oneDmg , twoDmg ; //chances for shot dealing certain dmg in percent (eg. 87 is 87%); must sum to 100
ui8 sum ; //I don't know if it is useful for anything, but it's in config file
template < typename Handler > void serialize ( Handler & h , const int version )
{
2017-07-31 15:35:42 +02:00
h & keep ;
h & tower ;
h & gate ;
h & wall ;
h & shots ;
h & noDmg ;
h & oneDmg ;
h & twoDmg ;
h & sum ;
2009-02-09 16:50:32 +02:00
}
} ;
std : : vector < SBallisticsLevelInfo > ballistics ; //info about ballistics ability per level; [0] - none; [1] - basic; [2] - adv; [3] - expert
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
2013-04-21 15:49:26 +03:00
std : : vector < JsonNode > loadLegacyData ( size_t dataSize ) 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 ;
h & ballistics ;
h & terrCosts ;
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