mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
Fix: gGameCTHConstants.BASE_CROUCHING_STANCE was missing from handling calculations in NCTH
- removed gGameExternalOptions.fUseNewCTHCalculation as it is not needed anymore - cleaned up function CalcNewChanceToHitGun git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8281 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+43
-47
@@ -2509,58 +2509,54 @@ BOOLEAN DrawCTHIndicator()
|
||||
FLOAT fBrightnessModifier = 1;
|
||||
FLOAT fEffectiveLaserRatio = 1;
|
||||
|
||||
// when using the reworked NCTH code we do additional calculations for iron sights and lasers
|
||||
if (gGameExternalOptions.fUseNewCTHCalculation)
|
||||
// silversurfer: New functionality for iron sights - There have been many complaints that iron sights lose their usefulness
|
||||
// very fast the farther the target is away. Setting IRON_SIGHT_PERFORMANCE_BONUS too high makes them overly powerful at
|
||||
// close range. This experimental formula implements a curve that lowers iBasicAperture the farther the target is away.
|
||||
// At 1 tile distance iBasicAperture will be the same as before. That's the common start.
|
||||
if ( gGameCTHConstants.IRON_SIGHTS_MAX_APERTURE_USE_GRADIENT && gCTHDisplay.ScopeMagFactor <= 1.0 && !pSoldier->IsValidAlternativeFireMode( pSoldier->aiData.bAimTime, gCTHDisplay.iTargetGridNo ) )
|
||||
|
||||
iBasicAperture = iBasicAperture * ( 1 / sqrt( d2DDistance / FLOAT(CELL_X_SIZE) ) / gGameCTHConstants.IRON_SIGHTS_MAX_APERTURE_MODIFIER
|
||||
+ (gGameCTHConstants.IRON_SIGHTS_MAX_APERTURE_MODIFIER - 1) / gGameCTHConstants.IRON_SIGHTS_MAX_APERTURE_MODIFIER );
|
||||
|
||||
// iron sights can get a percentage bonus to make them overall better but only when not shooting from hip
|
||||
if ( gCTHDisplay.ScopeMagFactor <= 1.0 && !pSoldier->IsValidAlternativeFireMode( pSoldier->aiData.bAimTime, gCTHDisplay.iTargetGridNo ) )
|
||||
|
||||
iBasicAperture = iBasicAperture * (FLOAT)( (100 - gGameCTHConstants.IRON_SIGHT_PERFORMANCE_BONUS) / 100);
|
||||
|
||||
// laser pointers can provide a percentage bonus to base aperture
|
||||
if ( gCTHDisplay.iBestLaserRange > 0
|
||||
&& ( gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) )
|
||||
{
|
||||
// silversurfer: New functionality for iron sights - There have been many complaints that iron sights lose their usefulness
|
||||
// very fast the farther the target is away. Setting IRON_SIGHT_PERFORMANCE_BONUS too high makes them overly powerful at
|
||||
// close range. This experimental formula implements a curve that lowers iBasicAperture the farther the target is away.
|
||||
// At 1 tile distance iBasicAperture will be the same as before. That's the common start.
|
||||
if ( gGameCTHConstants.IRON_SIGHTS_MAX_APERTURE_USE_GRADIENT && gCTHDisplay.ScopeMagFactor <= 1.0 && !pSoldier->IsValidAlternativeFireMode( pSoldier->aiData.bAimTime, gCTHDisplay.iTargetGridNo ) )
|
||||
INT8 bLightLevel = LightTrueLevel(gCTHDisplay.iTargetGridNo, gsInterfaceLevel );
|
||||
INT32 iMaxLaserRange = ( gCTHDisplay.iBestLaserRange*( 2*bLightLevel + 3*NORMAL_LIGHTLEVEL_NIGHT - 5*NORMAL_LIGHTLEVEL_DAY ) ) / ( 2 * ( NORMAL_LIGHTLEVEL_NIGHT - NORMAL_LIGHTLEVEL_DAY ) );
|
||||
|
||||
iBasicAperture = iBasicAperture * ( 1 / sqrt( d2DDistance / FLOAT(CELL_X_SIZE) ) / gGameCTHConstants.IRON_SIGHTS_MAX_APERTURE_MODIFIER
|
||||
+ (gGameCTHConstants.IRON_SIGHTS_MAX_APERTURE_MODIFIER - 1) / gGameCTHConstants.IRON_SIGHTS_MAX_APERTURE_MODIFIER );
|
||||
|
||||
// iron sights can get a percentage bonus to make them overall better but only when not shooting from hip
|
||||
if ( gCTHDisplay.ScopeMagFactor <= 1.0 && !pSoldier->IsValidAlternativeFireMode( pSoldier->aiData.bAimTime, gCTHDisplay.iTargetGridNo ) )
|
||||
|
||||
iBasicAperture = iBasicAperture * (FLOAT)( (100 - gGameCTHConstants.IRON_SIGHT_PERFORMANCE_BONUS) / 100);
|
||||
|
||||
// laser pointers can provide a percentage bonus to base aperture
|
||||
if ( gCTHDisplay.iBestLaserRange > 0
|
||||
&& ( gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) )
|
||||
// laser only has effect when in range
|
||||
if ( iMaxLaserRange > d2DDistance )
|
||||
{
|
||||
INT8 bLightLevel = LightTrueLevel(gCTHDisplay.iTargetGridNo, gsInterfaceLevel );
|
||||
INT32 iMaxLaserRange = ( gCTHDisplay.iBestLaserRange*( 2*bLightLevel + 3*NORMAL_LIGHTLEVEL_NIGHT - 5*NORMAL_LIGHTLEVEL_DAY ) ) / ( 2 * ( NORMAL_LIGHTLEVEL_NIGHT - NORMAL_LIGHTLEVEL_DAY ) );
|
||||
// which bonus do we want to apply?
|
||||
if ( pSoldier->IsValidAlternativeFireMode( pSoldier->aiData.bAimTime, gCTHDisplay.iTargetGridNo ) )
|
||||
// shooting from hip
|
||||
fLaserBonus = gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP;
|
||||
else if ( gCTHDisplay.ScopeMagFactor <= 1.0 )
|
||||
// using iron sights or other 1x sights
|
||||
fLaserBonus = gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON;
|
||||
else
|
||||
// must be using a scope
|
||||
fLaserBonus = gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE;
|
||||
|
||||
// laser only has effect when in range
|
||||
if ( iMaxLaserRange > d2DDistance )
|
||||
// light level influences how easy it is to spot the laser dot on the target
|
||||
fBrightnessModifier = (FLOAT)(bLightLevel) / (FLOAT)(NORMAL_LIGHTLEVEL_NIGHT);
|
||||
|
||||
// laser fully efficient
|
||||
if ( gCTHDisplay.iBestLaserRange > d2DDistance )
|
||||
// apply full bonus
|
||||
iBasicAperture = iBasicAperture * (FLOAT)( (100 - (fLaserBonus * fBrightnessModifier)) / 100);
|
||||
else
|
||||
{
|
||||
// which bonus do we want to apply?
|
||||
if ( pSoldier->IsValidAlternativeFireMode( pSoldier->aiData.bAimTime, gCTHDisplay.iTargetGridNo ) )
|
||||
// shooting from hip
|
||||
fLaserBonus = gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP;
|
||||
else if ( gCTHDisplay.ScopeMagFactor <= 1.0 )
|
||||
// using iron sights or other 1x sights
|
||||
fLaserBonus = gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON;
|
||||
else
|
||||
// must be using a scope
|
||||
fLaserBonus = gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE;
|
||||
|
||||
// light level influences how easy it is to spot the laser dot on the target
|
||||
fBrightnessModifier = (FLOAT)(bLightLevel) / (FLOAT)(NORMAL_LIGHTLEVEL_NIGHT);
|
||||
|
||||
// laser fully efficient
|
||||
if ( gCTHDisplay.iBestLaserRange > d2DDistance )
|
||||
// apply full bonus
|
||||
iBasicAperture = iBasicAperture * (FLOAT)( (100 - (fLaserBonus * fBrightnessModifier)) / 100);
|
||||
else
|
||||
{
|
||||
// beyond BestLaserRange laser bonus drops linearly to 0
|
||||
fEffectiveLaserRatio = (FLOAT)(iMaxLaserRange - d2DDistance) / (FLOAT)(iMaxLaserRange - gCTHDisplay.iBestLaserRange);
|
||||
// apply partial bonus
|
||||
iBasicAperture = iBasicAperture * (FLOAT)( (100 - (fLaserBonus * fBrightnessModifier * fEffectiveLaserRatio)) / 100);
|
||||
}
|
||||
// beyond BestLaserRange laser bonus drops linearly to 0
|
||||
fEffectiveLaserRatio = (FLOAT)(iMaxLaserRange - d2DDistance) / (FLOAT)(iMaxLaserRange - gCTHDisplay.iBestLaserRange);
|
||||
// apply partial bonus
|
||||
iBasicAperture = iBasicAperture * (FLOAT)( (100 - (fLaserBonus * fBrightnessModifier * fEffectiveLaserRatio)) / 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user