From 31e4937a8c881a7b29a85beaae1341ce28759f4b Mon Sep 17 00:00:00 2001 From: godric3 Date: Sun, 8 Dec 2024 17:49:41 +0100 Subject: [PATCH] Editing hero primary skill in map editor should not be influenced by artifacts --- lib/mapObjects/CGHeroInstance.cpp | 3 ++- mapeditor/inspector/heroskillswidget.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 6e84d0baf..acc563274 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -1923,7 +1923,8 @@ int CGHeroInstance::getBasePrimarySkillValue(PrimarySkill which) const { std::string cachingStr = "type_PRIMARY_SKILL_base_" + std::to_string(static_cast(which)); auto selector = Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(which)).And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL)); - return valOfBonuses(selector, cachingStr); + auto minSkillValue = VLC->engineSettings()->getVector(EGameSettings::HEROES_MINIMAL_PRIMARY_SKILLS)[which.getNum()]; + return std::max(valOfBonuses(selector, cachingStr), minSkillValue); } VCMI_LIB_NAMESPACE_END diff --git a/mapeditor/inspector/heroskillswidget.cpp b/mapeditor/inspector/heroskillswidget.cpp index 05ced71f0..79b7fd2e5 100644 --- a/mapeditor/inspector/heroskillswidget.cpp +++ b/mapeditor/inspector/heroskillswidget.cpp @@ -67,10 +67,10 @@ void HeroSkillsWidget::on_checkBox_toggled(bool checked) void HeroSkillsWidget::obtainData() { - ui->attack->setValue(hero.getPrimSkillLevel(PrimarySkill::ATTACK)); - ui->defence->setValue(hero.getPrimSkillLevel(PrimarySkill::DEFENSE)); - ui->power->setValue(hero.getPrimSkillLevel(PrimarySkill::SPELL_POWER)); - ui->knowledge->setValue(hero.getPrimSkillLevel(PrimarySkill::KNOWLEDGE)); + ui->attack->setValue(hero.getBasePrimarySkillValue(PrimarySkill::ATTACK)); + ui->defence->setValue(hero.getBasePrimarySkillValue(PrimarySkill::DEFENSE)); + ui->power->setValue(hero.getBasePrimarySkillValue(PrimarySkill::SPELL_POWER)); + ui->knowledge->setValue(hero.getBasePrimarySkillValue(PrimarySkill::KNOWLEDGE)); if(!hero.secSkills.empty() && hero.secSkills.front().first.getNum() == -1) return;