mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-14 10:12:59 +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:
parent
83ffbdff2b
commit
f8f10adb2e
@ -149,7 +149,7 @@ bool HeroPtr::operator==(const HeroPtr & rhs) const
|
||||
|
||||
bool isSafeToVisit(const CGHeroInstance * h, const CCreatureSet * heroArmy, uint64_t dangerStrength)
|
||||
{
|
||||
const ui64 heroStrength = h->getFightingStrength() * heroArmy->getArmyStrength();
|
||||
const ui64 heroStrength = h->getHeroStrength() * heroArmy->getArmyStrength();
|
||||
|
||||
if(dangerStrength)
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ void HeroManager::update()
|
||||
for(auto & hero : myHeroes)
|
||||
{
|
||||
scores[hero] = evaluateFightingStrength(hero);
|
||||
knownFightingStrength[hero->id] = hero->getFightingStrength();
|
||||
knownFightingStrength[hero->id] = hero->getHeroStrength();
|
||||
}
|
||||
|
||||
auto scoreSort = [&](const CGHeroInstance * h1, const CGHeroInstance * h2) -> bool
|
||||
@ -205,7 +205,7 @@ float HeroManager::getFightingStrengthCached(const CGHeroInstance * hero) const
|
||||
auto cached = knownFightingStrength.find(hero->id);
|
||||
|
||||
//FIXME: fallback to hero->getFightingStrength() is VERY slow on higher difficulties (no object graph? map reveal?)
|
||||
return cached != knownFightingStrength.end() ? cached->second : hero->getFightingStrength();
|
||||
return cached != knownFightingStrength.end() ? cached->second : hero->getHeroStrength();
|
||||
}
|
||||
|
||||
float HeroManager::getMagicStrength(const CGHeroInstance * hero) const
|
||||
@ -298,7 +298,7 @@ const CGHeroInstance * HeroManager::findWeakHeroToDismiss(uint64_t armyLimit) co
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!weakestHero || weakestHero->getFightingStrength() > existingHero->getFightingStrength())
|
||||
if(!weakestHero || weakestHero->getHeroStrength() > existingHero->getHeroStrength())
|
||||
{
|
||||
weakestHero = existingHero;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ ChainActor::ChainActor(const CGHeroInstance * hero, HeroRole heroRole, uint64_t
|
||||
initialMovement = hero->movementPointsRemaining();
|
||||
initialTurn = 0;
|
||||
armyValue = getHeroArmyStrengthWithCommander(hero, hero);
|
||||
heroFightingStrength = hero->getFightingStrength();
|
||||
heroFightingStrength = hero->getHeroStrength();
|
||||
tiCache.reset(new TurnInfo(hero));
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user