Allow embiggener to give mag ammo like in the sidemods.

This commit is contained in:
Mari the Deer 2022-09-15 13:46:46 +02:00
commit 6baa8b8215
8 changed files with 127 additions and 75 deletions

View file

@ -236,30 +236,6 @@ Class SWWMAmmo : Ammo
return Super.HandlePickup(item);
}
override bool CanPickup( Actor toucher )
{
// don't allow picking up ammo for weapons we can't pick up
if ( !Super.CanPickup(toucher) ) return false;
for ( int i=0; i<AllActorClasses.Size(); i++ )
{
let w = (Class<Weapon>)(AllActorClasses[i]);
if ( !w ) continue;
if ( w is 'SWWMWeapon' )
{
let def = GetDefaultByType((Class<SWWMWeapon>)(w));
if ( !def.UsesAmmo(GetClass()) ) continue;
if ( !def.CanPickup(toucher) ) return false;
}
else
{
let def = GetDefaultByType(w);
if ( (def.AmmoType1 != GetClass()) && (def.AmmoType2 != GetClass()) ) continue;
if ( !def.CanPickup(toucher) ) return false;
}
}
return true;
}
override void AttachToOwner( Actor other )
{
Super.AttachToOwner(other);
@ -310,6 +286,7 @@ Class MagAmmo : Inventory abstract
Property ParentAmmo : ParentAmmo;
Property ClipSize : ClipSize;
Property PickupTag : PickupTag;
Property BackpackAmount : BackpackAmount;
default
{
@ -378,17 +355,6 @@ Class MagAmmo : Inventory abstract
// drop excess mag ammo
if ( (item is 'MagAmmo') && (MagAmmo(item).GetParentMagAmmo() == GetClass()) )
{
// can somehow happen
if ( !pamo )
{
pamo = Ammo(Owner.FindInventory(ParentAmmo));
if ( !pamo )
{
pamo = Ammo(Spawn(ParentAmmo));
pamo.AttachToOwner(Owner);
pamo.Amount = 0;
}
}
if ( bUNDROPPABLE || bUNTOSSABLE )
{
// undroppable mag ammo only drops full mags.
@ -503,14 +469,6 @@ Class MagAmmo : Inventory abstract
return copy;
}
override bool CanPickup( Actor toucher )
{
// don't allow picking up ammo for weapons we can't pick up
if ( !Super.CanPickup(toucher) ) return false;
let def = GetDefaultByType(ParentAmmo);
return def.CanPickup(toucher);
}
private Inventory DoDrop( Class<Inventory> type )
{
let copy = Inventory(Spawn(type,Owner.Pos,NO_REPLACE));
@ -564,6 +522,18 @@ Class MagAmmo : Inventory abstract
MagFill();
}
override void AttachToOwner( Actor other )
{
Super.AttachToOwner(other);
pamo = Ammo(other.FindInventory(ParentAmmo));
if ( !pamo )
{
pamo = Ammo(Spawn(ParentAmmo));
pamo.AttachToOwner(other);
pamo.Amount = 0;
}
}
bool MagFill()
{
// double-check that parent ammo exists