Added LegalNPCDestination check to AI location search routines.

SearchForItems: avoid locations with bombs or red smoke danger.
FindFlankingSpot: removed check for edge of the map.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8754 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2020-02-15 13:38:41 +00:00
parent fe838ad7d9
commit 25701acf7b
2 changed files with 35 additions and 6 deletions
+35 -3
View File
@@ -1516,6 +1516,12 @@ INT32 FindSpotMaxDistFromOpponents(SOLDIERTYPE *pSoldier)
continue; continue;
} }
// check that spot is allowed
if (!LegalNPCDestination(pSoldier, sGridNo, IGNORE_PATH, NOWATER, 0))
{
continue; // skip on to the next potential grid
}
// OK, this place shows potential. How useful is it as cover? // OK, this place shows potential. How useful is it as cover?
//NumMessage("Promising seems gridno #",gridno); //NumMessage("Promising seems gridno #",gridno);
@@ -2021,11 +2027,32 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem )
} }
// exclude locations with tear/mustard gas (at this point, smoke is cool!) // exclude locations with tear/mustard gas (at this point, smoke is cool!)
if ( InGasOrSmoke( pSoldier, sGridNo ) ) if (InGas(pSoldier, sGridNo))
{ {
continue; continue;
} }
if (FindBombNearby(pSoldier, sGridNo, BOMB_DETECTION_RANGE))
{
continue;
}
// sevenfm: avoid staying at north edge
/*if (NorthSpot(sGridNo, pSoldier->pathing.bLevel))
{
continue;
}*/
if (RedSmokeDanger(sGridNo, pSoldier->pathing.bLevel))
{
continue;
}
if (!LegalNPCDestination(pSoldier, sGridNo, IGNORE_PATH, NOWATER, 0))
{
continue; // skip on to the next potential grid
}
if ( (gpWorldLevelData[sGridNo].uiFlags & MAPELEMENT_ITEMPOOL_PRESENT) if ( (gpWorldLevelData[sGridNo].uiFlags & MAPELEMENT_ITEMPOOL_PRESENT)
&& (gpWorldLevelData[sGridNo].uiFlags & MAPELEMENT_REACHABLE) ) && (gpWorldLevelData[sGridNo].uiFlags & MAPELEMENT_REACHABLE) )
{ {
@@ -2653,8 +2680,8 @@ INT32 FindFlankingSpot(SOLDIERTYPE *pSoldier, INT32 sPos, INT8 bAction )
DebugMsg ( TOPIC_JA2AI , DBG_LEVEL_3 , String("FindFlankingSpot: orig loc = %d, loc to flank = %d", pSoldier->sGridNo , sPos)); DebugMsg ( TOPIC_JA2AI , DBG_LEVEL_3 , String("FindFlankingSpot: orig loc = %d, loc to flank = %d", pSoldier->sGridNo , sPos));
// hit the edge of the map // hit the edge of the map
if ( FindNearestEdgePoint ( pSoldier->sGridNo ) == pSoldier->sGridNo ) /*if ( FindNearestEdgePoint ( pSoldier->sGridNo ) == pSoldier->sGridNo )
return NOWHERE; return NOWHERE;*/
// sevenfm: use max AP at the start of new turn // sevenfm: use max AP at the start of new turn
//gubNPCAPBudget=(UINT8) (iSearchRange*3); //gubNPCAPBudget=(UINT8) (iSearchRange*3);
@@ -2785,6 +2812,11 @@ INT32 FindFlankingSpot(SOLDIERTYPE *pSoldier, INT32 sPos, INT8 bAction )
continue; continue;
} }
if (!LegalNPCDestination(pSoldier, sGridNo, IGNORE_PATH, WATEROK, 0))
{
continue; // skip on to the next potential grid
}
// sevenfm: skip buildings if not in building already, because soldiers often run into buildings and stop flanking // sevenfm: skip buildings if not in building already, because soldiers often run into buildings and stop flanking
if (InARoom(sGridNo, NULL) && !InARoom(pSoldier->sGridNo, NULL)) if (InARoom(sGridNo, NULL) && !InARoom(pSoldier->sGridNo, NULL))
{ {
-3
View File
@@ -121,9 +121,6 @@ int LegalNPCDestination(SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubPathMode,
return(FALSE); // illegal destination return(FALSE); // illegal destination
} }
int TryToResumeMovement(SOLDIERTYPE *pSoldier, INT32 sGridNo) int TryToResumeMovement(SOLDIERTYPE *pSoldier, INT32 sGridNo)
{ {
UINT8 ubGottaCancel = FALSE; UINT8 ubGottaCancel = FALSE;