mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-29 21:56:54 +02:00
- More fixes for wander targets
- SectorMap won't find paths through the rock
This commit is contained in:
parent
d32461d9d1
commit
3e8c395156
@ -632,7 +632,7 @@ TGoalVec Explore::getAllPossibleSubgoals()
|
||||
for (auto obj : objs) //double loop, performance risk?
|
||||
{
|
||||
auto t = sm.firstTileToGet(h, obj->visitablePos()); //we assume that no more than one tile on the way is guarded
|
||||
if (ai->canReachTile(h, t))
|
||||
if (ai->isTileNotReserved(h, t))
|
||||
ret.push_back (sptr(Goals::ClearWayTo(obj->visitablePos(), h).setisAbstract(true)));
|
||||
}
|
||||
|
||||
@ -968,7 +968,7 @@ TGoalVec Conquer::getAllPossibleSubgoals()
|
||||
for (auto obj : ourObjs) //double loop, performance risk?
|
||||
{
|
||||
auto t = sm.firstTileToGet(h, obj->visitablePos()); //we assume that no more than one tile on the way is guarded
|
||||
if (ai->canReachTile(h, t))
|
||||
if (ai->isTileNotReserved(h, t))
|
||||
ret.push_back (sptr(Goals::ClearWayTo(obj->visitablePos(), h).setisAbstract(true)));
|
||||
}
|
||||
}
|
||||
|
@ -1348,13 +1348,16 @@ bool VCAI::isGoodForVisit(const CGObjectInstance *obj, HeroPtr h, SectorMap &sm)
|
||||
{
|
||||
const int3 pos = obj->visitablePos();
|
||||
const int3 targetPos = sm.firstTileToGet(h, pos);
|
||||
if (canReachTile(h.get(), targetPos) &&
|
||||
if (!targetPos.valid())
|
||||
return false;
|
||||
if (isTileNotReserved(h.get(), targetPos) &&
|
||||
!obj->wasVisited(playerID) &&
|
||||
(cb->getPlayerRelations(ai->playerID, obj->tempOwner) == PlayerRelations::ENEMIES || isWeeklyRevisitable(obj)) && //flag or get weekly resources / creatures
|
||||
isSafeToVisit(h, pos) &&
|
||||
shouldVisit(h, obj) &&
|
||||
!vstd::contains(alreadyVisited, obj) &&
|
||||
!vstd::contains(reservedObjs, obj))
|
||||
!vstd::contains(reservedObjs, obj) &&
|
||||
isAccessibleForHero(targetPos, h))
|
||||
{
|
||||
const CGObjectInstance *topObj = cb->getVisitableObjs(obj->visitablePos()).back(); //it may be hero visiting this obj
|
||||
//we don't try visiting object on which allied or owned hero stands
|
||||
@ -1386,7 +1389,7 @@ std::vector<const CGObjectInstance *> VCAI::getPossibleDestinations(HeroPtr h)
|
||||
return possibleDestinations;
|
||||
}
|
||||
|
||||
bool VCAI::canReachTile (const CGHeroInstance * h, int3 t)
|
||||
bool VCAI::isTileNotReserved(const CGHeroInstance * h, int3 t)
|
||||
{
|
||||
if (t.valid())
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ public:
|
||||
int3 explorationBestNeighbour(int3 hpos, int radius, HeroPtr h);
|
||||
int3 explorationNewPoint(HeroPtr h);
|
||||
int3 explorationDesperate(HeroPtr h);
|
||||
bool canReachTile (const CGHeroInstance * h, int3 t);
|
||||
bool isTileNotReserved(const CGHeroInstance * h, int3 t); //the tile is not occupied by allied hero and the object is not reserved
|
||||
void recruitHero();
|
||||
|
||||
virtual std::string getBattleAIName() const override;
|
||||
|
@ -340,6 +340,8 @@ bool CMap::isWaterTile(const int3 &pos) const
|
||||
|
||||
bool CMap::checkForVisitableDir(const int3 & src, const TerrainTile *pom, const int3 & dst ) const
|
||||
{
|
||||
if (!pom->entrableTerrain()) //rock is never accessible
|
||||
return false;
|
||||
for(ui32 b=0; b<pom->visitableObjects.size(); ++b) //checking destination tile
|
||||
{
|
||||
if(!vstd::contains(pom->blockingObjects, pom->visitableObjects[b])) //this visitable object is not blocking, ignore
|
||||
|
Loading…
x
Reference in New Issue
Block a user