Explorar el Código

Update RecruitHeroBehavior.cpp

Don't hire a hero in a town where another hero is currently defending against a threat. This would mean one of them has to stay outside and be exposed.
Xilmi hace 1 año
padre
commit
af7d5c7f7f
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. 10 0
      AI/Nullkiller/Behaviors/RecruitHeroBehavior.cpp

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

@@ -54,9 +54,19 @@ Goals::TGoalVec RecruitHeroBehavior::decompose(const Nullkiller * ai) const
 	const CGTownInstance* bestTownToHireFrom = nullptr;
 	float bestScore = 0;
 	bool haveCapitol = false;
+
+	ai->dangerHitMap->updateHitMap();
 	
 	for(auto town : towns)
 	{
+		uint8_t closestThreat = UINT8_MAX;
+		for (auto threat : ai->dangerHitMap->getTownThreats(town))
+		{
+			closestThreat = std::min(closestThreat, threat.turn);
+		}
+		//Don' hire a hero in a threatened town as one would have to stay outside
+		if (closestThreat <= 1 && (town->visitingHero || town->garrisonHero))
+			continue;
 		if(ai->heroManager->canRecruitHero(town))
 		{
 			auto availableHeroes = ai->cb->getAvailableHeroes(town);