2017-08-20 09:18:07 +02:00
|
|
|
/*
|
|
|
|
* CSkillHandler.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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdInc.h"
|
|
|
|
|
|
|
|
#include <cctype>
|
|
|
|
|
|
|
|
#include "CSkillHandler.h"
|
|
|
|
|
2024-07-20 14:55:17 +02:00
|
|
|
#include "constants/StringConstants.h"
|
2017-08-20 09:18:07 +02:00
|
|
|
#include "filesystem/Filesystem.h"
|
2024-02-14 15:48:06 +02:00
|
|
|
#include "json/JsonBonus.h"
|
2024-02-11 23:09:01 +02:00
|
|
|
#include "json/JsonUtils.h"
|
2023-07-30 19:12:25 +02:00
|
|
|
#include "modding/IdentifierStorage.h"
|
|
|
|
#include "modding/ModUtility.h"
|
|
|
|
#include "modding/ModScope.h"
|
2024-07-20 14:55:17 +02:00
|
|
|
#include "texts/CGeneralTextHandler.h"
|
|
|
|
#include "texts/CLegacyConfigParser.h"
|
|
|
|
#include "texts/TextOperations.h"
|
2024-05-17 00:05:51 +02:00
|
|
|
#include "VCMI_Lib.h"
|
2017-08-20 09:18:07 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2023-03-13 23:26:44 +02:00
|
|
|
CSkill::CSkill(const SecondarySkill & id, std::string identifier, bool obligatoryMajor, bool obligatoryMinor):
|
|
|
|
id(id),
|
|
|
|
identifier(std::move(identifier)),
|
|
|
|
obligatoryMajor(obligatoryMajor),
|
|
|
|
obligatoryMinor(obligatoryMinor)
|
2017-08-20 09:18:07 +02:00
|
|
|
{
|
2020-10-19 21:39:57 +02:00
|
|
|
gainChance[0] = gainChance[1] = 0; //affects CHeroClassHandler::afterLoadFinalization()
|
2018-03-31 07:56:40 +02:00
|
|
|
levels.resize(NSecondarySkill::levels.size() - 1);
|
2017-08-20 09:18:07 +02:00
|
|
|
}
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
int32_t CSkill::getIndex() const
|
|
|
|
{
|
|
|
|
return id.num;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CSkill::getIconIndex() const
|
|
|
|
{
|
2024-10-28 14:30:19 +02:00
|
|
|
return getIndex() * 3 + 3; // Base master level
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CSkill::getIconIndex(uint8_t skillMasterLevel) const
|
|
|
|
{
|
|
|
|
return getIconIndex() + skillMasterLevel;
|
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-01 22:20:41 +02:00
|
|
|
std::string CSkill::getNameTextID() const
|
|
|
|
{
|
|
|
|
TextIdentifier id("skill", modScope, identifier, "name");
|
|
|
|
return id.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CSkill::getNameTranslated() const
|
|
|
|
{
|
|
|
|
return VLC->generaltexth->translate(getNameTextID());
|
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
|
|
|
std::string CSkill::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
|
|
|
{
|
2024-01-16 21:02:39 +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
|
|
|
}
|
|
|
|
|
2024-08-10 16:08:04 +02:00
|
|
|
std::string CSkill::getModScope() const
|
|
|
|
{
|
|
|
|
return modScope;
|
|
|
|
}
|
|
|
|
|
2023-01-01 22:20:41 +02:00
|
|
|
std::string CSkill::getDescriptionTextID(int level) const
|
|
|
|
{
|
|
|
|
TextIdentifier id("skill", modScope, identifier, "description", NSecondarySkill::levels[level]);
|
|
|
|
return id.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CSkill::getDescriptionTranslated(int level) const
|
|
|
|
{
|
|
|
|
return VLC->generaltexth->translate(getDescriptionTextID(level));
|
|
|
|
}
|
|
|
|
|
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 CSkill::registerIcons(const IconRegistar & cb) const
|
|
|
|
{
|
|
|
|
for(int level = 1; level <= 3; level++)
|
|
|
|
{
|
2023-11-05 19:13:18 +02:00
|
|
|
int frame = 2 + level + 3 * id.getNum();
|
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 LevelInfo & skillAtLevel = at(level);
|
2022-11-29 14:47:51 +02:00
|
|
|
cb(frame, 0, "SECSK32", skillAtLevel.iconSmall);
|
|
|
|
cb(frame, 0, "SECSKILL", skillAtLevel.iconMedium);
|
|
|
|
cb(frame, 0, "SECSK82", skillAtLevel.iconLarge);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SecondarySkill CSkill::getId() const
|
|
|
|
{
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2017-08-30 09:19:54 +02:00
|
|
|
void CSkill::addNewBonus(const std::shared_ptr<Bonus> & b, int level)
|
2017-08-20 09:18:07 +02:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
b->source = BonusSource::SECONDARY_SKILL;
|
2023-10-21 13:50:42 +02:00
|
|
|
b->sid = BonusSourceID(id);
|
2023-05-01 00:20:01 +02:00
|
|
|
b->duration = BonusDuration::PERMANENT;
|
2024-04-07 18:57:49 +02:00
|
|
|
b->description.appendTextID(getNameTextID());
|
2024-04-08 17:21:24 +02:00
|
|
|
b->description.appendRawString(" %+d");
|
2017-08-30 06:23:03 +02:00
|
|
|
levels[level-1].effects.push_back(b);
|
2017-08-25 03:35:02 +02:00
|
|
|
}
|
|
|
|
|
2018-03-31 07:56:40 +02:00
|
|
|
const CSkill::LevelInfo & CSkill::at(int level) const
|
2017-08-25 03:35:02 +02:00
|
|
|
{
|
2018-03-31 07:56:40 +02:00
|
|
|
assert(1 <= level && level < NSecondarySkill::levels.size());
|
|
|
|
return levels[level - 1];
|
2017-08-25 03:35:02 +02:00
|
|
|
}
|
|
|
|
|
2018-03-31 07:56:40 +02:00
|
|
|
CSkill::LevelInfo & CSkill::at(int level)
|
2017-08-25 03:35:02 +02:00
|
|
|
{
|
2018-03-31 07:56:40 +02:00
|
|
|
assert(1 <= level && level < NSecondarySkill::levels.size());
|
|
|
|
return levels[level - 1];
|
2017-08-20 09:18:07 +02:00
|
|
|
}
|
|
|
|
|
2017-08-30 09:19:54 +02:00
|
|
|
DLL_LINKAGE std::ostream & operator<<(std::ostream & out, const CSkill::LevelInfo & info)
|
2017-08-20 09:18:07 +02:00
|
|
|
{
|
2017-08-30 06:23:03 +02:00
|
|
|
for(int i=0; i < info.effects.size(); i++)
|
2024-10-25 20:36:02 +02:00
|
|
|
out << (i ? "," : "") << info.effects[i]->Description(nullptr);
|
2017-08-30 06:23:03 +02:00
|
|
|
return out << "])";
|
2017-08-20 09:18:07 +02:00
|
|
|
}
|
|
|
|
|
2017-08-30 09:19:54 +02:00
|
|
|
DLL_LINKAGE std::ostream & operator<<(std::ostream & out, const CSkill & skill)
|
2017-08-23 00:19:30 +02:00
|
|
|
{
|
2023-11-02 17:48:48 +02:00
|
|
|
out << "Skill(" << skill.id.getNum() << "," << skill.identifier << "): [";
|
2017-08-30 06:23:03 +02:00
|
|
|
for(int i=0; i < skill.levels.size(); i++)
|
|
|
|
out << (i ? "," : "") << skill.levels[i];
|
|
|
|
return out << "]";
|
2017-08-26 04:06:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string CSkill::toString() const
|
|
|
|
{
|
|
|
|
std::ostringstream ss;
|
|
|
|
ss << *this;
|
|
|
|
return ss.str();
|
2017-08-23 00:19:30 +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 CSkill::updateFrom(const JsonNode & data)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSkill::serializeJson(JsonSerializeFormat & handler)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-08-20 09:18:07 +02:00
|
|
|
///CSkillHandler
|
2023-03-15 21:34:29 +02:00
|
|
|
std::vector<JsonNode> CSkillHandler::loadLegacyData()
|
2017-08-20 09:18:07 +02:00
|
|
|
{
|
2023-09-01 23:26:14 +02:00
|
|
|
CLegacyConfigParser parser(TextPath::builtin("DATA/SSTRAITS.TXT"));
|
2017-08-30 12:35:23 +02:00
|
|
|
|
|
|
|
//skip header
|
|
|
|
parser.endLine();
|
|
|
|
parser.endLine();
|
|
|
|
|
|
|
|
std::vector<std::string> skillNames;
|
|
|
|
std::vector<std::vector<std::string>> skillInfoTexts;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
skillNames.push_back(parser.readString());
|
2023-03-13 23:26:44 +02:00
|
|
|
skillInfoTexts.emplace_back();
|
2017-08-30 12:35:23 +02:00
|
|
|
for(int i = 0; i < 3; i++)
|
|
|
|
skillInfoTexts.back().push_back(parser.readString());
|
|
|
|
}
|
|
|
|
while (parser.endLine());
|
|
|
|
|
|
|
|
assert(skillNames.size() == GameConstants::SKILL_QUANTITY);
|
|
|
|
|
|
|
|
//store & construct JSON
|
2017-08-20 09:18:07 +02:00
|
|
|
std::vector<JsonNode> legacyData;
|
2017-08-30 06:03:24 +02:00
|
|
|
for(int id = 0; id < GameConstants::SKILL_QUANTITY; id++)
|
|
|
|
{
|
2024-02-13 13:18:10 +02:00
|
|
|
JsonNode skillNode;
|
2017-09-03 13:49:36 +02:00
|
|
|
skillNode["name"].String() = skillNames[id];
|
2017-08-30 06:03:24 +02:00
|
|
|
for(int level = 1; level < NSecondarySkill::levels.size(); level++)
|
|
|
|
{
|
2017-08-30 12:35:23 +02:00
|
|
|
std::string & desc = skillInfoTexts[id][level-1];
|
2017-08-30 06:03:24 +02:00
|
|
|
auto & levelNode = skillNode[NSecondarySkill::levels[level]].Struct();
|
|
|
|
levelNode["description"].String() = desc;
|
2017-09-03 13:49:36 +02:00
|
|
|
levelNode["effects"].Struct(); // create empty effects objects
|
2017-08-30 06:03:24 +02:00
|
|
|
}
|
|
|
|
legacyData.push_back(skillNode);
|
|
|
|
}
|
2017-09-03 13:49:36 +02:00
|
|
|
objects.resize(legacyData.size());
|
2017-08-20 09:18:07 +02:00
|
|
|
return legacyData;
|
|
|
|
}
|
|
|
|
|
2018-03-31 07:56:40 +02:00
|
|
|
const std::vector<std::string> & CSkillHandler::getTypeNames() const
|
2017-08-20 09:18:07 +02:00
|
|
|
{
|
2018-03-31 07:56:40 +02:00
|
|
|
static const std::vector<std::string> typeNames = { "skill", "secondarySkill" };
|
|
|
|
return typeNames;
|
2017-08-20 09:18:07 +02:00
|
|
|
}
|
|
|
|
|
2024-05-17 00:05:51 +02:00
|
|
|
std::shared_ptr<CSkill> CSkillHandler::loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index)
|
2017-08-20 09:18:07 +02:00
|
|
|
{
|
2023-01-18 23:56:01 +02:00
|
|
|
assert(identifier.find(':') == std::string::npos);
|
|
|
|
assert(!scope.empty());
|
2024-01-10 00:38:54 +02:00
|
|
|
bool major;
|
|
|
|
bool minor;
|
2023-01-18 23:56:01 +02:00
|
|
|
|
2023-02-27 11:42:57 +02:00
|
|
|
major = json["obligatoryMajor"].Bool();
|
|
|
|
minor = json["obligatoryMinor"].Bool();
|
2024-06-01 13:48:30 +02:00
|
|
|
auto skill = std::make_shared<CSkill>(SecondarySkill(index), identifier, major, minor);
|
2023-01-18 23:56:01 +02:00
|
|
|
skill->modScope = scope;
|
2017-08-30 06:23:03 +02:00
|
|
|
|
2023-07-18 10:54:36 +02:00
|
|
|
skill->onlyOnWaterMap = json["onlyOnWaterMap"].Bool();
|
|
|
|
|
2024-09-30 12:21:10 +02:00
|
|
|
VLC->generaltexth->registerString(scope, skill->getNameTextID(), json["name"]);
|
2018-03-31 07:56:40 +02:00
|
|
|
switch(json["gainChance"].getType())
|
2017-08-30 06:23:03 +02:00
|
|
|
{
|
2018-03-31 07:56:40 +02:00
|
|
|
case JsonNode::JsonType::DATA_INTEGER:
|
2020-10-01 10:38:06 +02:00
|
|
|
skill->gainChance[0] = static_cast<si32>(json["gainChance"].Integer());
|
|
|
|
skill->gainChance[1] = static_cast<si32>(json["gainChance"].Integer());
|
2018-03-31 07:56:40 +02:00
|
|
|
break;
|
|
|
|
case JsonNode::JsonType::DATA_STRUCT:
|
2020-10-01 10:38:06 +02:00
|
|
|
skill->gainChance[0] = static_cast<si32>(json["gainChance"]["might"].Integer());
|
|
|
|
skill->gainChance[1] = static_cast<si32>(json["gainChance"]["magic"].Integer());
|
2018-03-31 07:56:40 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2017-08-30 06:23:03 +02:00
|
|
|
}
|
|
|
|
for(int level = 1; level < NSecondarySkill::levels.size(); level++)
|
|
|
|
{
|
|
|
|
const std::string & levelName = NSecondarySkill::levels[level]; // basic, advanced, expert
|
|
|
|
const JsonNode & levelNode = json[levelName];
|
|
|
|
// parse bonus effects
|
2023-03-13 23:26:44 +02:00
|
|
|
for(const auto & b : levelNode["effects"].Struct())
|
2017-08-30 06:23:03 +02:00
|
|
|
{
|
2017-08-30 00:25:36 +02:00
|
|
|
auto bonus = JsonUtils::parseBonus(b.second);
|
2017-08-30 06:23:03 +02:00
|
|
|
skill->addNewBonus(bonus, level);
|
|
|
|
}
|
2018-03-31 07:56:40 +02:00
|
|
|
CSkill::LevelInfo & skillAtLevel = skill->at(level);
|
2024-09-30 12:21:10 +02:00
|
|
|
VLC->generaltexth->registerString(scope, skill->getDescriptionTextID(level), levelNode["description"]);
|
2018-03-31 07:56:40 +02:00
|
|
|
skillAtLevel.iconSmall = levelNode["images"]["small"].String();
|
|
|
|
skillAtLevel.iconMedium = levelNode["images"]["medium"].String();
|
|
|
|
skillAtLevel.iconLarge = levelNode["images"]["large"].String();
|
2017-08-30 06:23:03 +02:00
|
|
|
}
|
2023-11-02 17:48:48 +02:00
|
|
|
logMod->debug("loaded secondary skill %s(%d)", identifier, skill->id.getNum());
|
2017-08-20 09:18:07 +02:00
|
|
|
|
2017-08-30 06:23:03 +02:00
|
|
|
return skill;
|
2017-08-20 09:18:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSkillHandler::afterLoadFinalization()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSkillHandler::beforeValidate(JsonNode & object)
|
|
|
|
{
|
2017-08-30 00:25:36 +02:00
|
|
|
//handle "base" level info
|
|
|
|
JsonNode & base = object["base"];
|
|
|
|
|
|
|
|
auto inheritNode = [&](const std::string & name){
|
|
|
|
JsonUtils::inherit(object[name], base);
|
|
|
|
};
|
|
|
|
|
|
|
|
inheritNode("basic");
|
|
|
|
inheritNode("advanced");
|
|
|
|
inheritNode("expert");
|
2017-08-20 09:18:07 +02:00
|
|
|
}
|
|
|
|
|
2023-11-05 15:24:26 +02:00
|
|
|
std::set<SecondarySkill> CSkillHandler::getDefaultAllowed() const
|
2017-08-20 09:18:07 +02:00
|
|
|
{
|
2023-11-05 15:24:26 +02:00
|
|
|
std::set<SecondarySkill> result;
|
|
|
|
|
|
|
|
for (auto const & skill : objects)
|
|
|
|
result.insert(skill->getId());
|
|
|
|
|
|
|
|
return result;
|
2017-08-20 09:18:07 +02:00
|
|
|
}
|
2018-03-31 07:56:40 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|