mirror of
https://github.com/vcmi/vcmi.git
synced 2026-06-19 22:57:37 +02:00
Fix The AI can't find me #7410
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "../Goals/CaptureObject.h"
|
||||
#include "../Goals/ExploreNeighbourTile.h"
|
||||
#include "../Helpers/ExplorationHelper.h"
|
||||
#include "../../../lib/CPlayerState.h"
|
||||
|
||||
namespace NK2AI
|
||||
{
|
||||
@@ -54,16 +55,30 @@ Goals::TGoalVec ExplorationBehavior::decompose(const Nullkiller * aiNk) const
|
||||
case Obj::SUBTERRANEAN_GATE:
|
||||
case Obj::WHIRLPOOL:
|
||||
{
|
||||
const auto tObj = dynamic_cast<const CGTeleport*>(obj);
|
||||
for (auto exit : aiNk->cc->getTeleportChannelExits(tObj->channel))
|
||||
const auto tObj = dynamic_cast<const CGTeleport *>(obj);
|
||||
for(auto exit : aiNk->cc->getTeleportChannelExits(tObj->channel))
|
||||
{
|
||||
if (exit != tObj->id)
|
||||
if(exit != tObj->id)
|
||||
{
|
||||
// TODO: Mircea: Looks like a bug. Should use isVisibleFor with aiNk->playerID
|
||||
if (!aiNk->cc->isVisible(aiNk->cc->getObjInstance(exit)))
|
||||
bool isExplored = false;
|
||||
const CGObjectInstance * exitObj = aiNk->cc->getObjInstance(exit);
|
||||
|
||||
if(exitObj)
|
||||
{
|
||||
const auto teamState = aiNk->cc->getPlayerTeam(aiNk->playerID);
|
||||
if(teamState && teamState->fogOfWarMap[exitObj->visitablePos()])
|
||||
{
|
||||
isExplored = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isExplored)
|
||||
{
|
||||
tasks.push_back(sptr(Composition().addNext(ExplorationPoint(obj->visitablePos(), 50)).addNext(CaptureObject(obj))));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -819,7 +819,14 @@ public:
|
||||
if(evaluationContext.evaluator.aiNk->cc->getTile(task->tile)->roadType != RoadId::NO_ROAD)
|
||||
evaluationContext.explorePriority = 1;
|
||||
if(evaluationContext.explorePriority == 0)
|
||||
evaluationContext.explorePriority = 3;
|
||||
{
|
||||
if(tilesDiscovered >= 20)
|
||||
evaluationContext.explorePriority = 1;
|
||||
else if(tilesDiscovered >= 10)
|
||||
evaluationContext.explorePriority = 2;
|
||||
else
|
||||
evaluationContext.explorePriority = 3;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user