Переглянути джерело

maxRoamingHeroesPerTown as configuration

Mircea TheHonestCTO 4 місяців тому
батько
коміт
8789f83a90
1 змінених файлів з 6 додано та 1 видалено
  1. 6 1
      AI/Nullkiller2/Analyzers/HeroManager.cpp

+ 6 - 1
AI/Nullkiller2/Analyzers/HeroManager.cpp

@@ -196,8 +196,13 @@ float HeroManager::evaluateHero(const CGHeroInstance * hero) const
 bool HeroManager::heroCapReached(bool includeGarrisoned) const
 {
 	int heroCount = cc->getHeroCount(aiNk->playerID, includeGarrisoned);
+	int maxAllowed = aiNk->settings->getMaxRoamingHeroes();
+	if (aiNk->settings->getMaxRoamingHeroesPerTown() > 0)
+	{
+		maxAllowed += cc->howManyTowns() * aiNk->settings->getMaxRoamingHeroesPerTown();
+	}
 
-	return heroCount >= aiNk->settings->getMaxRoamingHeroes()
+	return heroCount >= maxAllowed
 		|| heroCount >= cc->getSettings().getInteger(EGameSettings::HEROES_PER_PLAYER_ON_MAP_CAP)
 		|| heroCount >= cc->getSettings().getInteger(EGameSettings::HEROES_PER_PLAYER_TOTAL_CAP);
 }