Browse Source

Update RecruitHeroBehavior.cpp

Modified how to score what hero to hire to make it more likely to rehire fled heroes with high levels when the army-gain from the hero would be rather insignificant.
Xilmi 1 year ago
parent
commit
37f9f93948
1 changed files with 3 additions and 1 deletions
  1. 3 1
      AI/Nullkiller/Behaviors/RecruitHeroBehavior.cpp

+ 3 - 1
AI/Nullkiller/Behaviors/RecruitHeroBehavior.cpp

@@ -32,9 +32,11 @@ Goals::TGoalVec RecruitHeroBehavior::decompose(const Nullkiller * ai) const
 
 	auto ourHeroes = ai->heroManager->getHeroRoles();
 	auto minScoreToHireMain = std::numeric_limits<float>::max();
+	int currentArmyValue = 0;
 
 	for(auto hero : ourHeroes)
 	{
+		currentArmyValue += hero.first->getArmyCost();
 		if(hero.second != HeroRole::MAIN)
 			continue;
 
@@ -84,7 +86,7 @@ Goals::TGoalVec RecruitHeroBehavior::decompose(const Nullkiller * ai) const
 				{
 					score *= score / minScoreToHireMain;
 				}
-				score *= hero->getArmyCost();
+				score *= (hero->getArmyCost() + currentArmyValue);
 				if (hero->type->heroClass->faction == town->getFaction())
 					score *= 1.5;
 				if (vstd::isAlmostZero(visitability))