mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Call TurnBasedHandleNPCAI() if no action is in progress
Several actions would sometimes get stuck in a forever loop, where they would not be executed, since no proper path for executing the actions is found. Originally TurnBasedHandleNPCAI() would only be called if aidata.bAction was AI_ACTION_NONE. Now we'll call it if an action is not already in progress, and will be executed if the action is affordable.
This commit is contained in:
+28
-28
@@ -859,7 +859,7 @@ void HandleSoldierAI( SOLDIERTYPE *pSoldier ) // FIXME - this function is named
|
||||
return;
|
||||
}
|
||||
|
||||
if (pSoldier->aiData.bAction == AI_ACTION_NONE)
|
||||
if (!pSoldier->aiData.bActionInProgress)
|
||||
{
|
||||
// being handled so turn off muzzle flash
|
||||
if ( pSoldier->flags.fMuzzleFlash )
|
||||
@@ -1837,42 +1837,42 @@ void TurnBasedHandleNPCAI(SOLDIERTYPE *pSoldier)
|
||||
{
|
||||
pSoldier->aiData.bAction = AI_ACTION_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
// if he chose to continue doing nothing
|
||||
if (pSoldier->aiData.bAction == AI_ACTION_NONE)
|
||||
{
|
||||
// if he chose to continue doing nothing
|
||||
if (pSoldier->aiData.bAction == AI_ACTION_NONE)
|
||||
{
|
||||
#ifdef RECORDNET
|
||||
fprintf(NetDebugFile,"\tMOVED BECOMING TRUE: Chose to do nothing, guynum %d\n",pSoldier->ubID);
|
||||
fprintf(NetDebugFile,"\tMOVED BECOMING TRUE: Chose to do nothing, guynum %d\n",pSoldier->ubID);
|
||||
#endif
|
||||
|
||||
DebugMsg (TOPIC_JA2AI,DBG_LEVEL_3,"NPC has no action assigned");
|
||||
NPCDoesNothing(pSoldier); // sets pSoldier->moved to TRUE
|
||||
return;
|
||||
}
|
||||
// to get here, we MUST have an action selected, but not in progress...
|
||||
// see if we can afford to do this action
|
||||
if (IsActionAffordable(pSoldier))
|
||||
{
|
||||
NPCDoesAct(pSoldier);
|
||||
DebugMsg (TOPIC_JA2AI,DBG_LEVEL_3,"NPC has no action assigned");
|
||||
NPCDoesNothing(pSoldier); // sets pSoldier->moved to TRUE
|
||||
return;
|
||||
}
|
||||
// to get here, we MUST have an action selected, but not in progress...
|
||||
// see if we can afford to do this action
|
||||
if (IsActionAffordable(pSoldier))
|
||||
{
|
||||
NPCDoesAct(pSoldier);
|
||||
|
||||
// perform the chosen action
|
||||
pSoldier->aiData.bActionInProgress = ExecuteAction(pSoldier); // if started, mark us as busy
|
||||
// perform the chosen action
|
||||
pSoldier->aiData.bActionInProgress = ExecuteAction(pSoldier); // if started, mark us as busy
|
||||
|
||||
if ( !pSoldier->aiData.bActionInProgress && !TileIsOutOfBounds(pSoldier->sAbsoluteFinalDestination))
|
||||
{
|
||||
// turn based... abort this guy's turn
|
||||
EndAIGuysTurn( pSoldier );
|
||||
}
|
||||
}
|
||||
else
|
||||
if ( !pSoldier->aiData.bActionInProgress && !TileIsOutOfBounds(pSoldier->sAbsoluteFinalDestination))
|
||||
{
|
||||
#ifdef DEBUGDECISIONS
|
||||
AINumMessage("HandleManAI - Not enough APs, skipping guy#",pSoldier->ubID);
|
||||
#endif
|
||||
HaltMoveForSoldierOutOfPoints( pSoldier);
|
||||
return;
|
||||
// turn based... abort this guy's turn
|
||||
EndAIGuysTurn( pSoldier );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUGDECISIONS
|
||||
AINumMessage("HandleManAI - Not enough APs, skipping guy#",pSoldier->ubID);
|
||||
#endif
|
||||
HaltMoveForSoldierOutOfPoints( pSoldier);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user