From 80554bcde891b26f1472b41fc0af786791b0b242 Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Mon, 26 Oct 2020 17:37:44 +0000 Subject: [PATCH] Hopefully improved AI code: don't try to resume movement after ActionDone was executed. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8911 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- TacticalAI/AIMain.cpp | 48 ++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/TacticalAI/AIMain.cpp b/TacticalAI/AIMain.cpp index 9d6bdee3..49ac80f6 100644 --- a/TacticalAI/AIMain.cpp +++ b/TacticalAI/AIMain.cpp @@ -782,34 +782,40 @@ void HandleSoldierAI( SOLDIERTYPE *pSoldier ) // FIXME - this function is named } //*** TRICK- TAKE INTO ACCOUNT PAUSED FOR NO TIME ( FOR NOW ) - if (pSoldier->flags.fNoAPToFinishMove ) + // sevenfm: check if we still have where to go and what to do + if (pSoldier->aiData.bAction != AI_ACTION_NONE && + pSoldier->aiData.bNewSituation != IS_NEW_SITUATION && + !TileIsOutOfBounds(pSoldier->aiData.usActionData) && + NewOKDestination(pSoldier, pSoldier->aiData.usActionData, TRUE, pSoldier->pathing.bLevel)) { - SoldierTriesToContinueAlongPath(pSoldier); - } - // ATE: Let's also test if we are in any stationary animation... - else if ( ( gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_STATIONARY ) ) - { - // ATE: Put some ( MORE ) refinements on here.... - // If we are trying to open door, or jump fence don't continue until done... - if ( !pSoldier->flags.fContinueMoveAfterStanceChange && !pSoldier->bEndDoorOpenCode ) + if (pSoldier->flags.fNoAPToFinishMove) { - //ATE: just a few more..... - // If we have ANY pending aninmation that is movement..... - if ( pSoldier->usPendingAnimation != NO_PENDING_ANIMATION && ( gAnimControl[ pSoldier->usPendingAnimation ].uiFlags & ANIM_MOVING ) ) + SoldierTriesToContinueAlongPath(pSoldier); + } + // ATE: Let's also test if we are in any stationary animation... + else if ((gAnimControl[pSoldier->usAnimState].uiFlags & ANIM_STATIONARY)) + { + // ATE: Put some ( MORE ) refinements on here.... + // If we are trying to open door, or jump fence don't continue until done... + if (!pSoldier->flags.fContinueMoveAfterStanceChange && !pSoldier->bEndDoorOpenCode) { - // Don't do anything, we're waiting on a pending animation.... - } - else - { - // OK, we have a move to finish... + //ATE: just a few more..... + // If we have ANY pending aninmation that is movement..... + if (pSoldier->usPendingAnimation != NO_PENDING_ANIMATION && (gAnimControl[pSoldier->usPendingAnimation].uiFlags & ANIM_MOVING)) + { + // Don't do anything, we're waiting on a pending animation.... + } + else + { + // OK, we have a move to finish... #ifdef TESTAI - DebugMsg( TOPIC_JA2AI, DBG_LEVEL_0, String("GONNA TRY TO CONTINUE PATH FOR %d", pSoldier->ubID ) ); + DebugMsg( TOPIC_JA2AI, DBG_LEVEL_0, String("GONNA TRY TO CONTINUE PATH FOR %d", pSoldier->ubID ) ); #endif - - SoldierTriesToContinueAlongPath(pSoldier); + SoldierTriesToContinueAlongPath(pSoldier); + } } } - } + } } else if (pSoldier->aiData.bAction == AI_ACTION_CLIMB_ROOF && !pSoldier->aiData.bActionInProgress) {