mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
AI: minor code improvements (best cover calculation).
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9273 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -505,7 +505,6 @@ INT32 CalcCoverValue(SOLDIERTYPE *pMe, INT32 sMyGridNo, INT32 iMyThreat, INT32 i
|
|||||||
iMyPosValue /= pMe->aiData.bOppCnt;
|
iMyPosValue /= pMe->aiData.bOppCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if my positional value is worth something at all here
|
// if my positional value is worth something at all here
|
||||||
if (iMyPosValue > 0)
|
if (iMyPosValue > 0)
|
||||||
{
|
{
|
||||||
@@ -533,13 +532,12 @@ INT32 CalcCoverValue(SOLDIERTYPE *pMe, INT32 sMyGridNo, INT32 iMyThreat, INT32 i
|
|||||||
iRangeFactor = (iRangeChange * iRCD) / 2;
|
iRangeFactor = (iRangeChange * iRCD) / 2;
|
||||||
|
|
||||||
// sevenfm: reduce range bonus depending on cover
|
// sevenfm: reduce range bonus depending on cover
|
||||||
if (gGameExternalOptions.fAIBetterCover)
|
if (gGameExternalOptions.fAIBetterCover &&
|
||||||
|
pMe->aiData.bAIMorale < MORALE_FEARLESS &&
|
||||||
|
AIGunRange(pMe) >= PythSpacesAway(sMyGridNo, sHisGridNo) &&
|
||||||
|
!AnyCoverFromSpot(sMyGridNo, bMyLevel, sHisGridNo, bHisLevel))
|
||||||
{
|
{
|
||||||
if (!AnyCoverFromSpot(sMyGridNo, bMyLevel, sHisGridNo, bHisLevel) &&
|
iRangeFactor = iRangeFactor * (100 - bHisCTGT * Threat[uiThreatIndex].iAPs / (2 * APBPConstants[AP_MAXIMUM])) / 100;
|
||||||
CountSeenEnemiesLastTurn(pMe) > CountNearbyFriends(pMe, sMyGridNo, TACTICAL_RANGE / 2))
|
|
||||||
{
|
|
||||||
iRangeFactor = iRangeFactor * (100 - bHisCTGT * __min(Threat[uiThreatIndex].iAPs, APBPConstants[AP_MAXIMUM]) / APBPConstants[AP_MAXIMUM]) / 100;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUGCOVER
|
#ifdef DEBUGCOVER
|
||||||
@@ -626,14 +624,15 @@ INT32 FindBestNearbyCover(SOLDIERTYPE *pSoldier, INT32 morale, INT32 *piPercentB
|
|||||||
UINT32 uiLoop;
|
UINT32 uiLoop;
|
||||||
INT32 iCurrentCoverValue, iCoverValue, iBestCoverValue;
|
INT32 iCurrentCoverValue, iCoverValue, iBestCoverValue;
|
||||||
INT32 iCurrentScale = -1, iCoverScale = -1, iBestCoverScale = -1;
|
INT32 iCurrentScale = -1, iCoverScale = -1, iBestCoverScale = -1;
|
||||||
INT32 iDistFromOrigin, iDistCoverFromOrigin, iThreatCertainty;
|
INT32 iDistFromOrigin, iDistCoverFromOrigin;
|
||||||
|
//INT32 iThreatCertainty;
|
||||||
INT32 sGridNo, sBestCover = NOWHERE;
|
INT32 sGridNo, sBestCover = NOWHERE;
|
||||||
INT32 iPathCost;
|
INT32 iPathCost;
|
||||||
INT32 iThreatRange, iClosestThreatRange = 1500;
|
INT32 iThreatRange, iClosestThreatRange = 1500;
|
||||||
// INT16 sClosestThreatGridno = NOWHERE;
|
// INT16 sClosestThreatGridno = NOWHERE;
|
||||||
INT32 iMyThreatValue;
|
INT32 iMyThreatValue;
|
||||||
INT32 sThreatLoc;
|
//INT32 sThreatLoc;
|
||||||
INT32 iMaxThreatRange;
|
//INT32 iMaxThreatRange;
|
||||||
UINT32 uiThreatCnt = 0;
|
UINT32 uiThreatCnt = 0;
|
||||||
INT32 iMaxMoveTilesLeft, iSearchRange, iRoamRange;
|
INT32 iMaxMoveTilesLeft, iSearchRange, iRoamRange;
|
||||||
INT16 sMaxLeft, sMaxRight, sMaxUp, sMaxDown, sXOffset, sYOffset;
|
INT16 sMaxLeft, sMaxRight, sMaxUp, sMaxDown, sXOffset, sYOffset;
|
||||||
@@ -641,7 +640,7 @@ INT32 FindBestNearbyCover(SOLDIERTYPE *pSoldier, INT32 morale, INT32 *piPercentB
|
|||||||
INT32 * pusLastLoc;
|
INT32 * pusLastLoc;
|
||||||
INT8 * pbPersOL;
|
INT8 * pbPersOL;
|
||||||
INT8 * pbPublOL;
|
INT8 * pbPublOL;
|
||||||
SOLDIERTYPE *pOpponent;
|
//SOLDIERTYPE *pOpponent;
|
||||||
UINT16 usMovementMode;
|
UINT16 usMovementMode;
|
||||||
|
|
||||||
UINT8 ubBackgroundLightLevel;
|
UINT8 ubBackgroundLightLevel;
|
||||||
|
|||||||
Reference in New Issue
Block a user