Browse Source

Be less wasteful with hiring heroes

When an enemy is near our city that currently has a hero hiding in it, we don't buy a hero without army as that one would be forced to wait outside and likely be killed.
Xilmi 10 months ago
parent
commit
aff73b6e65
1 changed files with 4 additions and 0 deletions
  1. 4 0
      AI/Nullkiller/Behaviors/RecruitHeroBehavior.cpp

+ 4 - 0
AI/Nullkiller/Behaviors/RecruitHeroBehavior.cpp

@@ -97,6 +97,10 @@ Goals::TGoalVec RecruitHeroBehavior::decompose(const Nullkiller * ai) const
 
 			for(auto hero : availableHeroes)
 			{
+				if ((town->visitingHero || town->garrisonHero) 
+					&& closestThreat < 0
+					&& hero->getArmyCost() < GameConstants::HERO_GOLD_COST / 3.0)
+					continue;
 				auto score = ai->heroManager->evaluateHero(hero);
 				if(score > minScoreToHireMain)
 				{