Skip to content

Commit

Permalink
Update AIModule.cpp
Browse files Browse the repository at this point in the history
When a unit would call of an attack in order to hide it now checks whether there actually is any location it might want to hide at. This prevents an issue where a unit just walks forward without attacking or hiding when it could.

When bug-hunt-mode for AI is enabled it will no longer waste TUs on searching enemies.
  • Loading branch information
Xilmi committed Oct 27, 2024
1 parent 6cba813 commit 45e1ee7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Battlescape/AIModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3710,7 +3710,7 @@ void AIModule::brutalThink(BattleAction* action)
directPeakScore = remainingTimeUnits;
}
}
if (visiblePathFromMyPos < visiblePath && (myMaxTU == _unit->getTimeUnits() || _save->getTileEngine()->isNextToDoor(myTile)))
if (!_unit->isCheatOnMovement() && visiblePathFromMyPos < visiblePath && (myMaxTU == _unit->getTimeUnits() || _save->getTileEngine()->isNextToDoor(myTile)))
indirectPeakScore = visiblePath;
}
}
Expand Down Expand Up @@ -3986,12 +3986,18 @@ void AIModule::brutalThink(BattleAction* action)
}
if (moveTU <= _unit->getTimeUnits() - attackTU)
haveTUToAttack = true;
if (bestAttackScore > 0 && !haveTUToAttack)
if (bestAttackScore > 0 && !haveTUToAttack && bestGreatCoverScore + bestGoodCoverScore + bestOkayCoverScore > 0)
{
shouldHaveLofAfterMove = iHaveLof;
if (_traceAI)
Log(LOG_INFO) << "Attack dismissed due to lack of TU to go back to hiding-spot afterwards. Attack + Hide: " << attackTU << " move: " << moveTU << " current: " << _unit->getTimeUnits();
}
else if (bestAttackScore > 0)
{
haveTUToAttack = true;
_tuCostToReachClosestPositionToBreakLos = -1;
_energyCostToReachClosestPositionToBreakLos = -1;
}
int newVisibleTilesDirect = 0;
int newVisibleTilesInDirect = 0;
for (int i = 0; i < 8; i++)
Expand Down

0 comments on commit 45e1ee7

Please sign in to comment.