mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
#3824 - fix cluster unlock
This commit is contained in:
parent
6e641dbdea
commit
afa766c763
@ -100,7 +100,7 @@ Goals::TGoalVec ClusterBehavior::decomposeCluster(const Nullkiller * ai, std::sh
|
||||
logAi->trace("Decompose unlock paths");
|
||||
#endif
|
||||
|
||||
auto unlockTasks = CaptureObjectsBehavior::getVisitGoals(blockerPaths, ai);
|
||||
auto unlockTasks = CaptureObjectsBehavior::getVisitGoals(blockerPaths, ai, cluster->blocker);
|
||||
|
||||
for(int i = 0; i < paths.size(); i++)
|
||||
{
|
||||
|
@ -375,12 +375,14 @@ void Nullkiller::makeTurn()
|
||||
if(cb->getPlayerStatus(playerID) != EPlayerStatus::INGAME)
|
||||
return;
|
||||
|
||||
std::string taskDescription = bestTask->toString();
|
||||
HeroPtr hero = bestTask->getHero();
|
||||
HeroRole heroRole = HeroRole::MAIN;
|
||||
if(!areAffectedObjectsPresent(bestTask))
|
||||
{
|
||||
logAi->debug("Affected object not found. Canceling task.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(hero.validAndSet())
|
||||
heroRole = heroManager->getHeroRole(hero);
|
||||
std::string taskDescription = bestTask->toString();
|
||||
HeroRole heroRole = getTaskRole(bestTask);
|
||||
|
||||
if(heroRole != HeroRole::MAIN || bestTask->getHeroExchangeCount() <= 1)
|
||||
useHeroChain = false;
|
||||
@ -448,6 +450,30 @@ void Nullkiller::makeTurn()
|
||||
}
|
||||
}
|
||||
|
||||
bool Nullkiller::areAffectedObjectsPresent(Goals::TTask task) const
|
||||
{
|
||||
auto affectedObjs = task->getAffectedObjects();
|
||||
|
||||
for(auto oid : affectedObjs)
|
||||
{
|
||||
if(!cb->getObj(oid, false))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
HeroRole Nullkiller::getTaskRole(Goals::TTask task) const
|
||||
{
|
||||
HeroPtr hero = task->getHero();
|
||||
HeroRole heroRole = HeroRole::MAIN;
|
||||
|
||||
if(hero.validAndSet())
|
||||
heroRole = heroManager->getHeroRole(hero);
|
||||
|
||||
return heroRole;
|
||||
}
|
||||
|
||||
bool Nullkiller::executeTask(Goals::TTask task)
|
||||
{
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
@ -124,6 +124,8 @@ private:
|
||||
Goals::TTask choseBestTask(Goals::TGoalVec & tasks) const;
|
||||
Goals::TTaskVec buildPlan(Goals::TGoalVec & tasks) const;
|
||||
bool executeTask(Goals::TTask task);
|
||||
bool areAffectedObjectsPresent(Goals::TTask task) const;
|
||||
HeroRole getTaskRole(Goals::TTask task) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ namespace Goals
|
||||
{
|
||||
tile = cluster->blocker->visitablePos();
|
||||
hero = pathToCenter.targetHero;
|
||||
objid = cluster->blocker->id;
|
||||
}
|
||||
|
||||
bool operator==(const UnlockCluster & other) const override;
|
||||
|
Loading…
Reference in New Issue
Block a user