mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
AI won't try visit objects on which another non-enemy hero stands.
This commit is contained in:
parent
d2756e8c88
commit
c9af2bb251
@ -1172,10 +1172,11 @@ std::vector<const CGObjectInstance *> VCAI::getPossibleDestinations(const CGHero
|
||||
|
||||
possibleDestinations.erase(boost::remove_if(possibleDestinations, [&](const CGObjectInstance *obj) -> bool
|
||||
{
|
||||
const int3 pos = obj->visitablePos();
|
||||
if(vstd::contains(alreadyVisited, obj))
|
||||
return true;
|
||||
|
||||
if(!isSafeToVisit(h, obj->visitablePos()))
|
||||
if(!isSafeToVisit(h, pos))
|
||||
return true;
|
||||
|
||||
if (!shouldVisit(h, obj))
|
||||
@ -1184,6 +1185,12 @@ std::vector<const CGObjectInstance *> VCAI::getPossibleDestinations(const CGHero
|
||||
if (vstd::contains(reservedObjs, obj)) //does checking for our own reserved objects make sense? here?
|
||||
return true;
|
||||
|
||||
const CGObjectInstance *topObj = cb->getVisitableObjs(pos).back(); //it may be hero visiting this obj
|
||||
//we don't try visiting object on which allied or owned hero stands
|
||||
// -> it will just trigger exchange windows and AI will be confused that obj behind doesn't get visited
|
||||
if(topObj->ID == GameConstants::HEROI_TYPE && cb->getPlayerRelations(h->tempOwner, topObj->tempOwner) != 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}),possibleDestinations.end());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user