Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

The Aaron's Ammo API

I love this thing. It's simplistic and can be used in many ways. However, I think I have run into a bit of a snag... I run Shadowrun 3rd edition. There are lots of bullets flying in the 6 seconds of combat that the players get for each round. Reloading is pretty simple if you have a full clip for a Beretta 101T ready to go (12 rounds). However, if you have to reload the clip in the middle of the fight due to poor planning, it becomes a little difficult. Let's say I have an Attribute called Beretta-101T-Rounds set for 12 max. The player spent all ammo and needs to reload the clip because they do not have a spare. This reload is based on their Quickness Attribute (4). This means this particular player can only reload four bullets per six seconds. When I apply this to the Ammo API, I get some goofy values. Reloading a clip into the weapon is cake. But, busting it out by Quickness at a time I go over the 12. Is there any way using the API as is that we can have a ceiling and a floor for values? Anyone out there run into this issue and have it figured out?
1563766222

Edited 1563766256
The Aaron
Roll20 Production Team
API Scripter
For players, it should cap at the max for the attribute.  You can hard code that with some inline roll math, just supply an adjustment based on the current remaining: +[[12-@{some char|ammo attribute}]] or similar. 
This did help me solve another issue I was having, however, I still break the max limit. I also get a warning that states "Yessira does not have enough storage space for ammo. Needs 14, but only has 12." "Ignoring warnings and applying adjustment anyway." Was 10/12 now: 14/12. The code I'm using. Replacing @{selected|Beretta-101T-Round|max} with 12 yields the same results. !ammo @{selected|character_id} Beretta-101T-Round @{selected|Quickness}+[[@{selected|Beretta-101T-Round|max}-@{selected|Beretta-101T-Round}]] When they just load a new clip, this code works perfectly: !ammo @{selected|character_id} Beretta-101T-Round [[@{selected|Beretta-101T-Round|max}-@{selected|Beretta-101T-Round}]] When you try to load it with 12/12, you get the message "Yessira gains 0 ammo and has 12 remaining."
1563768868
The Aaron
Roll20 Production Team
API Scripter
Hmm, that's surprising. I might have to experiment a bit, it's been a while since I used that script.
Certainly appreciate it, boss. You worked out some code for me about 10 months ago on Astral Presence. I still use that and variations of it to this day. Super helpful to my mage players!
1563919705
The Aaron
Roll20 Production Team
API Scripter
Hmm... I just tried this out and it seems like it works fine for my test character: With these commands: !ammo @{selected|character_id} taco +[[@{selected|taco|max}-@{selected|taco}]] taco !ammo @{selected|character_id} taco -3 taco Oh, I see the issue. You need to include the Quickness in the calculation: !ammo @{selected|character_id} Beretta-101T-Round +[[{(@{selected|Beretta-101T-Round|max}-@{selected|Beretta-101T-Round}),@{selected|Quickness}}kl1]] Breaking that down: [[{(@{selected|Beretta-101T-Round|max}-@{selected|Beretta-101T-Round}),@{selected|Quickness}}kl1]] { number, number, number}kl1 -- keep the lowest number from the group (@{selected|Beretta-101T-Round|max}-@{selected|Beretta-101T-Round})  -- the number of used rounds @{selected|Quickness}  -- the most that can be loaded in a turn manually So, the lowest of the used rounds or the quickness ability gets put back in the gun:
You, sir, can never leave the Roll20 community. Thank you so much for all your hard work on all of your scripts.
1563939440
The Aaron
Roll20 Production Team
API Scripter
Hahaha. No problem. =D