1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Take magic-capability into account for overall strength-estimation of hero-lead-armies

The magic-strength of a hero now checks if the hero has a spellbook and at least one combat-spell.
The impact of knowledge and spellpower to the hero's magic-strength is now also depending on it's current and max mana-pool-size as an empty mana-pool does not exactly contribute well to fights.

Replaced every call of getFightingStrength() with getHeroStrength() which uses both the fightingStrength and the (reworked) magicStrength to guess how much stronger a hero-lead army is.
This commit is contained in:
Xilmi
2024-07-15 17:42:02 +02:00
parent 83ffbdff2b
commit f8f10adb2e
4 changed files with 20 additions and 7 deletions

View File

@@ -651,7 +651,20 @@ double CGHeroInstance::getFightingStrength() const
double CGHeroInstance::getMagicStrength() const
{
return sqrt((1.0 + 0.05*getPrimSkillLevel(PrimarySkill::KNOWLEDGE)) * (1.0 + 0.05*getPrimSkillLevel(PrimarySkill::SPELL_POWER)));
if (!hasSpellbook())
return 1;
bool atLeastOneCombatSpell = false;
for (auto spell : spells)
{
if (spellbookContainsSpell(spell) && spell.toSpell()->isCombat())
{
atLeastOneCombatSpell = true;
break;
}
}
if (!atLeastOneCombatSpell)
return 1;
return sqrt((1.0 + 0.05*getPrimSkillLevel(PrimarySkill::KNOWLEDGE) * mana / manaLimit()) * (1.0 + 0.05*getPrimSkillLevel(PrimarySkill::SPELL_POWER) * mana / manaLimit()));
}
double CGHeroInstance::getHeroStrength() const
@@ -661,7 +674,7 @@ double CGHeroInstance::getHeroStrength() const
ui64 CGHeroInstance::getTotalStrength() const
{
double ret = getFightingStrength() * getArmyStrength();
double ret = getHeroStrength() * getArmyStrength();
return static_cast<ui64>(ret);
}