mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
Dynamic ammo weighting (DYNAMIC_AMMO_WEIGHT in JA2_Options.ini) now also applies to food, drugs, canteens and camo kits.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8624 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+28
-22
@@ -2983,13 +2983,13 @@ UINT16 CalculateObjectWeight( OBJECTTYPE *pObject )
|
|||||||
}
|
}
|
||||||
|
|
||||||
UINT16 weight = 0;
|
UINT16 weight = 0;
|
||||||
INVTYPE * pItem;
|
INVTYPE* pItem = &(Item[ pObject->usItem ]);
|
||||||
pItem = &(Item[ pObject->usItem ]);
|
|
||||||
//ADB it is much easier and faster to calculate ammo in a lump rather than accumulate a stack's weight
|
//ADB it is much easier and faster to calculate ammo in a lump rather than accumulate a stack's weight
|
||||||
if ( pItem->usItemClass == IC_AMMO)//Pulmu: added weight allowance for ammo not being full
|
if ( pItem->usItemClass == IC_AMMO)//Pulmu: added weight allowance for ammo not being full
|
||||||
{
|
{
|
||||||
if ( gGameExternalOptions.fAmmoDynamicWeight == TRUE ) {
|
if ( gGameExternalOptions.fAmmoDynamicWeight == TRUE ) {
|
||||||
for( int cnt = 0; cnt < pObject->ubNumberOfObjects; cnt++ )
|
for( int cnt = 0; cnt < pObject->ubNumberOfObjects; ++cnt )
|
||||||
{
|
{
|
||||||
weight += CalculateAmmoWeight(pObject->usItem, (*pObject)[cnt]->data.ubShotsLeft);
|
weight += CalculateAmmoWeight(pObject->usItem, (*pObject)[cnt]->data.ubShotsLeft);
|
||||||
}
|
}
|
||||||
@@ -3022,30 +3022,33 @@ UINT16 OBJECTTYPE::GetWeightOfObjectInStack(unsigned int index)
|
|||||||
|
|
||||||
// Start with base weight
|
// Start with base weight
|
||||||
UINT16 weight = pItem->ubWeight;
|
UINT16 weight = pItem->ubWeight;
|
||||||
if ( pItem->usItemClass != IC_AMMO )
|
|
||||||
|
// Are we looking at an LBENODE item? New inventory only.
|
||||||
|
if ( pItem->usItemClass == IC_LBEGEAR && IsActiveLBE( index ) && ( UsingNewInventorySystem() == true ) )
|
||||||
{
|
{
|
||||||
// Are we looking at an LBENODE item? New inventory only.
|
LBENODE* pLBE = GetLBEPointer( index );
|
||||||
if(pItem->usItemClass == IC_LBEGEAR && IsActiveLBE(index) && (UsingNewInventorySystem() == true))
|
if ( pLBE )
|
||||||
{
|
{
|
||||||
LBENODE* pLBE = GetLBEPointer(index);
|
UINT16 invsize = pLBE->inv.size();
|
||||||
if (pLBE)
|
for ( UINT16 subObjects = 0; subObjects < invsize; ++subObjects )
|
||||||
{
|
{
|
||||||
UINT16 invsize = pLBE->inv.size();
|
if ( pLBE->inv[subObjects].exists() == true )
|
||||||
for ( UINT16 subObjects = 0; subObjects < pLBE->inv.size(); ++subObjects)
|
|
||||||
{
|
{
|
||||||
if (pLBE->inv[subObjects].exists() == true)
|
weight += CalculateObjectWeight( &( pLBE->inv[subObjects] ) );
|
||||||
{
|
|
||||||
weight += CalculateObjectWeight(&(pLBE->inv[subObjects]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//do not search for attachments to an LBE
|
|
||||||
return weight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//do not search for attachments to an LBE
|
||||||
|
return weight;
|
||||||
|
}
|
||||||
|
else if ( pItem->usItemClass != IC_AMMO )
|
||||||
|
{
|
||||||
// account for any attachments
|
// account for any attachments
|
||||||
for (attachmentList::iterator iter = (*this)[index]->attachments.begin(); iter != (*this)[index]->attachments.end(); ++iter) {
|
for (attachmentList::iterator iter = (*this)[index]->attachments.begin(); iter != (*this)[index]->attachments.end(); ++iter)
|
||||||
if(iter->exists()){
|
{
|
||||||
|
if(iter->exists())
|
||||||
|
{
|
||||||
weight += CalculateObjectWeight(&(*iter));
|
weight += CalculateObjectWeight(&(*iter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3062,14 +3065,17 @@ UINT16 OBJECTTYPE::GetWeightOfObjectInStack(unsigned int index)
|
|||||||
weight += Item[ (*this)[index]->data.gun.usGunAmmoItem ].ubWeight;
|
weight += Item[ (*this)[index]->data.gun.usGunAmmoItem ].ubWeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// account for partially eaten food
|
|
||||||
if ( UsingFoodSystem() && Item[usItem].foodtype > 0 )
|
if ( gGameExternalOptions.fAmmoDynamicWeight && ( pItem->camouflagekit || pItem->canteen || pItem->drugtype || pItem->foodtype || usItem == JAR_ELIXIR ) )
|
||||||
weight *= (FLOAT)((*this)[index])->data.objectStatus/100.0f;
|
{
|
||||||
|
weight *= (FLOAT)( ( *this )[index] )->data.objectStatus / 100.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( pItem->usItemClass == IC_AMMO && gGameExternalOptions.fAmmoDynamicWeight == TRUE )//Pulmu: added weight allowance for ammo not being full
|
else if ( pItem->usItemClass == IC_AMMO && gGameExternalOptions.fAmmoDynamicWeight == TRUE )//Pulmu: added weight allowance for ammo not being full
|
||||||
{
|
{
|
||||||
weight = CalculateAmmoWeight(usItem, (*this)[index]->data.ubShotsLeft);
|
weight = CalculateAmmoWeight( usItem, ( *this )[index]->data.ubShotsLeft );
|
||||||
}
|
}
|
||||||
|
|
||||||
return weight;
|
return weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user