mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-17 11:56:46 +02:00
Fix for going through all passes despite not doing anything
AI now checks whether it moved anything when it executed tasks. If it didn't it will not continue to further passes.
This commit is contained in:
parent
c13edc8af3
commit
ae6dcf4c6b
@ -528,6 +528,12 @@ void Nullkiller::makeTurn()
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
logAi->info("Pass %d: Performing prio %d task %s with prio: %d", i, prioOfTask, bestTask->toString(), bestTask->priority);
|
||||
#endif
|
||||
int totalMPBefore = 0;
|
||||
int totalMPAfter = 0;
|
||||
for (auto hero : cb->getHeroesInfo(true))
|
||||
{
|
||||
totalMPBefore += hero->movementPointsRemaining();
|
||||
}
|
||||
if(!executeTask(bestTask))
|
||||
{
|
||||
if(hasAnySuccess)
|
||||
@ -535,7 +541,12 @@ void Nullkiller::makeTurn()
|
||||
else
|
||||
return;
|
||||
}
|
||||
hasAnySuccess = true;
|
||||
for (auto hero : cb->getHeroesInfo(true))
|
||||
{
|
||||
totalMPAfter += hero->movementPointsRemaining();
|
||||
}
|
||||
if(totalMPBefore > totalMPAfter)
|
||||
hasAnySuccess = true;
|
||||
}
|
||||
|
||||
hasAnySuccess |= handleTrading();
|
||||
|
Loading…
x
Reference in New Issue
Block a user