소스 검색

VCAI: do not attempt artefact and army exchange with ally hero

While visits of ally heroes supposedly occur accidentally It's still nice to handle it's gracefully.
No reason to prevent visits completely as they useful if hero have skill like Scholar.
Arseniy Shestakov 9 년 전
부모
커밋
ca0fe8fdc4
1개의 변경된 파일7개의 추가작업 그리고 3개의 파일을 삭제
  1. 7 3
      AI/VCAI/VCAI.cpp

+ 7 - 3
AI/VCAI/VCAI.cpp

@@ -321,7 +321,7 @@ void VCAI::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, Q
 	auto firstHero = cb->getHero(hero1);
 	auto secondHero = cb->getHero(hero2);
 
-	status.addQuery(query, boost::str(boost::format("Exchange between heroes %s and %s") % firstHero->name % secondHero->name));
+	status.addQuery(query, boost::str(boost::format("Exchange between heroes %s (%d) and %s (%d)") % firstHero->name % firstHero->tempOwner % secondHero->name % secondHero->tempOwner));
 
 	requestActionASAP([=]()
 	{
@@ -340,9 +340,13 @@ void VCAI::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, Q
 			this->pickBestArtifacts(h1, h2);
 		};
 
-		if (goalpriority1 > goalpriority2)
+		//Do not attempt army or artifacts exchange if we visited ally player
+		//Visits can still be useful if hero have skills like Scholar
+		if(firstHero->tempOwner != secondHero->tempOwner)
+			logAi->debug("Heroes owned by different players. Do not exchange army or artifacts.");
+		else if(goalpriority1 > goalpriority2)
 			transferFrom2to1 (firstHero, secondHero);
-		else if (goalpriority1 < goalpriority2)
+		else if(goalpriority1 < goalpriority2)
 			transferFrom2to1 (secondHero, firstHero);
 		else //regular criteria
 		{