From 19e619f61e2623e1970da5de54608bd11436e243 Mon Sep 17 00:00:00 2001 From: Henning Koehler Date: Sat, 26 Aug 2017 20:49:29 +1200 Subject: [PATCH] wisdom is now bonus-based --- config/skills.json | 134 ++++++++++++++++++++++++++++++ lib/mapObjects/CBank.cpp | 2 +- lib/mapObjects/CGHeroInstance.cpp | 7 +- lib/mapObjects/CGHeroInstance.h | 1 + lib/mapObjects/MiscObjects.cpp | 2 +- server/CGameHandler.cpp | 8 +- 6 files changed, 147 insertions(+), 7 deletions(-) diff --git a/config/skills.json b/config/skills.json index 9d8445ba8..9b8257e3e 100644 --- a/config/skills.json +++ b/config/skills.json @@ -136,6 +136,140 @@ ] } }, + "diplomacy" : { + "basic" : { + "description" : "", + "effects" : [ + { + "type" : "SURRENDER_DISCOUNT", + "val" : 20, + "valueType" : "BASE_NUMBER" + } + ] + }, + "advanced" : { + "description" : "", + "effects" : [ + { + "type" : "SURRENDER_DISCOUNT", + "val" : 40, + "valueType" : "BASE_NUMBER" + } + ] + }, + "expert" : { + "description" : "", + "effects" : [ + { + "type" : "SURRENDER_DISCOUNT", + "val" : 60, + "valueType" : "BASE_NUMBER" + } + ] + } + }, + "navigation" : { + "basic" : { + "description" : "", + "effects" : [ + { + "subtype" : "skill.navigation", + "type" : "SECONDARY_SKILL_PREMY", + "val" : 50, + "valueType" : "BASE_NUMBER" + } + ] + }, + "advanced" : { + "description" : "", + "effects" : [ + { + "subtype" : "skill.navigation", + "type" : "SECONDARY_SKILL_PREMY", + "val" : 100, + "valueType" : "BASE_NUMBER" + } + ] + }, + "expert" : { + "description" : "", + "effects" : [ + { + "subtype" : "skill.navigation", + "type" : "SECONDARY_SKILL_PREMY", + "val" : 150, + "valueType" : "BASE_NUMBER" + } + ] + } + }, + "leadership" : { + "basic" : { + "description" : "", + "effects" : [ + { + "type" : "MORALE", + "val" : 1, + "valueType" : "BASE_NUMBER" + } + ] + }, + "advanced" : { + "description" : "", + "effects" : [ + { + "type" : "MORALE", + "val" : 2, + "valueType" : "BASE_NUMBER" + } + ] + }, + "expert" : { + "description" : "", + "effects" : [ + { + "type" : "MORALE", + "val" : 3, + "valueType" : "BASE_NUMBER" + } + ] + } + }, + "wisdom" : { + "basic" : { + "description" : "", + "effects" : [ + { + "subtype" : "skill.wisdom", + "type" : "SECONDARY_SKILL_PREMY", + "val" : 1, + "valueType" : "BASE_NUMBER" + } + ] + }, + "advanced" : { + "description" : "", + "effects" : [ + { + "subtype" : "skill.wisdom", + "type" : "SECONDARY_SKILL_PREMY", + "val" : 2, + "valueType" : "BASE_NUMBER" + } + ] + }, + "expert" : { + "description" : "", + "effects" : [ + { + "subtype" : "skill.wisdom", + "type" : "SECONDARY_SKILL_PREMY", + "val" : 3, + "valueType" : "BASE_NUMBER" + } + ] + } + }, "estates" : { "basic" : { "description" : "", diff --git a/lib/mapObjects/CBank.cpp b/lib/mapObjects/CBank.cpp index 12848d258..44227ef7d 100644 --- a/lib/mapObjects/CBank.cpp +++ b/lib/mapObjects/CBank.cpp @@ -266,7 +266,7 @@ void CBank::doVisit(const CGHeroInstance * hero) const { const CSpell * spell = spellId.toSpell(); iw.text.addTxt (MetaString::SPELL_NAME, spellId); - if(spell->level <= hero->getSecSkillLevel(SecondarySkill::WISDOM) + 2) + if(spell->level <= hero->maxSpellLevel()) { if(hero->canLearnSpell(spell)) { diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index e8dea7953..d69e867fa 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -957,7 +957,7 @@ bool CGHeroInstance::canLearnSpell(const CSpell * spell) const if(!hasSpellbook()) return false; - if(spell->level > getSecSkillLevel(SecondarySkill::WISDOM) + 2) //not enough wisdom + if(spell->level > maxSpellLevel()) //not enough wisdom return false; if(vstd::contains(spells, spell->id))//already known @@ -1175,6 +1175,11 @@ bool CGHeroInstance::hasSpellbook() const return getArt(ArtifactPosition::SPELLBOOK); } +int CGHeroInstance::maxSpellLevel() const +{ + return std::min(GameConstants::SPELL_LEVELS, 2 + valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::WISDOM))); +} + void CGHeroInstance::deserializationFix() { artDeserializationFix(this); diff --git a/lib/mapObjects/CGHeroInstance.h b/lib/mapObjects/CGHeroInstance.h index b7752e684..73f93901f 100644 --- a/lib/mapObjects/CGHeroInstance.h +++ b/lib/mapObjects/CGHeroInstance.h @@ -146,6 +146,7 @@ public: ////////////////////////////////////////////////////////////////////////// bool hasSpellbook() const; + int maxSpellLevel() const; EAlignment::EAlignment getAlignment() const; const std::string &getBiography() const; bool needsLastStack()const override; diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index 2d66a9c02..e8000ec6f 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -1601,7 +1601,7 @@ void CGShrine::onHeroVisit( const CGHeroInstance * h ) const { iw.text.addTxt(MetaString::ADVOB_TXT,174); } - else if(ID == Obj::SHRINE_OF_MAGIC_THOUGHT && !h->getSecSkillLevel(SecondarySkill::WISDOM)) //it's third level spell and hero doesn't have wisdom + else if(ID == Obj::SHRINE_OF_MAGIC_THOUGHT && h->maxSpellLevel() < 3) //it's third level spell and hero doesn't have wisdom { iw.text.addTxt(MetaString::ADVOB_TXT,130); } diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 9aeadd2fb..329e5b5a0 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1974,7 +1974,7 @@ void CGameHandler::giveSpells(const CGTownInstance *t, const CGHeroInstance *h) if (t->hasBuilt(BuildingID::GRAIL, ETownType::CONFLUX) && t->hasBuilt(BuildingID::MAGES_GUILD_1)) { // Aurora Borealis give spells of all levels even if only level 1 mages guild built - for (int i = 0; i < h->getSecSkillLevel(SecondarySkill::WISDOM)+2; i++) + for (int i = 0; i < h->maxSpellLevel(); i++) { std::vector spells; getAllowedSpells(spells, i+1); @@ -1984,7 +1984,7 @@ void CGameHandler::giveSpells(const CGTownInstance *t, const CGHeroInstance *h) } else { - for (int i = 0; i < std::min(t->mageGuildLevel(), h->getSecSkillLevel(SecondarySkill::WISDOM)+2); i++) + for (int i = 0; i < std::min(t->mageGuildLevel(), h->maxSpellLevel()); i++) { for (int j = 0; j < t->spellsAtLevel(i+1, true) && j < t->spells.at(i).size(); j++) { @@ -2501,8 +2501,8 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t if (!ScholarLevel || !h1->hasSpellbook() || !h2->hasSpellbook()) return;//no scholar skill or no spellbook - int h1Lvl = std::min(ScholarLevel+1, h1->getSecSkillLevel(SecondarySkill::WISDOM)+2), - h2Lvl = std::min(ScholarLevel+1, h2->getSecSkillLevel(SecondarySkill::WISDOM)+2);//heroes can receive this levels + int h1Lvl = std::min(ScholarLevel+1, h1->maxSpellLevel()), + h2Lvl = std::min(ScholarLevel+1, h2->maxSpellLevel());//heroes can receive this levels ChangeSpells cs1; cs1.learn = true;