Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. function GiveAmmo(Pawn Other)
  2. {
  3. local class<Ammo> giveName;
  4. local Ammo giveAmmo;
  5. local int giveAmount;
  6. local int startAmount;
  7. local int endAmount;
  8. local int i;
  9.  
  10. // base it off AmmoType rather than AmmoName if possible, because
  11. // they may be out of sync (though that means deeper issues)
  12. if (AmmoType != None) { giveName = AmmoType.Class; }
  13. else { giveName = AmmoName; }
  14.  
  15. if (giveName == None) { return; }
  16.  
  17. giveAmmo = Ammo(Other.FindInventoryType(giveName));
  18. giveAmount = PickupAmmoCount;
  19.  
  20. for (i = 0; i < ArrayCount(AmmoNames); i++)
  21. {
  22. if (AmmoNames[i] == giveName && MaxAmmoDropCounts[i] != 0)
  23. {
  24. giveAmount = min(giveAmount, MaxAmmoDropCounts[i]);
  25. break;
  26. }
  27. }
  28.  
  29. if (giveAmount <= 0) { return; }
  30.  
  31. if (giveAmmo == None)
  32. {
  33. giveAmmo = Spawn(giveName);
  34. giveAmmo.GiveTo(Other);
  35.  
  36. startAmount = 0;
  37. giveAmmo.AmmoAmount = min(giveAmmo.MaxAmmo, giveAmount);
  38. }
  39. else
  40. {
  41. startAmount = giveAmmo.AmmoAmount;
  42. giveAmmo.AddAmmo(giveAmount);
  43. }
  44.  
  45. endAmount = giveAmmo.AmmoAmount;
  46. PickupAmmoCount = max(0, PickupAmmoCount + startAmount - endAmount);
  47.  
  48. if (endAmount > startAmount && giveAmmo.PickupViewMesh != LodMesh'DeusExItems.TestBox' && Other.IsA('DeusExPlayer'))
  49. {
  50. DeusExPlayer(Other).ClientMessage(giveAmmo.PickupMessage @ giveAmmo.itemArticle @ giveAmmo.itemName $" (" $ (endAmount - startAmount) $ ")", 'Pickup');
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement