|
@@ -41,9 +41,6 @@ Goals::TGoalVec DefenceBehavior::decompose(const Nullkiller * ai) const
|
|
|
for(auto town : ai->cb->getTownsInfo())
|
|
|
{
|
|
|
evaluateDefence(tasks, town, ai);
|
|
|
- //Let's do only one defence-task per pass since otherwise it can try to hire the same hero twice
|
|
|
- if (!tasks.empty())
|
|
|
- break;
|
|
|
}
|
|
|
|
|
|
return tasks;
|
|
@@ -422,6 +419,18 @@ void DefenceBehavior::evaluateRecruitingHero(Goals::TGoalVec & tasks, const HitM
|
|
|
if(hero->getTotalStrength() < threat.danger)
|
|
|
continue;
|
|
|
|
|
|
+ bool heroAlreadyHiredInOtherTown = false;
|
|
|
+ for (const auto& task : tasks)
|
|
|
+ {
|
|
|
+ if (auto recruitGoal = dynamic_cast<Goals::RecruitHero*>(task.get()))
|
|
|
+ {
|
|
|
+ if (recruitGoal->getHero() == hero)
|
|
|
+ heroAlreadyHiredInOtherTown = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (heroAlreadyHiredInOtherTown)
|
|
|
+ continue;
|
|
|
+
|
|
|
auto myHeroes = ai->cb->getHeroesInfo();
|
|
|
|
|
|
#if NKAI_TRACE_LEVEL >= 1
|