mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSoldier->aiData.bAction == AI_ACTION_NONE)
|
if (!pSoldier->aiData.bActionInProgress)
|
||||||
{
|
{
|
||||||
// being handled so turn off muzzle flash
|
// being handled so turn off muzzle flash
|
||||||
if ( pSoldier->flags.fMuzzleFlash )
|
if ( pSoldier->flags.fMuzzleFlash )
|
||||||
@@ -1837,42 +1837,42 @@ void TurnBasedHandleNPCAI(SOLDIERTYPE *pSoldier)
|
|||||||
{
|
{
|
||||||
pSoldier->aiData.bAction = AI_ACTION_NONE;
|
pSoldier->aiData.bAction = AI_ACTION_NONE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if he chose to continue doing nothing
|
// if he chose to continue doing nothing
|
||||||
if (pSoldier->aiData.bAction == AI_ACTION_NONE)
|
if (pSoldier->aiData.bAction == AI_ACTION_NONE)
|
||||||
{
|
{
|
||||||
#ifdef RECORDNET
|
#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
|
#endif
|
||||||
|
|
||||||
DebugMsg (TOPIC_JA2AI,DBG_LEVEL_3,"NPC has no action assigned");
|
DebugMsg (TOPIC_JA2AI,DBG_LEVEL_3,"NPC has no action assigned");
|
||||||
NPCDoesNothing(pSoldier); // sets pSoldier->moved to TRUE
|
NPCDoesNothing(pSoldier); // sets pSoldier->moved to TRUE
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// to get here, we MUST have an action selected, but not in progress...
|
// to get here, we MUST have an action selected, but not in progress...
|
||||||
// see if we can afford to do this action
|
// see if we can afford to do this action
|
||||||
if (IsActionAffordable(pSoldier))
|
if (IsActionAffordable(pSoldier))
|
||||||
{
|
{
|
||||||
NPCDoesAct(pSoldier);
|
NPCDoesAct(pSoldier);
|
||||||
|
|
||||||
// perform the chosen action
|
// perform the chosen action
|
||||||
pSoldier->aiData.bActionInProgress = ExecuteAction(pSoldier); // if started, mark us as busy
|
pSoldier->aiData.bActionInProgress = ExecuteAction(pSoldier); // if started, mark us as busy
|
||||||
|
|
||||||
if ( !pSoldier->aiData.bActionInProgress && !TileIsOutOfBounds(pSoldier->sAbsoluteFinalDestination))
|
if ( !pSoldier->aiData.bActionInProgress && !TileIsOutOfBounds(pSoldier->sAbsoluteFinalDestination))
|
||||||
{
|
|
||||||
// turn based... abort this guy's turn
|
|
||||||
EndAIGuysTurn( pSoldier );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
#ifdef DEBUGDECISIONS
|
// turn based... abort this guy's turn
|
||||||
AINumMessage("HandleManAI - Not enough APs, skipping guy#",pSoldier->ubID);
|
EndAIGuysTurn( pSoldier );
|
||||||
#endif
|
|
||||||
HaltMoveForSoldierOutOfPoints( pSoldier);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef DEBUGDECISIONS
|
||||||
|
AINumMessage("HandleManAI - Not enough APs, skipping guy#",pSoldier->ubID);
|
||||||
|
#endif
|
||||||
|
HaltMoveForSoldierOutOfPoints( pSoldier);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user