Kaynağa Gözat

#2018 - fix shipyard usage for NKAI, allied shipyard should work now

Andrii Danylchenko 2 yıl önce
ebeveyn
işleme
fbc9a32ad8

+ 1 - 1
AI/Nullkiller/Behaviors/CaptureObjectsBehavior.cpp

@@ -209,7 +209,7 @@ Goals::TGoalVec CaptureObjectsBehavior::decompose() const
 	{
 		captureObjects(ai->nullkiller->objectClusterizer->getNearbyObjects());
 
-		if(tasks.empty())
+		if(tasks.empty() || ai->nullkiller->getScanDepth() == ScanDepth::FULL)
 			captureObjects(ai->nullkiller->objectClusterizer->getFarObjects());
 	}
 

+ 7 - 7
AI/Nullkiller/Behaviors/DefenceBehavior.cpp

@@ -58,13 +58,6 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
 	auto treatNode = ai->nullkiller->dangerHitMap->getObjectTreat(town);
 	auto treats = { treatNode.maximumDanger, treatNode.fastestDanger };
 
-	if(!treatNode.fastestDanger.hero)
-	{
-		logAi->trace("No treat found for town %s", town->getNameTranslated());
-
-		return;
-	}
-
 	int dayOfWeek = cb->getDate(Date::DAY_OF_WEEK);
 
 	if(town->garrisonHero)
@@ -91,6 +84,13 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
 
 		return;
 	}
+
+	if(!treatNode.fastestDanger.hero)
+	{
+		logAi->trace("No treat found for town %s", town->getNameTranslated());
+
+		return;
+	}
 	
 	uint64_t reinforcement = ai->nullkiller->armyManager->howManyReinforcementsCanBuy(town->getUpperArmy(), town);
 

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

@@ -117,7 +117,7 @@ Goals::TTask Nullkiller::choseBestTask(Goals::TSubgoal behavior, int decompositi
 void Nullkiller::resetAiState()
 {
 	lockedResources = TResources();
-	scanDepth = ScanDepth::SMALL;
+	scanDepth = ScanDepth::FULL;
 	playerID = ai->playerID;
 	lockedHeroes.clear();
 	dangerHitMap->reset();

+ 1 - 0
AI/Nullkiller/Engine/Nullkiller.h

@@ -88,6 +88,7 @@ public:
 	int32_t getFreeGold() const { return getFreeResources()[EGameResID::GOLD]; }
 	void lockResources(const TResources & res);
 	const TResources & getLockedResources() const { return lockedResources; }
+	ScanDepth getScanDepth() const { return scanDepth; }
 
 private:
 	void resetAiState();

+ 2 - 4
AI/Nullkiller/Pathfinding/Rules/AILayerTransitionRule.cpp

@@ -53,15 +53,13 @@ namespace AIPathfinding
 
 		for(const CGTownInstance * t : cb->getTownsInfo())
 		{
-			// do not allow ally shipyards because of bug
-			if(t->hasBuilt(BuildingID::SHIPYARD) && t->getOwner() == ai->playerID)
+			if(t->hasBuilt(BuildingID::SHIPYARD))
 				shipyards.push_back(t);
 		}
 
 		for(const CGObjectInstance * obj : ai->memory->visitableObjs)
 		{
-			// do not allow ally shipyards because of bug
-			if(obj->ID != Obj::TOWN && obj->getOwner() == ai->playerID) //towns were handled in the previous loop
+			if(obj->ID != Obj::TOWN) //towns were handled in the previous loop
 			{
 				if(const IShipyard * shipyard = IShipyard::castFrom(obj))
 					shipyards.push_back(shipyard);