From 95a810e3829d5e4f5dcd5c7bd2096b52a7de74c3 Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Thu, 23 Sep 2021 18:20:49 +0000 Subject: [PATCH] AI flanking: - avoid moving too far from noise spot, except for CUNNINGSOLO - avoid moving too close to enemy vision range git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9167 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- TacticalAI/FindLocations.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/TacticalAI/FindLocations.cpp b/TacticalAI/FindLocations.cpp index 0de8a9c9..8fef70bc 100644 --- a/TacticalAI/FindLocations.cpp +++ b/TacticalAI/FindLocations.cpp @@ -2773,19 +2773,25 @@ INT32 FindFlankingSpot(SOLDIERTYPE *pSoldier, INT32 sPos, INT8 bAction ) } // sevenfm: penalize locations too far from noise gridno - if (PythSpacesAway(sGridNo, sPos) > MAX_FLANK_DIST_RED) + if (PythSpacesAway(sGridNo, sPos) > MAX_FLANK_DIST_RED - 5) { sTempDist = sTempDist / 2; } - // sevenfm: try to flank closer to vision distance limit for faster flanking - if (PythSpacesAway(sGridNo, sPos) > sDistanceVisible + 10) + // avoid moving too far from noise gridno + if (PythSpacesAway(sGridNo, sPos) > MAX_FLANK_DIST_RED && pSoldier->aiData.bAttitude != CUNNINGSOLO) + { + continue; + } + + // sevenfm: avoid moving too close to enemy vision range + if (PythSpacesAway(sGridNo, sPos) < sDistanceVisible + 5) { sTempDist = sTempDist / 2; } // sevenfm: penalize locations with no sight cover from noise gridno (supposed that we are sneaking) - if( //PythSpacesAway( sGridNo, sPos) <= sDistanceVisible && + if( PythSpacesAway( sGridNo, sPos) <= (INT16)MAX_VISION_RANGE && LocationToLocationLineOfSightTest( sGridNo, pSoldier->pathing.bLevel, sPos, pSoldier->pathing.bLevel, TRUE, CALC_FROM_ALL_DIRS) ) { //continue;