Browse Source

#4066 - fix exploration

Andrii Danylchenko 1 year ago
parent
commit
7bf047ff18

+ 2 - 2
AI/Nullkiller/Engine/Nullkiller.cpp

@@ -403,7 +403,7 @@ void Nullkiller::makeTurn()
 
 		if(selectedTasks.empty())
 		{
-			return;
+			selectedTasks.push_back(taskptr(Goals::Invalid()));
 		}
 
 		bool hasAnySuccess = false;
@@ -456,7 +456,7 @@ void Nullkiller::makeTurn()
 					scanDepth = ScanDepth::ALL_FULL;
 					useHeroChain = false;
 					hasAnySuccess = true;
-					break;;
+					break;
 				}
 
 				logAi->trace("Goal %s has too low priority. It is not worth doing it.", taskDescription);

+ 9 - 2
AI/Nullkiller/Goals/ExploreNeighbourTile.cpp

@@ -28,7 +28,7 @@ void ExploreNeighbourTile::accept(AIGateway * ai)
 {
 	ExplorationHelper h(hero, ai->nullkiller.get(), true);
 
-	for(int i = 0; i < tilesToExplore && hero->movementPointsRemaining() > 0; i++)
+	for(int i = 0; i < tilesToExplore && ai->myCb->getObj(hero->id, false) && hero->movementPointsRemaining() > 0; i++)
 	{
 		int3 pos = hero->visitablePos();
 		float value = 0;
@@ -54,7 +54,14 @@ void ExploreNeighbourTile::accept(AIGateway * ai)
 				}
 			});
 
-		if(!target.valid() || !ai->moveHeroToTile(target, hero))
+		if(!target.valid())
+		{
+			return;
+		}
+
+		auto danger = ai->nullkiller->pathfinder->getStorage()->evaluateDanger(target, hero, true);
+
+		if(danger > 0 || !ai->moveHeroToTile(target, hero))
 		{
 			return;
 		}

+ 1 - 1
AI/Nullkiller/Helpers/ExplorationHelper.cpp

@@ -104,7 +104,7 @@ bool ExplorationHelper::scanMap()
 
 	if(!bestGoal->invalid())
 	{
-		return false;
+		return true;
 	}
 
 	allowDeadEndCancellation = false;