Fix inconsistent mag/round pickup behavior.

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

View file

@ -1,3 +1,3 @@
[default]
SWWM_MODVER="\chSWWM \czGZ\c- \cw1.2pre r55 \cu(Sun 28 Nov 21:55:56 CET 2021)\c-";
SWWM_SHORTVER="\cw1.2pre r55 \cu(2021-11-28 21:55:56)\c-";
SWWM_MODVER="\chSWWM \czGZ\c- \cw1.2pre r56 \cu(Mon 29 Nov 16:39:16 CET 2021)\c-";
SWWM_SHORTVER="\cw1.2pre r56 \cu(2021-11-29 16:39:16)\c-";

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()) )
{