mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
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:
+22
-22
@@ -7364,6 +7364,7 @@ UINT32 AICalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTim
|
||||
// same as CCTHG but fakes the attacker always standing
|
||||
usTrueState = pSoldier->usAnimState;
|
||||
bTrueLevel = pSoldier->bTargetLevel;
|
||||
|
||||
pSoldier->bTargetLevel = bTargetLevel;
|
||||
pSoldier->usAnimState = usAnimState;
|
||||
if(Item[pSoldier->usAttackingWeapon].usItemClass & IC_THROWING_KNIFE)//dnl ch70 160913
|
||||
@@ -7373,18 +7374,11 @@ UINT32 AICalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTim
|
||||
else
|
||||
{
|
||||
uiChance = CalcChanceToHitGun(pSoldier, sGridNo, ubAimTime, ubAimPos);
|
||||
|
||||
// sevenfm: allow small CTH for AI for suppression fire
|
||||
if( gGameExternalOptions.fAIExtraSuppression &&
|
||||
pSoldier->aiData.bAlertStatus == STATUS_RED &&
|
||||
Weapon[ pSoldier->usAttackingWeapon ].bAutofireShotsPerFiveAP > 0 )
|
||||
{
|
||||
uiChance = __max(1, uiChance);
|
||||
}
|
||||
}
|
||||
pSoldier->usAnimState = usTrueState;
|
||||
pSoldier->bTargetLevel = bTrueLevel;
|
||||
if(UsingNewCTHSystem() == true && !(Item[pSoldier->usAttackingWeapon].usItemClass & IC_THROWING_KNIFE))//dnl ch70 160913
|
||||
|
||||
if(UsingNewCTHSystem() && !(Item[pSoldier->usAttackingWeapon].usItemClass & IC_THROWING_KNIFE))//dnl ch70 160913
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// HEADROCK HAM 4: NCTH calculation
|
||||
@@ -7468,11 +7462,7 @@ UINT32 AICalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTim
|
||||
// real aperture for shooter based on CTH calculation
|
||||
dAperture = dAperture * ( 100 - uiChance ) / 100.0f;
|
||||
|
||||
if (dAperture == 0)
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
else
|
||||
if(dAperture > 0)
|
||||
{
|
||||
// silversurfer: This cannot be correct. An aperture of 10 already gives a very good chance to hit. If we take this value and
|
||||
// calculate the target area it's PI * 10 * 10 which results in ~300 (rounded down) and not 28.26. This low number was the reason why AI
|
||||
@@ -7488,18 +7478,19 @@ UINT32 AICalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTim
|
||||
|
||||
uiChance = (UINT32)__min(100, (dTargetArea / dApertureArea) * 100);
|
||||
}
|
||||
FLOAT dGunRange;
|
||||
else
|
||||
{
|
||||
uiChance = 100;
|
||||
}
|
||||
|
||||
// Flugente: check for underbarrel weapons and use that object if necessary
|
||||
OBJECTTYPE* pObjAttHand = pSoldier->GetUsedWeapon( &(pSoldier->inv[pSoldier->ubAttackingHand]) );
|
||||
|
||||
dGunRange = (FLOAT)(GunRange( pObjAttHand, pSoldier ) );
|
||||
FLOAT dGunRange = (FLOAT)(GunRange(pObjAttHand, pSoldier));
|
||||
|
||||
FLOAT dMaxGunRange = dGunRange * gGameCTHConstants.MAX_EFFECTIVE_RANGE_MULTIPLIER;
|
||||
if ( dMaxGunRange < d2DDistance)
|
||||
{
|
||||
// Weapon out of conceivable hit range. Reduce chance to hit to 0!
|
||||
return (0);
|
||||
uiChance = 1; // sevenfm: set min CTH to 1% for AI
|
||||
}
|
||||
else if ( dGunRange < d2DDistance)
|
||||
{
|
||||
@@ -7508,15 +7499,24 @@ UINT32 AICalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTim
|
||||
if (gGameCTHConstants.MAX_EFFECTIVE_USE_GRADIENT)
|
||||
{
|
||||
// Just outside range. Reduce considerably!
|
||||
return min(uiChance, (UINT)(dChance - (dMaxChanceReduction * ((d2DDistance - dGunRange) / (dMaxGunRange - dGunRange)))));
|
||||
uiChance = min(uiChance, (UINT32)(dChance - (dMaxChanceReduction * ((d2DDistance - dGunRange) / (dMaxGunRange - dGunRange)))));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UINT)(dChance - dMaxChanceReduction);
|
||||
uiChance = (UINT32)(dChance - dMaxChanceReduction);
|
||||
}
|
||||
}
|
||||
}
|
||||
return( uiChance );
|
||||
|
||||
if (gGameExternalOptions.fAIExtraSuppression)
|
||||
{
|
||||
// sevenfm: always min 1% for AI to shoot
|
||||
return max(1, uiChance);
|
||||
}
|
||||
else
|
||||
{
|
||||
return uiChance;
|
||||
}
|
||||
}
|
||||
|
||||
INT32 CalcBodyImpactReduction( UINT8 ubAmmoType, UINT8 ubHitLocation )
|
||||
|
||||
Reference in New Issue
Block a user