mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-05 15:05:40 +02:00
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.
This commit is contained in:
parent
bdbb9d02fc
commit
af7d5c7f7f
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user