Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 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 (giveAmmo == None)
  30. {
  31. giveAmmo = Spawn(giveName);
  32. giveAmmo.GiveTo(Other);
  33.  
  34. startAmount = 0;
  35. giveAmmo.AmmoAmount = min(giveAmmo.MaxAmmo, giveAmount);
  36. }
  37. else
  38. {
  39. startAmount = giveAmmo.AmmoAmount;
  40. giveAmmo.AddAmmo(giveAmount);
  41. }
  42.  
  43. endAmount = giveAmmo.AmmoAmount;
  44. PickupAmmoCount = max(0, PickupAmmoCount + startAmount - endAmount);
  45.  
  46. if (endAmount > startAmount && giveAmmo.PickupViewMesh != LodMesh'DeusExItems.TestBox' && Other.IsA('DeusExPlayer'))
  47. {
  48. DeusExPlayer(Other).ClientMessage(giveAmmo.PickupMessage @ giveAmmo.itemArticle @ giveAmmo.itemName $" (" $ (endAmount - startAmount) $ ")", 'Pickup');
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement