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:
silversurfer
2016-08-06 10:44:42 +00:00
parent a58f8a6622
commit 73e3e1172c
8 changed files with 178 additions and 1419 deletions
-4
View File
@@ -716,10 +716,6 @@ void LoadGameExternalOptions()
gGameExternalOptions.guiMaxWeaponSize = iniReader.ReadInteger("System Limit Settings","MAX_WEAPON_SIZE", 9, 0, 32000);
gGameExternalOptions.guiOIVSizeNumber = iniReader.ReadInteger("System Limit Settings","OLD_INVENTORY_ITEM_NUMBER", 99, 0, 65535);
// silversurfer: this is only for the cleaned up NCTH calculation. Please remove if the new functions are accepted
// see Tactical\Weapons.cpp funtion CalcNewChanceToHitGun()
gGameExternalOptions.fUseNewCTHCalculation = iniReader.ReadBoolean("System Limit Settings", "USE_NEW_CTH_CALCULATION", TRUE);
// Flugente: this change allows to target head/torso/legs of prone targets. This option will be removed once accepted
gGameExternalOptions.fAllowTargetHeadAndLegIfProne = iniReader.ReadBoolean( "System Limit Settings", "ALLOW_TARGET_HEADANDLEG_IFPRONE", TRUE );
-4
View File
@@ -575,10 +575,6 @@ typedef struct
UINT16 guiMaxItemSize;
UINT16 guiOIVSizeNumber;
// silversurfer: this is only for the cleaned up NCTH calculation. Please remove if the new functions are accepted
// see Tactical\Weapons.cpp funtion CalcNewChanceToHitGun()
BOOLEAN fUseNewCTHCalculation;
// Flugente: this change allows to target head/torso/legs of prone targets. This option will be removed once accepted
BOOLEAN fAllowTargetHeadAndLegIfProne;
+9 -9
View File
@@ -15,9 +15,9 @@
#ifdef JA2EDITOR
#ifdef JA2UB
CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8278 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8281 (Development Build)" };
#else
CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8278 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8281 (Development Build)" };
#endif
// ------------------------------
@@ -27,11 +27,11 @@
//DEBUG BUILD VERSION
#ifdef JA2UB
CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8278 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8281 (Development Build)" };
#elif defined (JA113DEMO)
CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8278 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8281 (Development Build)" };
#else
CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8278 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8281 (Development Build)" };
#endif
#elif defined CRIPPLED_VERSION
@@ -46,16 +46,16 @@
//RELEASE BUILD VERSION
#ifdef JA2UB
CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8278 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8281 (Development Build)" };
#elif defined (JA113DEMO)
CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8278 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8281 (Development Build)" };
#else
CHAR16 zVersionLabel[256] = { L"Release v1.13.8278 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Release v1.13.8281 (Development Build)" };
#endif
#endif
CHAR8 czVersionNumber[16] = { "Build 16.07.31" }; //YY.MM.DD
CHAR8 czVersionNumber[16] = { "Build 16.08.06" }; //YY.MM.DD
CHAR16 zTrackingNumber[16] = { L"Z" };
// SAVE_GAME_VERSION is defined in header, change it there
+12 -12
View File
@@ -1474,7 +1474,7 @@ void InternalInitEDBTooltipRegion( OBJECTTYPE * gpItemDescObject, UINT32 guiCurr
if(UsingNewCTHSystem() == true)
{
// with the new Laser Performance Bonus we need to display a different text for laser on a weapons general tab
if ( gGameExternalOptions.fUseNewCTHCalculation && cnt == 6
if ( cnt == 6
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) )
swprintf( pStr, L"%s%s", szUDBAdvStatsTooltipText[64], szUDBGenWeaponsStatsExplanationsTooltipText[ cnt ]);
else if ( cnt == 10 && gGameExternalOptions.fAdvRepairSystem && !gSkillTraitValues.fTETraitsCanRestoreItemThreshold )
@@ -1628,7 +1628,7 @@ void InternalInitEDBTooltipRegion( OBJECTTYPE * gpItemDescObject, UINT32 guiCurr
// with the reworked NCTH code and the laser performance factor we will display BestLaserRange instead of ProjectionFactor but we still need the mouse region
if (UsingNewCTHSystem() == true &&
( (Item[gpItemDescObject->usItem].projectionfactor > 1.0 || GetProjectionFactor( gpItemDescObject ) > 1.0) ||
( gGameExternalOptions.fUseNewCTHCalculation && GetBestLaserRange( gpItemDescObject ) > 0
( GetBestLaserRange( gpItemDescObject ) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) )
{
ubRegionOffset = 6;
@@ -3158,7 +3158,7 @@ void InternalInitEDBTooltipRegion( OBJECTTYPE * gpItemDescObject, UINT32 guiCurr
///////////////////// PROJECTION FACTOR
// with the reworked NCTH code and the laser performance factor we will display BestLaserRange instead of ProjectionFactor
if ( gGameExternalOptions.fUseNewCTHCalculation && GetBestLaserRange( gpItemDescObject ) > 0
if ( GetBestLaserRange( gpItemDescObject ) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) )
{
if( UsingNewCTHSystem() == true )
@@ -4307,11 +4307,11 @@ void DrawWeaponStats( OBJECTTYPE * gpItemDescObject )
// with the reworked NCTH code and the laser performance factor we will display BestLaserRange instead of ProjectionFactor but we use the same icon
if ( (UsingNewCTHSystem() == true &&
( (Item[gpItemDescObject->usItem].projectionfactor > 1.0 || GetProjectionFactor( gpItemDescObject ) > 1.0) ||
( gGameExternalOptions.fUseNewCTHCalculation && GetBestLaserRange( gpItemDescObject ) > 0
( GetBestLaserRange( gpItemDescObject ) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) ) ||
( fComparisonMode && UsingNewCTHSystem() == true &&
( (Item[gpComparedItemDescObject->usItem].projectionfactor > 1.0 || GetProjectionFactor( gpComparedItemDescObject ) > 1.0) ||
( gGameExternalOptions.fUseNewCTHCalculation && GetBestLaserRange( gpComparedItemDescObject ) > 0
( GetBestLaserRange( gpComparedItemDescObject ) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) ) )
{
ubNumLine = 6;
@@ -5227,11 +5227,11 @@ void DrawAdvancedStats( OBJECTTYPE * gpItemDescObject )
// with the reworked NCTH code and the laser performance factor we will display BestLaserRange instead of ProjectionFactor but we use the same icon
if ( (cnt-sFirstLine < sLastLine &&
( GetProjectionFactor( gpItemDescObject ) > 1.0 ||
( gGameExternalOptions.fUseNewCTHCalculation && GetBestLaserRange( gpItemDescObject ) > 0
( GetBestLaserRange( gpItemDescObject ) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) ) ||
( fComparisonMode && (cnt-sFirstLine < sLastLine &&
( GetProjectionFactor( gpComparedItemDescObject ) > 1.0 ||
( gGameExternalOptions.fUseNewCTHCalculation && GetBestLaserRange( gpComparedItemDescObject ) > 0
( GetBestLaserRange( gpComparedItemDescObject ) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) ) ) )
{
if( UsingNewCTHSystem() == true )
@@ -7191,7 +7191,7 @@ void DrawWeaponValues( OBJECTTYPE * gpItemDescObject )
// with the reworked NCTH code and the laser performance factor we will display BestLaserRange instead of ProjectionFactor
if (UsingNewCTHSystem() == true &&
( (Item[gpItemDescObject->usItem].projectionfactor > 1.0 || GetProjectionFactor( gpItemDescObject ) > 1.0) ||
( gGameExternalOptions.fUseNewCTHCalculation && GetBestLaserRange( gpItemDescObject ) > 0
( GetBestLaserRange( gpItemDescObject ) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) )
{
// Set line to draw into
@@ -7202,7 +7202,7 @@ void DrawWeaponValues( OBJECTTYPE * gpItemDescObject )
FLOAT iFinalProjectionValue = 0;
BOOLEAN bNewCode = FALSE;
if ( gGameExternalOptions.fUseNewCTHCalculation && GetBestLaserRange( gpItemDescObject ) > 0
if ( GetBestLaserRange( gpItemDescObject ) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) )
{
// Get base laser range
@@ -7289,7 +7289,7 @@ void DrawWeaponValues( OBJECTTYPE * gpItemDescObject )
}
else if( fComparisonMode && UsingNewCTHSystem() == true &&
( (Item[gpComparedItemDescObject->usItem].projectionfactor > 1.0 || GetProjectionFactor( gpComparedItemDescObject ) > 1.0) ||
( gGameExternalOptions.fUseNewCTHCalculation && GetBestLaserRange( gpItemDescObject ) > 0
( GetBestLaserRange( gpItemDescObject ) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) )
{
ubNumLine = 6;
@@ -7299,7 +7299,7 @@ void DrawWeaponValues( OBJECTTYPE * gpItemDescObject )
FLOAT iFinalProjectionValue = 0;
BOOLEAN bNewCode = FALSE;
if ( gGameExternalOptions.fUseNewCTHCalculation && GetBestLaserRange( gpComparedItemDescObject ) > 0
if ( GetBestLaserRange( gpComparedItemDescObject ) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) )
{
// Get base laser range
@@ -11034,7 +11034,7 @@ void DrawAdvancedValues( OBJECTTYPE *gpItemDescObject )
BOOLEAN bNewCode = FALSE;
///////////////////// PROJECTION FACTOR
// with the reworked NCTH code and the laser performance factor we will display BestLaserRange instead of ProjectionFactor
if ( gGameExternalOptions.fUseNewCTHCalculation && GetBestLaserRange( gpItemDescObject ) > 0
if ( GetBestLaserRange( gpItemDescObject ) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) )
{
iFloatModifier[0] = ((FLOAT)GetBestLaserRange( gpItemDescObject ) / CELL_X_SIZE);
+43 -47
View File
@@ -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);
}
}
}
+9 -2
View File
@@ -7342,7 +7342,7 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew
break;
}
if (PlaceInAnySlot(pSoldier, pObj, (fNewItem == TRUE), bExcludeSlot, fStackOrSingleSlot) == true)
if ( PlaceInAnySlot(pSoldier, pObj, (fNewItem == TRUE), bExcludeSlot, fStackOrSingleSlot) )
return TRUE;
return( FALSE );
@@ -12845,7 +12845,14 @@ FLOAT GetBestScopeMagnificationFactor( SOLDIERTYPE *pSoldier, OBJECTTYPE * pObj,
INT32 iCurrentTotalPenalty = 0;
INT32 iBestTotalPenalty = 0;
FLOAT rangeModifier = GetScopeRangeMultiplier(pSoldier, pObjUsed, uiRange);
FLOAT iProjectionFactor = CalcProjectionFactor(pSoldier, pObjUsed, uiRange, 1);
FLOAT iProjectionFactor = 0;
// With the reworked NCTH code we don't want to use iProjectionFactor anymore.
// Instead we use the performance bonus if at least one bonus is != 0. Otherwise -> continue using Projection Factor.
if ( (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE) != 0 )
iProjectionFactor = 1.0;
else
iProjectionFactor = CalcProjectionFactor(pSoldier, pObjUsed, uiRange, 1);
// Flugente: if scope modes are allowed, use them
if ( gGameExternalOptions.fScopeModes && pSoldier && pObjUsed->exists() == true && Item[pObjUsed->usItem].usItemClass == IC_GUN )
+53 -50
View File
@@ -2505,7 +2505,7 @@ INT32 LocationToLocationLineOfSightTest( INT32 sStartGridNo, INT8 bStartLevel, I
{
FLOAT dStartZPos, dEndZPos;
INT16 sStartXPos, sStartYPos, sEndXPos, sEndYPos;
UINT8 ubStartID;
// UINT8 ubStartID;
// sevenfm: always use standing heights
/*ubStartID = WhoIsThere2( sStartGridNo, bStartLevel );
@@ -7901,59 +7901,55 @@ void AdjustTargetCenterPoint( SOLDIERTYPE *pShooter, INT32 iTargetGridNo, FLOAT
// First, let's calculate the basic Aperture. This is the size of an unmodified aperture at 1x Normal Distance.
iBasicAperture = CalcBasicAperture( );
// 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 && !pShooter->IsValidAlternativeFireMode( pShooter->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 && !pShooter->IsValidAlternativeFireMode( pShooter->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 && !pShooter->IsValidAlternativeFireMode( pShooter->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 && !pShooter->IsValidAlternativeFireMode( pShooter->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 ) );
FLOAT fLaserBonus = 0;
// which bonus do we want to apply?
if ( pShooter->IsValidAlternativeFireMode( pShooter->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
FLOAT 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
{
FLOAT fLaserBonus = 0;
// which bonus do we want to apply?
if ( pShooter->IsValidAlternativeFireMode( pShooter->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
FLOAT 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
FLOAT 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
FLOAT fEffectiveLaserRatio = (FLOAT)(iMaxLaserRange - d2DDistance) / (FLOAT)(iMaxLaserRange - gCTHDisplay.iBestLaserRange);
// apply partial bonus
iBasicAperture = iBasicAperture * (FLOAT)( (100 - (fLaserBonus * fBrightnessModifier * fEffectiveLaserRatio)) / 100);
}
}
}
@@ -8305,7 +8301,14 @@ FLOAT CalcMagFactor( SOLDIERTYPE *pShooter, OBJECTTYPE *pWeapon, FLOAT d2DDistan
iScopeFactor = GetBestScopeMagnificationFactor( pShooter, pWeapon, d2DDistance );
iScopeFactor = __min(iScopeFactor, __max(1.0f, iTargetMagFactor/rangeModifier));
}
iProjectionFactor = CalcProjectionFactor(pShooter, pWeapon, d2DDistance, ubAimTime);
// With the reworked NCTH code we don't want to use iProjectionFactor anymore.
// Instead we use the performance bonus if at least one bonus is != 0. Otherwise -> continue using Projection Factor.
if ( (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE) != 0 )
iProjectionFactor = 1.0;
else
iProjectionFactor = CalcProjectionFactor(pShooter, pWeapon, d2DDistance, ubAimTime);
iFinalMagFactor = __max(iScopeFactor, iProjectionFactor);
}
+52 -1291
View File
File diff suppressed because it is too large Load Diff