From 77e827c51ed3ff2385483ebb78c9d6d72fdf6c7a Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 26 Jun 2024 12:38:23 +0000 Subject: [PATCH] Fix leveling up secondary skills via Scholar (map object) visit --- lib/rewardable/Interface.cpp | 12 ++++++------ lib/rewardable/Reward.cpp | 8 +++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/rewardable/Interface.cpp b/lib/rewardable/Interface.cpp index eab619288..2a6cb3b27 100644 --- a/lib/rewardable/Interface.cpp +++ b/lib/rewardable/Interface.cpp @@ -106,12 +106,12 @@ void Rewardable::Interface::grantRewardBeforeLevelup(IGameCallback * cb, const R for(const auto & entry : info.reward.secondary) { - int current = hero->getSecSkillLevel(entry.first); - if( (current != 0 && current < entry.second) || - (hero->canLearnSkill() )) - { - cb->changeSecSkill(hero, entry.first, entry.second); - } + auto currentLevel = static_cast(hero->getSecSkillLevel(entry.first)); + if(currentLevel == MasteryLevel::EXPERT) + continue; + + if(currentLevel != MasteryLevel::NONE || hero->canLearnSkill()) + cb->changeSecSkill(hero, entry.first, entry.second, false); } for(int i=0; i< info.reward.primary.size(); i++) diff --git a/lib/rewardable/Reward.cpp b/lib/rewardable/Reward.cpp index a2e54fb80..e5171e40b 100644 --- a/lib/rewardable/Reward.cpp +++ b/lib/rewardable/Reward.cpp @@ -103,7 +103,13 @@ void Rewardable::Reward::loadComponents(std::vector & comps, const CG } for(const auto & entry : secondary) - comps.emplace_back(ComponentType::SEC_SKILL, entry.first, entry.second); + { + auto skillID = entry.first; + int levelsGained = entry.second; + int currentLevel = h->getSecSkillLevel(skillID); + int finalLevel = std::min(static_cast(MasteryLevel::EXPERT), currentLevel + levelsGained); + comps.emplace_back(ComponentType::SEC_SKILL, entry.first, finalLevel); + } for(const auto & entry : artifacts) comps.emplace_back(ComponentType::ARTIFACT, entry);