mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Try to find a cover spot when advancing to attack
Calling InternalGoAsFarAsPossibleTowards() with target's gridno means AI doesn't take into account eg. nearby friendlies resulting in them bunching up and making a beeline straight at whoever they're trying to attack. We'll first at least attempt to find a cover spot near said target, if it doesn't work, only then head straight at them.
This commit is contained in:
@@ -6697,7 +6697,18 @@ L_NEWAIM:
|
||||
INT8 oldOrders = pSoldier->aiData.bOrders;
|
||||
pSoldier->aiData.sPatrolGrid[0] = pSoldier->sGridNo;
|
||||
pSoldier->aiData.bOrders = CLOSEPATROL;
|
||||
pSoldier->aiData.usActionData = InternalGoAsFarAsPossibleTowards( pSoldier, sClosestOpponent, BestAttack.ubAPCost, AI_ACTION_GET_CLOSER, 0 );
|
||||
// Try to find a cover spot near opponent
|
||||
iCoverPercentBetter = 0;
|
||||
INT32 spotNearTarget = FindBestNearbyCover(pSoldier, pSoldier->aiData.bAIMorale, &iCoverPercentBetter, sClosestOpponent);
|
||||
if (spotNearTarget != NOWHERE)
|
||||
{
|
||||
pSoldier->aiData.usActionData = InternalGoAsFarAsPossibleTowards(pSoldier, spotNearTarget, BestAttack.ubAPCost, AI_ACTION_GET_CLOSER, 0);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pSoldier->aiData.usActionData = InternalGoAsFarAsPossibleTowards( pSoldier, sClosestOpponent, BestAttack.ubAPCost, AI_ACTION_GET_CLOSER, 0 );
|
||||
}
|
||||
pSoldier->aiData.sPatrolGrid[0] = tgrd;
|
||||
pSoldier->aiData.bOrders = oldOrders;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user