Fix AI units to reload/rechamber off-hand when necessary

Fix to prevent soldiers from climbing the wrong building while moving toward a disturbance
Fix to prevent soldiers from doing nothing when a climb point is not nearby
Fix improper indexing of directions

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1533 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Overhaul
2007-10-20 08:19:17 +00:00
parent dd0d6ea66d
commit 035359edf0
7 changed files with 205 additions and 142 deletions
+18 -5
View File
@@ -2773,7 +2773,12 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
if (!fUp)
DebugMsg ( TOPIC_JA2AI , DBG_LEVEL_3 , String("Soldier %d is climbing down",pSoldier->ubID) );
if ( CanClimbFromHere ( pSoldier, fUp ) )
// As mentioned in the next part, the sClosestDisturbance IS the climb point desired. So the
// check here should be "Am I aready there?" If so, THEN possibly climb. This previous check
// would have a soldier climbing any building, even if it was not the desired building. So
// WRONG WRONG WRONG
//if ( CanClimbFromHere ( pSoldier, fUp ) )
if (pSoldier->sGridNo == sClosestDisturbance)
{
if (IsActionAffordable(pSoldier) && pSoldier->bActionPoints >= ( AP_CLIMBROOF + MinAPsToAttack( pSoldier, sClosestDisturbance, ADDTURNCOST)))
{
@@ -2782,9 +2787,16 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
}
else
{
pSoldier->usActionData = FindClosestClimbPoint(pSoldier, pSoldier->sGridNo , sClosestDisturbance , fUp );
if ( pSoldier->usActionData != NOWHERE )
// Do not overwrite the usActionData here. If there's no nearby climb point, the action data
// would become NOWHERE, and then the SEEK_ENEMY fallback would also fail.
// In fact, sClosestDisturbance has ALREADY calculated the closest climb point when climbing is
// necessary. The returned grid # in sClosestDisturbance is that climb point. So if climb is
// set, then use sClosestDisturbance as is.
//INT16 usClimbPoint = FindClosestClimbPoint(pSoldier, pSoldier->sGridNo , sClosestDisturbance , fUp );
INT16 usClimbPoint = sClosestDisturbance;
if ( usClimbPoint != NOWHERE )
{
pSoldier->usActionData = usClimbPoint;
return( AI_ACTION_MOVE_TO_CLIMB );
}
}
@@ -2996,9 +3008,10 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
}
else
{
pSoldier->usActionData = FindClosestClimbPoint(pSoldier, pSoldier->sGridNo , sClosestFriend , fUp );
if ( pSoldier->usActionData != NOWHERE )
INT16 sClimbPoint = FindClosestClimbPoint(pSoldier, pSoldier->sGridNo , sClosestFriend , fUp );
if ( sClimbPoint != NOWHERE )
{
pSoldier->usActionData = sClimbPoint;
return( AI_ACTION_MOVE_TO_CLIMB );
}
}