mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
- 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:
+71
-50
@@ -12653,90 +12653,111 @@ 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 (TargetMagFactor <= 1.0f)
|
|
||||||
{
|
|
||||||
// Target is at Iron Sights range. No scope is required.
|
|
||||||
return 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pObj->exists() == true && UsingNewCTHSystem() == true )
|
|
||||||
{
|
|
||||||
// Real Scope Magnification Factor from the item
|
|
||||||
CurrentFactor = __max(1.0f, Item[pObjUsed->usItem].scopemagfactor);
|
|
||||||
|
|
||||||
if (CurrentFactor > 1.0f)
|
|
||||||
{
|
{
|
||||||
// Actual Scope Mag Factor is what we get at the distance the target's at.
|
|
||||||
ActualCurrentFactor = __min(CurrentFactor, (TargetMagFactor/rangeModifier));
|
|
||||||
|
|
||||||
if (ActualCurrentFactor >= CurrentFactor)
|
if (ActualCurrentFactor >= CurrentFactor)
|
||||||
{
|
{
|
||||||
// This scope gives no penalty. Record this as the best factor found so far.
|
// This scope gives no penalty. Record this as the best factor found.
|
||||||
BestFactor = CurrentFactor;
|
BestFactor = CurrentFactor;
|
||||||
iBestTotalPenalty = 0;
|
iBestTotalPenalty = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// This scopes gives a penalty for shooting under its range.
|
// This scope gives a penalty for shooting under its range.
|
||||||
FLOAT dScopePenaltyRatio = (CurrentFactor * rangeModifier / TargetMagFactor);
|
FLOAT dScopePenaltyRatio = (CurrentFactor * rangeModifier / TargetMagFactor);
|
||||||
INT32 iScopePenalty = (INT32)((dScopePenaltyRatio * gGameCTHConstants.AIM_TOO_CLOSE_SCOPE) * (CurrentFactor / 2));
|
INT32 iScopePenalty = (INT32)((dScopePenaltyRatio * gGameCTHConstants.AIM_TOO_CLOSE_SCOPE) * (CurrentFactor / 2));
|
||||||
|
|
||||||
// There's no previous scope to compare with so record this as the best factor for now.
|
|
||||||
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
|
if(iBestTotalPenalty < 0 && iProjectionFactor > 1.0f)
|
||||||
// BestTotalPenalty to find the scope that gives the least penalty compared to its bonus.
|
BestFactor = 1.0f;
|
||||||
for (attachmentList::iterator iter = (*pObjUsed)[0]->attachments.begin(); iter != (*pObjUsed)[0]->attachments.end(); ++iter)
|
|
||||||
{
|
|
||||||
if (iter->exists() && Item[iter->usItem].scopemagfactor > 1.0f)
|
|
||||||
{
|
|
||||||
// Real Scope Magnification Factor from the item
|
|
||||||
CurrentFactor = __max(1.0f, Item[iter->usItem].scopemagfactor);
|
|
||||||
|
|
||||||
|
return( __max(1.0f, BestFactor) );
|
||||||
|
}
|
||||||
|
// if not using scope modes find the best scope
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (TargetMagFactor <= 1.0f)
|
||||||
|
{
|
||||||
|
// Target is at Iron Sights range. No scope is required.
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( pObj->exists() == true && UsingNewCTHSystem() == true )
|
||||||
|
{
|
||||||
|
// Real Scope Magnification Factor from the item
|
||||||
|
CurrentFactor = __max(1.0f, Item[pObjUsed->usItem].scopemagfactor);
|
||||||
|
|
||||||
|
if (CurrentFactor > 1.0f)
|
||||||
|
{
|
||||||
// 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));
|
||||||
|
|
||||||
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. Record this as the best factor found so far.
|
||||||
if (iBestTotalPenalty >= 0 && CurrentFactor > BestFactor)
|
BestFactor = CurrentFactor;
|
||||||
{
|
iBestTotalPenalty = 0;
|
||||||
// This is the best scope we've found so far. Record it.
|
|
||||||
BestFactor = CurrentFactor;
|
|
||||||
iBestTotalPenalty = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// This scope will give a penalty if used. Is it worth using compared to other scopes found?
|
// This scopes gives a penalty for shooting under its range.
|
||||||
FLOAT dScopePenaltyRatio = (CurrentFactor * rangeModifier / TargetMagFactor);
|
FLOAT dScopePenaltyRatio = (CurrentFactor * rangeModifier / TargetMagFactor);
|
||||||
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?
|
// There's no previous scope to compare with so record this as the best factor for now.
|
||||||
if (iScopePenalty < iBestTotalPenalty)
|
BestFactor = CurrentFactor;
|
||||||
|
iBestTotalPenalty = iScopePenalty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now perform the same process for each scope installed on the item. The difference is, we also compare to
|
||||||
|
// BestTotalPenalty to find the scope that gives the least penalty compared to its bonus.
|
||||||
|
for (attachmentList::iterator iter = (*pObjUsed)[0]->attachments.begin(); iter != (*pObjUsed)[0]->attachments.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (iter->exists() && Item[iter->usItem].scopemagfactor > 1.0f)
|
||||||
|
{
|
||||||
|
// Real Scope Magnification Factor from the item
|
||||||
|
CurrentFactor = __max(1.0f, Item[iter->usItem].scopemagfactor);
|
||||||
|
|
||||||
|
// Actual Scope Mag Factor is what we get at the distance the target's at.
|
||||||
|
ActualCurrentFactor = __min(CurrentFactor, (TargetMagFactor/rangeModifier));
|
||||||
|
|
||||||
|
if (ActualCurrentFactor >= CurrentFactor)
|
||||||
{
|
{
|
||||||
// This is the best scope we've found so far. Record it.
|
// This scope gives no penalty. Is it any better than the ones we've already processed?
|
||||||
BestFactor = CurrentFactor;
|
if (iBestTotalPenalty <= 0 && CurrentFactor > BestFactor)
|
||||||
iBestTotalPenalty = iScopePenalty;
|
{
|
||||||
|
// This is the best scope we've found so far. Record it.
|
||||||
|
BestFactor = CurrentFactor;
|
||||||
|
iBestTotalPenalty = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// This scope will give a penalty if used. Is it worth using compared to other scopes found?
|
||||||
|
FLOAT dScopePenaltyRatio = (CurrentFactor * rangeModifier / TargetMagFactor);
|
||||||
|
INT32 iScopePenalty = (INT32)((dScopePenaltyRatio * gGameCTHConstants.AIM_TOO_CLOSE_SCOPE) * (CurrentFactor / 2));
|
||||||
|
|
||||||
|
// Is this scope any better than the ones we've already processed?
|
||||||
|
if (iScopePenalty > iBestTotalPenalty)
|
||||||
|
{
|
||||||
|
// This is the best scope we've found so far. Record it.
|
||||||
|
BestFactor = CurrentFactor;
|
||||||
|
iBestTotalPenalty = iScopePenalty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 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)
|
||||||
|
BestFactor = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
|
||||||
BestFactor = 1.0f;
|
|
||||||
|
|
||||||
return( __max(1.0f, BestFactor) );
|
return( __max(1.0f, BestFactor) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user