Flashlight/Searchlight implemented.

Proper handling of charge redistribution on multi-copy items (fixes infinitely replenishable charge exploit).
More preparation code for other items.
This commit is contained in:
Marisa the Magician 2019-09-05 16:22:17 +02:00
commit b12c4a4112
17 changed files with 270 additions and 24 deletions

View file

@ -616,14 +616,28 @@ Class UnrealInventory : Inventory
override void AttachToOwner( Actor other )
{
Super.AttachToOwner(other);
Charge = DefaultCharge;
if ( !Charge ) Charge = DefaultCharge;
InterHubAmount = MaxAmount; // it's annoying to set this per-subclass
}
override bool HandlePickup( Inventory item )
{
if ( (item.GetClass() == GetClass()) && ((MaxAmount > 1) || (DefaultCharge > 0)) )
{
if ( MaxAmount > 1 ) Amount = min(MaxAmount,Amount+item.Amount);
if ( MaxAmount > 1 )
{
if ( UnrealInventory(item).Charge ) // redistribute charge among copies
{
int addcharge = Charge+UnrealInventory(item).Charge;
charge = min(DefaultCharge,addcharge);
// if there's charge to spare, increase amount
if ( addcharge > charge )
{
Amount = min(MaxAmount,Amount+item.Amount);
charge = addcharge-charge;
}
}
else Amount = min(MaxAmount,Amount+item.Amount); // fully charged new copy, just increase
}
else Charge = DefaultCharge; // reset charge
item.bPickupGood = true;
return true;