mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
-additional code for item merges:
--prohibited attachments are removed from the new item --guns used as a merge target have their ammo removed if the magazine size or caliber don't match, or if the resulting item is no longer a gun This code change should allow for conversion kits for weapons (ie: Steyr Aug 5.56mm conversion kit to 9mm Steyr Aug Para) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@455 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -3337,6 +3337,45 @@ BOOLEAN AttachObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pTargetObj, OBJECTTYP
|
||||
StatChange( pSoldier, WISDOMAMT, 5, FALSE );
|
||||
}
|
||||
|
||||
//Madd: unload guns after merge if ammo caliber or mag size don't match
|
||||
if ( Item[pTargetObj->usItem].usItemClass == IC_GUN && pTargetObj->usGunAmmoItem != NONE && pTargetObj->ubGunShotsLeft > 0 )
|
||||
{
|
||||
if ( Item[usResult].usItemClass != IC_GUN || Weapon[Item[usResult].ubClassIndex].ubCalibre != Weapon[Item[pTargetObj->usItem].ubClassIndex].ubCalibre || pTargetObj->ubGunShotsLeft > Weapon[Item[usResult].ubClassIndex].ubMagSize )
|
||||
{ // item types/calibers/magazines don't match, spit out old ammo
|
||||
OBJECTTYPE newObj;
|
||||
CreateItem(pTargetObj->usGunAmmoItem, 100, &newObj);
|
||||
newObj.ubShotsLeft[0] = pTargetObj->ubGunShotsLeft;
|
||||
pTargetObj->ubGunShotsLeft = 0;
|
||||
pTargetObj->usGunAmmoItem = NONE;
|
||||
if ( !AutoPlaceObject( pSoldier, &newObj, FALSE ) )
|
||||
{ // put it on the ground
|
||||
AddItemToPool( pSoldier->sGridNo, &newObj, 1, pSoldier->bLevel, 0 , -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Madd: remove any prohibited attachments
|
||||
for (bAttachPos = 0; bAttachPos < MAX_ATTACHMENTS; bAttachPos++)
|
||||
{
|
||||
if (pTargetObj->usAttachItem[ bAttachPos ] != NOTHING && !ValidAttachment(pTargetObj->usAttachItem[ bAttachPos ],usResult) && !ValidLaunchable(pTargetObj->usAttachItem[ bAttachPos ],usResult) )
|
||||
{
|
||||
if ( !Item[pTargetObj->usAttachItem[ bAttachPos ]].inseparable )
|
||||
{//remove it
|
||||
OBJECTTYPE newObj;
|
||||
RemoveAttachment(pTargetObj,bAttachPos,&newObj);
|
||||
if ( !AutoPlaceObject( pSoldier, &newObj, FALSE ) )
|
||||
{ // put it on the ground
|
||||
AddItemToPool( pSoldier->sGridNo, &newObj, 1, pSoldier->bLevel, 0 , -1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{//destroy it
|
||||
pTargetObj->usAttachItem[bAttachPos] = NOTHING;
|
||||
pTargetObj->bAttachStatus[bAttachPos] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pTargetObj->usItem = usResult;
|
||||
//AutoPlaceObject( pAttachment );
|
||||
pTargetObj->ubWeight = CalculateObjectWeight( pTargetObj );
|
||||
@@ -3423,6 +3462,46 @@ BOOLEAN AttachObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pTargetObj, OBJECTTYP
|
||||
// fall through
|
||||
default:
|
||||
// the merge will combine the two items
|
||||
|
||||
//Madd: unload guns after merge if ammo caliber or mag size don't match
|
||||
if ( Item[pTargetObj->usItem].usItemClass == IC_GUN && pTargetObj->usGunAmmoItem != NONE && pTargetObj->ubGunShotsLeft > 0 )
|
||||
{
|
||||
if ( Item[usResult].usItemClass != IC_GUN || Weapon[Item[usResult].ubClassIndex].ubCalibre != Weapon[Item[pTargetObj->usItem].ubClassIndex].ubCalibre || pTargetObj->ubGunShotsLeft > Weapon[Item[usResult].ubClassIndex].ubMagSize )
|
||||
{ // item types/calibers/magazines don't match, spit out old ammo
|
||||
OBJECTTYPE newObj;
|
||||
CreateItem(pTargetObj->usGunAmmoItem, 100, &newObj);
|
||||
newObj.ubShotsLeft[0] = pTargetObj->ubGunShotsLeft;
|
||||
pTargetObj->ubGunShotsLeft = 0;
|
||||
pTargetObj->usGunAmmoItem = NONE;
|
||||
if ( !AutoPlaceObject( pSoldier, &newObj, FALSE ) )
|
||||
{ // put it on the ground
|
||||
AddItemToPool( pSoldier->sGridNo, &newObj, 1, pSoldier->bLevel, 0 , -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Madd: remove any prohibited attachments
|
||||
for (bAttachPos = 0; bAttachPos < MAX_ATTACHMENTS; bAttachPos++)
|
||||
{
|
||||
if (pTargetObj->usAttachItem[ bAttachPos ] != NOTHING && !ValidAttachment(pTargetObj->usAttachItem[ bAttachPos ],usResult) && !ValidLaunchable(pTargetObj->usAttachItem[ bAttachPos ],usResult) )
|
||||
{
|
||||
if ( !Item[pTargetObj->usAttachItem[ bAttachPos ]].inseparable )
|
||||
{//remove it
|
||||
OBJECTTYPE newObj;
|
||||
RemoveAttachment(pTargetObj,bAttachPos,&newObj);
|
||||
if ( !AutoPlaceObject( pSoldier, &newObj, FALSE ) )
|
||||
{ // put it on the ground
|
||||
AddItemToPool( pSoldier->sGridNo, &newObj, 1, pSoldier->bLevel, 0 , -1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{//destroy it
|
||||
pTargetObj->usAttachItem[bAttachPos] = NOTHING;
|
||||
pTargetObj->bAttachStatus[bAttachPos] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pTargetObj->usItem = usResult;
|
||||
if ( ubType != TREAT_ARMOUR )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user