mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Fixed #1962
This commit is contained in:
parent
fee2184996
commit
af02655b30
@ -369,6 +369,9 @@ TSubgoal GetObj::whatToDoToAchieve()
|
||||
const CGObjectInstance * obj = cb->getObj(ObjectInstanceID(objid));
|
||||
if(!obj)
|
||||
return sptr (Goals::Explore());
|
||||
if (obj->tempOwner == ai->playerID) //we can't capture our own object -> move to Win codition
|
||||
throw cannotFulfillGoalException("Cannot capture my own object " + obj->getObjectName());
|
||||
|
||||
int3 pos = obj->visitablePos();
|
||||
if (hero)
|
||||
{
|
||||
@ -377,8 +380,11 @@ TSubgoal GetObj::whatToDoToAchieve()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ai->isAccessible(obj->pos))
|
||||
return sptr (Goals::VisitTile(pos).sethero(hero)); //we must visit object with same hero, if any
|
||||
for (auto h : cb->getHeroesInfo())
|
||||
{
|
||||
if (ai->isAccessibleForHero(pos, h))
|
||||
return sptr(Goals::VisitTile(pos).sethero(h)); //we must visit object with same hero, if any
|
||||
}
|
||||
}
|
||||
return sptr (Goals::ClearWayTo(pos).sethero(hero));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user