mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
Fix: AI deadlocks in black state were caused by the AI falsely deciding to climb rooftops
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5886 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -2317,7 +2317,7 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier)
|
|||||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("Soldier GridNo = %d, action data = %d ", pSoldier->sGridNo , pSoldier->aiData.usActionData));
|
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("Soldier GridNo = %d, action data = %d ", pSoldier->sGridNo , pSoldier->aiData.usActionData));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( gfTurnBasedAI && pSoldier->aiData.bAlertStatus < STATUS_BLACK )
|
if ( gfTurnBasedAI && pSoldier->aiData.bAlertStatus <= STATUS_BLACK )
|
||||||
{
|
{
|
||||||
if (TileIsOutOfBounds(pSoldier->sLastTwoLocations[0]))
|
if (TileIsOutOfBounds(pSoldier->sLastTwoLocations[0]))
|
||||||
{
|
{
|
||||||
|
|||||||
+46
-55
@@ -5369,69 +5369,60 @@ INT16 ubMinAPCost;
|
|||||||
INT32 targetGridNo = -1;
|
INT32 targetGridNo = -1;
|
||||||
INT8 targetbLevel = 0;
|
INT8 targetbLevel = 0;
|
||||||
sClosestOpponent = ClosestSeenOpponentWithRoof(pSoldier, &targetGridNo, &targetbLevel);
|
sClosestOpponent = ClosestSeenOpponentWithRoof(pSoldier, &targetGridNo, &targetbLevel);
|
||||||
if (!TileIsOutOfBounds(sClosestOpponent) && ! ( (targetbLevel != pSoldier->pathing.bLevel) && SameBuilding( pSoldier->sGridNo, targetGridNo ) ) )
|
if ( !TileIsOutOfBounds(sClosestOpponent) && !TileIsOutOfBounds(targetGridNo) && SameBuilding( pSoldier->sGridNo, targetGridNo ) )
|
||||||
{
|
{
|
||||||
//////////////////////////////////////////////////////////////////////
|
if ( targetbLevel == pSoldier->pathing.bLevel && targetbLevel == 0 )
|
||||||
// GO DIRECTLY TOWARDS CLOSEST KNOWN OPPONENT
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// try to move towards him
|
|
||||||
pSoldier->aiData.usActionData = GoAsFarAsPossibleTowards(pSoldier,sClosestOpponent,AI_ACTION_GET_CLOSER);
|
|
||||||
|
|
||||||
// if it's possible
|
|
||||||
if (!TileIsOutOfBounds(sClosestOpponent))
|
|
||||||
{
|
{
|
||||||
if (targetbLevel != pSoldier->pathing.bLevel )
|
//////////////////////////////////////////////////////////////////////
|
||||||
return(AI_ACTION_MOVE_TO_CLIMB);
|
// GO DIRECTLY TOWARDS CLOSEST KNOWN OPPONENT
|
||||||
else
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// try to move towards him
|
||||||
|
pSoldier->aiData.usActionData = GoAsFarAsPossibleTowards(pSoldier,sClosestOpponent,AI_ACTION_GET_CLOSER);
|
||||||
|
|
||||||
|
// Flugente: if on the same level and there is a jumpable window here, jump through it
|
||||||
|
if ( gGameExternalOptions.fCanJumpThroughWindows )
|
||||||
{
|
{
|
||||||
// Flugente: if on the same level and there is a jumpable window here, jump through it
|
// determine if there is a jumpable window in the direction to our target
|
||||||
if ( gGameExternalOptions.fCanJumpThroughWindows && targetbLevel == pSoldier->pathing.bLevel && targetbLevel == 0 )
|
// if yes, and we are not facing it, face it now
|
||||||
|
// if yes, and we are facing it, jump
|
||||||
|
// if no, go on, nothing to see here
|
||||||
|
// determine direction of our target
|
||||||
|
UINT8 targetdirection = GetDirectionToGridNoFromGridNo(pSoldier->sGridNo, sClosestOpponent);
|
||||||
|
|
||||||
|
// determine if there is a jumpable window here, in the direction of our target
|
||||||
|
// store old direction for this check
|
||||||
|
UINT8 tmpdirection = pSoldier->ubDirection;
|
||||||
|
pSoldier->ubDirection = targetdirection;
|
||||||
|
|
||||||
|
INT8 windowdirection = DIRECTION_IRRELEVANT;
|
||||||
|
if ( FindWindowJumpDirection(pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &windowdirection) && targetdirection == (UINT8)windowdirection )
|
||||||
{
|
{
|
||||||
// determine if there is a jumpable window in the direction to our target
|
|
||||||
// if yes, and we are not facing it, face it now
|
|
||||||
// if yes, and we are facing it, jump
|
|
||||||
// if no, go on, nothing to see here
|
|
||||||
// determine direction of our target
|
|
||||||
UINT8 targetdirection = GetDirectionToGridNoFromGridNo(pSoldier->sGridNo, sClosestOpponent);
|
|
||||||
|
|
||||||
// determine if there is a jumpable window here, in the direction of our target
|
|
||||||
// store old direction for this check
|
|
||||||
UINT8 tmpdirection = pSoldier->ubDirection;
|
|
||||||
pSoldier->ubDirection = targetdirection;
|
|
||||||
|
|
||||||
INT8 windowdirection = DIRECTION_IRRELEVANT;
|
|
||||||
if ( FindWindowJumpDirection(pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &windowdirection) && targetdirection == (UINT8)windowdirection )
|
|
||||||
{
|
|
||||||
pSoldier->ubDirection = tmpdirection;
|
|
||||||
|
|
||||||
// are we already looking in that direction?
|
|
||||||
if ( pSoldier->ubDirection == targetdirection )
|
|
||||||
{
|
|
||||||
// jump through the window
|
|
||||||
return(AI_ACTION_JUMP_WINDOW);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// look into that direction
|
|
||||||
if ( pSoldier->InternalIsValidStance( targetdirection, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
|
|
||||||
{
|
|
||||||
pSoldier->aiData.usActionData = targetdirection;
|
|
||||||
return(AI_ACTION_CHANGE_FACING);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pSoldier->ubDirection = tmpdirection;
|
pSoldier->ubDirection = tmpdirection;
|
||||||
|
|
||||||
|
// are we already looking in that direction?
|
||||||
|
if ( pSoldier->ubDirection == targetdirection )
|
||||||
|
{
|
||||||
|
// jump through the window
|
||||||
|
return(AI_ACTION_JUMP_WINDOW);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// look into that direction
|
||||||
|
if ( pSoldier->InternalIsValidStance( targetdirection, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
|
||||||
|
{
|
||||||
|
pSoldier->aiData.usActionData = targetdirection;
|
||||||
|
return(AI_ACTION_CHANGE_FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pSoldier->ubDirection = tmpdirection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// The situation mentioned above happens...
|
||||||
// The situation mentioned above happens...
|
else
|
||||||
else if ( (targetbLevel != pSoldier->pathing.bLevel) && SameBuilding( pSoldier->sGridNo, targetGridNo ) )
|
|
||||||
{
|
|
||||||
if (!TileIsOutOfBounds(targetGridNo) )
|
|
||||||
{
|
{
|
||||||
// need to climb AND have enough APs to get there this turn
|
// need to climb AND have enough APs to get there this turn
|
||||||
BOOLEAN fUp = TRUE;
|
BOOLEAN fUp = TRUE;
|
||||||
|
|||||||
Reference in New Issue
Block a user