diff --git a/lib/CSkillHandler.cpp b/lib/CSkillHandler.cpp index 7f7f7fa5a..267b9f388 100644 --- a/lib/CSkillHandler.cpp +++ b/lib/CSkillHandler.cpp @@ -54,6 +54,10 @@ BonusList CSkill::getBonus(int level) ///CSkillHandler CSkillHandler::CSkillHandler() { + for(int id = 0; id < GameConstants::SKILL_QUANTITY; id++) + { + //TODO + } } std::vector CSkillHandler::loadLegacyData(size_t dataSize) @@ -114,3 +118,55 @@ std::vector CSkillHandler::getDefaultAllowed() const std::vector allowedSkills(objects.size(), true); return allowedSkills; } + +// HMM3 default bonus provided by secondary skill +const std::shared_ptr CSkillHandler::defaultBonus(SecondarySkill skill, int level) const +{ + Bonus::BonusType bonusType = Bonus::SECONDARY_SKILL_PREMY; + Bonus::ValueType valueType = Bonus::BASE_NUMBER; + int bonusVal = level; + + static const int archery_bonus[] = { 10, 25, 50 }; + switch (skill) + { + case SecondarySkill::LEADERSHIP: + bonusType = Bonus::MORALE; break; + case SecondarySkill::LUCK: + bonusType = Bonus::LUCK; break; + case SecondarySkill::DIPLOMACY: + bonusType = Bonus::SURRENDER_DISCOUNT; + bonusVal = 20 * level; break; + case SecondarySkill::ARCHERY: + bonusVal = archery_bonus[level-1]; break; + case SecondarySkill::LOGISTICS: + bonusVal = 10 * level; break; + case SecondarySkill::NAVIGATION: + bonusVal = 50 * level; break; + case SecondarySkill::MYSTICISM: + bonusVal = level; break; + case SecondarySkill::EAGLE_EYE: + bonusVal = 30 + 10 * level; break; + case SecondarySkill::NECROMANCY: + bonusVal = 10 * level; break; + case SecondarySkill::LEARNING: + bonusVal = 5 * level; break; + case SecondarySkill::OFFENCE: + bonusVal = 10 * level; break; + case SecondarySkill::ARMORER: + bonusVal = 5 * level; break; + case SecondarySkill::INTELLIGENCE: + bonusVal = 25 << (level-1); break; + case SecondarySkill::SORCERY: + bonusVal = 5 * level; break; + case SecondarySkill::RESISTANCE: + bonusVal = 5 << (level-1); break; + case SecondarySkill::FIRST_AID: + bonusVal = 25 + 25 * level; break; + case SecondarySkill::ESTATES: + bonusVal = 125 << (level-1); break; + default: + valueType = Bonus::INDEPENDENT_MIN; break; + } + + return std::make_shared(Bonus::PERMANENT, bonusType, Bonus::SECONDARY_SKILL, bonusVal, skill, skill, valueType); +} diff --git a/lib/CSkillHandler.h b/lib/CSkillHandler.h index e29c06fba..26227f154 100644 --- a/lib/CSkillHandler.h +++ b/lib/CSkillHandler.h @@ -63,4 +63,5 @@ public: protected: CSkill * loadFromJson(const JsonNode & json, const std::string & identifier) override; + const std::shared_ptr defaultBonus(SecondarySkill skill, int level) const; }; diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 2884e6e91..fee3134d4 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -17,6 +17,7 @@ #include "../CModHandler.h" #include "../CSoundBase.h" #include "../spells/CSpellHandler.h" +#include "../CSkillHandler.h" #include "CObjectClassesHandler.h" #include "../IGameCallback.h" #include "../CGameState.h" @@ -765,6 +766,11 @@ void CGHeroInstance::recreateSecondarySkillsBonuses() void CGHeroInstance::updateSkill(SecondarySkill which, int val) { + BonusList skillBonus = (*VLC->skillh)[which]->getBonus(val); + for (auto b : skillBonus) + addNewBonus(std::make_shared(*b)); + + /* if(which == SecondarySkill::LEADERSHIP || which == SecondarySkill::LUCK) { //luck-> VLC->generaltexth->arraytxt[73+luckSkill]; VLC->generaltexth->arraytxt[104+moraleSkill] bool luck = which == SecondarySkill::LUCK; @@ -844,6 +850,7 @@ void CGHeroInstance::updateSkill(SecondarySkill which, int val) bonus->source = Bonus::SECONDARY_SKILL; addNewBonus(bonus); } + */ CBonusSystemNode::treeHasChanged(); }