mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
Fix: singleshot launchers are always displayed as out of range
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7979 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+18
-17
@@ -5194,25 +5194,24 @@ CompileWorldMovementCosts();
|
||||
BOOLEAN InRange( SOLDIERTYPE *pSoldier, INT32 sGridNo )
|
||||
{
|
||||
INT32 sRange;
|
||||
UINT16 usInHand;
|
||||
OBJECTTYPE *pObj;
|
||||
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("InRange"));
|
||||
|
||||
if ( !pSoldier )
|
||||
return FALSE;
|
||||
|
||||
// Flugente: check for underbarrel weapons and use that object if necessary
|
||||
pObj = pSoldier->GetUsedWeapon( &pSoldier->inv[HANDPOS] );
|
||||
|
||||
usInHand = (*pObj).usItem;
|
||||
INVTYPE* pItemInHand = &Item[ usInHand ];
|
||||
|
||||
if ( pItemInHand->usItemClass == IC_GUN || pItemInHand->usItemClass == IC_THROWING_KNIFE || (pItemInHand->rocketlauncher && !pItemInHand->singleshotrocketlauncher))
|
||||
if ( Item[pObj->usItem].usItemClass & (IC_GUN | IC_THROWING_KNIFE | IC_LAUNCHER) )
|
||||
{
|
||||
// Determine range
|
||||
sRange = GetRangeInCellCoordsFromGridNoDiff( pSoldier->sGridNo, sGridNo );
|
||||
|
||||
if ( pItemInHand->usItemClass == IC_THROWING_KNIFE )
|
||||
if ( Item[pObj->usItem].usItemClass & (IC_THROWING_KNIFE) )
|
||||
{
|
||||
// NB CalcMaxTossRange returns range in tiles, not in world units
|
||||
if ( sRange <= CalcMaxTossRange( pSoldier, usInHand, TRUE ) * CELL_X_SIZE )
|
||||
if ( sRange <= CalcMaxTossRange( pSoldier, pObj->usItem, TRUE ) * CELL_X_SIZE )
|
||||
{
|
||||
return( TRUE );
|
||||
}
|
||||
@@ -5222,10 +5221,11 @@ BOOLEAN InRange( SOLDIERTYPE *pSoldier, INT32 sGridNo )
|
||||
// For given weapon, check range
|
||||
if ( sRange <= GunRange( pObj, pSoldier ) ) // SANDRO - added argument
|
||||
{
|
||||
return( TRUE );
|
||||
return( TRUE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
@@ -11436,13 +11436,14 @@ INT32 CalcMaxTossRange( SOLDIERTYPE * pSoldier, UINT16 usItem, BOOLEAN fArmed, O
|
||||
//MM: So instead, let's look at the soldier's hand, and check his gun for an underbarrel GL
|
||||
if ( fArmed )
|
||||
{
|
||||
OBJECTTYPE *pObj = NULL;
|
||||
pObj = pSoldier->GetUsedWeapon( &pSoldier->inv[pSoldier->ubAttackingHand] );
|
||||
OBJECTTYPE *pObj = pSoldier->GetUsedWeapon( &pSoldier->inv[pSoldier->ubAttackingHand] );
|
||||
if ( pObj != NULL )
|
||||
{
|
||||
if (Item[pObj->usItem].usItemClass == IC_LAUNCHER)
|
||||
if ( Item[pObj->usItem].usItemClass & IC_LAUNCHER )
|
||||
{
|
||||
usSubItem = pObj->usItem;
|
||||
else if (Item[pObj->usItem].usItemClass == IC_GUN)
|
||||
}
|
||||
else if ( Item[pObj->usItem].usItemClass & IC_GUN )
|
||||
{
|
||||
usSubItem = GetAttachedGrenadeLauncher(pObj);
|
||||
}
|
||||
@@ -11454,7 +11455,7 @@ INT32 CalcMaxTossRange( SOLDIERTYPE * pSoldier, UINT16 usItem, BOOLEAN fArmed, O
|
||||
usItem = usSubItem;
|
||||
}
|
||||
|
||||
if ( Item[ usItem ].usItemClass == IC_LAUNCHER && fArmed )
|
||||
if ( (Item[ usItem ].usItemClass & IC_LAUNCHER) && fArmed )
|
||||
{
|
||||
// this function returns range in tiles so, stupidly, we have to divide by 10 here
|
||||
iRange = GetModifiedGunRange(usItem) / CELL_X_SIZE;
|
||||
@@ -11462,18 +11463,18 @@ INT32 CalcMaxTossRange( SOLDIERTYPE * pSoldier, UINT16 usItem, BOOLEAN fArmed, O
|
||||
else
|
||||
{
|
||||
// sevenfm: calculate total weight of object with all attachments
|
||||
if(pObject!= NULL)
|
||||
if ( pObject )
|
||||
itemWeight = CalculateObjectWeight(pObject);
|
||||
else
|
||||
itemWeight=Item[usItem].ubWeight;
|
||||
// if ( Item[ usItem ].fFlags & ITEM_UNAERODYNAMIC )
|
||||
|
||||
if ( Item[ usItem ].unaerodynamic )
|
||||
{
|
||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"calcmaxtossrange: not aerodynamic");
|
||||
iRange = 1;
|
||||
}
|
||||
// sevenfm: this formula should be used only for hand grenades and not launched grenades
|
||||
else if ( Item[ usItem ].usItemClass == IC_GRENADE && Item[usItem].ubCursor == TOSSCURS)
|
||||
else if ( (Item[ usItem ].usItemClass & IC_GRENADE) && Item[usItem].ubCursor == TOSSCURS)
|
||||
{
|
||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"calcmaxtossrange: grenade");
|
||||
// start with the range based on the soldier's strength and the item's weight
|
||||
@@ -11503,7 +11504,7 @@ INT32 CalcMaxTossRange( SOLDIERTYPE * pSoldier, UINT16 usItem, BOOLEAN fArmed, O
|
||||
// SANDRO - old/new traits
|
||||
if( gGameOptions.fNewTraitSystem )
|
||||
{
|
||||
if ( (Item[ usItem ].usItemClass == IC_THROWING_KNIFE) && (HAS_SKILL_TRAIT( pSoldier, THROWING_NT )) )
|
||||
if ( (Item[ usItem ].usItemClass & IC_THROWING_KNIFE) && (HAS_SKILL_TRAIT( pSoldier, THROWING_NT )) )
|
||||
{
|
||||
// better max range due to expertise
|
||||
iRange += ((iRange * gSkillTraitValues.ubTHBladesMaxRange ) / 100);
|
||||
|
||||
Reference in New Issue
Block a user