Selaa lähdekoodia

Fixed #957 / #938.
AI won't try visit objects on which another non-enemy hero stands.

Michał W. Urbańczyk 13 vuotta sitten
vanhempi
sitoutus
c9af2bb251
1 muutettua tiedostoa jossa 8 lisäystä ja 1 poistoa
  1. 8 1
      AI/VCAI/VCAI.cpp

+ 8 - 1
AI/VCAI/VCAI.cpp

@@ -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());