mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
More AI logging information.
PanicAI: use correct movement and stealth mode when determining AP needed. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8768 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -6463,6 +6463,7 @@ SOLDIERTYPE * pSoldier;
|
|||||||
pSoldier = FindSoldierByProfileID( ID, FALSE );
|
pSoldier = FindSoldierByProfileID( ID, FALSE );
|
||||||
if (pSoldier)
|
if (pSoldier)
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: lua cancel action"));
|
||||||
CancelAIAction( pSoldier, TRUE );
|
CancelAIAction( pSoldier, TRUE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ void ExitBoxing( void )
|
|||||||
SetSoldierNeutral( pSoldier );
|
SetSoldierNeutral( pSoldier );
|
||||||
RecalculateOppCntsDueToBecomingNeutral( pSoldier );
|
RecalculateOppCntsDueToBecomingNeutral( pSoldier );
|
||||||
}
|
}
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: exit boxing"));
|
||||||
CancelAIAction( pSoldier, TRUE );
|
CancelAIAction( pSoldier, TRUE );
|
||||||
pSoldier->aiData.bAlertStatus = STATUS_GREEN;
|
pSoldier->aiData.bAlertStatus = STATUS_GREEN;
|
||||||
pSoldier->aiData.bUnderFire = 0;
|
pSoldier->aiData.bUnderFire = 0;
|
||||||
@@ -396,6 +397,7 @@ BOOLEAN PickABoxer( void )
|
|||||||
pBoxer->flags.uiStatusFlags |= SOLDIER_BOXER;
|
pBoxer->flags.uiStatusFlags |= SOLDIER_BOXER;
|
||||||
SetSoldierNonNeutral( pBoxer );
|
SetSoldierNonNeutral( pBoxer );
|
||||||
RecalculateOppCntsDueToNoLongerNeutral( pBoxer );
|
RecalculateOppCntsDueToNoLongerNeutral( pBoxer );
|
||||||
|
DebugAI(AI_MSG_INFO, pBoxer, String("CancelAIAction: pick a boxer"));
|
||||||
CancelAIAction( pBoxer, TRUE );
|
CancelAIAction( pBoxer, TRUE );
|
||||||
RESETTIMECOUNTER( pBoxer->timeCounters.AICounter, 0 );
|
RESETTIMECOUNTER( pBoxer->timeCounters.AICounter, 0 );
|
||||||
gfBoxerFought[ uiLoop ] = TRUE;
|
gfBoxerFought[ uiLoop ] = TRUE;
|
||||||
|
|||||||
@@ -468,6 +468,7 @@ void ProcessImplicationsOfPCMessingWithDoor( SOLDIERTYPE * pSoldier )
|
|||||||
// alert her if she hasn't been alerted
|
// alert her if she hasn't been alerted
|
||||||
pGoon->aiData.bAlertStatus = STATUS_RED;
|
pGoon->aiData.bAlertStatus = STATUS_RED;
|
||||||
CheckForChangingOrders( pGoon );
|
CheckForChangingOrders( pGoon );
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: tixa door"));
|
||||||
CancelAIAction( pGoon, TRUE );
|
CancelAIAction( pGoon, TRUE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6604,6 +6604,7 @@ void RemoveBlueFlag( INT32 sGridNo, INT8 bLevel )
|
|||||||
|
|
||||||
void MakeNPCGrumpyForMinorOffense( SOLDIERTYPE * pSoldier, SOLDIERTYPE *pOffendingSoldier )
|
void MakeNPCGrumpyForMinorOffense( SOLDIERTYPE * pSoldier, SOLDIERTYPE *pOffendingSoldier )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: MakeNPCGrumpyForMinorOffense"));
|
||||||
CancelAIAction( pSoldier, TRUE );
|
CancelAIAction( pSoldier, TRUE );
|
||||||
|
|
||||||
switch( pSoldier->ubProfile )
|
switch( pSoldier->ubProfile )
|
||||||
|
|||||||
@@ -2722,6 +2722,7 @@ void UIHandleMercAttack( SOLDIERTYPE *pSoldier , SOLDIERTYPE *pTargetSoldier, IN
|
|||||||
if ( NPCFirstDraw( pSoldier, pTargetSoldier ) )
|
if ( NPCFirstDraw( pSoldier, pTargetSoldier ) )
|
||||||
{
|
{
|
||||||
// go into turnbased for that person
|
// go into turnbased for that person
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: UIHandleMercAttack"));
|
||||||
CancelAIAction( pTargetSoldier, TRUE );
|
CancelAIAction( pTargetSoldier, TRUE );
|
||||||
AddToShouldBecomeHostileOrSayQuoteList( pTargetSoldier->ubID );
|
AddToShouldBecomeHostileOrSayQuoteList( pTargetSoldier->ubID );
|
||||||
//MakeCivHostile( pTargetSoldier, 2 );
|
//MakeCivHostile( pTargetSoldier, 2 );
|
||||||
|
|||||||
@@ -3510,6 +3510,7 @@ void HandlePlayerTeamMemberDeath( SOLDIERTYPE *pSoldier )
|
|||||||
{
|
{
|
||||||
if ( pSoldier->ubAutoBandagingMedic != NOBODY )
|
if ( pSoldier->ubAutoBandagingMedic != NOBODY )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, MercPtrs[pSoldier->ubAutoBandagingMedic], String("CancelAIAction: stop autobandaging in HandlePlayerTeamMemberDeath"));
|
||||||
CancelAIAction( MercPtrs[ pSoldier->ubAutoBandagingMedic ], TRUE );
|
CancelAIAction( MercPtrs[ pSoldier->ubAutoBandagingMedic ], TRUE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6073,6 +6074,7 @@ void CommonEnterCombatModeCode( )
|
|||||||
pSoldier->EVENT_StopMerc( pSoldier->sGridNo, pSoldier->ubDirection );
|
pSoldier->EVENT_StopMerc( pSoldier->sGridNo, pSoldier->ubDirection );
|
||||||
|
|
||||||
// END AI actions
|
// END AI actions
|
||||||
|
DebugAI(AI_MSG_INFO, MercPtrs[pSoldier->ubAutoBandagingMedic], String("CancelAIAction: enter combat mode"));
|
||||||
CancelAIAction( pSoldier, TRUE );
|
CancelAIAction( pSoldier, TRUE );
|
||||||
|
|
||||||
// turn off AI controlled flag
|
// turn off AI controlled flag
|
||||||
@@ -8812,6 +8814,7 @@ void HandleSuppressionFire( UINT8 ubTargetedMerc, UINT8 ubCausedAttacker )
|
|||||||
// AI people will have to have their actions canceled
|
// AI people will have to have their actions canceled
|
||||||
if (!(pSoldier->flags.uiStatusFlags & SOLDIER_PC))
|
if (!(pSoldier->flags.uiStatusFlags & SOLDIER_PC))
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: suppression: change stance/cower"));
|
||||||
CancelAIAction( pSoldier, TRUE );
|
CancelAIAction( pSoldier, TRUE );
|
||||||
#if 0
|
#if 0
|
||||||
pSoldier->aiData.bAction = AI_ACTION_CHANGE_STANCE;
|
pSoldier->aiData.bAction = AI_ACTION_CHANGE_STANCE;
|
||||||
@@ -9768,6 +9771,7 @@ void CencelAllActionsForTimeCompression( )
|
|||||||
if ( pSoldier->bInSector )
|
if ( pSoldier->bInSector )
|
||||||
{
|
{
|
||||||
// Hault!
|
// Hault!
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: time compression"));
|
||||||
pSoldier->EVENT_StopMerc( pSoldier->sGridNo, pSoldier->ubDirection );
|
pSoldier->EVENT_StopMerc( pSoldier->sGridNo, pSoldier->ubDirection );
|
||||||
|
|
||||||
// END AI actions
|
// END AI actions
|
||||||
|
|||||||
@@ -1987,6 +1987,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
|
|||||||
|
|
||||||
if ( pTSoldier->bTeam != gbPlayerNum )
|
if ( pTSoldier->bTeam != gbPlayerNum )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pTSoldier, String("CancelAIAction: dodge"));
|
||||||
CancelAIAction( pTSoldier, TRUE );
|
CancelAIAction( pTSoldier, TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2493,6 +2494,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
|
|||||||
{
|
{
|
||||||
if (!TileIsOutOfBounds(pSoldier->sAbsoluteFinalDestination))
|
if (!TileIsOutOfBounds(pSoldier->sAbsoluteFinalDestination))
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: end door open code"));
|
||||||
CancelAIAction( pSoldier, FORCE );
|
CancelAIAction( pSoldier, FORCE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12649,6 +12649,7 @@ void SOLDIERTYPE::EVENT_SoldierBeginBladeAttack( INT32 sGridNo, UINT8 ubDirectio
|
|||||||
|
|
||||||
if ( pTSoldier->bTeam != gbPlayerNum )
|
if ( pTSoldier->bTeam != gbPlayerNum )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pTSoldier, String("CancelAIAction: begin blade attack"));
|
||||||
CancelAIAction( pTSoldier, TRUE );
|
CancelAIAction( pTSoldier, TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12984,6 +12985,7 @@ void SOLDIERTYPE::EVENT_SoldierBeginPunchAttack( INT32 sGridNo, UINT8 ubDirectio
|
|||||||
|
|
||||||
if ( pTSoldier->bTeam != gbPlayerNum )
|
if ( pTSoldier->bTeam != gbPlayerNum )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pTSoldier, String("CancelAIAction: begin blade attack"));
|
||||||
CancelAIAction( pTSoldier, TRUE );
|
CancelAIAction( pTSoldier, TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16522,16 +16524,6 @@ BOOLEAN SOLDIERTYPE::IsAssassin( )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN SOLDIERTYPE::CheckInitialAP(void)
|
|
||||||
{
|
|
||||||
if (this->bActionPoints < this->bInitialActionPoints || this->usSoldierFlagMask2 & SOLDIER_SPENT_AP)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT8 SOLDIERTYPE::GetMultiTurnAction( )
|
UINT8 SOLDIERTYPE::GetMultiTurnAction( )
|
||||||
{
|
{
|
||||||
return usMultiTurnAction;
|
return usMultiTurnAction;
|
||||||
@@ -22171,6 +22163,7 @@ BOOLEAN SOLDIERTYPE::PlayerSoldierStartTalking( UINT8 ubTargetID, BOOLEAN fValid
|
|||||||
{
|
{
|
||||||
// Start combat etc
|
// Start combat etc
|
||||||
DeleteTalkingMenu( );
|
DeleteTalkingMenu( );
|
||||||
|
DebugAI(AI_MSG_INFO, pTSoldier, String("CancelAIAction: assasin: start talking"));
|
||||||
CancelAIAction( pTSoldier, TRUE );
|
CancelAIAction( pTSoldier, TRUE );
|
||||||
AddToShouldBecomeHostileOrSayQuoteList( pTSoldier->ubID );
|
AddToShouldBecomeHostileOrSayQuoteList( pTSoldier->ubID );
|
||||||
}
|
}
|
||||||
@@ -24789,3 +24782,26 @@ BOOLEAN ApplyConsumable( SOLDIERTYPE* pSoldier, OBJECTTYPE *pObj, BOOLEAN fForce
|
|||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sevenfm: service functions
|
||||||
|
BOOLEAN SOLDIERTYPE::CheckInitialAP(void)
|
||||||
|
{
|
||||||
|
if (this->bActionPoints < this->bInitialActionPoints || this->usSoldierFlagMask2 & SOLDIER_SPENT_AP)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN SOLDIERTYPE::IsFlanking(void)
|
||||||
|
{
|
||||||
|
if (this->aiData.bAlertStatus < STATUS_YELLOW ||
|
||||||
|
this->numFlanks == 0 ||
|
||||||
|
this->numFlanks >= MAX_FLANKS_RED)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1840,9 +1840,12 @@ public:
|
|||||||
// lose disguise or take off any clothes item and switch back to original clothes
|
// lose disguise or take off any clothes item and switch back to original clothes
|
||||||
void Strip();
|
void Strip();
|
||||||
|
|
||||||
// check wether our disguise is any good
|
// check whether our disguise is any good
|
||||||
void SpySelfTest();
|
void SpySelfTest();
|
||||||
|
|
||||||
|
// sevenfm: service functions
|
||||||
|
BOOLEAN IsFlanking(void);
|
||||||
|
|
||||||
// Flugente: prisoner system
|
// Flugente: prisoner system
|
||||||
BOOLEAN CanProcessPrisoners();
|
BOOLEAN CanProcessPrisoners();
|
||||||
UINT32 GetSurrenderStrength();
|
UINT32 GetSurrenderStrength();
|
||||||
|
|||||||
@@ -1843,7 +1843,7 @@ void HandleManNoLongerSeen( SOLDIERTYPE * pSoldier, SOLDIERTYPE * pOpponent, INT
|
|||||||
{
|
{
|
||||||
// unauthorized!
|
// unauthorized!
|
||||||
// make guard run to block guard room
|
// make guard run to block guard room
|
||||||
CancelAIAction( pSoldier, TRUE );
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: make guard run to block guard room")); CancelAIAction( pSoldier, TRUE );
|
||||||
RESETTIMECOUNTER( pSoldier->timeCounters.AICounter, 0 );
|
RESETTIMECOUNTER( pSoldier->timeCounters.AICounter, 0 );
|
||||||
pSoldier->aiData.bNextAction = AI_ACTION_RUN;
|
pSoldier->aiData.bNextAction = AI_ACTION_RUN;
|
||||||
pSoldier->aiData.usNextActionData = 13250;
|
pSoldier->aiData.usNextActionData = 13250;
|
||||||
@@ -2298,6 +2298,7 @@ void ManSeesMan(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, INT32 sOppGridNo,
|
|||||||
if ( pSoldier->aiData.bOppCnt == 0 )
|
if ( pSoldier->aiData.bOppCnt == 0 )
|
||||||
{
|
{
|
||||||
// didn't see anyone before!
|
// didn't see anyone before!
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: NPC with profile: change orders, reset action"));
|
||||||
CancelAIAction( pSoldier, TRUE );
|
CancelAIAction( pSoldier, TRUE );
|
||||||
SetNewSituation( pSoldier );
|
SetNewSituation( pSoldier );
|
||||||
}
|
}
|
||||||
@@ -2314,6 +2315,7 @@ void ManSeesMan(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, INT32 sOppGridNo,
|
|||||||
}
|
}
|
||||||
else if ( ( CheckFact( FACT_ANGEL_LEFT_DEED, ANGEL ) == TRUE ) && ( CheckFact( FACT_ANGEL_MENTIONED_DEED, ANGEL ) == FALSE ) )
|
else if ( ( CheckFact( FACT_ANGEL_LEFT_DEED, ANGEL ) == TRUE ) && ( CheckFact( FACT_ANGEL_MENTIONED_DEED, ANGEL ) == FALSE ) )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: NPC: Angel code"));
|
||||||
CancelAIAction( pSoldier, TRUE );
|
CancelAIAction( pSoldier, TRUE );
|
||||||
pSoldier->sAbsoluteFinalDestination = NOWHERE;
|
pSoldier->sAbsoluteFinalDestination = NOWHERE;
|
||||||
pSoldier->EVENT_StopMerc( pSoldier->sGridNo, pSoldier->ubDirection );
|
pSoldier->EVENT_StopMerc( pSoldier->sGridNo, pSoldier->ubDirection );
|
||||||
@@ -2389,6 +2391,7 @@ void ManSeesMan(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, INT32 sOppGridNo,
|
|||||||
if ( pSoldier->aiData.bOppCnt == 0 )
|
if ( pSoldier->aiData.bOppCnt == 0 )
|
||||||
{
|
{
|
||||||
// didn't see anyone before!
|
// didn't see anyone before!
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: assasin: didn't see anyone before!"));
|
||||||
CancelAIAction( pSoldier, TRUE );
|
CancelAIAction( pSoldier, TRUE );
|
||||||
SetNewSituation( pSoldier );
|
SetNewSituation( pSoldier );
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-4
@@ -81,6 +81,9 @@ extern BOOLEAN gfWaitingForTriggerTimer;
|
|||||||
|
|
||||||
UINT8 gubAICounter;
|
UINT8 gubAICounter;
|
||||||
|
|
||||||
|
extern STR16 gStrAction[];
|
||||||
|
extern STR szAction[];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Commented out/ to fix:
|
// Commented out/ to fix:
|
||||||
// lots of other stuff, I think
|
// lots of other stuff, I think
|
||||||
@@ -572,6 +575,7 @@ void HandleSoldierAI( SOLDIERTYPE *pSoldier ) // FIXME - this function is named
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// stunned/collapsed!
|
// stunned/collapsed!
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: collapsed"));
|
||||||
CancelAIAction( pSoldier, FORCE );
|
CancelAIAction( pSoldier, FORCE );
|
||||||
EndAIGuysTurn( pSoldier );
|
EndAIGuysTurn( pSoldier );
|
||||||
return;
|
return;
|
||||||
@@ -612,6 +616,7 @@ void HandleSoldierAI( SOLDIERTYPE *pSoldier ) // FIXME - this function is named
|
|||||||
{
|
{
|
||||||
// don't force, don't want escorted mercs reacting to new opponents, etc.
|
// don't force, don't want escorted mercs reacting to new opponents, etc.
|
||||||
// now we don't have AI controlled escorted mercs though - CJC
|
// now we don't have AI controlled escorted mercs though - CJC
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: escorted merc"));
|
||||||
CancelAIAction( pSoldier, FORCE );
|
CancelAIAction( pSoldier, FORCE );
|
||||||
// zap any next action too
|
// zap any next action too
|
||||||
if ( pSoldier->aiData.bAction != AI_ACTION_END_COWER_AND_MOVE )
|
if ( pSoldier->aiData.bAction != AI_ACTION_END_COWER_AND_MOVE )
|
||||||
@@ -645,8 +650,6 @@ void HandleSoldierAI( SOLDIERTYPE *pSoldier ) // FIXME - this function is named
|
|||||||
Start of new overall AI system
|
Start of new overall AI system
|
||||||
********/
|
********/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (gfTurnBasedAI)
|
if (gfTurnBasedAI)
|
||||||
{
|
{
|
||||||
if ( ( GetJA2Clock() - gTacticalStatus.uiTimeSinceMercAIStart ) > ( (UINT32)gGameExternalOptions.gubDeadLockDelay * 1000 ) && !gfUIInDeadlock )
|
if ( ( GetJA2Clock() - gTacticalStatus.uiTimeSinceMercAIStart ) > ( (UINT32)gGameExternalOptions.gubDeadLockDelay * 1000 ) && !gfUIInDeadlock )
|
||||||
@@ -654,6 +657,9 @@ void HandleSoldierAI( SOLDIERTYPE *pSoldier ) // FIXME - this function is named
|
|||||||
// ATE: Display message that deadlock occured...
|
// ATE: Display message that deadlock occured...
|
||||||
LiveMessage( "Breaking Deadlock" );
|
LiveMessage( "Breaking Deadlock" );
|
||||||
|
|
||||||
|
//ScreenMsg(FONT_MCOLOR_LTRED, MSG_INTERFACE, L"Aborting AI deadlock for [%d] %s data %d", pSoldier->ubID, gStrAction[pSoldier->aiData.bAction], pSoldier->aiData.usActionData);
|
||||||
|
DebugAI(String("Aborting AI deadlock for [%d] %s data %d", pSoldier->ubID, szAction[pSoldier->aiData.bAction], pSoldier->aiData.usActionData));
|
||||||
|
|
||||||
#ifdef JA2TESTVERSION
|
#ifdef JA2TESTVERSION
|
||||||
// display deadlock message
|
// display deadlock message
|
||||||
gfUIInDeadlock = TRUE;
|
gfUIInDeadlock = TRUE;
|
||||||
@@ -923,6 +929,12 @@ void EndAIDeadlock(void)
|
|||||||
DebugAI( String("Ending turn for %d because breaking deadlock", pSoldier->ubID ) );
|
DebugAI( String("Ending turn for %d because breaking deadlock", pSoldier->ubID ) );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
// sevenfm: abort flanking
|
||||||
|
if (pSoldier->IsFlanking())
|
||||||
|
{
|
||||||
|
pSoldier->numFlanks = MAX_FLANKS_RED + 1;
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("abort flanking, numFlanks = %d", pSoldier->numFlanks));
|
||||||
|
}
|
||||||
|
|
||||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Number of bullets in the air is %ld", guiNumBullets ) );
|
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Number of bullets in the air is %ld", guiNumBullets ) );
|
||||||
|
|
||||||
@@ -936,7 +948,6 @@ void EndAIDeadlock(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!bFound)
|
if (!bFound)
|
||||||
{
|
{
|
||||||
StartPlayerTeamTurn( TRUE, FALSE );
|
StartPlayerTeamTurn( TRUE, FALSE );
|
||||||
@@ -1428,6 +1439,8 @@ void CancelAIAction(SOLDIERTYPE *pSoldier, UINT8 ubForce)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction"));
|
||||||
|
|
||||||
// re-enable cover checking, something is new or something strange happened
|
// re-enable cover checking, something is new or something strange happened
|
||||||
if ( gGameExternalOptions.fEnemyTanksCanMoveInTactical || !ARMED_VEHICLE( pSoldier ) )//dnl ch64 290813
|
if ( gGameExternalOptions.fEnemyTanksCanMoveInTactical || !ARMED_VEHICLE( pSoldier ) )//dnl ch64 290813
|
||||||
SkipCoverCheck = FALSE;
|
SkipCoverCheck = FALSE;
|
||||||
@@ -1708,9 +1721,15 @@ void RefreshAI(SOLDIERTYPE *pSoldier)
|
|||||||
DecideAlertStatus(pSoldier);
|
DecideAlertStatus(pSoldier);
|
||||||
|
|
||||||
if (pSoldier->aiData.bAlertStatus == STATUS_YELLOW)
|
if (pSoldier->aiData.bAlertStatus == STATUS_YELLOW)
|
||||||
|
{
|
||||||
SkipCoverCheck = FALSE;
|
SkipCoverCheck = FALSE;
|
||||||
if ( !gGameExternalOptions.fEnemyTanksCanMoveInTactical && ARMED_VEHICLE( pSoldier ) )//dnl ch64 290813 tanks don't have move animations
|
DebugAI(AI_MSG_INFO, pSoldier, String("RefreshAI: disable SkipCoverCheck in yellow AI"));
|
||||||
|
}
|
||||||
|
if (!gGameExternalOptions.fEnemyTanksCanMoveInTactical && ARMED_VEHICLE(pSoldier))//dnl ch64 290813 tanks don't have move animations
|
||||||
|
{
|
||||||
SkipCoverCheck = TRUE;
|
SkipCoverCheck = TRUE;
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("RefreshAI: enable SkipCoverCheck for armed vehicle"));
|
||||||
|
}
|
||||||
|
|
||||||
// if he's in battle or knows opponents are here
|
// if he's in battle or knows opponents are here
|
||||||
if (gfTurnBasedAI)
|
if (gfTurnBasedAI)
|
||||||
@@ -2064,12 +2083,14 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier)
|
|||||||
|
|
||||||
if (!pSoldier->pathing.bPathStored)
|
if (!pSoldier->pathing.bPathStored)
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: no path stored, could not find path"));
|
||||||
CancelAIAction(pSoldier,FORCE);
|
CancelAIAction(pSoldier,FORCE);
|
||||||
return(FALSE); // nothing is in progress
|
return(FALSE); // nothing is in progress
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: no path stored"));
|
||||||
CancelAIAction(pSoldier,FORCE);
|
CancelAIAction(pSoldier,FORCE);
|
||||||
return(FALSE); // nothing is in progress
|
return(FALSE); // nothing is in progress
|
||||||
}
|
}
|
||||||
@@ -2124,6 +2145,7 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier)
|
|||||||
pSoldier->pathing.sBlackList = (INT16) pSoldier->aiData.usActionData;
|
pSoldier->pathing.sBlackList = (INT16) pSoldier->aiData.usActionData;
|
||||||
|
|
||||||
DebugAI( String( "Setting blacklist for %d to %d", pSoldier->ubID, pSoldier->pathing.sBlackList ) );
|
DebugAI( String( "Setting blacklist for %d to %d", pSoldier->ubID, pSoldier->pathing.sBlackList ) );
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: sFinalDestination != usActionData"));
|
||||||
|
|
||||||
CancelAIAction(pSoldier,FORCE);
|
CancelAIAction(pSoldier,FORCE);
|
||||||
return(FALSE); // nothing is in progress
|
return(FALSE); // nothing is in progress
|
||||||
@@ -2214,6 +2236,7 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier)
|
|||||||
DebugAI( String( "AI %d got error code %ld from HandleItem, doing action %d, has %d APs... aborting deadlock!", pSoldier->ubID, iRetCode, pSoldier->aiData.bAction, pSoldier->bActionPoints ) );
|
DebugAI( String( "AI %d got error code %ld from HandleItem, doing action %d, has %d APs... aborting deadlock!", pSoldier->ubID, iRetCode, pSoldier->aiData.bAction, pSoldier->bActionPoints ) );
|
||||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"AI %d got error code %ld from HandleItem, doing action %d... aborting deadlock!", pSoldier->ubID, iRetCode, pSoldier->aiData.bAction );
|
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"AI %d got error code %ld from HandleItem, doing action %d... aborting deadlock!", pSoldier->ubID, iRetCode, pSoldier->aiData.bAction );
|
||||||
}
|
}
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: !ITEM_HANDLE_OK"));
|
||||||
CancelAIAction( pSoldier, FORCE);
|
CancelAIAction( pSoldier, FORCE);
|
||||||
#ifdef TESTAICONTROL
|
#ifdef TESTAICONTROL
|
||||||
if (gfTurnBasedAI)
|
if (gfTurnBasedAI)
|
||||||
@@ -2391,6 +2414,7 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier)
|
|||||||
iRetCode = HandleItem( pSoldier, pSoldier->aiData.usActionData, 0, pSoldier->inv[HANDPOS].usItem, FALSE );
|
iRetCode = HandleItem( pSoldier, pSoldier->aiData.usActionData, 0, pSoldier->inv[HANDPOS].usItem, FALSE );
|
||||||
if ( iRetCode != ITEM_HANDLE_OK)
|
if ( iRetCode != ITEM_HANDLE_OK)
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: AI_ACTION_GIVE_AID: !ITEM_HANDLE_OK"));
|
||||||
#ifdef JA2BETAVERSION
|
#ifdef JA2BETAVERSION
|
||||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_ERROR, L"AI %d got error code %ld from HandleItem, doing action %d... aborting deadlock!", pSoldier->ubID, iRetCode, pSoldier->aiData.bAction );
|
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_ERROR, L"AI %d got error code %ld from HandleItem, doing action %d... aborting deadlock!", pSoldier->ubID, iRetCode, pSoldier->aiData.bAction );
|
||||||
#endif
|
#endif
|
||||||
@@ -2429,6 +2453,7 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier)
|
|||||||
#ifdef JA2TESTVERSION
|
#ifdef JA2TESTVERSION
|
||||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_ERROR, L"AI %d tried to open door it could not then find in %d", pSoldier->ubID, sDoorGridNo );
|
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_ERROR, L"AI %d tried to open door it could not then find in %d", pSoldier->ubID, sDoorGridNo );
|
||||||
#endif
|
#endif
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: door: cannot find structure"));
|
||||||
CancelAIAction( pSoldier, FORCE);
|
CancelAIAction( pSoldier, FORCE);
|
||||||
#ifdef TESTAICONTROL
|
#ifdef TESTAICONTROL
|
||||||
if (gfTurnBasedAI)
|
if (gfTurnBasedAI)
|
||||||
@@ -2459,6 +2484,7 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier)
|
|||||||
//if ( pSoldier->aiData.bOrders == SNIPER && pSoldier->aiData.bLastAction == AI_ACTION_RAISE_GUN)
|
//if ( pSoldier->aiData.bOrders == SNIPER && pSoldier->aiData.bLastAction == AI_ACTION_RAISE_GUN)
|
||||||
if ( pSoldier->aiData.bLastAction == AI_ACTION_RAISE_GUN)
|
if ( pSoldier->aiData.bLastAction == AI_ACTION_RAISE_GUN)
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("sniper deadlock fix !!! repeated AI_ACTION_RAISE_GUN, set next action to AI_ACTION_END_TURN"));
|
||||||
pSoldier->aiData.bNextAction = AI_ACTION_END_TURN;
|
pSoldier->aiData.bNextAction = AI_ACTION_END_TURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3729,7 +3729,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sevenfm: possibly start RED flanking
|
// sevenfm: possibly start RED flanking
|
||||||
if ( ( pSoldier->aiData.bAttitude == CUNNINGAID || pSoldier->aiData.bAttitude == CUNNINGSOLO ||
|
if (( pSoldier->aiData.bAttitude == CUNNINGAID || pSoldier->aiData.bAttitude == CUNNINGSOLO ||
|
||||||
( pSoldier->aiData.bAttitude == BRAVESOLO || pSoldier->aiData.bAttitude == BRAVEAID ) && fOvercrowded ) &&
|
( pSoldier->aiData.bAttitude == BRAVESOLO || pSoldier->aiData.bAttitude == BRAVEAID ) && fOvercrowded ) &&
|
||||||
pSoldier->bTeam == ENEMY_TEAM &&
|
pSoldier->bTeam == ENEMY_TEAM &&
|
||||||
gAnimControl[ pSoldier->usAnimState ].ubHeight != ANIM_PRONE &&
|
gAnimControl[ pSoldier->usAnimState ].ubHeight != ANIM_PRONE &&
|
||||||
|
|||||||
@@ -1897,6 +1897,7 @@ INT32 FindNearbyDarkerSpot(SOLDIERTYPE *pSoldier)
|
|||||||
INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
||||||
{
|
{
|
||||||
DebugMsg(TOPIC_JA2AI,DBG_LEVEL_3,String("SearchForItems"));
|
DebugMsg(TOPIC_JA2AI,DBG_LEVEL_3,String("SearchForItems"));
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("SearchForItems [%d] bReason %d usItem %d", pSoldier->ubID, bReason, usItem));
|
||||||
|
|
||||||
INT32 iSearchRange;
|
INT32 iSearchRange;
|
||||||
INT16 sMaxLeft, sMaxRight, sMaxUp, sMaxDown, sXOffset, sYOffset;
|
INT16 sMaxLeft, sMaxRight, sMaxUp, sMaxDown, sXOffset, sYOffset;
|
||||||
@@ -1915,20 +1916,24 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
// No fair picking up weapons while boxing!
|
// No fair picking up weapons while boxing!
|
||||||
if (gTacticalStatus.bBoxingState == BOXING)
|
if (gTacticalStatus.bBoxingState == BOXING)
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("no picking up items for boxers!"));
|
||||||
return AI_ACTION_NONE;
|
return AI_ACTION_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSoldier->bActionPoints < GetBasicAPsToPickupItem( pSoldier ))
|
if (pSoldier->bActionPoints < GetBasicAPsToPickupItem( pSoldier ))
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("not enough AP!"));
|
||||||
return( AI_ACTION_NONE );
|
return( AI_ACTION_NONE );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !IS_MERC_BODY_TYPE( pSoldier ) )
|
if ( !IS_MERC_BODY_TYPE( pSoldier ) )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("not merc bodytype!"));
|
||||||
return( AI_ACTION_NONE );
|
return( AI_ACTION_NONE );
|
||||||
}
|
}
|
||||||
|
|
||||||
iSearchRange = gbDiff[DIFF_MAX_COVER_RANGE][ SoldierDifficultyLevel( pSoldier ) ];
|
iSearchRange = gbDiff[DIFF_MAX_COVER_RANGE][ SoldierDifficultyLevel( pSoldier ) ];
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("use search range %d", iSearchRange));
|
||||||
|
|
||||||
switch (pSoldier->aiData.bAttitude)
|
switch (pSoldier->aiData.bAttitude)
|
||||||
{
|
{
|
||||||
@@ -1995,8 +2000,11 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
FindBestPath( pSoldier, GRIDSIZE, pSoldier->pathing.bLevel, DetermineMovementMode( pSoldier, AI_ACTION_PICKUP_ITEM ), COPYREACHABLE, 0 );//dnl ch50 071009
|
FindBestPath( pSoldier, GRIDSIZE, pSoldier->pathing.bLevel, DetermineMovementMode( pSoldier, AI_ACTION_PICKUP_ITEM ), COPYREACHABLE, 0 );//dnl ch50 071009
|
||||||
|
|
||||||
// Flugente: if the soldier is 'dumb enough', he may pick up certain items... which can be used to lure the AI into traps
|
// Flugente: if the soldier is 'dumb enough', he may pick up certain items... which can be used to lure the AI into traps
|
||||||
if ( pSoldier->stats.bWisdom < 70 )
|
if (pSoldier->stats.bWisdom < 70)
|
||||||
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("dumb enough to pick up items"));
|
||||||
fDumbEnoughtoPickup = TRUE;
|
fDumbEnoughtoPickup = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
// SET UP DOUBLE-LOOP TO STEP THROUGH POTENTIAL GRID #s
|
// SET UP DOUBLE-LOOP TO STEP THROUGH POTENTIAL GRID #s
|
||||||
for (sYOffset = -sMaxUp; sYOffset <= sMaxDown; sYOffset++)
|
for (sYOffset = -sMaxUp; sYOffset <= sMaxDown; sYOffset++)
|
||||||
@@ -2030,16 +2038,21 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("check spot %d, found items", sGridNo));
|
||||||
|
|
||||||
iValue = 0;
|
iValue = 0;
|
||||||
GetItemPool( sGridNo, &pItemPool, pSoldier->pathing.bLevel );
|
GetItemPool( sGridNo, &pItemPool, pSoldier->pathing.bLevel );
|
||||||
switch( bReason )
|
switch( bReason )
|
||||||
{
|
{
|
||||||
case SEARCH_AMMO:
|
case SEARCH_AMMO:
|
||||||
// we are looking for ammo to match the gun in usItem
|
// we are looking for ammo to match the gun in usItem
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("SEARCH_AMMO"));
|
||||||
while( pItemPool )
|
while( pItemPool )
|
||||||
{
|
{
|
||||||
pObj = &(gWorldItems[ pItemPool->iItemIndex ].object);
|
pObj = &(gWorldItems[ pItemPool->iItemIndex ].object);
|
||||||
pItem = &(Item[pObj->usItem]);
|
pItem = &(Item[pObj->usItem]);
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("check item %d at %d status %d", pObj->usItem, sGridNo, (*pObj)[0]->data.objectStatus));
|
||||||
|
|
||||||
if ( pItem->usItemClass == IC_GUN && (*pObj)[0]->data.objectStatus >= MINIMUM_REQUIRED_STATUS )
|
if ( pItem->usItemClass == IC_GUN && (*pObj)[0]->data.objectStatus >= MINIMUM_REQUIRED_STATUS )
|
||||||
{
|
{
|
||||||
// maybe this gun has ammo (adjust for whether it is better than ours!)
|
// maybe this gun has ammo (adjust for whether it is better than ours!)
|
||||||
@@ -2054,14 +2067,19 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
}
|
}
|
||||||
else if (ValidAmmoType( usItem, pObj->usItem ) )
|
else if (ValidAmmoType( usItem, pObj->usItem ) )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("good ammo"));
|
||||||
iTempValue = TotalPoints( pObj );
|
iTempValue = TotalPoints( pObj );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("not gun, not ammo - skip"));
|
||||||
iTempValue = 0;
|
iTempValue = 0;
|
||||||
}
|
}
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("iTempValue %d", iTempValue));
|
||||||
|
|
||||||
if (iTempValue > iValue )
|
if (iTempValue > iValue )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("select this ammo"));
|
||||||
iValue = iTempValue;
|
iValue = iTempValue;
|
||||||
iItemIndex = pItemPool->iItemIndex;
|
iItemIndex = pItemPool->iItemIndex;
|
||||||
}
|
}
|
||||||
@@ -2069,19 +2087,25 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SEARCH_WEAPONS:
|
case SEARCH_WEAPONS:
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("SEARCH_WEAPONS"));
|
||||||
while( pItemPool )
|
while( pItemPool )
|
||||||
{
|
{
|
||||||
pObj = &(gWorldItems[ pItemPool->iItemIndex ].object);
|
pObj = &(gWorldItems[ pItemPool->iItemIndex ].object);
|
||||||
pItem = &(Item[pObj->usItem]);
|
pItem = &(Item[pObj->usItem]);
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("check item %d at %d status %d", pObj->usItem, sGridNo, (*pObj)[0]->data.objectStatus));
|
||||||
|
|
||||||
if (pItem->usItemClass & IC_WEAPON && (*pObj)[0]->data.objectStatus >= MINIMUM_REQUIRED_STATUS )
|
if (pItem->usItemClass & IC_WEAPON && (*pObj)[0]->data.objectStatus >= MINIMUM_REQUIRED_STATUS )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("weapon has good status"));
|
||||||
if ( (pItem->usItemClass & IC_GUN) && ((*pObj)[0]->data.gun.bGunAmmoStatus < 0 || (*pObj)[0]->data.gun.ubGunShotsLeft == 0 || (( Item[pObj->usItem].fingerprintid ) && (*pObj)[0]->data.ubImprintID != NOBODY && (*pObj)[0]->data.ubImprintID != pSoldier->ubID) ) )
|
if ( (pItem->usItemClass & IC_GUN) && ((*pObj)[0]->data.gun.bGunAmmoStatus < 0 || (*pObj)[0]->data.gun.ubGunShotsLeft == 0 || (( Item[pObj->usItem].fingerprintid ) && (*pObj)[0]->data.ubImprintID != NOBODY && (*pObj)[0]->data.ubImprintID != pSoldier->ubID) ) )
|
||||||
{
|
{
|
||||||
// jammed or out of ammo, skip it!
|
// jammed or out of ammo, skip it!
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("jammed or out of ammo, skip it!"));
|
||||||
iTempValue = 0;
|
iTempValue = 0;
|
||||||
}
|
}
|
||||||
else if ( Item[pSoldier->inv[HANDPOS].usItem].usItemClass & IC_WEAPON )
|
else if ( Item[pSoldier->inv[HANDPOS].usItem].usItemClass & IC_WEAPON )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("compare with gun in hand"));
|
||||||
if (Weapon[pObj->usItem].ubDeadliness > Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness)
|
if (Weapon[pObj->usItem].ubDeadliness > Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness)
|
||||||
{
|
{
|
||||||
iTempValue = 100 * Weapon[pObj->usItem].ubDeadliness / Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness;
|
iTempValue = 100 * Weapon[pObj->usItem].ubDeadliness / Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness;
|
||||||
@@ -2098,10 +2122,14 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("not weapon or bad status"));
|
||||||
iTempValue = 0;
|
iTempValue = 0;
|
||||||
}
|
}
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("iTempValue %d", iTempValue));
|
||||||
|
|
||||||
if (iTempValue > iValue )
|
if (iTempValue > iValue )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("select this weapon"));
|
||||||
iValue = iTempValue;
|
iValue = iTempValue;
|
||||||
iItemIndex = pItemPool->iItemIndex;
|
iItemIndex = pItemPool->iItemIndex;
|
||||||
}
|
}
|
||||||
@@ -2109,19 +2137,26 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("search items"));
|
||||||
|
|
||||||
while( pItemPool )
|
while( pItemPool )
|
||||||
{
|
{
|
||||||
pObj = &(gWorldItems[ pItemPool->iItemIndex ].object);
|
pObj = &(gWorldItems[ pItemPool->iItemIndex ].object);
|
||||||
pItem = &(Item[pObj->usItem]);
|
pItem = &(Item[pObj->usItem]);
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("check item %d at %d status %d", pObj->usItem, sGridNo, (*pObj)[0]->data.objectStatus));
|
||||||
|
|
||||||
if ( pItem->usItemClass & IC_WEAPON && (*pObj)[0]->data.objectStatus >= MINIMUM_REQUIRED_STATUS )
|
if ( pItem->usItemClass & IC_WEAPON && (*pObj)[0]->data.objectStatus >= MINIMUM_REQUIRED_STATUS )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("gun has good status"));
|
||||||
if ( (pItem->usItemClass & IC_GUN) && ((*pObj)[0]->data.gun.bGunAmmoStatus < 0 || (*pObj)[0]->data.gun.ubGunShotsLeft == 0 || (( Item[pObj->usItem].fingerprintid ) && (*pObj)[0]->data.ubImprintID != NOBODY && (*pObj)[0]->data.ubImprintID != pSoldier->ubID) ) )
|
if ( (pItem->usItemClass & IC_GUN) && ((*pObj)[0]->data.gun.bGunAmmoStatus < 0 || (*pObj)[0]->data.gun.ubGunShotsLeft == 0 || (( Item[pObj->usItem].fingerprintid ) && (*pObj)[0]->data.ubImprintID != NOBODY && (*pObj)[0]->data.ubImprintID != pSoldier->ubID) ) )
|
||||||
{
|
{
|
||||||
// jammed or out of ammo, skip it!
|
// jammed or out of ammo, skip it!
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("jammed or out of ammo, skip it!"));
|
||||||
iTempValue = 0;
|
iTempValue = 0;
|
||||||
}
|
}
|
||||||
else if ( (Item[pSoldier->inv[HANDPOS].usItem].usItemClass & IC_WEAPON) )
|
else if (pSoldier->inv[HANDPOS].exists() && (Item[pSoldier->inv[HANDPOS].usItem].usItemClass & IC_WEAPON))
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("compare with weapon in hand"));
|
||||||
if (Weapon[pObj->usItem].ubDeadliness > Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness)
|
if (Weapon[pObj->usItem].ubDeadliness > Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness)
|
||||||
{
|
{
|
||||||
if ((Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness != NULL) && (Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness > 0))
|
if ((Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness != NULL) && (Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness > 0))
|
||||||
@@ -2142,14 +2177,17 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
{
|
{
|
||||||
iTempValue = 200 + Weapon[pObj->usItem].ubDeadliness;
|
iTempValue = 200 + Weapon[pObj->usItem].ubDeadliness;
|
||||||
}
|
}
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("iTempValue %d", iTempValue));
|
||||||
}
|
}
|
||||||
else if (pItem->usItemClass == IC_ARMOUR && (*pObj)[0]->data.objectStatus >= MINIMUM_REQUIRED_STATUS )
|
else if (pItem->usItemClass == IC_ARMOUR && (*pObj)[0]->data.objectStatus >= MINIMUM_REQUIRED_STATUS )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("armour has good status"));
|
||||||
iTempValue = 0;
|
iTempValue = 0;
|
||||||
|
|
||||||
switch( Armour[pItem->ubClassIndex].ubArmourClass )
|
switch( Armour[pItem->ubClassIndex].ubArmourClass )
|
||||||
{
|
{
|
||||||
case ARMOURCLASS_HELMET:
|
case ARMOURCLASS_HELMET:
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("ARMOURCLASS_HELMET"));
|
||||||
if (pSoldier->inv[HELMETPOS].exists() == false)
|
if (pSoldier->inv[HELMETPOS].exists() == false)
|
||||||
{
|
{
|
||||||
iTempValue = 200 + EffectiveArmour( pObj );
|
iTempValue = 200 + EffectiveArmour( pObj );
|
||||||
@@ -2158,8 +2196,10 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
{
|
{
|
||||||
iTempValue = 100 * EffectiveArmour( pObj ) / (EffectiveArmour( &(pSoldier->inv[HELMETPOS]) ) + 1);
|
iTempValue = 100 * EffectiveArmour( pObj ) / (EffectiveArmour( &(pSoldier->inv[HELMETPOS]) ) + 1);
|
||||||
}
|
}
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("iTempValue %d", iTempValue));
|
||||||
break;
|
break;
|
||||||
case ARMOURCLASS_VEST:
|
case ARMOURCLASS_VEST:
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("ARMOURCLASS_VEST"));
|
||||||
if (pSoldier->inv[VESTPOS].exists() == false)
|
if (pSoldier->inv[VESTPOS].exists() == false)
|
||||||
{
|
{
|
||||||
iTempValue = 200 + EffectiveArmour( pObj );
|
iTempValue = 200 + EffectiveArmour( pObj );
|
||||||
@@ -2168,8 +2208,10 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
{
|
{
|
||||||
iTempValue = 100 * EffectiveArmour( pObj ) / (EffectiveArmour( &(pSoldier->inv[VESTPOS]) ) + 1);
|
iTempValue = 100 * EffectiveArmour( pObj ) / (EffectiveArmour( &(pSoldier->inv[VESTPOS]) ) + 1);
|
||||||
}
|
}
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("iTempValue %d", iTempValue));
|
||||||
break;
|
break;
|
||||||
case ARMOURCLASS_LEGGINGS:
|
case ARMOURCLASS_LEGGINGS:
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("ARMOURCLASS_LEGGINGS"));
|
||||||
if (pSoldier->inv[LEGPOS].exists() == false)
|
if (pSoldier->inv[LEGPOS].exists() == false)
|
||||||
{
|
{
|
||||||
iTempValue = 200 + EffectiveArmour( pObj );
|
iTempValue = 200 + EffectiveArmour( pObj );
|
||||||
@@ -2178,6 +2220,7 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
{
|
{
|
||||||
iTempValue = 100 * EffectiveArmour( pObj ) / (EffectiveArmour( &(pSoldier->inv[LEGPOS]) ) + 1);
|
iTempValue = 100 * EffectiveArmour( pObj ) / (EffectiveArmour( &(pSoldier->inv[LEGPOS]) ) + 1);
|
||||||
}
|
}
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("iTempValue %d", iTempValue));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@@ -2188,6 +2231,7 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
// Flugente: if the soldier is 'dumb enough', he may pick up 'interesting items'. This can be used to lure him into traps (a certain scene in FMJ comes to mind)
|
// Flugente: if the soldier is 'dumb enough', he may pick up 'interesting items'. This can be used to lure him into traps (a certain scene in FMJ comes to mind)
|
||||||
else if ( fDumbEnoughtoPickup && pItem->usItemClass == IC_MISC && HasItemFlag(pObj->usItem, ATTENTION_ITEM) )
|
else if ( fDumbEnoughtoPickup && pItem->usItemClass == IC_MISC && HasItemFlag(pObj->usItem, ATTENTION_ITEM) )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("dumb soldier picks up item!"));
|
||||||
// oooh... shiny!
|
// oooh... shiny!
|
||||||
iTempValue = 1000;
|
iTempValue = 1000;
|
||||||
}
|
}
|
||||||
@@ -2195,9 +2239,11 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
{
|
{
|
||||||
iTempValue = 0;
|
iTempValue = 0;
|
||||||
}
|
}
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("iTempValue %d", iTempValue));
|
||||||
|
|
||||||
if (iTempValue > iValue )
|
if (iTempValue > iValue )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("select item"));
|
||||||
iValue = iTempValue;
|
iValue = iTempValue;
|
||||||
iItemIndex = pItemPool->iItemIndex;
|
iItemIndex = pItemPool->iItemIndex;
|
||||||
}
|
}
|
||||||
@@ -2206,8 +2252,12 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
iValue = (3 * iValue) / (3 + PythSpacesAway( sGridNo, pSoldier->sGridNo ));
|
iValue = (3 * iValue) / (3 + PythSpacesAway( sGridNo, pSoldier->sGridNo ));
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("iBestValue %d", iBestValue));
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("value modified by distance %d", iValue));
|
||||||
|
|
||||||
if (iValue > iBestValue )
|
if (iValue > iBestValue )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("select item at %d", sGridNo));
|
||||||
sBestSpot = sGridNo;
|
sBestSpot = sGridNo;
|
||||||
iBestValue = iValue;
|
iBestValue = iValue;
|
||||||
iBestItemIndex = iItemIndex;
|
iBestItemIndex = iItemIndex;
|
||||||
@@ -2218,7 +2268,7 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
|
|
||||||
if (!TileIsOutOfBounds(sBestSpot))
|
if (!TileIsOutOfBounds(sBestSpot))
|
||||||
{
|
{
|
||||||
DebugAI( String( "%d decides to pick up %S", pSoldier->ubID, ItemNames[ gWorldItems[ iBestItemIndex ].object.usItem ] ) );
|
DebugAI(AI_MSG_INFO, pSoldier, String("%d decides to pick up %S", pSoldier->ubID, ItemNames[gWorldItems[iBestItemIndex].object.usItem]));
|
||||||
if (Item[gWorldItems[ iBestItemIndex ].object.usItem].usItemClass == IC_GUN)
|
if (Item[gWorldItems[ iBestItemIndex ].object.usItem].usItemClass == IC_GUN)
|
||||||
{
|
{
|
||||||
//CHRISL: This is the line from ADB's code but I removed it, for now, to match what 0verhaul has been working on
|
//CHRISL: This is the line from ADB's code but I removed it, for now, to match what 0verhaul has been working on
|
||||||
@@ -2232,14 +2282,14 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
|
|||||||
if (pSoldier->inv[HANDPOS].fFlags & OBJECT_UNDROPPABLE)
|
if (pSoldier->inv[HANDPOS].fFlags & OBJECT_UNDROPPABLE)
|
||||||
{
|
{
|
||||||
// destroy this item!
|
// destroy this item!
|
||||||
DebugAI( String( "%d decides he must drop %S first so destroys it", pSoldier->ubID, ItemNames[ pSoldier->inv[HANDPOS].usItem ] ) );
|
DebugAI(AI_MSG_INFO, pSoldier, String("%d decides he must drop %S first so destroys it", pSoldier->ubID, ItemNames[pSoldier->inv[HANDPOS].usItem]));
|
||||||
DeleteObj( &(pSoldier->inv[HANDPOS]) );
|
DeleteObj( &(pSoldier->inv[HANDPOS]) );
|
||||||
DeductPoints( pSoldier, GetBasicAPsToPickupItem( pSoldier ), 0, AFTERACTION_INTERRUPT );
|
DeductPoints( pSoldier, GetBasicAPsToPickupItem( pSoldier ), 0, AFTERACTION_INTERRUPT );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// we want to drop this item!
|
// we want to drop this item!
|
||||||
DebugAI( String( "%d decides he must drop %S first", pSoldier->ubID, ItemNames[ pSoldier->inv[HANDPOS].usItem ] ) );
|
DebugAI(AI_MSG_INFO, pSoldier, String("%d decides he must drop %S first", pSoldier->ubID, ItemNames[pSoldier->inv[HANDPOS].usItem]));
|
||||||
|
|
||||||
pSoldier->aiData.bNextAction = AI_ACTION_PICKUP_ITEM;
|
pSoldier->aiData.bNextAction = AI_ACTION_PICKUP_ITEM;
|
||||||
pSoldier->aiData.usNextActionData = sBestSpot;
|
pSoldier->aiData.usNextActionData = sBestSpot;
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ void CallEldinTo( INT32 sGridNo )
|
|||||||
pSoldier->aiData.bAlertStatus = STATUS_RED;
|
pSoldier->aiData.bAlertStatus = STATUS_RED;
|
||||||
if ( (pSoldier->aiData.bAction != AI_ACTION_GET_CLOSER) || CheckFact( FACT_MUSEUM_ALARM_WENT_OFF, 0 ) == FALSE )
|
if ( (pSoldier->aiData.bAction != AI_ACTION_GET_CLOSER) || CheckFact( FACT_MUSEUM_ALARM_WENT_OFF, 0 ) == FALSE )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: CallEldinTo"));
|
||||||
CancelAIAction( pSoldier, TRUE );
|
CancelAIAction( pSoldier, TRUE );
|
||||||
pSoldier->aiData.bNextAction = AI_ACTION_GET_CLOSER;
|
pSoldier->aiData.bNextAction = AI_ACTION_GET_CLOSER;
|
||||||
pSoldier->aiData.usNextActionData = sGridNo;
|
pSoldier->aiData.usNextActionData = sGridNo;
|
||||||
|
|||||||
@@ -382,6 +382,7 @@ INT8 FindBestPatient( SOLDIERTYPE * pSoldier, BOOLEAN * pfDoClimb )
|
|||||||
if (pBestPatient->ubAutoBandagingMedic != NOBODY)
|
if (pBestPatient->ubAutoBandagingMedic != NOBODY)
|
||||||
{
|
{
|
||||||
// cancel that medic
|
// cancel that medic
|
||||||
|
DebugAI(AI_MSG_INFO, MercPtrs[pBestPatient->ubAutoBandagingMedic], String("CancelAIAction: medic: find patient"));
|
||||||
CancelAIAction( MercPtrs[ pBestPatient->ubAutoBandagingMedic ], TRUE );
|
CancelAIAction( MercPtrs[ pBestPatient->ubAutoBandagingMedic ], TRUE );
|
||||||
}
|
}
|
||||||
pBestPatient->ubAutoBandagingMedic = pSoldier->ubID;
|
pBestPatient->ubAutoBandagingMedic = pSoldier->ubID;
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ int TryToResumeMovement(SOLDIERTYPE *pSoldier, INT32 sGridNo)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// must work even for escorted civs, can't just set the flag
|
// must work even for escorted civs, can't just set the flag
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: could not resume movement"));
|
||||||
CancelAIAction(pSoldier,FORCE);
|
CancelAIAction(pSoldier,FORCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,6 +189,7 @@ int TryToResumeMovement(SOLDIERTYPE *pSoldier, INT32 sGridNo)
|
|||||||
|
|
||||||
if (!pSoldier->aiData.bUnderEscort)
|
if (!pSoldier->aiData.bUnderEscort)
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: not under escort"));
|
||||||
CancelAIAction(pSoldier,DONTFORCE); // no need to force this
|
CancelAIAction(pSoldier,DONTFORCE); // no need to force this
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -222,6 +224,7 @@ int TryToResumeMovement(SOLDIERTYPE *pSoldier, INT32 sGridNo)
|
|||||||
if (ubGottaCancel)
|
if (ubGottaCancel)
|
||||||
{
|
{
|
||||||
// can't get close, gotta abort the movement!
|
// can't get close, gotta abort the movement!
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: can't get close, abort movement"));
|
||||||
CancelAIAction(pSoldier,FORCE);
|
CancelAIAction(pSoldier,FORCE);
|
||||||
|
|
||||||
// tell the player doing the escorting that civilian has stopped
|
// tell the player doing the escorting that civilian has stopped
|
||||||
@@ -754,18 +757,21 @@ void SoldierTriesToContinueAlongPath(SOLDIERTYPE *pSoldier)
|
|||||||
|
|
||||||
if (pSoldier->aiData.bNewSituation == IS_NEW_SITUATION)
|
if (pSoldier->aiData.bNewSituation == IS_NEW_SITUATION)
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: IS_NEW_SITUATION"));
|
||||||
CancelAIAction(pSoldier,DONTFORCE);
|
CancelAIAction(pSoldier,DONTFORCE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TileIsOutOfBounds(pSoldier->aiData.usActionData))
|
if (TileIsOutOfBounds(pSoldier->aiData.usActionData))
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: bad usActionData"));
|
||||||
CancelAIAction(pSoldier,DONTFORCE);
|
CancelAIAction(pSoldier,DONTFORCE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NewOKDestination( pSoldier,pSoldier->aiData.usActionData, TRUE, pSoldier->pathing.bLevel ))
|
if (!NewOKDestination( pSoldier,pSoldier->aiData.usActionData, TRUE, pSoldier->pathing.bLevel ))
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: !NewOKDestination"));
|
||||||
CancelAIAction(pSoldier,DONTFORCE);
|
CancelAIAction(pSoldier,DONTFORCE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -801,6 +807,7 @@ void SoldierTriesToContinueAlongPath(SOLDIERTYPE *pSoldier)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: !IsActionAffordable"));
|
||||||
CancelAIAction(pSoldier,DONTFORCE);
|
CancelAIAction(pSoldier,DONTFORCE);
|
||||||
#ifdef TESTAI
|
#ifdef TESTAI
|
||||||
DebugMsg( TOPIC_JA2AI, DBG_LEVEL_3,
|
DebugMsg( TOPIC_JA2AI, DBG_LEVEL_3,
|
||||||
@@ -826,6 +833,7 @@ void SoldierTriesToContinueAlongPath(SOLDIERTYPE *pSoldier)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: not enough AP"));
|
||||||
CancelAIAction(pSoldier,DONTFORCE);
|
CancelAIAction(pSoldier,DONTFORCE);
|
||||||
#ifdef TESTAI
|
#ifdef TESTAI
|
||||||
DebugMsg( TOPIC_JA2AI, DBG_LEVEL_3,
|
DebugMsg( TOPIC_JA2AI, DBG_LEVEL_3,
|
||||||
|
|||||||
@@ -2240,6 +2240,7 @@ void Converse( UINT8 ubNPC, UINT8 ubMerc, INT8 bApproach, UINT32 uiApproachData
|
|||||||
case OLGA:
|
case OLGA:
|
||||||
case TYRONE:
|
case TYRONE:
|
||||||
// Start combat etc
|
// Start combat etc
|
||||||
|
DebugAI(AI_MSG_INFO, pNPC, String("CancelAIAction: NPC coverse"));
|
||||||
CancelAIAction( pNPC, TRUE );
|
CancelAIAction( pNPC, TRUE );
|
||||||
AddToShouldBecomeHostileOrSayQuoteList( pNPC->ubID );
|
AddToShouldBecomeHostileOrSayQuoteList( pNPC->ubID );
|
||||||
default:
|
default:
|
||||||
|
|||||||
+47
-25
@@ -249,14 +249,17 @@ void PossiblyMakeThisEnemyChosenOne( SOLDIERTYPE * pSoldier )
|
|||||||
|
|
||||||
INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
||||||
{
|
{
|
||||||
BOOLEAN fFoundRoute = FALSE;
|
BOOLEAN fFoundRoute = FALSE;
|
||||||
INT8 bSlot;
|
INT8 bSlot;
|
||||||
INT32 iPathCost;
|
INT32 iPathCost;
|
||||||
INT8 bPanicTrigger;
|
INT8 bPanicTrigger;
|
||||||
INT32 sPanicTriggerGridNo;
|
INT32 sPanicTriggerGridNo;
|
||||||
#ifdef DEBUGDECISIONS
|
UINT16 usMovementMode;
|
||||||
STR16 tempstr;
|
#ifdef DEBUGDECISIONS
|
||||||
#endif
|
STR16 tempstr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("[Panic AI]"));
|
||||||
|
|
||||||
// if there are panic bombs here
|
// if there are panic bombs here
|
||||||
if (gTacticalStatus.fPanicFlags & PANIC_BOMBS_HERE)
|
if (gTacticalStatus.fPanicFlags & PANIC_BOMBS_HERE)
|
||||||
@@ -265,6 +268,7 @@ INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
|||||||
bSlot = FindTrigger( pSoldier );
|
bSlot = FindTrigger( pSoldier );
|
||||||
if (bSlot != NO_SLOT)
|
if (bSlot != NO_SLOT)
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("found trigger, slot %d", bSlot));
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// ACTIVATE DETONATOR: blow up sector's panic bombs
|
// ACTIVATE DETONATOR: blow up sector's panic bombs
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@@ -277,11 +281,13 @@ INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
|||||||
PopMessage(tempstr);
|
PopMessage(tempstr);
|
||||||
#endif
|
#endif
|
||||||
// blow up all the PANIC bombs!
|
// blow up all the PANIC bombs!
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("blow up panic bomb"));
|
||||||
return(AI_ACTION_USE_DETONATOR);
|
return(AI_ACTION_USE_DETONATOR);
|
||||||
}
|
}
|
||||||
else // otherwise, wait a turn
|
else // otherwise, wait a turn
|
||||||
{
|
{
|
||||||
pSoldier->aiData.usActionData = NOWHERE;
|
pSoldier->aiData.usActionData = NOWHERE;
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("wait a turn"));
|
||||||
return(AI_ACTION_NONE);
|
return(AI_ACTION_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,54 +298,66 @@ INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
|||||||
// if there's a panic trigger here (DOESN'T MATTER IF ANY PANIC BOMBS EXIST!)
|
// if there's a panic trigger here (DOESN'T MATTER IF ANY PANIC BOMBS EXIST!)
|
||||||
if ( gTacticalStatus.fPanicFlags & PANIC_TRIGGERS_HERE )
|
if ( gTacticalStatus.fPanicFlags & PANIC_TRIGGERS_HERE )
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("found panic trigger"));
|
||||||
|
usMovementMode = DetermineMovementMode(pSoldier, AI_ACTION_GET_CLOSER);
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("movement mode %d", usMovementMode));
|
||||||
|
|
||||||
// Have WE been chosen to go after the trigger?
|
// Have WE been chosen to go after the trigger?
|
||||||
if (pSoldier->ubID == gTacticalStatus.ubTheChosenOne)
|
if (pSoldier->ubID == gTacticalStatus.ubTheChosenOne)
|
||||||
{
|
{
|
||||||
bPanicTrigger = ClosestPanicTrigger( pSoldier );
|
bPanicTrigger = ClosestPanicTrigger( pSoldier );
|
||||||
|
|
||||||
if (bPanicTrigger == -1)
|
if (bPanicTrigger == -1)
|
||||||
{
|
{
|
||||||
// augh!
|
// augh!
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
sPanicTriggerGridNo = gTacticalStatus.sPanicTriggerGridNo[ bPanicTrigger ];
|
sPanicTriggerGridNo = gTacticalStatus.sPanicTriggerGridNo[ bPanicTrigger ];
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("closest panic trigger %d, spot %d", bPanicTrigger, sPanicTriggerGridNo));
|
||||||
|
|
||||||
// if not standing on the panic trigger
|
// if not standing on the panic trigger
|
||||||
if (pSoldier->sGridNo != sPanicTriggerGridNo)
|
if (pSoldier->sGridNo != sPanicTriggerGridNo)
|
||||||
{
|
{
|
||||||
// determine whether we can still get there
|
// determine whether we can still get there
|
||||||
iPathCost = PlotPath( pSoldier, sPanicTriggerGridNo, FALSE, FALSE, FALSE, RUNNING, FALSE, FALSE, 0);
|
//iPathCost = PlotPath( pSoldier, sPanicTriggerGridNo, FALSE, FALSE, FALSE, RUNNING, FALSE, FALSE, 0);
|
||||||
|
iPathCost = PlotPath(pSoldier, sPanicTriggerGridNo, FALSE, FALSE, FALSE, usMovementMode, pSoldier->bStealthMode, FALSE, 0);
|
||||||
|
|
||||||
if (iPathCost != 0)
|
if (iPathCost != 0)
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("found route to panic trigger, path cost %d", iPathCost));
|
||||||
fFoundRoute = TRUE;
|
fFoundRoute = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("standing at panic trigger spot"));
|
||||||
fFoundRoute = TRUE;
|
fFoundRoute = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we managed to find an adjacent spot
|
// if we managed to find an adjacent spot
|
||||||
if (fFoundRoute)
|
if (fFoundRoute)
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("have good route to panic triger"));
|
||||||
|
/*
|
||||||
|
*** COMMENTED OUT BECAUSE WE DON'T HAVE SUPPORT ROUTINES YET
|
||||||
|
|
||||||
/*
|
// make sure it's not in water (those triggers can't be pulled)
|
||||||
*** COMMENTED OUT BECAUSE WE DON'T HAVE SUPPORT ROUTINES YET
|
if (Water(Terrain(gTacticalStatus.sHandGrid),Structure(gTacticalStatus.sHandGrid)))
|
||||||
|
{
|
||||||
|
#ifdef BETAVERSION
|
||||||
|
PopMessage("BAD SCENARIO DESIGN: Enemies can't use this panic trigger!");
|
||||||
|
#endif
|
||||||
|
gTacticalStatus.ubTheChosenOne = NOBODY; // strip him of his Chosen One status
|
||||||
|
// don't bother replacing him either, the next won't have more luck!
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// make sure it's not in water (those triggers can't be pulled)
|
|
||||||
if (Water(Terrain(gTacticalStatus.sHandGrid),Structure(gTacticalStatus.sHandGrid)))
|
|
||||||
{
|
|
||||||
#ifdef BETAVERSION
|
|
||||||
PopMessage("BAD SCENARIO DESIGN: Enemies can't use this panic trigger!");
|
|
||||||
#endif
|
|
||||||
gTacticalStatus.ubTheChosenOne = NOBODY; // strip him of his Chosen One status
|
|
||||||
// don't bother replacing him either, the next won't have more luck!
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
// if we are at that spot now
|
// if we are at that spot now
|
||||||
if (pSoldier->sGridNo == sPanicTriggerGridNo)
|
if (pSoldier->sGridNo == sPanicTriggerGridNo)
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("we are at the spot, activate the trigger!"));
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
// PULL THE PANIC TRIGGER!
|
// PULL THE PANIC TRIGGER!
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
@@ -355,11 +373,12 @@ INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
|||||||
pSoldier->name,pSoldier->aiData.usActionData);
|
pSoldier->name,pSoldier->aiData.usActionData);
|
||||||
PopMessage(tempstr);
|
PopMessage(tempstr);
|
||||||
#endif
|
#endif
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("enough AP, activate trigger!"));
|
||||||
return(AI_ACTION_PULL_TRIGGER);
|
return(AI_ACTION_PULL_TRIGGER);
|
||||||
}
|
}
|
||||||
else // otherwise, wait a turn
|
else // otherwise, wait a turn
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("wait a turn, not enough AP"));
|
||||||
pSoldier->aiData.usActionData = NOWHERE;
|
pSoldier->aiData.usActionData = NOWHERE;
|
||||||
return(AI_ACTION_NONE);
|
return(AI_ACTION_NONE);
|
||||||
}
|
}
|
||||||
@@ -380,7 +399,7 @@ INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
|||||||
sprintf(tempstr,"%s - GETTING CLOSER to PANIC TRIGGER at grid %d (Trigger at %d)", pSoldier->name,pSoldier->aiData.usActionData,sPanicTriggerGridNo);
|
sprintf(tempstr,"%s - GETTING CLOSER to PANIC TRIGGER at grid %d (Trigger at %d)", pSoldier->name,pSoldier->aiData.usActionData,sPanicTriggerGridNo);
|
||||||
AIPopMessage(tempstr);
|
AIPopMessage(tempstr);
|
||||||
#endif
|
#endif
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("move closet to panic trigger %d", sPanicTriggerGridNo));
|
||||||
return(AI_ACTION_GET_CLOSER);
|
return(AI_ACTION_GET_CLOSER);
|
||||||
}
|
}
|
||||||
else // Oh oh, the chosen one can't get to the trigger!
|
else // Oh oh, the chosen one can't get to the trigger!
|
||||||
@@ -388,12 +407,14 @@ INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
|||||||
#ifdef TESTVERSION
|
#ifdef TESTVERSION
|
||||||
PopMessage("TEST MSG: Oh oh! !legalDest - ChosenOne can't get to the trigger!");
|
PopMessage("TEST MSG: Oh oh! !legalDest - ChosenOne can't get to the trigger!");
|
||||||
#endif
|
#endif
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("cannot move to the trigger, find another chosen one"));
|
||||||
gTacticalStatus.ubTheChosenOne = NOBODY; // strip him of his Chosen One status
|
gTacticalStatus.ubTheChosenOne = NOBODY; // strip him of his Chosen One status
|
||||||
MakeClosestEnemyChosenOne(); // and replace him!
|
MakeClosestEnemyChosenOne(); // and replace him!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // can't move, wait 1 turn
|
else // can't move, wait 1 turn
|
||||||
{
|
{
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("cannot move, wait one turn"));
|
||||||
pSoldier->aiData.usActionData = NOWHERE;
|
pSoldier->aiData.usActionData = NOWHERE;
|
||||||
return(AI_ACTION_NONE);
|
return(AI_ACTION_NONE);
|
||||||
}
|
}
|
||||||
@@ -404,6 +425,7 @@ INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
|||||||
#ifdef TESTVERSION
|
#ifdef TESTVERSION
|
||||||
PopMessage("TEST MSG: Oh oh! !adjacentFound - ChosenOne can't get to the trigger!");
|
PopMessage("TEST MSG: Oh oh! !adjacentFound - ChosenOne can't get to the trigger!");
|
||||||
#endif
|
#endif
|
||||||
|
DebugAI(AI_MSG_TOPIC, pSoldier, String("cannot find route to the trigger, find another chosen one"));
|
||||||
gTacticalStatus.ubTheChosenOne = NOBODY; // strip him of his Chosen One status
|
gTacticalStatus.ubTheChosenOne = NOBODY; // strip him of his Chosen One status
|
||||||
MakeClosestEnemyChosenOne(); // and replace him!
|
MakeClosestEnemyChosenOne(); // and replace him!
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user