Various AI improvements.

FindThrowableGrenade: allows to specify type and damage of searched grenade.
New counter SOLDIER_COUNTER_RETREAT allows to set number of turns which soldier will try to retreat and take cover.
FindBestNearbyCover: use PrepareThreatlist as unified function to make list of all known opponents.

Militia Control:
- start retreating mode for 2 turns when ordering retreat
- replace AI_ACTION_RUN_AWAY with AI_ACTION_TAKE_COVER order so that militia do not retreat from sector

New AI behavior:
- soldier can use smoke grenade to cover himself when under fire
- soldier can use use smoke grenade on his friend to cover him
- if soldier used smoke, he starts retreat mode for 2 turns
- added retreat code to Red, Black AI
- improved Main Red AI for civilians (they only run away)

Improved suppression code:
- less chance of suppression when opponent has high shock level
- prefer using suppression fire when soldier is in cover

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8879 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2020-08-07 12:12:31 +00:00
parent 93c41f2f97
commit 5903abee09
14 changed files with 1359 additions and 292 deletions
+11 -10
View File
@@ -1378,6 +1378,8 @@ void MilitiaControlMenuBtnCallBack( MOUSE_REGION * pRegion, INT32 iReason )
pTMilitiaSoldier->aiData.bAttitude = DEFENSIVE;
pTMilitiaSoldier->usUIMovementMode = RUNNING;
pTMilitiaSoldier->RetreatCounterStart(2);
// set up next action to run away
sActionGridNo = FindSpotMaxDistFromOpponents( pTMilitiaSoldier );
@@ -1385,7 +1387,10 @@ void MilitiaControlMenuBtnCallBack( MOUSE_REGION * pRegion, INT32 iReason )
if (!TileIsOutOfBounds(pTMilitiaSoldier->aiData.usNextActionData))
{
pTMilitiaSoldier->aiData.bNextAction = AI_ACTION_RUN_AWAY;
// sevenfm: use TAKE_COVER order to stop soldier from retreating
pTMilitiaSoldier->aiData.bNextAction = AI_ACTION_TAKE_COVER;
//pTMilitiaSoldier->aiData.bNextAction = AI_ACTION_RUN_AWAY;
pTMilitiaSoldier->aiData.usActionData = ANIM_STAND;
// SEND PENDING ACTION
@@ -1635,14 +1640,7 @@ void MilitiaControlMenuBtnCallBack( MOUSE_REGION * pRegion, INT32 iReason )
pTeamSoldier->aiData.bAttitude = DEFENSIVE;
pTeamSoldier->usUIMovementMode = RUNNING;
//// set up next action to run away
//pTeamSoldier->usNextActionData = FindSpotMaxDistFromOpponents( pTeamSoldier );
//if ( !TileIsOutOfBounds(pTeamSoldier->usNextActionData) )
//{
// pTeamSoldier->bNextAction = AI_ACTION_RUN_AWAY;
// pTeamSoldier->usActionData = ANIM_STAND;
//}
pTeamSoldier->RetreatCounterStart(2);
// set up next action to run away
sActionGridNo = FindSpotMaxDistFromOpponents( pTeamSoldier );
@@ -1651,7 +1649,10 @@ void MilitiaControlMenuBtnCallBack( MOUSE_REGION * pRegion, INT32 iReason )
if ( !TileIsOutOfBounds(pTeamSoldier->aiData.usNextActionData) )
{
pTeamSoldier->aiData.bNextAction = AI_ACTION_RUN_AWAY;
// sevenfm: use TAKE_COVER order to stop soldier from retreating
//pTeamSoldier->aiData.bNextAction = AI_ACTION_RUN_AWAY;
pTeamSoldier->aiData.bNextAction = AI_ACTION_TAKE_COVER;
pTeamSoldier->aiData.usActionData = ANIM_STAND;
// SEND PENDING ACTION