mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +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:
+47
-25
@@ -249,14 +249,17 @@ void PossiblyMakeThisEnemyChosenOne( SOLDIERTYPE * pSoldier )
|
||||
|
||||
INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
||||
{
|
||||
BOOLEAN fFoundRoute = FALSE;
|
||||
INT8 bSlot;
|
||||
INT32 iPathCost;
|
||||
INT8 bPanicTrigger;
|
||||
INT32 sPanicTriggerGridNo;
|
||||
#ifdef DEBUGDECISIONS
|
||||
STR16 tempstr;
|
||||
#endif
|
||||
BOOLEAN fFoundRoute = FALSE;
|
||||
INT8 bSlot;
|
||||
INT32 iPathCost;
|
||||
INT8 bPanicTrigger;
|
||||
INT32 sPanicTriggerGridNo;
|
||||
UINT16 usMovementMode;
|
||||
#ifdef DEBUGDECISIONS
|
||||
STR16 tempstr;
|
||||
#endif
|
||||
|
||||
DebugAI(AI_MSG_TOPIC, pSoldier, String("[Panic AI]"));
|
||||
|
||||
// if there are panic bombs here
|
||||
if (gTacticalStatus.fPanicFlags & PANIC_BOMBS_HERE)
|
||||
@@ -265,6 +268,7 @@ INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
||||
bSlot = FindTrigger( pSoldier );
|
||||
if (bSlot != NO_SLOT)
|
||||
{
|
||||
DebugAI(AI_MSG_TOPIC, pSoldier, String("found trigger, slot %d", bSlot));
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ACTIVATE DETONATOR: blow up sector's panic bombs
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@@ -277,11 +281,13 @@ INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
||||
PopMessage(tempstr);
|
||||
#endif
|
||||
// blow up all the PANIC bombs!
|
||||
DebugAI(AI_MSG_TOPIC, pSoldier, String("blow up panic bomb"));
|
||||
return(AI_ACTION_USE_DETONATOR);
|
||||
}
|
||||
else // otherwise, wait a turn
|
||||
{
|
||||
pSoldier->aiData.usActionData = NOWHERE;
|
||||
DebugAI(AI_MSG_TOPIC, pSoldier, String("wait a turn"));
|
||||
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 ( 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?
|
||||
if (pSoldier->ubID == gTacticalStatus.ubTheChosenOne)
|
||||
{
|
||||
bPanicTrigger = ClosestPanicTrigger( pSoldier );
|
||||
|
||||
if (bPanicTrigger == -1)
|
||||
{
|
||||
// augh!
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
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 (pSoldier->sGridNo != sPanicTriggerGridNo)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
DebugAI(AI_MSG_TOPIC, pSoldier, String("found route to panic trigger, path cost %d", iPathCost));
|
||||
fFoundRoute = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugAI(AI_MSG_TOPIC, pSoldier, String("standing at panic trigger spot"));
|
||||
fFoundRoute = TRUE;
|
||||
}
|
||||
|
||||
// if we managed to find an adjacent spot
|
||||
if (fFoundRoute)
|
||||
{
|
||||
DebugAI(AI_MSG_TOPIC, pSoldier, String("have good route to panic triger"));
|
||||
/*
|
||||
*** COMMENTED OUT BECAUSE WE DON'T HAVE SUPPORT ROUTINES YET
|
||||
|
||||
/*
|
||||
*** COMMENTED OUT BECAUSE WE DON'T HAVE SUPPORT ROUTINES YET
|
||||
// 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);
|
||||
}
|
||||
*/
|
||||
|
||||
// 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 (pSoldier->sGridNo == sPanicTriggerGridNo)
|
||||
{
|
||||
DebugAI(AI_MSG_TOPIC, pSoldier, String("we are at the spot, activate the trigger!"));
|
||||
////////////////////////////////////////////////////////////////
|
||||
// PULL THE PANIC TRIGGER!
|
||||
////////////////////////////////////////////////////////////////
|
||||
@@ -355,11 +373,12 @@ INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
||||
pSoldier->name,pSoldier->aiData.usActionData);
|
||||
PopMessage(tempstr);
|
||||
#endif
|
||||
|
||||
DebugAI(AI_MSG_TOPIC, pSoldier, String("enough AP, activate trigger!"));
|
||||
return(AI_ACTION_PULL_TRIGGER);
|
||||
}
|
||||
else // otherwise, wait a turn
|
||||
{
|
||||
DebugAI(AI_MSG_TOPIC, pSoldier, String("wait a turn, not enough AP"));
|
||||
pSoldier->aiData.usActionData = NOWHERE;
|
||||
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);
|
||||
AIPopMessage(tempstr);
|
||||
#endif
|
||||
|
||||
DebugAI(AI_MSG_TOPIC, pSoldier, String("move closet to panic trigger %d", sPanicTriggerGridNo));
|
||||
return(AI_ACTION_GET_CLOSER);
|
||||
}
|
||||
else // Oh oh, the chosen one can't get to the trigger!
|
||||
@@ -388,12 +407,14 @@ INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
||||
#ifdef TESTVERSION
|
||||
PopMessage("TEST MSG: Oh oh! !legalDest - ChosenOne can't get to the trigger!");
|
||||
#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
|
||||
MakeClosestEnemyChosenOne(); // and replace him!
|
||||
}
|
||||
}
|
||||
else // can't move, wait 1 turn
|
||||
{
|
||||
DebugAI(AI_MSG_TOPIC, pSoldier, String("cannot move, wait one turn"));
|
||||
pSoldier->aiData.usActionData = NOWHERE;
|
||||
return(AI_ACTION_NONE);
|
||||
}
|
||||
@@ -404,6 +425,7 @@ INT8 PanicAI(SOLDIERTYPE *pSoldier, UINT8 ubCanMove)
|
||||
#ifdef TESTVERSION
|
||||
PopMessage("TEST MSG: Oh oh! !adjacentFound - ChosenOne can't get to the trigger!");
|
||||
#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
|
||||
MakeClosestEnemyChosenOne(); // and replace him!
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user