From 7116377e4e164452820aa93407d886aa943ae104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Sat, 19 May 2012 00:38:25 +0000 Subject: [PATCH] More robust fix for #957 / #938. AI won't try clearing way by attacking its own heroes. --- AI/VCAI/VCAI.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index b279d44c8..23e1d5303 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -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);