mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Merge pull request #2988 from IvanSavenko/configurable_extensions
Extension of configurable object functionality
This commit is contained in:
@@ -272,7 +272,7 @@ CGHeroInstance::CGHeroInstance():
|
||||
{
|
||||
setNodeType(HERO);
|
||||
ID = Obj::HERO;
|
||||
secSkills.emplace_back(SecondarySkill::DEFAULT, -1);
|
||||
secSkills.emplace_back(SecondarySkill::NONE, -1);
|
||||
blockVisit = true;
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ void CGHeroInstance::initHero(CRandomGenerator & rand)
|
||||
pushPrimSkill(static_cast<PrimarySkill>(g), type->heroClass->primarySkillInitial[g]);
|
||||
}
|
||||
}
|
||||
if(secSkills.size() == 1 && secSkills[0] == std::pair<SecondarySkill,ui8>(SecondarySkill::DEFAULT, -1)) //set secondary skills to default
|
||||
if(secSkills.size() == 1 && secSkills[0] == std::pair<SecondarySkill,ui8>(SecondarySkill::NONE, -1)) //set secondary skills to default
|
||||
secSkills = type->secSkillsInit;
|
||||
|
||||
if (gender == EHeroGender::DEFAULT)
|
||||
@@ -789,9 +789,9 @@ bool CGHeroInstance::canCastThisSpell(const spells::Spell * spell) const
|
||||
}
|
||||
}
|
||||
|
||||
bool CGHeroInstance::canLearnSpell(const spells::Spell * spell) const
|
||||
bool CGHeroInstance::canLearnSpell(const spells::Spell * spell, bool allowBanned) const
|
||||
{
|
||||
if(!hasSpellbook())
|
||||
if(!hasSpellbook())
|
||||
return false;
|
||||
|
||||
if(spell->getLevel() > maxSpellLevel()) //not enough wisdom
|
||||
@@ -812,7 +812,7 @@ bool CGHeroInstance::canLearnSpell(const spells::Spell * spell) const
|
||||
return false;//creature abilities can not be learned
|
||||
}
|
||||
|
||||
if(!IObjectInterface::cb->isAllowed(0, spell->getIndex()))
|
||||
if(!allowBanned && !IObjectInterface::cb->isAllowed(0, spell->getIndex()))
|
||||
{
|
||||
logGlobal->warn("Hero %s try to learn banned spell %s", nodeName(), spell->getNameTranslated());
|
||||
return false;//banned spells should not be learned
|
||||
@@ -1598,7 +1598,7 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler)
|
||||
bool normalSkills = false;
|
||||
for(const auto & p : secSkills)
|
||||
{
|
||||
if(p.first == SecondarySkill(SecondarySkill::DEFAULT))
|
||||
if(p.first == SecondarySkill(SecondarySkill::NONE))
|
||||
defaultSkills = true;
|
||||
else
|
||||
normalSkills = true;
|
||||
@@ -1636,7 +1636,7 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler)
|
||||
secSkills.clear();
|
||||
if(secondarySkills.getType() == JsonNode::JsonType::DATA_NULL)
|
||||
{
|
||||
secSkills.emplace_back(SecondarySkill::DEFAULT, -1);
|
||||
secSkills.emplace_back(SecondarySkill::NONE, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user