mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
New option AI_SHOOT_UNSEEN (disabled by default): allow AI to shoot at recently seen/heard enemies (targets that nobody from soldier's team sees currently).
CalcBestShot: - improved hit rate calculation, take into account possible options INCREASE_AIMING_COSTS, FIRST_AIM_READY_COST_DIVISOR - minor code improvements New AI function LOS_Raised checks LOS with forced raised gun status, to get max view distance with scope git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8889 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+7
-270
@@ -10679,275 +10679,12 @@ FLOAT CalcCounterForceChange( SOLDIERTYPE * pShooter, UINT32 uiCounterForceAccur
|
||||
return dDelta;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
// sevenfm: AI function to quickly determine LOS between soldiers, forcing raised gun status to get max view distance
|
||||
INT32 LOS_Raised(SOLDIERTYPE * pStartSoldier, SOLDIERTYPE * pEndSoldier, int iTileSightLimit, UINT8 ubAimLocation)
|
||||
{
|
||||
INT32 cntx, cnty;
|
||||
INT8 bX, bY;
|
||||
INT16 sAngleSum = 0;
|
||||
INT8 bNumSums = 0;
|
||||
INT16 sAngleAv;
|
||||
BOOLEAN fOkX, fOkY;
|
||||
BOOLEAN fGoodX, fGoodY;
|
||||
|
||||
//OK, center on xy and goforit!
|
||||
for ( cntx = 0; cntx < 3; cntx++ )
|
||||
{
|
||||
bX = bLOSX + ( cntx - 1 );
|
||||
|
||||
// Check for boundry conditions, use same as one before boundary
|
||||
if ( bX < 0 || bX > 4 )
|
||||
{
|
||||
fOkX = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fOkX = 1;
|
||||
}
|
||||
|
||||
for ( cnty = 0; cnty < 3; cnty++ )
|
||||
{
|
||||
fGoodX = fGoodY = TRUE;
|
||||
|
||||
bY = bLOSY + ( cnty - 1 );
|
||||
|
||||
if ( bY < 0 || bY > 4 )
|
||||
{
|
||||
fOkY = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fOkY = 1;
|
||||
}
|
||||
|
||||
if ( bY < 0 )
|
||||
{
|
||||
if ( fOkX )
|
||||
{
|
||||
bY = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fGoodY = FALSE;
|
||||
}
|
||||
}
|
||||
if ( bY > 4 )
|
||||
{
|
||||
if ( fOkX )
|
||||
{
|
||||
bY = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
fGoodY = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( bX < 0 )
|
||||
{
|
||||
if ( fOkY )
|
||||
{
|
||||
bX = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fGoodX = FALSE;
|
||||
}
|
||||
}
|
||||
if ( bX > 4 )
|
||||
{
|
||||
if ( fOkX )
|
||||
{
|
||||
bX = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
fGoodX = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !fGoodX || !fGoodY )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((*(pStructure->pShape))[bX][bY] & AtHeight[ bLOSZ ]) > 0)
|
||||
{
|
||||
// OK, now add angles, but not the center!
|
||||
if ( cntx == 1 && cnty == 1 )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sAngleSum += gsLOSDirLUT[ cntx ][cnty];
|
||||
bNumSums++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Average angle
|
||||
if ( bNumSums > 0)
|
||||
{
|
||||
sAngleAv = sAngleSum / bNumSums;
|
||||
|
||||
// This is our normal in XY plane!
|
||||
// Get unit vector from this
|
||||
*pdNormalX = cos( ( (float)sAngleAv / 180 ) * PI );
|
||||
*pdNormalY = sin( ( (float)sAngleAv / 180 ) * PI );
|
||||
|
||||
// OK done, now determine direction
|
||||
if ( dDeltaX > 0 )
|
||||
{
|
||||
*pdNormalX *= -1;
|
||||
}
|
||||
|
||||
if ( dDeltaY > 0 )
|
||||
{
|
||||
*pdNormalY *= -1;
|
||||
}
|
||||
|
||||
if ( bLOSZ == 3 )
|
||||
{
|
||||
// Prependicular
|
||||
*pdNormalX = 0;
|
||||
*pdNormalY = 0;
|
||||
*pdNormalZ = -1;
|
||||
}
|
||||
else if ( bLOSZ > 0 && (((*(pStructure->pShape))[bLOSX][bLOSY] & AtHeight[ bLOSZ +1 ]) ) == 0)
|
||||
{
|
||||
*pdNormalX = 0;
|
||||
*pdNormalY = 0;
|
||||
*pdNormalZ = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pdNormalZ = 0;
|
||||
}
|
||||
|
||||
return( TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
*pdNormalX = 0;
|
||||
*pdNormalY = 0;
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
INT32 result;
|
||||
gbForceWeaponReady = true;
|
||||
result = SoldierToSoldierLineOfSightTest(pStartSoldier, pEndSoldier, TRUE, iTileSightLimit, ubAimLocation);
|
||||
gbForceWeaponReady = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
{
|
||||
INT32 cntx, cnty;
|
||||
INT8 bX, bY;
|
||||
INT16 sAngleSum = 0;
|
||||
INT8 bNumSums = 0;
|
||||
INT16 sAngleAv;
|
||||
BOOLEAN fAlongX, fAlongY;
|
||||
|
||||
|
||||
fAlongX = fAlongY = FALSE;
|
||||
|
||||
//1) LOOK ALONG X
|
||||
bX = bLOSX - 1;
|
||||
bY = bLOSY;
|
||||
|
||||
if ( bX >= 0 && bX <= 4 )
|
||||
{
|
||||
if (((*(pStructure->pShape))[bX][bY] & AtHeight[ bLOSZ ]) > 0 )
|
||||
{
|
||||
fAlongX = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
bX = bLOSX + 1;
|
||||
bY = bLOSY;
|
||||
|
||||
if ( bX >= 0 && bX <= 4 )
|
||||
{
|
||||
if (((*(pStructure->pShape))[bX][bY] & AtHeight[ bLOSZ ]) > 0 )
|
||||
{
|
||||
fAlongX = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
//1) LOOK ALONG Y
|
||||
bX = bLOSX;
|
||||
bY = bLOSY - 1;
|
||||
|
||||
if ( bY >= 0 && bY <= 4 )
|
||||
{
|
||||
if (((*(pStructure->pShape))[bX][bY] & AtHeight[ bLOSZ ]) > 0 )
|
||||
{
|
||||
fAlongY = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
bX = bLOSX;
|
||||
bY = bLOSY + 1;
|
||||
|
||||
if ( bY >= 0 && bY <= 4 )
|
||||
{
|
||||
if (((*(pStructure->pShape))[bX][bY] & AtHeight[ bLOSZ ]) > 0 )
|
||||
{
|
||||
fAlongY = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( fAlongX )
|
||||
{
|
||||
*pdNormalY = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pdNormalY = 0;
|
||||
}
|
||||
|
||||
if ( fAlongY )
|
||||
{
|
||||
*pdNormalX = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pdNormalX = 0;
|
||||
}
|
||||
|
||||
// OK done, now determine direction
|
||||
if ( dDeltaX > 0 )
|
||||
{
|
||||
*pdNormalX *= -1;
|
||||
}
|
||||
|
||||
if ( dDeltaY < 0 )
|
||||
{
|
||||
*pdNormalY *= -1;
|
||||
}
|
||||
|
||||
if ( bLOSZ < 4 && (((*(pStructure->pShape))[bLOSX][bLOSY] & AtHeight[ bLOSZ +1 ]) ) == 0)
|
||||
{
|
||||
*pdNormalX = 0;
|
||||
*pdNormalY = 0;
|
||||
*pdNormalZ = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pdNormalZ = 0;
|
||||
}
|
||||
|
||||
if ( *pdNormalX == 0 && *pdNormalY == 0 && *pdNormalZ == 0 )
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user