diff --git a/language.version b/language.version index 72b448b4b..926eecbf9 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.2.22 \cu(Tue 7 Jun 21:04:33 CEST 2022)\c-"; -SWWM_SHORTVER="\cw1.2.22 \cu(2022-06-07 21:04:33)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.2.23 \cu(Tue 7 Jun 23:11:25 CEST 2022)\c-"; +SWWM_SHORTVER="\cw1.2.23 \cu(2022-06-07 23:11:25)\c-"; diff --git a/zscript/items/swwm_baseammo.zsc b/zscript/items/swwm_baseammo.zsc index 50eb262f0..8f9a6114e 100644 --- a/zscript/items/swwm_baseammo.zsc +++ b/zscript/items/swwm_baseammo.zsc @@ -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 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);