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

Dice: Multiple successes from a single roll of a single die

I'm wondering if anyone can help with this dice problem. I require a single roll of a die to be evaluated for multiple successes based upon the value of the die roll. For example: A character requires a 10+ (or greater) on a d20 to be successful; however, for each +2 over the target (10), she gets another success, to a maximum of 3 successes regardless of the roll result. Something like: /r d20>10s2m3 , where 10 is the target, success step ( s ) is 2, and the maximum number of successes ( m ) is 3. Is this currently doable? If so how? If not, any help in making it happen would be great. Thanks!
1596796010
Ziechael
Forum Champion
Sheet Author
API Scripter
[[ floor({({1d20-10,0d0}kh1)/2,3+0d0}kl1) ]] successes It's a bit convoluted but it works :)
It definitely works, thanks! I notice it generates more than 3 successes. If the "K11" is lowered to, say 3 or 5, etc. Since I'm not sure how to divine the wizardry that you use here, I can't tell if there is a way to adjust the maximum number of successes. If you wouldn't mind breaking down the function for me so that I know what it doing, that would be most appreciated. Thanks again!
Ziechael, I'm not sure how willing or able you are to help me troubleshoot this, but I'm having trouble working your formula into a macro. I expect something like this: But incorporating the formula that you created, I get this:   Any thoughts?
1596829735

Edited 1596831205
Ziechael
Forum Champion
Sheet Author
API Scripter
You shouldn't get any more than 3 successes out of the box... if you want to alter the max successes possible you'd just change the bold number below: [[ floor({({1d20-10,0d0}kh1)/2, 3 +0d0}kl1) ]] successes Most of the formula is fluff to get the Roll20 dice engine to play nice (rolls require rolls for comparison hence all the 0d0 stuff) but it is essentially rolling a d20 and taking 10 off which means any positive result is a success, if the result is 10-20 (therefore a success) it divides that positive by 2 to get the extra success for every 2 over 10. The floor keeps it a whole number and then the last section is the limiter to ensure no more than 3 successes. Looking at it now, it isn't perfect... I've put the end of the floor result in the wrong place and might not be classing 10 or 11 as an actual success... oops. [[ {floor(({1d20-8,0d0}kh1)/2), 3 +0d0}kl1) ]] successes The above should work correctly (again change the bold number to change the max number of successes): 9 or below = 0 successes 10 or 11 = 1 success 12 or 13 = 2 successes 14 or 15 = 3 successes 16+ = 3 successes To have it nested in a query you need to do html replacement on the offending characters as outlined here . Doing this will stop the formula working as a standalone thing but when called in a query will prevent it breaking: [[ {floor(({1d20-8 , 0d0 } kh1)/2) , 3+0d0 } kl1) ]] successes The bold bits above are the replacements for the commas and closing curly brackets that are breaking your query. There are other things you can do to add variable success thresholds or success limits but that will increase the complexity with nesting of characters too... hope that helps?
That helps immensely! Thanks so much. +1 for Ziechael!
In the case below, the two bottom weapons WP2 and WP3 work as expected withing the choice macro. However, WP1, for which I am attempting to draw the actual target to hit roll from the selected target's WP1Hit Attribute, then subtract 1 from it (so that it aligns with the function that you've created), blows up with the error in the screen capture. I thought I had a handle on those HTML escapes, but obviously there is something that I am missing. @{selected|token_name} attacks... (?{weapon |  @{selected|WP1}, [[ {floor(({1d20-@{selected|WP1Hit}-1),0d0}kh1)/2),3+0d0}kl1) ]] successes | @{selected|WP2}, [[ {floor(({1d20-8,0d0}kh1)/2),3+0d0}kl1) ]] successes | @{selected|WP3}, [[ {floor(({1d20-8,0d0}kh1)/2),3+0d0}kl1) ]] successes }) Also, I don't know how you embedded that code in the gray box in your post, so mine is ugly. Sorry about that.
1596834429
Ziechael
Forum Champion
Sheet Author
API Scripter
Told you this stuff was complex... or inferred it at least lol You are close but don't need to replace characters that are part of attribute calls: @{selected|token_name} attacks... (?{weapon |  @{selected|WP1}, [[ {floor(({1d20- @{selected|WP1Hit} -1),0d0}kh1)/2),3+0d0}kl1) ]] successes | @{selected|WP2}, [[ {floor(({1d20-8,0d0}kh1)/2),3+0d0}kl1) ]] successes | @{selected|WP3}, [[ {floor(({1d20-8,0d0}kh1)/2),3+0d0}kl1) ]] successes }) To do the code blocks you can use the format 'wand' at the top left of the text box:
1596835551

Edited 1596837846
Nice Unfortunately when I tried the code that you corrected, I am met with no response when selecting WP1 for my weapon. The drop-down works fine, and the other weapons continue to generate results, but the one calling on WP1 generates nothing. Just to make sure that my pull from that attribute is working, I used this in another macro, and it does generate a response (in this case, the number 11, which is correct): [[@{selected|WP1Hit}-1]]
1596929369
Ziechael
Forum Champion
Sheet Author
API Scripter
My bad again, there was an extra ) in there! [[ {floor(({1d20-@{selected|WP1Hit}-1 ) ,0d0}kh1)/2),3+0d0}kl1) ]] successes This works: @{selected|token_name} attacks... (?{weapon |  @{selected|WP1}, [[ {floor(({1d20- @{selected|WP1Hit} -1,0d0}kh1)/2),3+0d0}kl1) ]] successes | @{selected|WP2}, [[ {floor(({1d20-8,0d0}kh1)/2),3+0d0}kl1) ]] successes | @{selected|WP3}, [[ {floor(({1d20-8,0d0}kh1)/2),3+0d0}kl1) ]] successes }) You might need to mess with the math a bit to get the ranges right with WP1Hit as 12 you'll need a 15 before a single success with your current code. What system is this for or what is the to hit calculation usually?
Sorry for the late response.. things got busy. Thanks for the extra effort. I have yet to test it. Its for a home grown system. I really wish this platform supported IF THEN ELSE statements.
1598210983
GiGs
Pro
Sheet Author
API Scripter
vorgrist said: Sorry for the late response.. things got busy. Thanks for the extra effort. I have yet to test it. Its for a home grown system. I really wish this platform supported IF THEN ELSE statements. Note to mention recognising nesting in queries. Those two changes would be massive improvements.