فهرست منبع

Garrisoning behavior improvement

AI will now also garrison a hero as defender if the town to be defended has troops as long as the hero can merge their own troops with the town.

AI will no longer just dismiss existing troops in a town if a hero trying to garrison there can merge with it.
Xilmi 1 سال پیش
والد
کامیت
11980e0f97
2فایلهای تغییر یافته به همراه6 افزوده شده و 2 حذف شده
  1. 1 0
      AI/Nullkiller/Behaviors/DefenceBehavior.cpp
  2. 5 2
      AI/Nullkiller/Goals/ExchangeSwapTownHeroes.cpp

+ 1 - 0
AI/Nullkiller/Behaviors/DefenceBehavior.cpp

@@ -270,6 +270,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
 				// dismiss creatures we are not able to pick to be able to hide in garrison
 				// dismiss creatures we are not able to pick to be able to hide in garrison
 				if(town->garrisonHero
 				if(town->garrisonHero
 					|| town->getUpperArmy()->stacksCount() == 0
 					|| town->getUpperArmy()->stacksCount() == 0
+					|| path.targetHero->canBeMergedWith(*town)
 					|| (town->getUpperArmy()->getArmyStrength() < 500 && town->fortLevel() >= CGTownInstance::CITADEL))
 					|| (town->getUpperArmy()->getArmyStrength() < 500 && town->fortLevel() >= CGTownInstance::CITADEL))
 				{
 				{
 					tasks.push_back(
 					tasks.push_back(

+ 5 - 2
AI/Nullkiller/Goals/ExchangeSwapTownHeroes.cpp

@@ -90,9 +90,12 @@ void ExchangeSwapTownHeroes::accept(AIGateway * ai)
 	
 	
 	if(!town->garrisonHero)
 	if(!town->garrisonHero)
 	{
 	{
-		while(upperArmy->stacksCount() != 0)
+		if (!garrisonHero->canBeMergedWith(*town))
 		{
 		{
-			cb->dismissCreature(upperArmy, upperArmy->Slots().begin()->first);
+			while (upperArmy->stacksCount() != 0)
+			{
+				cb->dismissCreature(upperArmy, upperArmy->Slots().begin()->first);
+			}
 		}
 		}
 	}
 	}