mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
added bonus type SECONDARY_SKILL_VAL2; refactored CSkillHandler::defaultBonus; made eagleEye level bonus-based
This commit is contained in:
parent
9bbfb57b93
commit
25e6b5cc07
@ -369,6 +369,59 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"eagleEye" : {
|
||||
"basic" : {
|
||||
"description" : "",
|
||||
"effects" : [
|
||||
{
|
||||
"subtype" : "skill.eagleEye",
|
||||
"type" : "SECONDARY_SKILL_PREMY",
|
||||
"val" : 40,
|
||||
"valueType" : "BASE_NUMBER"
|
||||
},
|
||||
{
|
||||
"subtype" : "skill.eagleEye",
|
||||
"type" : "SECONDARY_SKILL_VAL2",
|
||||
"val" : 2,
|
||||
"valueType" : "BASE_NUMBER"
|
||||
}
|
||||
]
|
||||
},
|
||||
"advanced" : {
|
||||
"description" : "",
|
||||
"effects" : [
|
||||
{
|
||||
"subtype" : "skill.eagleEye",
|
||||
"type" : "SECONDARY_SKILL_PREMY",
|
||||
"val" : 50,
|
||||
"valueType" : "BASE_NUMBER"
|
||||
},
|
||||
{
|
||||
"subtype" : "skill.eagleEye",
|
||||
"type" : "SECONDARY_SKILL_VAL2",
|
||||
"val" : 3,
|
||||
"valueType" : "BASE_NUMBER"
|
||||
}
|
||||
]
|
||||
},
|
||||
"expert" : {
|
||||
"description" : "",
|
||||
"effects" : [
|
||||
{
|
||||
"subtype" : "skill.eagleEye",
|
||||
"type" : "SECONDARY_SKILL_PREMY",
|
||||
"val" : 60,
|
||||
"valueType" : "BASE_NUMBER"
|
||||
},
|
||||
{
|
||||
"subtype" : "skill.eagleEye",
|
||||
"type" : "SECONDARY_SKILL_VAL2",
|
||||
"val" : 4,
|
||||
"valueType" : "BASE_NUMBER"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"estates" : {
|
||||
"basic" : {
|
||||
"description" : "With Basic Estates, a hero contributes 125 gold per day to your cause.",
|
||||
|
@ -54,6 +54,7 @@ CSkill::~CSkill()
|
||||
void CSkill::addNewBonus(const std::shared_ptr<Bonus>& b, int level)
|
||||
{
|
||||
b->source = Bonus::SECONDARY_SKILL;
|
||||
b->sid = id;
|
||||
b->duration = Bonus::PERMANENT;
|
||||
b->description = identifier;
|
||||
levels[level-1].effects.push_back(b);
|
||||
@ -104,7 +105,8 @@ CSkillHandler::CSkillHandler()
|
||||
{
|
||||
CSkill * skill = new CSkill(SecondarySkill(id));
|
||||
for(int level = 1; level < NSecondarySkill::levels.size(); level++)
|
||||
skill->addNewBonus(defaultBonus(SecondarySkill(id), level), level);
|
||||
for (auto bonus : defaultBonus(SecondarySkill(id), level))
|
||||
skill->addNewBonus(bonus, level);
|
||||
objects.push_back(skill);
|
||||
}
|
||||
}
|
||||
@ -209,56 +211,61 @@ std::vector<bool> CSkillHandler::getDefaultAllowed() const
|
||||
}
|
||||
|
||||
// HMM3 default bonus provided by secondary skill
|
||||
const std::shared_ptr<Bonus> CSkillHandler::defaultBonus(SecondarySkill skill, int level) const
|
||||
std::vector<std::shared_ptr<Bonus>> CSkillHandler::defaultBonus(SecondarySkill skill, int level) const
|
||||
{
|
||||
Bonus::BonusType bonusType = Bonus::SECONDARY_SKILL_PREMY;
|
||||
Bonus::ValueType valueType = Bonus::BASE_NUMBER;
|
||||
int bonusVal = level;
|
||||
std::vector<std::shared_ptr<Bonus>> result;
|
||||
|
||||
switch (skill)
|
||||
// add bonus based on current values - useful for adding multiple bonuses easily
|
||||
auto addBonus = [=,&result](int bonusVal, Bonus::BonusType bonusType = Bonus::SECONDARY_SKILL_PREMY) {
|
||||
int subtype = (bonusType == Bonus::SECONDARY_SKILL_PREMY || bonusType == Bonus::SECONDARY_SKILL_VAL2) ? skill : 0;
|
||||
result.push_back(std::make_shared<Bonus>(Bonus::PERMANENT, bonusType, Bonus::SECONDARY_SKILL, bonusVal, skill, subtype, Bonus::BASE_NUMBER));
|
||||
};
|
||||
|
||||
switch(skill)
|
||||
{
|
||||
case SecondarySkill::PATHFINDING:
|
||||
bonusVal = 25 * level; break;
|
||||
addBonus(25 * level); break;
|
||||
case SecondarySkill::ARCHERY:
|
||||
bonusVal = 5 + 5 * level * level; break;
|
||||
addBonus(5 + 5 * level * level); break;
|
||||
case SecondarySkill::LOGISTICS:
|
||||
bonusVal = 10 * level; break;
|
||||
addBonus(10 * level); break;
|
||||
case SecondarySkill::SCOUTING:
|
||||
bonusType = Bonus::SIGHT_RADIOUS; break;
|
||||
addBonus(level, Bonus::SIGHT_RADIOUS); break;
|
||||
case SecondarySkill::DIPLOMACY:
|
||||
bonusType = Bonus::SURRENDER_DISCOUNT;
|
||||
bonusVal = 20 * level; break;
|
||||
addBonus(20 * level, Bonus::SURRENDER_DISCOUNT); break;
|
||||
case SecondarySkill::NAVIGATION:
|
||||
bonusVal = 50 * level; break;
|
||||
addBonus(50 * level); break;
|
||||
case SecondarySkill::LEADERSHIP:
|
||||
bonusType = Bonus::MORALE; break;
|
||||
addBonus(level, Bonus::MORALE); break;
|
||||
case SecondarySkill::LUCK:
|
||||
bonusType = Bonus::LUCK; break;
|
||||
addBonus(level, Bonus::LUCK); break;
|
||||
case SecondarySkill::EAGLE_EYE:
|
||||
bonusVal = 30 + 10 * level; break;
|
||||
case SecondarySkill::NECROMANCY:
|
||||
bonusVal = 10 * level; break;
|
||||
case SecondarySkill::ESTATES:
|
||||
bonusVal = 125 << (level-1); break;
|
||||
case SecondarySkill::TACTICS:
|
||||
bonusVal = 1 + 2 * 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;
|
||||
default:
|
||||
addBonus(30 + 10 * level);
|
||||
addBonus(1 + level, Bonus::SECONDARY_SKILL_VAL2);
|
||||
break;
|
||||
case SecondarySkill::NECROMANCY:
|
||||
addBonus(10 * level); break;
|
||||
case SecondarySkill::ESTATES:
|
||||
addBonus(125 << (level-1)); break;
|
||||
case SecondarySkill::TACTICS:
|
||||
addBonus(1 + 2 * level); break;
|
||||
case SecondarySkill::LEARNING:
|
||||
addBonus(5 * level); break;
|
||||
case SecondarySkill::OFFENCE:
|
||||
addBonus(10 * level); break;
|
||||
case SecondarySkill::ARMORER:
|
||||
addBonus(5 * level); break;
|
||||
case SecondarySkill::INTELLIGENCE:
|
||||
addBonus(25 << (level-1)); break;
|
||||
case SecondarySkill::SORCERY:
|
||||
addBonus(5 * level); break;
|
||||
case SecondarySkill::RESISTANCE:
|
||||
addBonus(5 << (level-1)); break;
|
||||
case SecondarySkill::FIRST_AID:
|
||||
addBonus(25 + 25 * level); break;
|
||||
default:
|
||||
addBonus(level); break;
|
||||
}
|
||||
|
||||
return std::make_shared<Bonus>(Bonus::PERMANENT, bonusType, Bonus::SECONDARY_SKILL, bonusVal, skill, skill, valueType);
|
||||
return result;
|
||||
}
|
||||
|
@ -84,5 +84,5 @@ public:
|
||||
|
||||
protected:
|
||||
CSkill * loadFromJson(const JsonNode & json, const std::string & identifier) override;
|
||||
const std::shared_ptr<Bonus> defaultBonus(SecondarySkill skill, int level) const;
|
||||
std::vector<std::shared_ptr<Bonus>> defaultBonus(SecondarySkill skill, int level) const;
|
||||
};
|
||||
|
@ -95,6 +95,7 @@ private:
|
||||
BONUS_NAME(FULL_MANA_REGENERATION) /*all mana points are replenished every day*/ \
|
||||
BONUS_NAME(NONEVIL_ALIGNMENT_MIX) /*good and neutral creatures can be mixed without morale penalty*/ \
|
||||
BONUS_NAME(SECONDARY_SKILL_PREMY) /*%*/ \
|
||||
BONUS_NAME(SECONDARY_SKILL_VAL2) /*for secondary skills that have multiple effects, like eagle eye (max level and chance)*/ \
|
||||
BONUS_NAME(SURRENDER_DISCOUNT) /*%*/ \
|
||||
BONUS_NAME(STACKS_SPEED) /*additional info - percent of speed bonus applied after direct bonuses; >0 - added, <0 - subtracted to this part*/ \
|
||||
BONUS_NAME(FLYING_MOVEMENT) /*value - penalty percentage*/ \
|
||||
|
@ -592,12 +592,11 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
|
||||
|
||||
if (finishingBattle->winnerHero)
|
||||
{
|
||||
if (int eagleEyeLevel = finishingBattle->winnerHero->getSecSkillLevel(SecondarySkill::EAGLE_EYE))
|
||||
if (int eagleEyeLevel = finishingBattle->winnerHero->valOfBonuses(Bonus::SECONDARY_SKILL_VAL2, SecondarySkill::EAGLE_EYE))
|
||||
{
|
||||
int maxLevel = eagleEyeLevel + 1;
|
||||
double eagleEyeChance = finishingBattle->winnerHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::EAGLE_EYE);
|
||||
for (const CSpell *sp : gs->curB->sides.at(!battleResult.data->winner).usedSpellsHistory)
|
||||
if (sp->level <= maxLevel && !vstd::contains(finishingBattle->winnerHero->spells, sp->id) && getRandomGenerator().nextInt(99) < eagleEyeChance)
|
||||
if (sp->level <= eagleEyeLevel && !vstd::contains(finishingBattle->winnerHero->spells, sp->id) && getRandomGenerator().nextInt(99) < eagleEyeChance)
|
||||
cs.spells.insert(sp->id);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user