From 8bdb8f01ca3f776784526a12e222eac4fd03f277 Mon Sep 17 00:00:00 2001 From: Henning Koehler Date: Sun, 27 Aug 2017 20:10:25 +1200 Subject: [PATCH] made scholar skill bonus-based --- config/skills.json | 35 +++++++++++++++++++++++++++++++++++ lib/CSkillHandler.cpp | 2 ++ server/CGameHandler.cpp | 10 ++++++---- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/config/skills.json b/config/skills.json index 99595797e..57e208159 100644 --- a/config/skills.json +++ b/config/skills.json @@ -631,5 +631,40 @@ } ] } + }, + "scholar" : { + "basic" : { + "description" : "", + "effects" : [ + { + "subtype" : "skill.scholar", + "type" : "SECONDARY_SKILL_PREMY", + "val" : 2, + "valueType" : "BASE_NUMBER" + } + ] + }, + "advanced" : { + "description" : "", + "effects" : [ + { + "subtype" : "skill.scholar", + "type" : "SECONDARY_SKILL_PREMY", + "val" : 3, + "valueType" : "BASE_NUMBER" + } + ] + }, + "expert" : { + "description" : "", + "effects" : [ + { + "subtype" : "skill.scholar", + "type" : "SECONDARY_SKILL_PREMY", + "val" : 4, + "valueType" : "BASE_NUMBER" + } + ] + } } } diff --git a/lib/CSkillHandler.cpp b/lib/CSkillHandler.cpp index 05ba079c3..236a033a9 100644 --- a/lib/CSkillHandler.cpp +++ b/lib/CSkillHandler.cpp @@ -252,6 +252,8 @@ std::vector> CSkillHandler::defaultBonus(SecondarySkill s case SecondarySkill::WATER_MAGIC: case SecondarySkill::EARTH_MAGIC: addBonus(level); break; + case SecondarySkill::SCHOLAR: + addBonus(1 + level); break; case SecondarySkill::TACTICS: addBonus(1 + 2 * level); break; case SecondarySkill::LEARNING: diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index e809c2115..760990510 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -2489,19 +2489,21 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t { const CGHeroInstance * h1 = getHero(fromHero); const CGHeroInstance * h2 = getHero(toHero); + int h1_scholarLevel = h1->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::SCHOLAR); + int h2_scholarLevel = h1->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::SCHOLAR); - if (h1->getSecSkillLevel(SecondarySkill::SCHOLAR) < h2->getSecSkillLevel(SecondarySkill::SCHOLAR)) + if (h1_scholarLevel < h2_scholarLevel) { std::swap (h1,h2);//1st hero need to have higher scholar level for correct message std::swap(fromHero, toHero); } - int ScholarLevel = h1->getSecSkillLevel(SecondarySkill::SCHOLAR);//heroes can trade up to this level + int ScholarLevel = std::max(h1_scholarLevel, h2_scholarLevel);//heroes can trade up to this level if (!ScholarLevel || !h1->hasSpellbook() || !h2->hasSpellbook()) return;//no scholar skill or no spellbook - int h1Lvl = std::min(ScholarLevel+1, h1->maxSpellLevel()), - h2Lvl = std::min(ScholarLevel+1, h2->maxSpellLevel());//heroes can receive this levels + int h1Lvl = std::min(ScholarLevel, h1->maxSpellLevel()), + h2Lvl = std::min(ScholarLevel, h2->maxSpellLevel());//heroes can receive this levels ChangeSpells cs1; cs1.learn = true;