AI pathing: avoid deep water if not in deep water already and not SEEKENEMY (allow max 2 tiles of deep water for other soldiers).

CONSIDERED_NEUTRAL: removed dying check as it may cause problems with AI.
Improved code to avoid moving into gas/deep water/light/artillery danger zone.
ClosestReachableDisturbance: 
- skip dying opponent if found not dying
- when in deep water, skip opponents in deep water
ClosestKnownOpponent: skip dying opponent if found not dying.
RedSmokeDanger: consider deep water as safe from artillery strike.
Allow deep water flanking for soldiers of ENEMY_TEAM with SEEKENEMY orders and CUNNINGSOLO attitude or athletics trait.
CalcBestShot:
- dying, cowering or unconscious soldiers have very low priority
- added safety checks
- if best opponent is dying and new opponent is ok, use new opponent
DecideAction: improved deep water checks.
Red, Black AI: when SEEKENEMY soldier is in deep water, move to closest opponent on the ground.
FindNearestUngassedLand: 
- increased max search distance to 35
- added speed optimization
- removed max AP budget
FindNearbyDarkerSpot:
- increased max search range to 25
- added speed optimization
- removed max AP budget
FindFlankingSpot: added condition to allow deep water flanking


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8758 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2020-02-17 19:20:28 +00:00
parent 019eccb5b9
commit 4fb6369368
12 changed files with 285 additions and 131 deletions
+47
View File
@@ -22,6 +22,8 @@
#include "random.h"
#include "render fun.h"
#include "GameSettings.h"
// sevenfm
#include "PATHAI.H"
#endif
extern BOOLEAN gfBasement;
@@ -4176,3 +4178,48 @@ BOOLEAN IsLegionLevel( INT32 sGridNo )
}
//-------------------------------------------------------------------
// sevenfm: check adjacent tiles
BOOLEAN FindNotDeepWaterNearby(INT32 sSpot, BOOLEAN bLevel)
{
UINT8 ubMovementCost;
INT32 sTempGridNo;
UINT8 ubDirection;
// check adjacent reachable tiles
for (ubDirection = 0; ubDirection < NUM_WORLD_DIRECTIONS; ubDirection++)
{
sTempGridNo = NewGridNo(sSpot, DirectionInc(ubDirection));
ubMovementCost = gubWorldMovementCosts[sTempGridNo][ubDirection][bLevel];
if (ubMovementCost < TRAVELCOST_BLOCKED &&
!DeepWater(sTempGridNo, bLevel))
{
return(TRUE);
}
}
return FALSE;
}
BOOLEAN FindNotWaterNearby(INT32 sSpot, BOOLEAN bLevel)
{
UINT8 ubMovementCost;
INT32 sTempGridNo;
UINT8 ubDirection;
// check adjacent reachable tiles
for (ubDirection = 0; ubDirection < NUM_WORLD_DIRECTIONS; ubDirection++)
{
sTempGridNo = NewGridNo(sSpot, DirectionInc(ubDirection));
ubMovementCost = gubWorldMovementCosts[sTempGridNo][ubDirection][bLevel];
if (ubMovementCost < TRAVELCOST_BLOCKED &&
!Water(sTempGridNo, bLevel))
{
return(TRUE);
}
}
return FALSE;
}