2017-07-13 10:26:03 +02:00
/*
* CHeroHandler . cpp , 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
*
*/
2011-12-14 00:23:17 +03:00
# include "StdInc.h"
2007-06-08 17:58:04 +03:00
# include "CHeroHandler.h"
2011-12-14 00:23:17 +03:00
2012-08-25 11:44:51 +03:00
# include "CGeneralTextHandler.h"
2013-07-28 17:49:50 +03:00
# include "filesystem/Filesystem.h"
2012-08-25 11:44:51 +03:00
# include "VCMI_Lib.h"
# include "JsonNode.h"
2023-08-19 23:22:31 +02:00
# include "constants/StringConstants.h"
2017-06-24 16:42:05 +02:00
# include "battle/BattleHex.h"
2013-12-13 21:27:54 +03:00
# include "CCreatureHandler.h"
2023-03-15 21:34:29 +02:00
# include "GameSettings.h"
2012-12-15 11:47:02 +03:00
# include "CTownHandler.h"
2018-03-31 07:56:40 +02:00
# include "CSkillHandler.h"
2022-06-28 10:05:30 +02:00
# include "BattleFieldHandler.h"
2023-04-30 15:52:48 +02:00
# include "bonuses/Limiters.h"
# include "bonuses/Updaters.h"
2023-06-02 20:47:37 +02:00
# include "mapObjectConstructors/AObjectTypeHandler.h"
# include "mapObjectConstructors/CObjectClassesHandler.h"
2023-07-30 19:12:25 +02:00
# include "modding/IdentifierStorage.h"
2014-06-05 19:52:14 +03:00
2022-07-26 15:07:42 +02:00
VCMI_LIB_NAMESPACE_BEGIN
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 : : CHero ( ) = default ;
CHero : : ~ CHero ( ) = default ;
int32_t CHero : : getIndex ( ) const
{
return ID . getNum ( ) ;
}
int32_t CHero : : getIconIndex ( ) const
{
return imageIndex ;
}
2023-01-18 23:56:01 +02:00
std : : string CHero : : getJsonKey ( ) 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
{
2023-01-18 23:56:01 +02:00
return modScope + ' : ' + identifier ; ;
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 CHero : : getId ( ) const
{
return ID ;
}
2023-01-02 13:27:03 +02:00
std : : string CHero : : getNameTranslated ( ) const
{
return VLC - > generaltexth - > translate ( getNameTextID ( ) ) ;
}
std : : string CHero : : getBiographyTranslated ( ) const
{
return VLC - > generaltexth - > translate ( getBiographyTextID ( ) ) ;
}
std : : string CHero : : getSpecialtyNameTranslated ( ) const
{
return VLC - > generaltexth - > translate ( getSpecialtyNameTextID ( ) ) ;
}
std : : string CHero : : getSpecialtyDescriptionTranslated ( ) const
{
return VLC - > generaltexth - > translate ( getSpecialtyDescriptionTextID ( ) ) ;
}
std : : string CHero : : getSpecialtyTooltipTranslated ( ) const
{
return VLC - > generaltexth - > translate ( getSpecialtyTooltipTextID ( ) ) ;
}
std : : string CHero : : getNameTextID ( ) const
{
return TextIdentifier ( " hero " , modScope , identifier , " name " ) . get ( ) ;
}
std : : string CHero : : getBiographyTextID ( ) const
{
return TextIdentifier ( " hero " , modScope , identifier , " biography " ) . get ( ) ;
}
std : : string CHero : : getSpecialtyNameTextID ( ) const
{
return TextIdentifier ( " hero " , modScope , identifier , " specialty " , " name " ) . get ( ) ;
}
std : : string CHero : : getSpecialtyDescriptionTextID ( ) const
{
return TextIdentifier ( " hero " , modScope , identifier , " specialty " , " description " ) . get ( ) ;
}
std : : string CHero : : getSpecialtyTooltipTextID ( ) const
{
return TextIdentifier ( " hero " , modScope , identifier , " specialty " , " tooltip " ) . get ( ) ;
}
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 CHero : : registerIcons ( const IconRegistar & cb ) const
{
2022-11-29 14:47:51 +02:00
cb ( getIconIndex ( ) , 0 , " UN32 " , iconSpecSmall ) ;
cb ( getIconIndex ( ) , 0 , " UN44 " , iconSpecLarge ) ;
cb ( getIconIndex ( ) , 0 , " PORTRAITSLARGE " , portraitLarge ) ;
cb ( getIconIndex ( ) , 0 , " PORTRAITSSMALL " , portraitSmall ) ;
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 CHero : : updateFrom ( const JsonNode & data )
{
//todo: CHero::updateFrom
}
void CHero : : serializeJson ( JsonSerializeFormat & handler )
{
}
2014-04-10 20:11:09 +03:00
SecondarySkill CHeroClass : : chooseSecSkill ( const std : : set < SecondarySkill > & possibles , CRandomGenerator & rand ) const //picks secondary skill out from given possibilities
2008-08-04 18:56:36 +03:00
{
int totalProb = 0 ;
2023-03-13 23:26:44 +02:00
for ( const auto & possible : possibles )
2008-08-04 18:56:36 +03:00
{
2013-06-29 16:05:48 +03:00
totalProb + = secSkillProbability [ possible ] ;
2008-08-04 18:56:36 +03:00
}
2013-09-05 02:00:51 +03:00
if ( totalProb ! = 0 ) // may trigger if set contains only banned skills (0 probability)
2008-08-04 18:56:36 +03:00
{
2014-04-10 20:11:09 +03:00
auto ran = rand . nextInt ( totalProb - 1 ) ;
2023-03-13 23:26:44 +02:00
for ( const auto & possible : possibles )
2013-09-05 02:00:51 +03:00
{
ran - = secSkillProbability [ possible ] ;
2014-04-10 20:11:09 +03:00
if ( ran < 0 )
{
2013-09-05 02:00:51 +03:00
return possible ;
2014-04-10 20:11:09 +03:00
}
2013-09-05 02:00:51 +03:00
}
2008-08-04 18:56:36 +03:00
}
2013-09-05 02:00:51 +03:00
// FIXME: select randomly? How H3 handles such rare situation?
return * possibles . begin ( ) ;
2008-08-04 18:56:36 +03:00
}
2013-09-09 18:23:59 +03:00
bool CHeroClass : : isMagicHero ( ) const
{
2013-12-13 21:27:54 +03:00
return affinity = = MAGIC ;
2013-09-09 18:23:59 +03:00
}
2023-04-04 12:36:42 +02:00
EAlignment CHeroClass : : getAlignment ( ) const
2010-07-20 09:05:45 +03:00
{
2023-04-04 12:36:42 +02:00
return VLC - > factions ( ) - > getByIndex ( faction ) - > getAlignment ( ) ;
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 CHeroClass : : getIndex ( ) const
{
return id . getNum ( ) ;
}
int32_t CHeroClass : : getIconIndex ( ) const
{
return getIndex ( ) ;
}
2023-01-18 23:56:01 +02:00
std : : string CHeroClass : : getJsonKey ( ) 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
{
2023-01-18 23:56:01 +02:00
return modScope + ' : ' + identifier ; ;
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 CHeroClass : : getId ( ) const
{
return id ;
}
void CHeroClass : : registerIcons ( const IconRegistar & cb ) const
{
}
2023-01-02 13:27:03 +02:00
std : : string CHeroClass : : getNameTranslated ( ) const
{
return VLC - > generaltexth - > translate ( getNameTextID ( ) ) ;
}
std : : string CHeroClass : : getNameTextID ( ) const
{
2023-01-19 01:45:01 +02:00
return TextIdentifier ( " heroClass " , modScope , identifier , " name " ) . get ( ) ;
2023-01-02 13:27:03 +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 CHeroClass : : updateFrom ( const JsonNode & data )
{
//TODO: CHeroClass::updateFrom
}
void CHeroClass : : serializeJson ( JsonSerializeFormat & handler )
{
2010-07-20 09:05:45 +03:00
}
2023-03-13 23:26:44 +02:00
CHeroClass : : CHeroClass ( ) :
faction ( 0 ) ,
affinity ( 0 ) ,
defaultTavernChance ( 0 ) ,
commander ( nullptr )
2014-01-06 20:45:21 +03:00
{
}
2023-08-19 20:43:50 +02:00
void CHeroClassHandler : : fillPrimarySkillData ( const JsonNode & node , CHeroClass * heroClass , PrimarySkill pSkill ) const
2021-02-12 23:24:14 +02:00
{
2023-08-19 20:43:50 +02:00
const auto & skillName = NPrimarySkill : : names [ static_cast < int > ( pSkill ) ] ;
2023-03-13 23:26:44 +02:00
auto currentPrimarySkillValue = static_cast < int > ( node [ " primarySkills " ] [ skillName ] . Integer ( ) ) ;
2021-02-12 23:24:14 +02:00
//minimal value is 0 for attack and defense and 1 for spell power and knowledge
auto primarySkillLegalMinimum = ( pSkill = = PrimarySkill : : ATTACK | | pSkill = = PrimarySkill : : DEFENSE ) ? 0 : 1 ;
if ( currentPrimarySkillValue < primarySkillLegalMinimum )
{
logMod - > error ( " Hero class '%s' has incorrect initial value '%d' for skill '%s'. Value '%d' will be used instead. " ,
2023-01-18 23:56:01 +02:00
heroClass - > getNameTranslated ( ) , currentPrimarySkillValue , skillName , primarySkillLegalMinimum ) ;
2021-02-12 23:24:14 +02:00
currentPrimarySkillValue = primarySkillLegalMinimum ;
}
heroClass - > primarySkillInitial . push_back ( currentPrimarySkillValue ) ;
2023-03-13 23:26:44 +02:00
heroClass - > primarySkillLowLevel . push_back ( static_cast < int > ( node [ " lowLevelChance " ] [ skillName ] . Float ( ) ) ) ;
heroClass - > primarySkillHighLevel . push_back ( static_cast < int > ( node [ " highLevelChance " ] [ skillName ] . Float ( ) ) ) ;
2021-02-12 23:24: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
const std : : vector < std : : string > & CHeroClassHandler : : getTypeNames ( ) const
{
static const std : : vector < std : : string > typeNames = { " heroClass " } ;
return typeNames ;
}
CHeroClass * CHeroClassHandler : : loadFromJson ( const std : : string & scope , const JsonNode & node , const std : : string & identifier , size_t index )
2009-01-11 00:08:18 +02:00
{
2023-01-18 23:56:01 +02:00
assert ( identifier . find ( ' : ' ) = = std : : string : : npos ) ;
assert ( ! scope . empty ( ) ) ;
2013-12-13 21:27:54 +03:00
std : : string affinityStr [ 2 ] = { " might " , " magic " } ;
2023-03-13 23:26:44 +02:00
auto * heroClass = new 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
heroClass - > id = HeroClassID ( index ) ;
2015-08-24 10:55:45 +02:00
heroClass - > identifier = identifier ;
2023-01-18 23:56:01 +02:00
heroClass - > modScope = scope ;
2013-04-21 15:49:26 +03:00
heroClass - > imageBattleFemale = node [ " animation " ] [ " battle " ] [ " female " ] . String ( ) ;
heroClass - > imageBattleMale = node [ " animation " ] [ " battle " ] [ " male " ] . String ( ) ;
2014-06-16 19:27:26 +03:00
//MODS COMPATIBILITY FOR 0.96
2013-04-21 15:49:26 +03:00
heroClass - > imageMapFemale = node [ " animation " ] [ " map " ] [ " female " ] . String ( ) ;
heroClass - > imageMapMale = node [ " animation " ] [ " map " ] [ " male " ] . String ( ) ;
2023-02-09 15:03:49 +02:00
VLC - > generaltexth - > registerString ( scope , heroClass - > getNameTextID ( ) , node [ " name " ] . String ( ) ) ;
2023-01-02 13:27:03 +02:00
2013-12-13 21:27:54 +03:00
heroClass - > affinity = vstd : : find_pos ( affinityStr , node [ " affinity " ] . String ( ) ) ;
2013-04-21 15:49:26 +03:00
2021-02-12 23:24:14 +02:00
fillPrimarySkillData ( node , heroClass , PrimarySkill : : ATTACK ) ;
fillPrimarySkillData ( node , heroClass , PrimarySkill : : DEFENSE ) ;
fillPrimarySkillData ( node , heroClass , PrimarySkill : : SPELL_POWER ) ;
fillPrimarySkillData ( node , heroClass , PrimarySkill : : KNOWLEDGE ) ;
2013-04-21 15:49:26 +03:00
2021-07-28 17:54:32 +02:00
auto percentSumm = std : : accumulate ( heroClass - > primarySkillLowLevel . begin ( ) , heroClass - > primarySkillLowLevel . end ( ) , 0 ) ;
if ( percentSumm ! = 100 )
logMod - > error ( " Hero class %s has wrong lowLevelChance values: summ should be 100, but %d instead " , heroClass - > identifier , percentSumm ) ;
percentSumm = std : : accumulate ( heroClass - > primarySkillHighLevel . begin ( ) , heroClass - > primarySkillHighLevel . end ( ) , 0 ) ;
if ( percentSumm ! = 100 )
logMod - > error ( " Hero class %s has wrong highLevelChance values: summ should be 100, but %d instead " , heroClass - > identifier , percentSumm ) ;
2018-03-31 07:56:40 +02:00
for ( auto skillPair : node [ " secondarySkills " ] . Struct ( ) )
2013-04-21 15:49:26 +03:00
{
2020-10-01 10:38:06 +02:00
int probability = static_cast < int > ( skillPair . second . Integer ( ) ) ;
2023-07-30 19:12:25 +02:00
VLC - > identifiers ( ) - > requestIdentifier ( skillPair . second . meta , " skill " , skillPair . first , [ heroClass , probability ] ( si32 skillID )
2018-03-31 07:56:40 +02:00
{
if ( heroClass - > secSkillProbability . size ( ) < = skillID )
heroClass - > secSkillProbability . resize ( skillID + 1 , - 1 ) ; // -1 = override with default later
heroClass - > secSkillProbability [ skillID ] = probability ;
} ) ;
2013-04-21 15:49:26 +03:00
}
2023-07-30 19:12:25 +02:00
VLC - > identifiers ( ) - > requestIdentifier ( " creature " , node [ " commander " ] ,
2014-06-23 20:10:08 +03:00
[ = ] ( si32 commanderID )
2013-12-13 21:27:54 +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
heroClass - > commander = VLC - > creh - > objects [ commanderID ] ;
2014-06-23 20:10:08 +03:00
} ) ;
2013-12-13 21:27:54 +03:00
2020-10-01 10:38:06 +02:00
heroClass - > defaultTavernChance = static_cast < ui32 > ( node [ " defaultTavern " ] . Float ( ) ) ;
2023-03-13 23:26:44 +02:00
for ( const auto & tavern : node [ " tavern " ] . Struct ( ) )
2013-04-21 15:49:26 +03:00
{
2020-10-01 10:38:06 +02:00
int value = static_cast < int > ( tavern . second . Float ( ) ) ;
2013-04-21 15:49:26 +03:00
2023-07-30 19:12:25 +02:00
VLC - > identifiers ( ) - > requestIdentifier ( tavern . second . meta , " faction " , tavern . first ,
2013-04-21 15:49:26 +03:00
[ = ] ( si32 factionID )
{
2023-04-09 17:26:32 +02:00
heroClass - > selectionProbability [ FactionID ( factionID ) ] = value ;
2013-04-21 15:49:26 +03:00
} ) ;
}
2023-07-30 19:12:25 +02:00
VLC - > identifiers ( ) - > requestIdentifier ( " faction " , node [ " faction " ] ,
2013-04-21 15:49:26 +03:00
[ = ] ( si32 factionID )
{
heroClass - > faction = factionID ;
} ) ;
2023-07-30 19:12:25 +02:00
VLC - > identifiers ( ) - > requestIdentifier ( scope , " object " , " hero " , [ = ] ( si32 index )
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
{
JsonNode classConf = node [ " mapObject " ] ;
classConf [ " heroClass " ] . String ( ) = identifier ;
classConf . setMeta ( scope ) ;
VLC - > objtypeh - > loadSubObject ( identifier , classConf , index , heroClass - > getIndex ( ) ) ;
} ) ;
2013-04-21 15:49:26 +03:00
return heroClass ;
}
2023-03-15 21:34:29 +02:00
std : : vector < JsonNode > CHeroClassHandler : : loadLegacyData ( )
2013-04-21 15:49:26 +03:00
{
2023-03-15 21:34:29 +02:00
size_t dataSize = VLC - > settings ( ) - > getInteger ( EGameSettings : : TEXTS_HERO_CLASS ) ;
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
objects . resize ( dataSize ) ;
2013-04-21 15:49:26 +03:00
std : : vector < JsonNode > h3Data ;
h3Data . reserve ( dataSize ) ;
2012-12-14 18:32:53 +03:00
CLegacyConfigParser parser ( " DATA/HCTRAITS.TXT " ) ;
parser . endLine ( ) ; // header
parser . endLine ( ) ;
2013-04-21 15:49:26 +03:00
for ( size_t i = 0 ; i < dataSize ; i + + )
2012-12-14 18:32:53 +03:00
{
2013-03-12 17:56:23 +03:00
JsonNode entry ;
entry [ " name " ] . String ( ) = parser . readString ( ) ;
parser . readNumber ( ) ; // unused aggression
2012-12-14 18:32:53 +03:00
2023-08-19 20:43:50 +02:00
for ( const auto & name : NPrimarySkill : : names )
2013-06-29 16:05:48 +03:00
entry [ " primarySkills " ] [ name ] . Float ( ) = parser . readNumber ( ) ;
2012-12-14 18:32:53 +03:00
2023-08-19 20:43:50 +02:00
for ( const auto & name : NPrimarySkill : : names )
2013-06-29 16:05:48 +03:00
entry [ " lowLevelChance " ] [ name ] . Float ( ) = parser . readNumber ( ) ;
2012-12-14 18:32:53 +03:00
2023-08-19 20:43:50 +02:00
for ( const auto & name : NPrimarySkill : : names )
2013-06-29 16:05:48 +03:00
entry [ " highLevelChance " ] [ name ] . Float ( ) = parser . readNumber ( ) ;
2009-01-11 00:08:18 +02:00
2023-03-13 23:26:44 +02:00
for ( const auto & name : NSecondarySkill : : names )
2013-06-29 16:05:48 +03:00
entry [ " secondarySkills " ] [ name ] . Float ( ) = parser . readNumber ( ) ;
2012-12-14 18:32:53 +03:00
2023-08-18 12:38:19 +02:00
for ( const auto & name : NFaction : : names )
2013-06-29 16:05:48 +03:00
entry [ " tavern " ] [ name ] . Float ( ) = parser . readNumber ( ) ;
2012-12-14 18:32:53 +03:00
2013-04-21 15:49:26 +03:00
parser . endLine ( ) ;
2013-03-12 17:56:23 +03:00
h3Data . push_back ( entry ) ;
2012-12-14 18:32:53 +03:00
}
2013-04-21 15:49:26 +03:00
return h3Data ;
2012-12-14 18:32:53 +03:00
}
2013-11-03 15:07:23 +03:00
void CHeroClassHandler : : afterLoadFinalization ( )
{
// for each pair <class, town> set selection probability if it was not set before in tavern entries
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
for ( CHeroClass * heroClass : objects )
2013-11-03 15:07:23 +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
for ( CFaction * faction : VLC - > townh - > objects )
2013-11-03 15:07:23 +03:00
{
if ( ! faction - > town )
continue ;
2023-04-09 17:26:32 +02:00
if ( heroClass - > selectionProbability . count ( faction - > getId ( ) ) )
2013-11-03 15:07:23 +03:00
continue ;
2023-03-13 23:26:44 +02:00
auto chance = static_cast < float > ( heroClass - > defaultTavernChance * faction - > town - > defaultTavernChance ) ;
2023-04-09 17:26:32 +02:00
heroClass - > selectionProbability [ faction - > getId ( ) ] = static_cast < int > ( sqrt ( chance ) + 0.5 ) ; //FIXME: replace with std::round once MVS supports it
2013-11-03 15:07:23 +03:00
}
2018-03-31 07:56:40 +02:00
// set default probabilities for gaining secondary skills where not loaded previously
heroClass - > secSkillProbability . resize ( VLC - > skillh - > size ( ) , - 1 ) ;
for ( int skillID = 0 ; skillID < VLC - > skillh - > size ( ) ; skillID + + )
{
if ( heroClass - > secSkillProbability [ skillID ] < 0 )
{
const CSkill * skill = ( * VLC - > skillh ) [ SecondarySkill ( skillID ) ] ;
2023-01-01 22:20:41 +02:00
logMod - > trace ( " %s: no probability for %s, using default " , heroClass - > identifier , skill - > getJsonKey ( ) ) ;
2018-03-31 07:56:40 +02:00
heroClass - > secSkillProbability [ skillID ] = skill - > gainChance [ heroClass - > affinity ] ;
}
}
2013-11-03 15:07:23 +03:00
}
2014-01-03 02:48:38 +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
for ( CHeroClass * hc : objects )
2014-01-03 02:48:38 +03:00
{
2014-06-04 11:25:13 +03:00
if ( ! hc - > imageMapMale . empty ( ) )
{
JsonNode templ ;
templ [ " animation " ] . String ( ) = hc - > imageMapMale ;
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
VLC - > objtypeh - > getHandlerFor ( Obj : : HERO , hc - > getIndex ( ) ) - > addTemplate ( templ ) ;
2014-06-04 11:25:13 +03:00
}
2014-01-03 02:48:38 +03:00
}
2013-11-03 15:07:23 +03:00
}
2013-04-21 15:49:26 +03:00
std : : vector < bool > CHeroClassHandler : : getDefaultAllowed ( ) 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
return std : : vector < bool > ( size ( ) , true ) ;
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
CHeroClassHandler : : ~ CHeroClassHandler ( ) = default ;
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
CHeroHandler : : ~ CHeroHandler ( ) = default ;
2009-01-11 00:08:18 +02:00
CHeroHandler : : CHeroHandler ( )
2012-12-26 12:46:09 +03:00
{
2013-04-21 15:49:26 +03:00
loadExperience ( ) ;
2012-12-15 11:47:02 +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
const std : : vector < std : : string > & CHeroHandler : : getTypeNames ( ) const
{
static const std : : vector < std : : string > typeNames = { " hero " } ;
return typeNames ;
}
CHero * CHeroHandler : : loadFromJson ( const std : : string & scope , const JsonNode & node , const std : : string & identifier , size_t index )
2012-12-15 11:47:02 +03:00
{
2023-01-18 23:56:01 +02:00
assert ( identifier . find ( ' : ' ) = = std : : string : : npos ) ;
assert ( ! scope . empty ( ) ) ;
2023-03-13 23:26:44 +02:00
auto * hero = new CHero ( ) ;
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
hero - > ID = HeroTypeID ( index ) ;
2015-08-24 10:55:45 +02:00
hero - > identifier = identifier ;
2023-01-18 23:56:01 +02:00
hero - > modScope = scope ;
2023-04-02 18:56:10 +02:00
hero - > gender = node [ " female " ] . Bool ( ) ? EHeroGender : : FEMALE : EHeroGender : : MALE ;
2013-03-03 21:00:37 +03:00
hero - > special = node [ " special " ] . Bool ( ) ;
2023-07-09 11:16:36 +02:00
//Default - both false
hero - > onlyOnWaterMap = node [ " onlyOnWaterMap " ] . Bool ( ) ;
hero - > onlyOnMapWithoutWater = node [ " onlyOnMapWithoutWater " ] . Bool ( ) ;
2013-03-03 21:00:37 +03:00
2023-02-09 15:03:49 +02:00
VLC - > generaltexth - > registerString ( scope , hero - > getNameTextID ( ) , node [ " texts " ] [ " name " ] . String ( ) ) ;
VLC - > generaltexth - > registerString ( scope , hero - > getBiographyTextID ( ) , node [ " texts " ] [ " biography " ] . String ( ) ) ;
VLC - > generaltexth - > registerString ( scope , hero - > getSpecialtyNameTextID ( ) , node [ " texts " ] [ " specialty " ] [ " name " ] . String ( ) ) ;
VLC - > generaltexth - > registerString ( scope , hero - > getSpecialtyTooltipTextID ( ) , node [ " texts " ] [ " specialty " ] [ " tooltip " ] . String ( ) ) ;
VLC - > generaltexth - > registerString ( scope , hero - > getSpecialtyDescriptionTextID ( ) , node [ " texts " ] [ " specialty " ] [ " description " ] . String ( ) ) ;
2012-12-16 16:47:53 +03:00
hero - > iconSpecSmall = node [ " images " ] [ " specialtySmall " ] . String ( ) ;
hero - > iconSpecLarge = node [ " images " ] [ " specialtyLarge " ] . String ( ) ;
hero - > portraitSmall = node [ " images " ] [ " small " ] . String ( ) ;
hero - > portraitLarge = node [ " images " ] [ " large " ] . String ( ) ;
2018-09-13 01:33:34 +02:00
hero - > battleImage = node [ " battleImage " ] . String ( ) ;
2012-12-16 16:47:53 +03:00
2013-03-03 21:00:37 +03:00
loadHeroArmy ( hero , node ) ;
loadHeroSkills ( hero , node ) ;
loadHeroSpecialty ( hero , node ) ;
2023-07-30 19:12:25 +02:00
VLC - > identifiers ( ) - > requestIdentifier ( " heroClass " , node [ " class " ] ,
2013-03-03 21:00:37 +03:00
[ = ] ( si32 classID )
{
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
hero - > heroClass = classes [ HeroClassID ( classID ) ] ;
2013-03-03 21:00:37 +03:00
} ) ;
return hero ;
}
2023-03-13 23:26:44 +02:00
void CHeroHandler : : loadHeroArmy ( CHero * hero , const JsonNode & node ) const
2013-03-03 21:00:37 +03:00
{
2012-12-16 16:47:53 +03:00
assert ( node [ " army " ] . Vector ( ) . size ( ) < = 3 ) ; // anything bigger is useless - army initialization uses up to 3 slots
2013-03-03 21:00:37 +03:00
2012-12-16 16:47:53 +03:00
hero - > initialArmy . resize ( node [ " army " ] . Vector ( ) . size ( ) ) ;
for ( size_t i = 0 ; i < hero - > initialArmy . size ( ) ; i + + )
{
const JsonNode & source = node [ " army " ] . Vector ( ) [ i ] ;
2020-10-01 10:38:06 +02:00
hero - > initialArmy [ i ] . minAmount = static_cast < ui32 > ( source [ " min " ] . Float ( ) ) ;
hero - > initialArmy [ i ] . maxAmount = static_cast < ui32 > ( source [ " max " ] . Float ( ) ) ;
2012-12-16 16:47:53 +03:00
assert ( hero - > initialArmy [ i ] . minAmount < = hero - > initialArmy [ i ] . maxAmount ) ;
2023-07-30 19:12:25 +02:00
VLC - > identifiers ( ) - > requestIdentifier ( " creature " , source [ " creature " ] , [ = ] ( si32 creature )
2012-12-16 16:47:53 +03:00
{
2013-02-11 02:24:57 +03:00
hero - > initialArmy [ i ] . creature = CreatureID ( creature ) ;
2012-12-16 16:47:53 +03:00
} ) ;
}
}
2023-03-13 23:26:44 +02:00
void CHeroHandler : : loadHeroSkills ( CHero * hero , const JsonNode & node ) const
2012-12-16 16:47:53 +03:00
{
2013-06-29 16:05:48 +03:00
for ( const JsonNode & set : node [ " skills " ] . Vector ( ) )
2012-12-16 16:47:53 +03:00
{
2020-10-01 10:38:06 +02:00
int skillLevel = static_cast < int > ( boost : : range : : find ( NSecondarySkill : : levels , set [ " level " ] . String ( ) ) - std : : begin ( NSecondarySkill : : levels ) ) ;
2013-04-23 12:16:20 +03:00
if ( skillLevel < SecSkillLevel : : LEVELS_SIZE )
{
size_t currentIndex = hero - > secSkillsInit . size ( ) ;
2023-03-13 23:26:44 +02:00
hero - > secSkillsInit . emplace_back ( SecondarySkill ( - 1 ) , skillLevel ) ;
2013-04-23 12:16:20 +03:00
2023-07-30 19:12:25 +02:00
VLC - > identifiers ( ) - > requestIdentifier ( " skill " , set [ " skill " ] , [ = ] ( si32 id )
2013-04-23 12:16:20 +03:00
{
hero - > secSkillsInit [ currentIndex ] . first = SecondarySkill ( id ) ;
} ) ;
}
else
{
2017-08-30 23:23:19 +02:00
logMod - > error ( " Unknown skill level: %s " , set [ " level " ] . String ( ) ) ;
2013-04-23 12:16:20 +03:00
}
2012-12-16 16:47:53 +03:00
}
2013-03-02 19:55:51 +03:00
// spellbook is considered present if hero have "spellbook" entry even when this is an empty set (0 spells)
2013-03-03 21:00:37 +03:00
hero - > haveSpellBook = ! node [ " spellbook " ] . isNull ( ) ;
2013-03-02 19:55:51 +03:00
2013-06-29 16:05:48 +03:00
for ( const JsonNode & spell : node [ " spellbook " ] . Vector ( ) )
2012-12-16 16:47:53 +03:00
{
2023-07-30 19:12:25 +02:00
VLC - > identifiers ( ) - > requestIdentifier ( " spell " , spell ,
2013-08-19 14:50:53 +03:00
[ = ] ( si32 spellID )
2013-03-02 19:55:51 +03:00
{
2013-08-19 14:50:53 +03:00
hero - > spells . insert ( SpellID ( spellID ) ) ;
} ) ;
2012-12-16 16:47:53 +03:00
}
2013-03-03 21:00:37 +03:00
}
2012-12-16 16:47:53 +03:00
2023-03-28 16:09:54 +02:00
/// creates standard H3 hero specialty for creatures
static std : : vector < std : : shared_ptr < Bonus > > createCreatureSpecialty ( CreatureID baseCreatureID )
2018-02-06 02:44:43 +02:00
{
2023-03-28 16:09:54 +02:00
std : : vector < std : : shared_ptr < Bonus > > result ;
std : : set < CreatureID > targets ;
targets . insert ( baseCreatureID ) ;
2018-02-06 02:44:43 +02:00
2023-03-28 16:09:54 +02:00
// go through entire upgrade chain and collect all creatures to which baseCreatureID can be upgraded
for ( ; ; )
2018-02-06 02:44:43 +02:00
{
2023-03-28 16:09:54 +02:00
std : : set < CreatureID > oldTargets = targets ;
2018-02-06 02:44:43 +02:00
2023-03-28 16:09:54 +02:00
for ( auto const & upgradeSourceID : oldTargets )
{
const CCreature * upgradeSource = VLC - > creh - > objects [ upgradeSourceID ] ;
targets . insert ( upgradeSource - > upgrades . begin ( ) , upgradeSource - > upgrades . end ( ) ) ;
}
2018-02-06 02:44:43 +02:00
2023-03-28 16:09:54 +02:00
if ( oldTargets . size ( ) = = targets . size ( ) )
break ;
2018-02-06 02:44:43 +02:00
}
2023-03-28 16:09:54 +02:00
for ( CreatureID cid : targets )
2017-09-10 04:10:50 +02:00
{
2023-03-28 16:09:54 +02:00
const CCreature & specCreature = * VLC - > creh - > objects [ cid ] ;
2023-04-05 02:26:29 +02:00
int stepSize = specCreature . getLevel ( ) ? specCreature . getLevel ( ) : 5 ;
2023-03-28 16:09:54 +02:00
2023-03-05 02:16:05 +02:00
{
2023-03-28 16:09:54 +02:00
std : : shared_ptr < Bonus > bonus = std : : make_shared < Bonus > ( ) ;
bonus - > limiter . reset ( new CCreatureTypeLimiter ( specCreature , false ) ) ;
2023-05-01 00:20:01 +02:00
bonus - > type = BonusType : : STACKS_SPEED ;
2023-03-28 16:09:54 +02:00
bonus - > val = 1 ;
2023-03-05 02:16:05 +02:00
result . push_back ( bonus ) ;
}
2023-03-28 16:09:54 +02:00
2017-09-15 13:32:32 +02:00
{
2023-03-28 16:09:54 +02:00
std : : shared_ptr < Bonus > bonus = std : : make_shared < Bonus > ( ) ;
2023-05-01 00:20:01 +02:00
bonus - > type = BonusType : : PRIMARY_SKILL ;
2023-08-19 20:43:50 +02:00
bonus - > subtype = static_cast < int > ( PrimarySkill : : ATTACK ) ;
2023-03-28 16:09:54 +02:00
bonus - > val = 0 ;
bonus - > limiter . reset ( new CCreatureTypeLimiter ( specCreature , false ) ) ;
bonus - > updater . reset ( new GrowsWithLevelUpdater ( specCreature . getAttack ( false ) , stepSize ) ) ;
2023-03-05 20:50:58 +02:00
result . push_back ( bonus ) ;
}
2023-03-28 16:09:54 +02:00
2017-09-15 13:32:32 +02:00
{
2023-03-28 16:09:54 +02:00
std : : shared_ptr < Bonus > bonus = std : : make_shared < Bonus > ( ) ;
2023-05-01 00:20:01 +02:00
bonus - > type = BonusType : : PRIMARY_SKILL ;
2023-08-19 20:43:50 +02:00
bonus - > subtype = static_cast < int > ( PrimarySkill : : DEFENSE ) ;
2023-03-28 16:09:54 +02:00
bonus - > val = 0 ;
bonus - > limiter . reset ( new CCreatureTypeLimiter ( specCreature , false ) ) ;
bonus - > updater . reset ( new GrowsWithLevelUpdater ( specCreature . getDefense ( false ) , stepSize ) ) ;
result . push_back ( bonus ) ;
2017-09-15 13:32:32 +02:00
}
2017-09-10 04:10:50 +02:00
}
return result ;
}
2017-09-14 00:45:54 +02:00
void CHeroHandler : : beforeValidate ( JsonNode & object )
{
//handle "base" specialty info
2017-09-14 09:03:25 +02:00
JsonNode & specialtyNode = object [ " specialty " ] ;
2017-09-14 03:03:44 +02:00
if ( specialtyNode . getType ( ) = = JsonNode : : JsonType : : DATA_STRUCT )
2017-09-14 00:45:54 +02:00
{
const JsonNode & base = specialtyNode [ " base " ] ;
if ( ! base . isNull ( ) )
{
2018-02-06 02:44:43 +02:00
if ( specialtyNode [ " bonuses " ] . isNull ( ) )
{
logMod - > warn ( " specialty has base without bonuses " ) ;
}
else
{
JsonMap & bonuses = specialtyNode [ " bonuses " ] . Struct ( ) ;
for ( std : : pair < std : : string , JsonNode > keyValue : bonuses )
JsonUtils : : inherit ( bonuses [ keyValue . first ] , base ) ;
}
2017-09-14 00:45:54 +02:00
}
}
}
2023-03-28 16:09:54 +02:00
void CHeroHandler : : afterLoadFinalization ( )
{
for ( auto const & functor : callAfterLoadFinalization )
functor ( ) ;
callAfterLoadFinalization . clear ( ) ;
}
void CHeroHandler : : loadHeroSpecialty ( CHero * hero , const JsonNode & node )
2013-03-03 21:00:37 +03:00
{
2017-09-10 04:10:50 +02:00
auto prepSpec = [ = ] ( std : : shared_ptr < Bonus > bonus )
{
2023-05-01 00:20:01 +02:00
bonus - > duration = BonusDuration : : PERMANENT ;
bonus - > source = BonusSource : : HERO_SPECIAL ;
2023-03-28 16:09:54 +02:00
bonus - > sid = hero - > getIndex ( ) ;
2017-09-10 04:10:50 +02:00
return bonus ;
} ;
2023-03-05 16:09:16 +02:00
//new format, using bonus system
2017-09-14 00:45:54 +02:00
const JsonNode & specialtyNode = node [ " specialty " ] ;
2023-03-28 16:09:54 +02:00
if ( specialtyNode . getType ( ) ! = JsonNode : : JsonType : : DATA_STRUCT )
{
logMod - > error ( " Unsupported speciality format for hero %s! " , hero - > getNameTranslated ( ) ) ;
return ;
}
//creature specialty - alias for simplicity
if ( ! specialtyNode [ " creature " ] . isNull ( ) )
2017-09-14 00:45:54 +02:00
{
2023-03-28 16:09:54 +02:00
JsonNode creatureNode = specialtyNode [ " creature " ] ;
std : : function < void ( ) > specialtyLoader = [ creatureNode , hero , prepSpec ]
2018-02-06 02:44:43 +02:00
{
2023-07-30 19:12:25 +02:00
VLC - > identifiers ( ) - > requestIdentifier ( " creature " , creatureNode , [ hero , prepSpec ] ( si32 creature )
2023-03-28 16:09:54 +02:00
{
for ( const auto & bonus : createCreatureSpecialty ( CreatureID ( creature ) ) )
hero - > specialty . push_back ( prepSpec ( bonus ) ) ;
2018-02-06 02:44:43 +02:00
} ) ;
2023-03-28 16:09:54 +02:00
} ;
callAfterLoadFinalization . push_back ( specialtyLoader ) ;
2013-01-19 20:38:37 +03:00
}
2023-03-28 16:09:54 +02:00
for ( const auto & keyValue : specialtyNode [ " bonuses " ] . Struct ( ) )
hero - > specialty . push_back ( prepSpec ( JsonUtils : : parseBonus ( keyValue . second ) ) ) ;
2012-12-15 11:47:02 +03:00
}
void CHeroHandler : : loadExperience ( )
{
expPerLevel . push_back ( 0 ) ;
expPerLevel . push_back ( 1000 ) ;
expPerLevel . push_back ( 2000 ) ;
expPerLevel . push_back ( 3200 ) ;
expPerLevel . push_back ( 4600 ) ;
expPerLevel . push_back ( 6200 ) ;
expPerLevel . push_back ( 8000 ) ;
expPerLevel . push_back ( 10000 ) ;
expPerLevel . push_back ( 12200 ) ;
expPerLevel . push_back ( 14700 ) ;
expPerLevel . push_back ( 17500 ) ;
expPerLevel . push_back ( 20600 ) ;
expPerLevel . push_back ( 24320 ) ;
expPerLevel . push_back ( 28784 ) ;
expPerLevel . push_back ( 34140 ) ;
while ( expPerLevel [ expPerLevel . size ( ) - 1 ] > expPerLevel [ expPerLevel . size ( ) - 2 ] )
{
2018-04-28 19:51:30 +02:00
auto i = expPerLevel . size ( ) - 1 ;
auto diff = expPerLevel [ i ] - expPerLevel [ i - 1 ] ;
diff + = diff / 5 ;
expPerLevel . push_back ( expPerLevel [ i ] + diff ) ;
2012-12-15 11:47:02 +03:00
}
expPerLevel . pop_back ( ) ; //last value is broken
2012-12-14 18:32:53 +03:00
}
2013-03-03 21:00:37 +03:00
/// convert h3-style ID (e.g. Gobin Wolf Rider) to vcmi (e.g. goblinWolfRider)
static std : : string genRefName ( std : : string input )
{
boost : : algorithm : : replace_all ( input , " " , " " ) ; //remove spaces
input [ 0 ] = std : : tolower ( input [ 0 ] ) ; // to camelCase
return input ;
}
2023-03-15 21:34:29 +02:00
std : : vector < JsonNode > CHeroHandler : : loadLegacyData ( )
2007-06-08 17:58:04 +03:00
{
2023-03-15 21:34:29 +02:00
size_t dataSize = VLC - > settings ( ) - > getInteger ( EGameSettings : : TEXTS_HERO ) ;
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
objects . resize ( dataSize ) ;
2013-04-21 15:49:26 +03:00
std : : vector < JsonNode > h3Data ;
h3Data . reserve ( dataSize ) ;
2013-03-02 19:55:51 +03:00
CLegacyConfigParser specParser ( " DATA/HEROSPEC.TXT " ) ;
CLegacyConfigParser bioParser ( " DATA/HEROBIOS.TXT " ) ;
2012-08-25 11:44:51 +03:00
CLegacyConfigParser parser ( " DATA/HOTRAITS.TXT " ) ;
parser . endLine ( ) ; //ignore header
parser . endLine ( ) ;
2007-08-04 22:01:22 +03:00
2013-03-02 19:55:51 +03:00
specParser . endLine ( ) ; //ignore header
specParser . endLine ( ) ;
2011-12-14 00:23:17 +03:00
for ( int i = 0 ; i < GameConstants : : HEROES_QUANTITY ; i + + )
2007-06-08 17:58:04 +03:00
{
2013-03-03 21:00:37 +03:00
JsonNode heroData ;
heroData [ " texts " ] [ " name " ] . String ( ) = parser . readString ( ) ;
heroData [ " texts " ] [ " biography " ] . String ( ) = bioParser . readString ( ) ;
heroData [ " texts " ] [ " specialty " ] [ " name " ] . String ( ) = specParser . readString ( ) ;
heroData [ " texts " ] [ " specialty " ] [ " tooltip " ] . String ( ) = specParser . readString ( ) ;
heroData [ " texts " ] [ " specialty " ] [ " description " ] . String ( ) = specParser . readString ( ) ;
2007-08-04 22:01:22 +03:00
2008-05-03 18:30:11 +03:00
for ( int x = 0 ; x < 3 ; x + + )
{
2013-03-03 21:00:37 +03:00
JsonNode armySlot ;
armySlot [ " min " ] . Float ( ) = parser . readNumber ( ) ;
armySlot [ " max " ] . Float ( ) = parser . readNumber ( ) ;
armySlot [ " creature " ] . String ( ) = genRefName ( parser . readString ( ) ) ;
2012-12-03 19:00:17 +03:00
2013-03-03 21:00:37 +03:00
heroData [ " army " ] . Vector ( ) . push_back ( armySlot ) ;
2008-05-03 18:30:11 +03:00
}
2012-08-25 11:44:51 +03:00
parser . endLine ( ) ;
2013-03-02 19:55:51 +03:00
specParser . endLine ( ) ;
bioParser . endLine ( ) ;
2012-08-25 11:44:51 +03:00
2013-03-03 21:00:37 +03:00
h3Data . push_back ( heroData ) ;
2007-06-08 17:58:04 +03:00
}
2013-04-21 15:49:26 +03:00
return h3Data ;
}
2011-08-27 18:53:45 +03:00
2013-04-21 15:49:26 +03:00
void CHeroHandler : : loadObject ( std : : string scope , std : : string name , const JsonNode & data )
{
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
size_t index = objects . size ( ) ;
2023-03-13 23:26:44 +02:00
auto * object = loadFromJson ( scope , data , name , index ) ;
object - > imageIndex = static_cast < si32 > ( index ) + GameConstants : : HERO_PORTRAIT_SHIFT ; // 2 special frames + some extra portraits
2013-03-03 21:00:37 +03:00
2023-03-13 23:26:44 +02:00
objects . emplace_back ( object ) ;
2013-03-03 21:00: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
registerObject ( scope , " hero " , name , object - > getIndex ( ) ) ;
2012-12-16 16:47:53 +03:00
}
2011-08-27 20:33:07 +03:00
2013-04-21 15:49:26 +03:00
void CHeroHandler : : loadObject ( std : : string scope , std : : string name , const JsonNode & data , size_t index )
2012-12-15 11:47:02 +03:00
{
2023-03-13 23:26:44 +02:00
auto * object = loadFromJson ( scope , data , name , index ) ;
2020-10-01 10:38:06 +02:00
object - > imageIndex = static_cast < si32 > ( index ) ;
2012-08-25 11:44:51 +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
assert ( objects [ index ] = = nullptr ) ; // ensure that this id was not loaded before
objects [ index ] = object ;
2012-08-25 11:44:51 +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
registerObject ( scope , " hero " , name , object - > getIndex ( ) ) ;
2007-06-09 16:28:03 +03:00
}
2011-08-27 20:33:07 +03:00
2011-12-14 00:23:17 +03:00
ui32 CHeroHandler : : level ( ui64 experience ) const
2007-08-12 20:48:05 +03:00
{
2020-10-01 10:38:06 +02:00
return static_cast < ui32 > ( boost : : range : : upper_bound ( expPerLevel , experience ) - std : : begin ( expPerLevel ) ) ;
2008-01-27 18:07:27 +02:00
}
2011-12-14 00:23:17 +03:00
ui64 CHeroHandler : : reqExp ( ui32 level ) const
2008-01-27 18:07:27 +02:00
{
2009-07-20 06:30:48 +03:00
if ( ! level )
return 0 ;
2009-10-28 12:45:45 +02:00
if ( level < = expPerLevel . size ( ) )
2009-07-20 06:30:48 +03:00
{
2009-10-28 12:45:45 +02:00
return expPerLevel [ level - 1 ] ;
2009-07-20 06:30:48 +03:00
}
2008-01-27 18:07:27 +02:00
else
2007-09-14 16:11:10 +03:00
{
2016-08-12 11:10:27 +02:00
logGlobal - > warn ( " A hero has reached unsupported amount of experience " ) ;
2010-08-16 12:54:09 +03:00
return expPerLevel [ expPerLevel . size ( ) - 1 ] ;
2007-09-14 16:11:10 +03:00
}
2007-08-12 20:48:05 +03:00
}
2013-04-21 15:49:26 +03:00
std : : vector < bool > CHeroHandler : : getDefaultAllowed ( ) const
2012-11-20 20:53:45 +03:00
{
// Look Data/HOTRAITS.txt for reference
2013-02-05 00:58:42 +03:00
std : : vector < bool > allowedHeroes ;
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
allowedHeroes . reserve ( size ( ) ) ;
2012-12-17 15:55:29 +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
for ( const CHero * hero : objects )
2012-11-20 20:53:45 +03:00
{
2023-08-05 11:49:38 +02:00
allowedHeroes . push_back ( hero & & ! hero - > special ) ;
2012-11-20 20:53:45 +03:00
}
2012-12-17 15:55:29 +03:00
2012-11-20 20:53:45 +03:00
return allowedHeroes ;
2012-12-17 15:55:29 +03:00
}
2022-07-26 15:07:42 +02:00
VCMI_LIB_NAMESPACE_END