Fix major flaws in ammo pickup logic.
This commit is contained in:
parent
2afad5d0d1
commit
189d65d035
2 changed files with 39 additions and 22 deletions
|
|
@ -170,7 +170,7 @@ Class SWWMAmmo : Ammo
|
|||
ma.Amount = 0;
|
||||
ma.AttachToOwner(Owner);
|
||||
}
|
||||
if ( ma.Amount < (ma.MaxAmount-ma.ClipSize) )
|
||||
if ( ma.Amount <= (ma.MaxAmount-ma.ClipSize) )
|
||||
{
|
||||
ma.Amount += ma.ClipSize;
|
||||
excess--;
|
||||
|
|
@ -192,7 +192,7 @@ Class SWWMAmmo : Ammo
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ( MagAmmoType && !GetDefaultByType(MagAmmoType).bUNDROPPABLE && !GetDefaultByType(MagAmmoType).bUNTOSSABLE )
|
||||
else if ( MagAmmoType )
|
||||
{
|
||||
// can we split it into mag ammo?
|
||||
let ma = MagAmmo(Owner.FindInventory(MagAmmoType));
|
||||
|
|
@ -202,22 +202,32 @@ Class SWWMAmmo : Ammo
|
|||
ma.Amount = 0;
|
||||
ma.AttachToOwner(Owner);
|
||||
}
|
||||
if ( ma.Amount < ma.MaxAmount )
|
||||
if ( !GetDefaultByType(MagAmmoType).bUNDROPPABLE && !GetDefaultByType(MagAmmoType).bUNTOSSABLE )
|
||||
{
|
||||
// split into bullets
|
||||
for ( int i=0; i<item.Amount; i++ )
|
||||
if ( ma.Amount < ma.MaxAmount )
|
||||
{
|
||||
if ( Amount < MaxAmount )
|
||||
// split into bullets
|
||||
for ( int i=0; i<item.Amount; i++ )
|
||||
{
|
||||
Amount++;
|
||||
continue;
|
||||
if ( Amount < MaxAmount )
|
||||
{
|
||||
Amount++;
|
||||
continue;
|
||||
}
|
||||
int bul = ma.ClipSize;
|
||||
int maxgiveamt = min(ma.MaxAmount-ma.Amount,bul);
|
||||
int dropamt = bul-maxgiveamt;
|
||||
if ( dropamt > 0 ) ma.CreateTossable(dropamt);
|
||||
ma.Amount = min(ma.MaxAmount,ma.Amount+bul);
|
||||
}
|
||||
int bul = ma.ClipSize;
|
||||
int maxgiveamt = min(ma.MaxAmount-ma.Amount,bul);
|
||||
int dropamt = bul-maxgiveamt;
|
||||
if ( dropamt > 0 ) ma.CreateTossable(dropamt);
|
||||
ma.Amount = min(ma.MaxAmount,ma.Amount+bul);
|
||||
item.bPickupGood = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ( ma.Amount <= (ma.MaxAmount-ma.ClipSize*item.Amount) )
|
||||
{
|
||||
// when mag ammo is undroppable, can only divide in full mags EXACTLY
|
||||
ma.Amount += ma.ClipSize*item.Amount;
|
||||
item.bPickupGood = true;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -381,6 +391,20 @@ Class MagAmmo : Inventory abstract
|
|||
Amount -= ClipSize;
|
||||
}
|
||||
}
|
||||
else if ( pamo.Amount < pamo.MaxAmount )
|
||||
{
|
||||
// see if we can fill mags with this, and drop the excess
|
||||
int toadd = Amount+item.Amount;
|
||||
while ( (pamo.Amount < pamo.MaxAmount) && (toadd >= ClipSize) )
|
||||
{
|
||||
pamo.Amount++;
|
||||
toadd -= ClipSize;
|
||||
}
|
||||
Amount = toadd;
|
||||
if ( Amount > MaxAmount ) CreateTossable(Amount-MaxAmount);
|
||||
item.bPickupGood = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int excess = Amount+item.Amount;
|
||||
|
|
@ -404,13 +428,6 @@ Class MagAmmo : Inventory abstract
|
|||
// drop full mag if possible
|
||||
if ( excess >= ClipSize )
|
||||
{
|
||||
// first of all, check if we can ADD a mag
|
||||
if ( pamo.Amount < pamo.MaxAmount )
|
||||
{
|
||||
pamo.Amount++;
|
||||
excess -= ClipSize;
|
||||
continue;
|
||||
}
|
||||
double ang = FRandom[Junk](0,360);
|
||||
last = DoDrop(ParentAmmo);
|
||||
last.SetOrigin(item.pos,false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue