Mag/Round pickup fix from devel.

This commit is contained in:
Mari the Deer 2021-11-29 16:40:57 +01:00
commit d3d848a182
2 changed files with 28 additions and 31 deletions

View file

@ -177,6 +177,32 @@ Class SWWMAmmo : Ammo
}
}
}
else if ( MagAmmoType )
{
// can we split it into mag ammo?
let ma = MagAmmo(Owner.FindInventory(MagAmmoType));
if ( !ma )
{
ma = MagAmmo(Spawn(MagAmmoType));
ma.Amount = 0;
ma.AttachToOwner(Owner);
}
if ( ma.Amount < ma.MaxAmount )
{
// split into bullets
for ( int i=0; i<item.Amount; i++ )
{
int bul = ma.ClipSize;
int maxgiveamt = min(ma.MaxAmount-ma.Amount,bul);
int dropamt = bul-maxgiveamt;
if ( dropamt > 0 ) ma.CreateTossable(dropamt);
if ( (bul == ma.ClipSize) && (Amount < MaxAmount) ) Amount++;
else ma.Amount = min(ma.MaxAmount,ma.Amount+bul);
}
item.bPickupGood = true;
return true;
}
}
}
return Super.HandlePickup(item);
}
@ -330,35 +356,6 @@ Class MagAmmo : Inventory abstract
override bool HandlePickup( Inventory item )
{
// see if the mag can be split apart
if ( (item is 'Ammo') && (ParentAmmo == Ammo(item).GetParentAmmo()) )
{
// double-check that parent ammo exists
if ( !pamo )
{
pamo = Ammo(Owner.FindInventory(ParentAmmo));
if ( !pamo )
{
pamo = Ammo(Spawn(ParentAmmo));
pamo.AttachToOwner(Owner);
pamo.Amount = 0;
}
}
if ( (pamo.Amount >= pamo.MaxAmount) && (Amount < MaxAmount) )
{
// split
for ( int i=0; i<item.Amount; i++ )
{
int bul = ClipSize;
int maxgiveamt = min(MaxAmount-Amount,bul);
int dropamt = bul-maxgiveamt;
if ( dropamt > 0 ) CreateTossable(dropamt);
Amount = min(MaxAmount,Amount+bul);
}
item.bPickupGood = true;
return true;
}
}
// drop excess mag ammo
if ( (item is 'MagAmmo') && (MagAmmo(item).GetParentMagAmmo() == GetClass()) )
{