mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
New feature: guns can be cannibalized via merge, increasing the status of the first gun while lowering that of the second gun.
For more info, see http://thepit.ja-galaxy-forum.com/index.php?t=msg&th=20659&goto=350386&#msg_350386 git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8426 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -1178,8 +1178,12 @@ typedef struct
|
|||||||
INT16 sBackpackWeightModifier; //modifier to weight calculation to climb.
|
INT16 sBackpackWeightModifier; //modifier to weight calculation to climb.
|
||||||
BOOLEAN fAllowClimbing; //does item allow climbing while wearing it
|
BOOLEAN fAllowClimbing; //does item allow climbing while wearing it
|
||||||
|
|
||||||
BOOLEAN cigarette; // Flugenete: this item can be smoked
|
BOOLEAN cigarette; // Flugente: this item can be smoked
|
||||||
UINT8 usPortionSize; // Flugente: for consumables: how much of this item is consumed at once
|
UINT8 usPortionSize; // Flugente: for consumables: how much of this item is consumed at once
|
||||||
|
|
||||||
|
// Flugente: riot shields
|
||||||
|
UINT16 usRiotShieldStrength; // strength of shield
|
||||||
|
UINT16 usRiotShieldGraphic; // graphic of shield (when deployed in tactical, taken from Tilecache/riotshield.sti)
|
||||||
|
|
||||||
} INVTYPE;
|
} INVTYPE;
|
||||||
|
|
||||||
@@ -1800,6 +1804,7 @@ typedef enum
|
|||||||
MECHANICAL_MERGE_HARD,
|
MECHANICAL_MERGE_HARD,
|
||||||
TRIPWIRE_ROLL,
|
TRIPWIRE_ROLL,
|
||||||
USE_ITEM_NEW,
|
USE_ITEM_NEW,
|
||||||
|
CANNIBALIZE,
|
||||||
} MergeType;
|
} MergeType;
|
||||||
|
|
||||||
extern UINT16 Merge[MAXITEMS+1][6];
|
extern UINT16 Merge[MAXITEMS+1][6];
|
||||||
|
|||||||
+108
-24
@@ -1527,7 +1527,7 @@ UINT8 ItemSlotLimit( OBJECTTYPE * pObject, INT16 bSlot, SOLDIERTYPE *pSoldier, B
|
|||||||
if(cntAttach == TRUE)
|
if(cntAttach == TRUE)
|
||||||
{
|
{
|
||||||
iSize = CalculateItemSize(pObject);
|
iSize = CalculateItemSize(pObject);
|
||||||
if(pSoldier != NULL && pSoldier->inv[bSlot].usItem == pObject->usItem)
|
if(pSoldier != NULL && pSoldier->inv[bSlot].usItem == usItem)
|
||||||
{
|
{
|
||||||
sSize = CalculateItemSize(&pSoldier->inv[bSlot]);
|
sSize = CalculateItemSize(&pSoldier->inv[bSlot]);
|
||||||
if(LBEPocketType[pIndex].ItemCapacityPerSize[sSize] < LBEPocketType[pIndex].ItemCapacityPerSize[iSize])
|
if(LBEPocketType[pIndex].ItemCapacityPerSize[sSize] < LBEPocketType[pIndex].ItemCapacityPerSize[iSize])
|
||||||
@@ -1535,7 +1535,7 @@ UINT8 ItemSlotLimit( OBJECTTYPE * pObject, INT16 bSlot, SOLDIERTYPE *pSoldier, B
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
iSize = Item[pObject->usItem].ItemSize;
|
iSize = Item[usItem].ItemSize;
|
||||||
iSize = __min(iSize,gGameExternalOptions.guiMaxItemSize);
|
iSize = __min(iSize,gGameExternalOptions.guiMaxItemSize);
|
||||||
ubSlotLimit = LBEPocketType[pIndex].ItemCapacityPerSize[iSize];
|
ubSlotLimit = LBEPocketType[pIndex].ItemCapacityPerSize[iSize];
|
||||||
|
|
||||||
@@ -2696,11 +2696,21 @@ BOOLEAN EvaluateValidMerge( UINT16 usMerge, UINT16 usItem, UINT16 * pusResult, U
|
|||||||
INT32 iLoop = 0;
|
INT32 iLoop = 0;
|
||||||
|
|
||||||
//CHRISL: Update this so we can also merge IC_MONEY like wallets and nuggets.
|
//CHRISL: Update this so we can also merge IC_MONEY like wallets and nuggets.
|
||||||
if (usMerge == usItem && (Item[ usItem ].usItemClass == IC_AMMO || Item[ usItem ].usItemClass == IC_MONEY))
|
if (usMerge == usItem )
|
||||||
{
|
{
|
||||||
*pusResult = usItem;
|
if ( (Item[usItem].usItemClass == IC_AMMO || Item[usItem].usItemClass == IC_MONEY) )
|
||||||
*pubType = COMBINE_POINTS;
|
{
|
||||||
return( TRUE );
|
*pusResult = usItem;
|
||||||
|
*pubType = COMBINE_POINTS;
|
||||||
|
return( TRUE );
|
||||||
|
}
|
||||||
|
// Flugente: guns can be merged to cannibalize them
|
||||||
|
else if ( (Item[usItem].usItemClass & (IC_GUN | IC_LAUNCHER) ) )
|
||||||
|
{
|
||||||
|
*pusResult = usItem;
|
||||||
|
*pubType = CANNIBALIZE;
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// look for the section of the array pertaining to this Merge...
|
// look for the section of the array pertaining to this Merge...
|
||||||
while( 1 )
|
while( 1 )
|
||||||
@@ -3063,20 +3073,26 @@ UINT16 OBJECTTYPE::GetWeightOfObjectInStack(unsigned int index)
|
|||||||
return weight;
|
return weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32 CalculateCarriedWeight( SOLDIERTYPE * pSoldier )
|
UINT32 GetTotalWeight( SOLDIERTYPE* pSoldier )
|
||||||
{
|
{
|
||||||
UINT32 uiTotalWeight = 0;
|
UINT32 uiTotalWeight = 0;
|
||||||
UINT32 uiPercent;
|
|
||||||
UINT8 ubLoop;
|
|
||||||
UINT32 ubStrengthForCarrying;
|
|
||||||
|
|
||||||
//Pulmu: Changes for dynamic ammo weight
|
UINT8 invsize = pSoldier->inv.size( );
|
||||||
UINT8 invsize = pSoldier->inv.size();
|
for ( UINT8 ubLoop = 0; ubLoop < invsize; ++ubLoop )
|
||||||
for( ubLoop = 0; ubLoop < invsize; ++ubLoop)
|
|
||||||
{
|
{
|
||||||
//ADB the weight of the object is already counting stacked objects, attachments, et al
|
//ADB the weight of the object is already counting stacked objects, attachments, et al
|
||||||
uiTotalWeight += CalculateObjectWeight(&pSoldier->inv[ubLoop]);
|
uiTotalWeight += CalculateObjectWeight( &pSoldier->inv[ubLoop] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return uiTotalWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 CalculateCarriedWeight( SOLDIERTYPE * pSoldier )
|
||||||
|
{
|
||||||
|
UINT32 uiTotalWeight = GetTotalWeight( pSoldier );
|
||||||
|
UINT32 uiPercent;
|
||||||
|
UINT32 ubStrengthForCarrying;
|
||||||
|
|
||||||
// for now, assume soldiers can carry 1/2 their strength in KGs without penalty.
|
// for now, assume soldiers can carry 1/2 their strength in KGs without penalty.
|
||||||
// instead of multiplying by 100 for percent, and then dividing by 10 to account
|
// instead of multiplying by 100 for percent, and then dividing by 10 to account
|
||||||
// for weight units being in 10ths of kilos, not kilos... we just start with 10 instead of 100!
|
// for weight units being in 10ths of kilos, not kilos... we just start with 10 instead of 100!
|
||||||
@@ -4242,13 +4258,15 @@ BOOLEAN OBJECTTYPE::AttachObjectOAS( SOLDIERTYPE * pSoldier, OBJECTTYPE * pAttac
|
|||||||
if(this->IsActiveLBE(subObject) == true)
|
if(this->IsActiveLBE(subObject) == true)
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
}
|
}
|
||||||
//CHRISL: We don't want to do any merges if we're looking at a stack of items, with the exception of combines.
|
|
||||||
if ( this->ubNumberOfObjects > 1 && ubType != COMBINE_POINTS )
|
|
||||||
{
|
|
||||||
return( FALSE );
|
|
||||||
}
|
|
||||||
if ( ubType != COMBINE_POINTS )
|
if ( ubType != COMBINE_POINTS )
|
||||||
{
|
{
|
||||||
|
//CHRISL: We don't want to do any merges if we're looking at a stack of items, with the exception of combines.
|
||||||
|
if ( this->ubNumberOfObjects > 1 )
|
||||||
|
{
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
if ( pSoldier )
|
if ( pSoldier )
|
||||||
{
|
{
|
||||||
if ( !EnoughPoints( pSoldier, ubAPCost, 0, TRUE ) )
|
if ( !EnoughPoints( pSoldier, ubAPCost, 0, TRUE ) )
|
||||||
@@ -4382,6 +4400,38 @@ BOOLEAN OBJECTTYPE::AttachObjectOAS( SOLDIERTYPE * pSoldier, OBJECTTYPE * pAttac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Flugente: guns can be cannibalized
|
||||||
|
// A gun is merged with a similar gun. This improves a gun's condition, but the other gun is damaged a lot more
|
||||||
|
case CANNIBALIZE:
|
||||||
|
{
|
||||||
|
INT16 cannibalize_max = 90;
|
||||||
|
INT16 cannibalize_min = 20;
|
||||||
|
FLOAT cannibalize_lossratio = 2.0f;
|
||||||
|
|
||||||
|
for ( bLoop = 0; bLoop < pAttachment->ubNumberOfObjects; ++bLoop )
|
||||||
|
{
|
||||||
|
if ( (*this)[subObject]->data.objectStatus >= cannibalize_max )
|
||||||
|
break;
|
||||||
|
|
||||||
|
if ( (*pAttachment)[bLoop]->data.objectStatus > cannibalize_min )
|
||||||
|
{
|
||||||
|
INT16 possibleincrease = cannibalize_max - (*this)[subObject]->data.objectStatus;
|
||||||
|
INT16 possibletake = (*pAttachment)[bLoop]->data.objectStatus - cannibalize_min;
|
||||||
|
|
||||||
|
INT16 transfer = min( possibletake / cannibalize_lossratio, possibleincrease );
|
||||||
|
|
||||||
|
(*pAttachment)[bLoop]->data.objectStatus -= transfer * cannibalize_lossratio;
|
||||||
|
(*this)[subObject]->data.objectStatus += transfer;
|
||||||
|
|
||||||
|
// we also have to alter the repair threshold
|
||||||
|
(*pAttachment)[bLoop]->data.sRepairThreshold = max( 1, (*pAttachment)[bLoop]->data.sRepairThreshold * (FLOAT)(1.0f - transfer * cannibalize_lossratio / 100.0f) );
|
||||||
|
(*this)[subObject]->data.sRepairThreshold = min( 100, (*this)[subObject]->data.sRepairThreshold * (FLOAT)(1.0f + transfer / cannibalize_lossratio / 100.0f) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case DESTRUCTION:
|
case DESTRUCTION:
|
||||||
// the merge destroyed both items!
|
// the merge destroyed both items!
|
||||||
this->RemoveObjectsFromStack(1);
|
this->RemoveObjectsFromStack(1);
|
||||||
@@ -4988,13 +5038,15 @@ BOOLEAN OBJECTTYPE::AttachObjectNAS( SOLDIERTYPE * pSoldier, OBJECTTYPE * pAttac
|
|||||||
if(this->IsActiveLBE(subObject) == true)
|
if(this->IsActiveLBE(subObject) == true)
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
}
|
}
|
||||||
//CHRISL: We don't want to do any merges if we're looking at a stack of items, with the exception of combines.
|
|
||||||
if ( this->ubNumberOfObjects > 1 && ubType != COMBINE_POINTS )
|
|
||||||
{
|
|
||||||
return( FALSE );
|
|
||||||
}
|
|
||||||
if ( ubType != COMBINE_POINTS )
|
if ( ubType != COMBINE_POINTS )
|
||||||
{
|
{
|
||||||
|
//CHRISL: We don't want to do any merges if we're looking at a stack of items, with the exception of combines.
|
||||||
|
if ( this->ubNumberOfObjects > 1 )
|
||||||
|
{
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
if ( pSoldier )
|
if ( pSoldier )
|
||||||
{
|
{
|
||||||
if ( !EnoughPoints( pSoldier, ubAPCost, 0, TRUE ) )
|
if ( !EnoughPoints( pSoldier, ubAPCost, 0, TRUE ) )
|
||||||
@@ -5167,6 +5219,38 @@ BOOLEAN OBJECTTYPE::AttachObjectNAS( SOLDIERTYPE * pSoldier, OBJECTTYPE * pAttac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Flugente: guns can be cannibalized
|
||||||
|
// A gun is merged with a similar gun. This improves a gun's condition, but the other gun is damaged a lot more
|
||||||
|
case CANNIBALIZE:
|
||||||
|
{
|
||||||
|
INT16 cannibalize_max = 90;
|
||||||
|
INT16 cannibalize_min = 20;
|
||||||
|
FLOAT cannibalize_lossratio = 2.0f;
|
||||||
|
|
||||||
|
for ( bLoop = 0; bLoop < pAttachment->ubNumberOfObjects; ++bLoop )
|
||||||
|
{
|
||||||
|
if ( (*this)[subObject]->data.objectStatus >= cannibalize_max )
|
||||||
|
break;
|
||||||
|
|
||||||
|
if ( (*pAttachment)[bLoop]->data.objectStatus > cannibalize_min )
|
||||||
|
{
|
||||||
|
INT16 possibleincrease = cannibalize_max - (*this)[subObject]->data.objectStatus;
|
||||||
|
INT16 possibletake = (*pAttachment)[bLoop]->data.objectStatus - cannibalize_min;
|
||||||
|
|
||||||
|
INT16 transfer = min( possibletake / cannibalize_lossratio, possibleincrease );
|
||||||
|
|
||||||
|
(*pAttachment)[bLoop]->data.objectStatus -= transfer * cannibalize_lossratio;
|
||||||
|
(*this)[subObject]->data.objectStatus += transfer;
|
||||||
|
|
||||||
|
// we also have to alter the repair threshold
|
||||||
|
(*pAttachment)[bLoop]->data.sRepairThreshold = max( 1, (*pAttachment)[bLoop]->data.sRepairThreshold * (FLOAT)(1.0f - transfer * cannibalize_lossratio / 100.0f) );
|
||||||
|
(*this)[subObject]->data.sRepairThreshold = min( 100, (*this)[subObject]->data.sRepairThreshold * (FLOAT)(1.0f + transfer / cannibalize_lossratio / 100.0f) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case DESTRUCTION:
|
case DESTRUCTION:
|
||||||
// the merge destroyed both items!
|
// the merge destroyed both items!
|
||||||
this->RemoveObjectsFromStack(1);
|
this->RemoveObjectsFromStack(1);
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ extern BOOLEAN PlaceObjectAtObjectIndex( OBJECTTYPE * pSourceObj, OBJECTTYPE * p
|
|||||||
|
|
||||||
UINT16 CalculateAmmoWeight( UINT16 usGunAmmoItem, UINT16 ubShotsLeft );
|
UINT16 CalculateAmmoWeight( UINT16 usGunAmmoItem, UINT16 ubShotsLeft );
|
||||||
UINT16 CalculateObjectWeight( OBJECTTYPE *pObject );
|
UINT16 CalculateObjectWeight( OBJECTTYPE *pObject );
|
||||||
|
UINT32 GetTotalWeight( SOLDIERTYPE* pSoldier );
|
||||||
UINT32 CalculateCarriedWeight( SOLDIERTYPE * pSoldier );
|
UINT32 CalculateCarriedWeight( SOLDIERTYPE * pSoldier );
|
||||||
// CHRISL:
|
// CHRISL:
|
||||||
UINT16 CalculateItemSize( OBJECTTYPE *pObject );
|
UINT16 CalculateItemSize( OBJECTTYPE *pObject );
|
||||||
|
|||||||
Reference in New Issue
Block a user