1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

* Fixed #1417 — infinite loop of AI trying to visit allied creture generator

* Fixed #1401 — battle AI won't attempt attacks with First Aid Tent
This commit is contained in:
Michał W. Urbańczyk
2013-08-25 13:03:29 +00:00
parent 4287b2b7bb
commit 92246a2c17
5 changed files with 53 additions and 2 deletions

View File

@@ -112,6 +112,20 @@ BattleAction CBattleAI::activeStack( const CStack * stack )
print("activeStack called for " + stack->nodeName());
if(stack->type->idNumber == CreatureID::CATAPULT)
return useCatapult(stack);
if(stack->hasBonusOfType(Bonus::SIEGE_WEAPON) && stack->hasBonusOfType(Bonus::HEALER))
{
auto healingTargets = cb->battleGetStacks(CBattleInfoEssentials::ONLY_MINE);
std::map<int, const CStack*> woundHpToStack;
for(auto stack : healingTargets)
if(auto woundHp = stack->MaxHealth() - stack->firstHPleft)
woundHpToStack[woundHp] = stack;
if(woundHpToStack.size())
return BattleAction::makeHeal(stack, woundHpToStack.rbegin()->second); //last element of the woundHpToStack is the most wounded stack
else
return BattleAction::makeDefend(stack);
}
if(cb->battleCanCastSpell())
attemptCastingSpell();