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

Is there an API to roll bulk token hit points WITHOUT a character sheet?

1567180280
Layton
API Scripter
For example: 2 tokens on screen, both do not represent a character sheet. Highlight both. Click a macro. Type HP formula. The formula is rolled for EACH TOKEN INDIVIDUALLY and set to a bar's current & max values based on input. Currently I use token-mod with the following macro script: !token-mod --set bar3|[[?{HP?}]] /w gm &{template:desc}{{desc=HP set to ?{HP?}.}} The only issue with the above macro/API setup is that it sets all highlighted tokens to the same result (it rolls the formula only once, assigning the single result to all tokens). Because of this I am required to repeat the entry for each token individually. All help appreciated and I hope this post is coherent enough to understand. Thanks!
1567181925
The Aaron
Roll20 Production Team
API Scripter
I have a script called MonsterHitPoints that can be configured to roll hitpoints on token creation. It's based on characters though. I could certainly write something for you. I've been meaning to make individual changes for tokens, maybe I can prioritize that. 
1567183368
Layton
API Scripter
I'd really appreciate it. I hope it's not too much trouble.
Hey, wrote this a while back. Maybe useful: <a href="https://gist.github.com/Bastlifa/847e6300790a918a1f8e5383f5d38b92" rel="nofollow">https://gist.github.com/Bastlifa/847e6300790a918a1f8e5383f5d38b92</a>
1567796165

Edited 1567798681
Layton
API Scripter
EDIT 3 Got it working. The code had an incorrect line. My fixed line: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let hp = xDy(parseInt(hpEntry[0]), parseInt(hpEntry[1])) + hpBonus; Original: let hp = xDy(parseInt(hpEntry[0]), parseInt(hpEntry[1])) + hpBonus*parseInt(hpEntry[0]); EDIT 2 No, that doesnt work !RollForHP 7d8 21 It makes results of 100+ EDIT I'm dumb, I should have used the code: !RollForHP 7d8 21 Sorry. Bast L. said: Hey, wrote this a while back. Maybe useful: <a href="https://gist.github.com/Bastlifa/847e6300790a918a1f8e5383f5d38b92" rel="nofollow">https://gist.github.com/Bastlifa/847e6300790a918a1f8e5383f5d38b92</a> It looks like this tries to do exactly what I'm after, but fails. The average roll of 7d8+21 (entered in the chat as below) is 51, yet the results were as the attatched image. !RollForHP 7d8+21
Heh, I missed this reply, sorry. Did you use the macro from the gist? !RollForHP ?{xdy} ?{hp bonus} It's like, 3d4 for the dice, and 1 for the bonus, = 3d4 + 3. Or in the case of your example, 7d8 +21 would be 7d8 in the first dialogue box, and 3 in the second.
1572190168

Edited 1572190235
Layton
API Scripter
I did, there was a bit of off code? For how we planned to use it anyway. The second input is multiplied by the number of dice, stopping us from inputting monster health formulae as written on the sheet. So instead of: 1) xDy, 2) Total HP bonus, we needed to enter: 1) xDy, 2) ConBonus So I guess at the end of the day there was no error, just a prefferential difference? The code I'm referring to is on line 22: let hp = xDy ( parseInt (hpEntry[ 0 ]), parseInt (hpEntry[ 1 ])) + hpBonus * parseInt (hpEntry[ 0 ]); Which we changed to: let hp = xDy ( parseInt (hpEntry[ 0 ]), parseInt (hpEntry[ 1 ])) + hpBonus ;
Ah, yes. That's the way 5E formulas are listed, IIRC. I think I must have written this with another game in mind.