Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GiveAmmo(Pawn Other)
- {
- local class<Ammo> giveName;
- local Ammo giveAmmo;
- local int giveAmount;
- local int startAmount;
- local int endAmount;
- local int i;
- // base it off AmmoType rather than AmmoName if possible, because
- // they may be out of sync (though that means deeper issues)
- if (AmmoType != None) { giveName = AmmoType.Class; }
- else { giveName = AmmoName; }
- if (giveName == None) { return; }
- giveAmmo = Ammo(Other.FindInventoryType(giveName));
- giveAmount = PickupAmmoCount;
- for (i = 0; i < ArrayCount(AmmoNames); i++)
- {
- if (AmmoNames[i] == giveName && MaxAmmoDropCounts[i] != 0)
- {
- giveAmount = min(giveAmount, MaxAmmoDropCounts[i]);
- break;
- }
- }
- if (giveAmount <= 0) { return; }
- if (giveAmmo == None)
- {
- giveAmmo = Spawn(giveName);
- giveAmmo.GiveTo(Other);
- startAmount = 0;
- giveAmmo.AmmoAmount = min(giveAmmo.MaxAmmo, giveAmount);
- }
- else
- {
- startAmount = giveAmmo.AmmoAmount;
- giveAmmo.AddAmmo(giveAmount);
- }
- endAmount = giveAmmo.AmmoAmount;
- PickupAmmoCount = max(0, PickupAmmoCount + startAmount - endAmount);
- if (endAmount > startAmount && giveAmmo.PickupViewMesh != LodMesh'DeusExItems.TestBox' && Other.IsA('DeusExPlayer'))
- {
- DeusExPlayer(Other).ClientMessage(giveAmmo.PickupMessage @ giveAmmo.itemArticle @ giveAmmo.itemName $" (" $ (endAmount - startAmount) $ ")", 'Pickup');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement