浏览代码

Fixes #1096 - do not propose banned skills on levelup

Remove possibility to get banned skill on levelup as "obligatory skill"
if all other such skills have been learned before.

May happen under some conditions, e.g. if hero quickly learns other
magic schools - in witch hut/university, leading to case where banned
skill is the only obligatory skill that can be offered on levelup
Ivan Savenko 3 年之前
父节点
当前提交
e06db2365d
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      lib/mapObjects/CGHeroInstance.cpp

+ 5 - 3
lib/mapObjects/CGHeroInstance.cpp

@@ -1117,7 +1117,9 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelUpProposedSecondarySkills()
 	std::vector<SecondarySkill> obligatorySkills; //hero is offered magic school or wisdom if possible
 	if (!skillsInfo.wisdomCounter)
 	{
-		if (cb->isAllowed(2, SecondarySkill::WISDOM) && !getSecSkillLevel(SecondarySkill::WISDOM))
+		if (cb->isAllowed(2, SecondarySkill::WISDOM) &&
+				!getSecSkillLevel(SecondarySkill::WISDOM) &&
+				type->heroClass->secSkillProbability[SecondarySkill::WISDOM] > 0)
 			obligatorySkills.push_back(SecondarySkill::WISDOM);
 	}
 	if (!skillsInfo.magicSchoolCounter)
@@ -1131,7 +1133,7 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelUpProposedSecondarySkills()
 
 		for (auto skill : ss)
 		{
-			if (cb->isAllowed(2, skill) && !getSecSkillLevel(skill)) //only schools hero doesn't know yet
+			if (cb->isAllowed(2, skill) && !getSecSkillLevel(skill) && type->heroClass->secSkillProbability[skill] > 0) //only schools hero doesn't know yet
 			{
 				obligatorySkills.push_back(skill);
 				break; //only one
@@ -1143,7 +1145,7 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelUpProposedSecondarySkills()
 	//picking sec. skills for choice
 	std::set<SecondarySkill> basicAndAdv, expert, none;
 	for(int i = 0; i < VLC->skillh->size(); i++)
-		if (cb->isAllowed(2,i))
+		if (cb->isAllowed(2,i) && type->heroClass->secSkillProbability[i] > 0)
 			none.insert(SecondarySkill(i));
 
 	for(auto & elem : secSkills)