- AI Improvements: Made enemies more likely to make a partial move toward the target if the chance to hit is really, really low (by tazpn)

Now a more controversial change and perhaps unrelated now since its not in NCTH code. In line with my comment above I tried to make soldiers more likely to make a partial move toward the target if the chance to hit is really, really low and out of effective gun range but still reserving enough AP to make a partial shot. I also allowed this on Cunning soldiers instead of just aggressives figuring that target is in sight they are more likely to fight.

This with the other change has at least made them more aggressive and less likely to run in circles when armed with pistols and has actually made them quite a threat again. Not crazy about the implementation since I'd like a more accurate range check and AP calculation since AP to fire will change after movement. I figure the increased CTH by getting closer will counteract the cost to move.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4715 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2011-10-15 23:16:07 +00:00
parent 73dc6f250d
commit 1af9037c1e
+33
View File
@@ -4815,6 +4815,39 @@ INT16 ubMinAPCost;
pSoldier->bDoAutofire = 0;
}
// IF WAY OUT OF EFFECTIVE RANGE TRY TO ADVANCE RESERVING ENOUGH AP FOR A SHOT IF NOT ACTED YET
if ((pSoldier->bActionPoints > BestAttack.ubAPCost) &&
(pSoldier->aiData.bShock == 0) &&
(pSoldier->stats.bLife >= pSoldier->stats.bLifeMax / 2) &&
(BestAttack.ubChanceToReallyHit < 8) &&
(PythSpacesAway( pSoldier->sGridNo, BestAttack.sTarget ) > usRange / CELL_X_SIZE ) &&
(RangeChangeDesire( pSoldier ) >= 3) ) // Cunning and above
{
sClosestOpponent = Menptr[BestShot.ubOpponent].sGridNo;
if (!TileIsOutOfBounds(sClosestOpponent))
{
// temporarily make merc get closer reserving enough for expected cost of shot
USHORT tgrd = pSoldier->aiData.sPatrolGrid[0];
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 );
pSoldier->aiData.sPatrolGrid[0] = tgrd;
pSoldier->aiData.bOrders = oldOrders;
if (!TileIsOutOfBounds(pSoldier->aiData.usActionData))
{
pSoldier->aiData.usActionData = pSoldier->sGridNo ;
pSoldier->pathing.sFinalDestination = pSoldier->aiData.usActionData;
pSoldier->aiData.bNextAction = AI_ACTION_FIRE_GUN;
pSoldier->aiData.usNextActionData = BestAttack.sTarget;
pSoldier->aiData.bNextTargetLevel = BestAttack.bTargetLevel;
return( AI_ACTION_GET_CLOSER );
}
}
}
//////////////////////////////////////////////////////////////////////////
// IF NOT CROUCHED & WILL STILL HAVE ENOUGH APs TO DO THIS SAME BEST
// ATTACK AFTER A STANCE CHANGE, CONSIDER CHANGING STANCE