From 638de03d8d35e2c25b1607862e8b4727ee6f84ed Mon Sep 17 00:00:00 2001 From: Kriplo Date: Sun, 25 Aug 2013 08:40:36 +0000 Subject: [PATCH] Brief: //dnl ch62 - Ignore firing into dying and breathless targets. Details: - AI will ignore attack breathless targets if there are other in better condition. - AI will not fire into dying targets. - AI should avoid go into creature gas. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6314 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- TacticalAI/AIUtils.cpp | 5 +++-- TacticalAI/Attacks.cpp | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/TacticalAI/AIUtils.cpp b/TacticalAI/AIUtils.cpp index e1803a05..9c54f155 100644 --- a/TacticalAI/AIUtils.cpp +++ b/TacticalAI/AIUtils.cpp @@ -1940,9 +1940,10 @@ BOOLEAN InGas( SOLDIERTYPE *pSoldier, INT32 sGridNo ) { return(TRUE); } - if ( gpWorldLevelData[iNeighbourGridNo].ubExtFlags[pSoldier->pathing.bLevel] & MAPELEMENT_EXT_BURNABLEGAS ) + // fire/creature gas + if(gpWorldLevelData[iNeighbourGridNo].ubExtFlags[pSoldier->pathing.bLevel] & (MAPELEMENT_EXT_BURNABLEGAS|MAPELEMENT_EXT_CREATUREGAS))//dnl ch62 240813 { - return( TRUE ); + return(TRUE); } } } diff --git a/TacticalAI/Attacks.cpp b/TacticalAI/Attacks.cpp index 453750f6..d1b73a18 100644 --- a/TacticalAI/Attacks.cpp +++ b/TacticalAI/Attacks.cpp @@ -470,6 +470,10 @@ void CalcBestShot(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestShot, BOOLEAN shootUns // OK, how does our chance to hit him compare to the previous best one? iPercentBetter = ((ubChanceToReallyHit * 100) / pBestShot->ubChanceToReallyHit) - 100; + //dnl ch62 180813 ignore firing into breathless targets if there are targets in better condition + if((Menptr[pBestShot->ubOpponent].bCollapsed || Menptr[pBestShot->ubOpponent].bBreathCollapsed) && Menptr[pBestShot->ubOpponent].bBreath < OKBREATH && Menptr[pBestShot->ubOpponent].bBreath < pOpponent->bBreath) + iPercentBetter = PERCENT_TO_IGNORE_THREAT; + // if this chance to really hit is more than 50% worse, and the other // guy is conscious at all if ((iPercentBetter < -PERCENT_TO_IGNORE_THREAT) && (Menptr[pBestShot->ubOpponent].stats.bLife >= OKLIFE)) @@ -485,6 +489,9 @@ void CalcBestShot(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestShot, BOOLEAN shootUns continue; // next opponent } } + //dnl ch62 180813 ignore firing into dying targets + if((pOpponent->bCollapsed || pOpponent->bBreathCollapsed) && pOpponent->stats.bLife < OKLIFE/* && !(pSoldier->aiData.bAttitude == AGGRESSIVE && Random(100) < 20)*/) + continue; // OOOF! That was a lot of work! But we've got a new best target! pBestShot->ubPossible = TRUE;