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

Optimized getHeroStrength method

- replaced 4x access to bonus system with single access
- fixed formula for Diplomacy
- fxied formula for hero transfer in campaigns
- removed pointless sqrt(pow()) construct
This commit is contained in:
Ivan Savenko
2024-12-22 14:49:35 +00:00
parent 5caf12f22f
commit e035cf9e63
7 changed files with 89 additions and 29 deletions

View File

@@ -336,7 +336,7 @@ void CGCreature::setPropertyDer(ObjProperty what, ObjPropertyID identifier)
int CGCreature::takenAction(const CGHeroInstance *h, bool allowJoin) const
{
//calculate relative strength of hero and creatures armies
double relStrength = static_cast<double>(h->getTotalStrength()) / getArmyStrength();
double relStrength = static_cast<double>(h->getValueForDiplomacy()) / getArmyStrength();
int powerFactor;
if(relStrength >= 7)