mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
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:
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user