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

[Help] Use ammo script with a bar value

Hey, I use The Aaron's ammo script to handle ammunition tracking - got it all set up and it's working great for characters, but now I want to use it for mooks. I've got a "hirelings" character sheet set up as a mook with a rollable table token and variable hitpoints so that, when the party hires men-at-arms, I can just pull out a couple tokens, rename the tokens, and poof! instant meatshields. However, for those that have missile weapons, I want to use the script to track their ammo, but it seems that it changes the attribute on the character sheet. How can I make this script work for me in this instance? I had thought maybe use bar3 for example (right now it's set up as movement, but that can be changed) to keep track of arrows. That would make it pull from the token, but I tried it and it didn't work. Here's the macro I'm using now: /em @{selected|token_name} attacks! ==a bunch of stuff to roll the attack, which doesn't matter here== !ammo @{selected|token_id} arrows -1 The sheet has an attribute "arrows." Then, to recover ammo: /em @{selected|token_name} recovers arrows... !ammo @{selected|token_id} arrows [[ceil(?{Shots fired?|1} * (1d21+39) /100) ]] This just gives a random percentage (40-60%) of fired arrows as recoverable. What do I need to make this work on a token level, rather than from the character sheet?
1432051298

Edited 1432051361
Did you try setting the token bar value to the attribute "ammo"? First set the token so that it represents the character. Then, click the dropdown menu and find "ammo" to have it appear as a bar.
1432053921
The Aaron
Pro
API Scripter
Setting it to the ammo attribute will cause all the Mooks to share the same pool of ammo. I'd probably suggest using TokenMod for the mook ammo. Something like this: !token-mod {{ --set bar1_value|[[ {@{selected|bar1}-1,0}kh1 ]] --ids @{selected|token_id} }} Recovery is a bit harder, but you could use something like: !token-mod {{ --set bar1_value|[[ {((@{selected|bar1|max}-@{selected|bar1})* (1d21+39) /100),@{selected|bar1|max}}kl1 ]] --ids @{selected|token_id} }} You might need to play some tricks in there with d1s to make everything in the kl1 work right.
Hm...The first works fine - although, I don't get the chat notification that I do with the ammo script. But it works. I tried the recovery macro and I get the following error: "Cannot mix sum and M rolls in a roll group" I'm not sure what tricks I need to play, with d1s or any others for that matter, to make it work. By the way, I'm doing this as a token ability, in case I didn't make that clear earlier - and if it makes a difference.
1432059094
The Aaron
Pro
API Scripter
Try one of these: !token-mod {{ --set bar1_value|[[ {((@{selected|bar1|max}-@{selected|bar1})* (1d21+39) /100),@{selected|bar1|max} d1 }kl1 ]] --ids @{selected|token_id} }} !token-mod {{ --set bar1_value|[[ {((@{selected|bar1|max}-@{selected|bar1})* (1d21+39) /100) d1 ,@{selected|bar1|max}}kl1 ]] --ids @{selected|token_id} }} As Abilities on the Mook which are Token Actions is what I assumed you'd be doing. =D There aren't notifications for this, but it's coming. I've written notification options into CharMod, and will be back porting them.
Ok, tried the first one, and went from 10/12 arrows to 0.9 out of 12 arrows. Not too good recovery. :) Trying number 2 I got: "SyntaxError: Expected ",", "[", "}", [ |\t] or [+|\-|*|\/|%] but "d" found."
1432060967
The Aaron
Pro
API Scripter
HA ok, so some adjustment may be necessary to the math... =D I just copied your math from above into the formula. Just noticed that you need to add in the current value of the bar: !token-mod {{ --set bar1_value|[[ @{selected|bar1}+ {((@{selected|bar1|max}-@{selected|bar1})* (1d21+39) /100),@{selected|bar1|max}d1}kl1 ]] --ids @{selected|token_id} }} This will be the number of ammo less than max: (@{selected|bar1|max}-@{selected|bar1}) You'll just need to multiple that by something to scale it. You could use that number as the sides of a die: !token-mod {{ --set bar1_value|[[ @{selected|bar1}+{(1d(@{selected|bar1|max}-@{selected|bar1})),@{selected|bar1|max}d1}kl1 ]] --ids @{selected|token_id} }} You can adjust the scaling factor here: !token-mod {{ --set bar1_value|[[ @{selected|bar1}+{((@{selected|bar1|max}-@{selected|bar1}) * (1d21+39) /100 ),@{selected|bar1|max}d1}kl1 ]] --ids @{selected|token_id} }}
Ok, that's better - this time I got 11.16 arrows. :) I think I need to put a round() function in there. I've tried it a couple different ways, but keep getting lost in the parentheses.
1432061678
The Aaron
Pro
API Scripter
probably here? !token-mod {{ --set bar1_value|[[ @{selected|bar1}+{ round ((@{selected|bar1|max}-@{selected|bar1})* (1d21+39) /100),@{selected|bar1|max}d1}kl1 ]] --ids @{selected|token_id} }}
Yep! I actually figured it out myself! Thanks so much for your help! Looking forward to that update.
1432062000
The Aaron
Pro
API Scripter
Me too! =D
Ok, now I have another problem that came up in our last session. Really something I just didn't think about with my character recovery macro, and I imagine it would be the same for mooks. We had one combat, and the player recovered arrows after the combat. The macro worked great - he got about 50% of his arrows that were fired back. Which left him with 10 arrows. Ok. Then we had a second combat. He fired off 2 shots, bringing his current total down to 8, but when he ran the recovery macro again, he recovered three arrows (because his max had not been adjusted, and the math in the macro subtracts the current from the max and recovers a percentage). So, I guess I need another step after the recover macro, which will adjust the max to the current amount. I think it would be something using TokenMod, but I'm not sure of the syntax needed. So the macro as it is is this: /em @{selected|token_name} recovers arrows... !ammo @{selected|token_id} arrows [[ceil(?{Shots fired?|1} * (1d21+39) /100) ]] Then I need something which does something like: set @{selected|arrows|max} to @{selected|arrows|current} Help?
1432648006
The Aaron
Pro
API Scripter
If you use --set bar1 instead of bar1_value it will set the max along with the current value. :)
Ok, so I got the script to set the bar, but either something's wrong in the timing, or the order of operations. Here's my recover macro, basically it has 2 stages, so I separated them with a space for ease of viewing. (This is the character macro, by the way, not the mook macro): /me tries to recover arrows... !ammo @{selected|token_id} arrows [[ round((@{selected|arrows|max}-@{selected|arrows})* (1d21+39) /100) ]] !token-mod {{ --set bar3|@{selected|bar3|current} --ids @{selected|token_id} }} So, the first part works fine by itself. I get the total of arrows fired by subtracting the current attribute from the max, and then allowing for a certain random percent of them to be recovered. I get the chat feedback saying that arrows were gained, and the new max is posted. Then the second part (the TokenMod part) runs, and it sets both the max and current of bar3 (which in this case is linked to the attribute "arrows") to the initial value, before the Ammo part of the script was run. So, for example, the max arrows are 24. He fires off 6 arrows, and is now down to 18. Then I run the recover script, the chat says that I've gained 3 arrows, and now have 21 remaining, but the attribute of "arrows" is at 18/18. Is it happening too fast, or is there an order of operations thing here that I'm not seeing?
1432663562
The Aaron
Pro
API Scripter
It's because of the Order of Operations for expanding commands. All of the attribute references @{} are expanded before any commands are executed (dice rolls or API commands). If you do the math in the token-mod command, all will be well. I'll have better reporting later on.
Ok, so basically I have to use the same recover macro as for my mooks. That works - I like the chat notification I get from the Ammo script, but this keeps my players from recovering arrows out of thin air.
1432669049
The Aaron
Pro
API Scripter
Yeah. I'll add better notices soon, sorry!