- Bugfix: NCTH - Scope Penalties (by silversurfer)

o see: http://www.ja-galaxy-forum.com/board/ubbthreads.php/topics/321860/Re_NCTH_Scope_penalties_below_.html#Post321860


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6155 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2013-06-25 06:30:57 +00:00
parent 911e255bb0
commit fa2fe99b1d
+29 -8
View File
@@ -12653,10 +12653,34 @@ FLOAT GetBestScopeMagnificationFactor( SOLDIERTYPE *pSoldier, OBJECTTYPE * pObj,
// Actual Scope Mag Factor is what we get at the distance the target's at. // Actual Scope Mag Factor is what we get at the distance the target's at.
ActualCurrentFactor = __min(CurrentFactor, (TargetMagFactor/rangeModifier)); ActualCurrentFactor = __min(CurrentFactor, (TargetMagFactor/rangeModifier));
// as we only use once scope, we can return from here // using NCTH system?
return( __max(1.0f, ActualCurrentFactor) ); if ( pObj->exists() == true && UsingNewCTHSystem() == true )
{
if (ActualCurrentFactor >= CurrentFactor)
{
// This scope gives no penalty. Record this as the best factor found.
BestFactor = CurrentFactor;
iBestTotalPenalty = 0;
}
else
{
// This scope gives a penalty for shooting under its range.
FLOAT dScopePenaltyRatio = (CurrentFactor * rangeModifier / TargetMagFactor);
INT32 iScopePenalty = (INT32)((dScopePenaltyRatio * gGameCTHConstants.AIM_TOO_CLOSE_SCOPE) * (CurrentFactor / 2));
BestFactor = CurrentFactor;
iBestTotalPenalty = iScopePenalty;
}
} }
if(iBestTotalPenalty < 0 && iProjectionFactor > 1.0f)
BestFactor = 1.0f;
return( __max(1.0f, BestFactor) );
}
// if not using scope modes find the best scope
else
{
if (TargetMagFactor <= 1.0f) if (TargetMagFactor <= 1.0f)
{ {
// Target is at Iron Sights range. No scope is required. // Target is at Iron Sights range. No scope is required.
@@ -12689,7 +12713,6 @@ FLOAT GetBestScopeMagnificationFactor( SOLDIERTYPE *pSoldier, OBJECTTYPE * pObj,
BestFactor = CurrentFactor; BestFactor = CurrentFactor;
iBestTotalPenalty = iScopePenalty; iBestTotalPenalty = iScopePenalty;
} }
} }
// Now perform the same process for each scope installed on the item. The difference is, we also compare to // Now perform the same process for each scope installed on the item. The difference is, we also compare to
@@ -12707,7 +12730,7 @@ FLOAT GetBestScopeMagnificationFactor( SOLDIERTYPE *pSoldier, OBJECTTYPE * pObj,
if (ActualCurrentFactor >= CurrentFactor) if (ActualCurrentFactor >= CurrentFactor)
{ {
// This scope gives no penalty. Is it any better than the ones we've already processed? // This scope gives no penalty. Is it any better than the ones we've already processed?
if (iBestTotalPenalty >= 0 && CurrentFactor > BestFactor) if (iBestTotalPenalty <= 0 && CurrentFactor > BestFactor)
{ {
// This is the best scope we've found so far. Record it. // This is the best scope we've found so far. Record it.
BestFactor = CurrentFactor; BestFactor = CurrentFactor;
@@ -12721,7 +12744,7 @@ FLOAT GetBestScopeMagnificationFactor( SOLDIERTYPE *pSoldier, OBJECTTYPE * pObj,
INT32 iScopePenalty = (INT32)((dScopePenaltyRatio * gGameCTHConstants.AIM_TOO_CLOSE_SCOPE) * (CurrentFactor / 2)); INT32 iScopePenalty = (INT32)((dScopePenaltyRatio * gGameCTHConstants.AIM_TOO_CLOSE_SCOPE) * (CurrentFactor / 2));
// Is this scope any better than the ones we've already processed? // Is this scope any better than the ones we've already processed?
if (iScopePenalty < iBestTotalPenalty) if (iScopePenalty > iBestTotalPenalty)
{ {
// This is the best scope we've found so far. Record it. // This is the best scope we've found so far. Record it.
BestFactor = CurrentFactor; BestFactor = CurrentFactor;
@@ -12730,13 +12753,11 @@ FLOAT GetBestScopeMagnificationFactor( SOLDIERTYPE *pSoldier, OBJECTTYPE * pObj,
} }
} }
} }
} }
// Now that we have selected the best available scope, don't use it if we get a penalty and have a functional laser // Now that we have selected the best available scope, don't use it if we get a penalty and have a functional laser
if(iBestTotalPenalty < 0 && iProjectionFactor > 1.0f) if(iBestTotalPenalty < 0 && iProjectionFactor > 1.0f)
BestFactor = 1.0f; BestFactor = 1.0f;
}
return( __max(1.0f, BestFactor) ); return( __max(1.0f, BestFactor) );
} }