Fix: when using scope modes with NCTH, non-internal projection factor from lasers was ignored.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6078 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2013-05-14 21:11:24 +00:00
parent e365ac9f1b
commit cefa9cfcc1
3 changed files with 38 additions and 7 deletions
+32
View File
@@ -12729,6 +12729,38 @@ FLOAT GetProjectionFactor( OBJECTTYPE * pObj )
return( BestFactor );
}
// Flugente: projection factor while using scope modes excludes those factors coming from not-used scopes and sights
FLOAT GetScopeModeProjectionFactor( SOLDIERTYPE *pSoldier, OBJECTTYPE * pObj )
{
if ( !gGameExternalOptions.fScopeModes || !pSoldier || pSoldier->bTeam != gbPlayerNum || !pObj || !pObj->exists() || Item[pObj->usItem].usItemClass != IC_GUN )
return GetProjectionFactor(pObj);
if ( !UsingNewCTHSystem() || pSoldier->bScopeMode == USE_ALT_WEAPON_HOLD )
return 1.0;
// Flugente: check for scope mode
std::map<INT8, OBJECTTYPE*> ObjList;
GetScopeLists(pObj, ObjList);
FLOAT BestFactor = 1.0;
BestFactor = __max((FLOAT)Item[pObj->usItem].projectionfactor, 1.0f);
for (attachmentList::iterator iter = (*pObj)[0]->attachments.begin(); iter != (*pObj)[0]->attachments.end(); ++iter)
{
if (iter->exists())
{
// if attachment is scope/sight and not used, ignore it!
if ( IsAttachmentClass(iter->usItem, AC_SCOPE|AC_SIGHT|AC_IRONSIGHT ) && iter->usItem != ObjList[pSoldier->bScopeMode]->usItem )
continue;
BestFactor = __max(BestFactor, Item[iter->usItem].projectionfactor);
}
}
return( BestFactor );
}
FLOAT GetScopeRangeMultiplier( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObj, FLOAT d2DDistance )
{
FLOAT iScopeFactor = 0;
+3
View File
@@ -417,6 +417,9 @@ FLOAT GetHighestScopeMagnificationFactor( OBJECTTYPE *pObj );
FLOAT GetScopeMagnificationFactor( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObj, FLOAT uiRange );
FLOAT GetBestScopeMagnificationFactor( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObj, FLOAT uiRange );
FLOAT GetProjectionFactor( OBJECTTYPE *pObj );
// Flugente: projection factor while using scope modes excludes those factors coming from not-used scopes and sights
FLOAT GetScopeModeProjectionFactor( SOLDIERTYPE *pSoldier, OBJECTTYPE * pObj );
FLOAT GetScopeRangeMultiplier( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObj, FLOAT d2DDistance );
INT32 GetGunAccuracy( OBJECTTYPE *pObj );
INT32 GetAccuracyModifier( OBJECTTYPE *pObj );
+3 -7
View File
@@ -7813,13 +7813,9 @@ FLOAT CalcProjectionFactor( SOLDIERTYPE *pShooter, OBJECTTYPE *pWeapon, FLOAT d2
// Flugente: if scope modes are allowed, player team uses them
if ( gGameExternalOptions.fScopeModes && pShooter && pShooter->bTeam == gbPlayerNum && pObjUsed->exists() == true && Item[pObjUsed->usItem].usItemClass == IC_GUN )
{
// Flugente: check for scope mode
std::map<INT8, OBJECTTYPE*> ObjList;
GetScopeLists(pObjUsed, ObjList);
// only use scope mode if gun is in hand, otherwise an error might occur!
if ( (&pShooter->inv[HANDPOS]) == pObjUsed && ObjList[pShooter->bScopeMode] != NULL && pShooter->bScopeMode != USE_ALT_WEAPON_HOLD )
iProjectionFactor = Item[ObjList[pShooter->bScopeMode]->usItem].projectionfactor;
// we calculate the projection factor of the item, but EXCLUDE those factors coming from scopes/sights we are not using at the moment. This means that factors from lasers
// count, but from reflex sights only if we are using the specific sight
iProjectionFactor = GetScopeModeProjectionFactor(pShooter, pObjUsed);
}
else
iProjectionFactor = GetProjectionFactor( pObjUsed );