AI flanking improvement by Sevenfm:

Improved AI RED/YELLOW flanking:
 - better direction calculation (use direction arrays)
 - increased search range 4->8
 - removed incorrectly calculated AP limit (use CalcActionPoints instead)
 - additional direction for flank spot searching
 - prefer desired direction
 - penalize tiles with no cover from noise location
 - penalize tiles too far from noise location
 - don't go into deep water for flanking
 - skip water tiles (can flank over water tiles only if can cross them in one turn)
 - min/max flanking range depends on time of day and base sight range
 - skip buildings when searching for flank spot if not in building already, because soldiers often run into buildings and stop flanking
 - use RUNNING movement mode for flanking instead of default SWATTING
 - only CUNNINGSOLO and CUNNINGAID soldiers flank
 - don't start flanking when no friends between soldier and noise gridno (in 3 directions)
 - stop flanking when no friends between soldier and noise gridno (in 3 directions)
 - stop flanking and reset flank counter in BLACK state
 - avoid map edges when flanking
 - disable flanking for soldiers with limited roaming range (STATIONARY/ONGUARD/CLOSEPATROL/SNIPER)

 In general, AI flanking is much more effective now (it never fully worked previously, especially in turnbased).

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8003 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
silversurfer
2015-11-17 19:19:22 +00:00
parent 38e77c7295
commit 1e54f492ff
4 changed files with 179 additions and 93 deletions
+23
View File
@@ -271,4 +271,27 @@ UINT8 GetClosestWoundedSoldierID( SOLDIERTYPE * pSoldier, INT16 aRange, UINT8 au
// get the id of the closest medic (closer than x tiles) of a specific team
UINT8 GetClosestMedicSoldierID( SOLDIERTYPE * pSoldier, INT16 aRange, UINT8 auTeam );
// sevenfm:
INT16 MaxNormalVisionDistance( void );
UINT8 CountFriendsInDirection( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo );
BOOLEAN GuySawEnemyThisTurnOrBefore( SOLDIERTYPE * pSoldier );
// moved from DecideAction.cpp
// sevenfm: set MAX_FLANKS_RED and MAX_FLANKS_YELLOW to equal values to avoid problems when soldier's alert state changes
#define MAX_FLANKS_RED 25
#define MAX_FLANKS_YELLOW 25
// limit min/max flank distance depending on sight range and time of day
//#define MIN_FLANK_DIST_YELLOW 10 * STRAIGHT_RATIO
//#define MAX_FLANK_DIST_YELLOW 50 * STRAIGHT_RATIO
#define MIN_FLANK_DIST_YELLOW (2*MaxNormalVisionDistance()/3)
#define MAX_FLANK_DIST_YELLOW (MaxNormalVisionDistance() + 20)
// limit min/max flank distance depending on sight range and time of day
//#define MIN_FLANK_DIST_RED 10 * STRAIGHT_RATIO
//#define MAX_FLANK_DIST_RED 40 * STRAIGHT_RATIO
#define MIN_FLANK_DIST_RED (2*MaxNormalVisionDistance()/3)
#define MAX_FLANK_DIST_RED (MaxNormalVisionDistance() + 20)
#endif