1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

More robust fix for #957 / #938.

AI won't try clearing way by attacking its own heroes.
This commit is contained in:
Michał W. Urbańczyk 2012-05-19 00:38:25 +00:00
parent c9af2bb251
commit 7116377e4e

View File

@ -2367,7 +2367,14 @@ TSubgoal CGoal::whatToDoToAchieve()
{
tlog1 << boost::format("Very strange, tile to hit is %s and tile is also %s, while hero %s is at %s\n")
% tileToHit % tile % h->name % h->visitablePos();
throw cannotFulfillGoalException("Retreiving first tile to hit failed (probably)!");
throw cannotFulfillGoalException("Retrieving first tile to hit failed (probably)!");
}
auto topObj = backOrNull(cb->getVisitableObjs(tileToHit));
if(topObj && topObj->ID == GameConstants::HEROI_TYPE && cb->getPlayerRelations(h->tempOwner, topObj->tempOwner) != 0)
{
std::string problem = boost::str(boost::format("%s stands in the way of %s.\n") % topObj->getHoverText() % h->getHoverText());
throw cannotFulfillGoalException(problem);
}
return CGoal(VISIT_TILE).settile(tileToHit).sethero(h);