1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

AI: danger hitmap using visible enemy heroes

This commit is contained in:
Andrii Danylchenko
2021-05-15 21:57:36 +03:00
committed by Andrii Danylchenko
parent 04bf6f536d
commit 4bf653f596
9 changed files with 146 additions and 8 deletions

View File

@@ -9,6 +9,7 @@
*/
#include "StdInc.h"
#include "../VCAI.h"
#include "../Engine/Nullkiller.h"
#include "../AIhelper.h"
#include "../Goals/ExecuteHeroChain.h"
#include "CaptureObjectsBehavior.h"
@@ -47,6 +48,7 @@ Goals::TGoalVec CaptureObjectsBehavior::getTasks()
continue;
const int3 pos = objToVisit->visitablePos();
auto paths = ai->ah->getPathsToTile(pos);
std::vector<std::shared_ptr<ExecuteHeroChain>> waysToVisitObj;
std::shared_ptr<ExecuteHeroChain> closestWay;
@@ -61,6 +63,14 @@ Goals::TGoalVec CaptureObjectsBehavior::getTasks()
logAi->trace("Path found %s", path.toString());
#endif
if(ai->nullkiller->dangerHitMap->enemyCanKillOurHeroesAlongThePath(path))
{
#ifdef VCMI_TRACE_PATHFINDER
logAi->trace("Ignore path. Target hero can be killed by enemy");
#endif
continue;
}
if(!shouldVisit(path.targetHero, objToVisit))
continue;