Ver código fonte

Fix incorrect icon on removal of skill

Ivan Savenko 5 meses atrás
pai
commit
c7228b7e50

+ 1 - 0
docs/modders/Map_Objects/Rewardable.md

@@ -418,6 +418,7 @@ Keep in mind, that all randomization is performed on map load and on object rese
 - If hero does not have selected skill and have free skill slots, he will receive skill at specified level
 - Possible values: 1 (basic), 2 (advanced), 3 (expert)
 - Each secondary skill can be explicitly specified or randomly selected
+- Negative values can be used to downgrade or remove secondary skills from hero
 
 ```json
 "secondary": [

+ 1 - 1
lib/rewardable/Reward.cpp

@@ -107,7 +107,7 @@ void Rewardable::Reward::loadComponents(std::vector<Component> & comps, const CG
 		auto skillID = entry.first;
 		int levelsGained = entry.second;
 		int currentLevel = h ? h->getSecSkillLevel(skillID) : 0;
-		int finalLevel = std::min(static_cast<int>(MasteryLevel::EXPERT), currentLevel + levelsGained);
+		int finalLevel = std::clamp<int>(currentLevel + levelsGained, MasteryLevel::BASIC, MasteryLevel::EXPERT);
 		comps.emplace_back(ComponentType::SEC_SKILL, entry.first, finalLevel);
 	}