mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-18 03:21:27 +02:00
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.
This commit is contained in:
parent
f04e110e2c
commit
11980e0f97
@ -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
|
||||
if(town->garrisonHero
|
||||
|| town->getUpperArmy()->stacksCount() == 0
|
||||
|| path.targetHero->canBeMergedWith(*town)
|
||||
|| (town->getUpperArmy()->getArmyStrength() < 500 && town->fortLevel() >= CGTownInstance::CITADEL))
|
||||
{
|
||||
tasks.push_back(
|
||||
|
@ -90,9 +90,12 @@ void ExchangeSwapTownHeroes::accept(AIGateway * ai)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user