Red, Black AI: try to use sidearm if not enough AP to shoot with main weapon.

Black AI: improved check to avoid friendly fire.
FindAIUsableObjClass: by default search for weapon with longest range, if fSidearm = TRUE search for fastest weapon.
AICalcChanceToHitGun: if AI_EXTRA_SUPPRESSION = TRUE, always return min 1% for AI.
RangeChangeDesire:
- civilians only want to run away
- added small bonus to range change desire if soldier has no gun or short range weapon
CalcBestShot, CheckIfShotPossible: always check if can shoot at target seen by another soldier.
CalcBestShot, CalcBestThrow, CalcBestStab: initialize attack data.
Removed obsolete code.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8782 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2020-04-08 21:24:56 +00:00
parent 5350258334
commit 4e34605f86
8 changed files with 209 additions and 607 deletions
+25 -8
View File
@@ -3104,21 +3104,38 @@ INT32 RangeChangeDesire( SOLDIERTYPE * pSoldier )
INT32 iRangeFactorMultiplier;
iRangeFactorMultiplier = pSoldier->aiData.bAIMorale - 1;
// civilians only run away
if (pSoldier->aiData.bNeutral)
{
return 0;
}
switch (pSoldier->aiData.bAttitude)
{
case DEFENSIVE: iRangeFactorMultiplier += -1; break;
case BRAVESOLO: iRangeFactorMultiplier += 2; break;
case BRAVEAID: iRangeFactorMultiplier += 2; break;
case CUNNINGSOLO: iRangeFactorMultiplier += 0; break;
case CUNNINGAID: iRangeFactorMultiplier += 0; break;
case ATTACKSLAYONLY:
case AGGRESSIVE: iRangeFactorMultiplier += 1; break;
case DEFENSIVE: iRangeFactorMultiplier += -1; break;
case BRAVESOLO: iRangeFactorMultiplier += 2; break;
case BRAVEAID: iRangeFactorMultiplier += 2; break;
case CUNNINGSOLO: iRangeFactorMultiplier += 0; break;
case CUNNINGAID: iRangeFactorMultiplier += 0; break;
case ATTACKSLAYONLY:
case AGGRESSIVE: iRangeFactorMultiplier += 1; break;
}
if(IS_MERC_BODY_TYPE(pSoldier))
{
if (!AICheckHasGun(pSoldier))
iRangeFactorMultiplier += 2; // if we have no weapons, try to get closer to enemy
else if (GuySawEnemy(pSoldier, SEEN_LAST_TURN) && AICheckShortWeaponRange(pSoldier))
iRangeFactorMultiplier += 1; // bonus if weapon range is short
}
if ( gTacticalStatus.bConsNumTurnsWeHaventSeenButEnemyDoes > 0 )
{
iRangeFactorMultiplier += gTacticalStatus.bConsNumTurnsWeHaventSeenButEnemyDoes;
}
return( iRangeFactorMultiplier );
return iRangeFactorMultiplier;
}
BOOLEAN ArmySeesOpponents( void )