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

formula to auto calculate not just the sum but also above a specific number

April 09 (3 months ago)

I need something for xd10 where it sums the total, counts successes, and tells you how many criticals there are. Like for instance if I roll 10d10 I need it to tell me the sum of all the dice, and also tell me how many dice there are that rolled above a certain number, let's say 4. I need this so that it doesn't take 10 minutes to count up all of the criticals, or even longer getting the sum.

April 09 (3 months ago)

Edited April 09 (3 months ago)

It's not pretty, but you can do it with a /roll command:

/roll [[?{number of dice}d10>4]]d10r<3+(?{number of dice}-$[[0]])d3

replace the 4 with whatever is that certain number  and the two 3's with that minus one, and the number in the inline roll is the number that matches or beats that target, while the end result is the total.

EDIT: here's a version where the target number is queried, if you prefer that - the successes are still the first inline roll.

/roll [[?{number of dice}d10>?{target|4}]]d10r<[[?{target}-1]]+(?{number of dice}-$[[0]])d[[?{target}-1]]
April 09 (3 months ago)
Gauss
Forum Champion

Tuo, 

Could you explain how this works? I am not seeing where it gives the number of successes. 

The number of successes is the first inline roll on the first line. Because the /roll command is resolved in a separate step from the inline rolls, we can reuse the check against the target to roll the dice again knowing how many met it and how many didn't.

April 09 (3 months ago)
Gauss
Forum Champion


Tuo said:

The number of successes is the first inline roll on the first line. Because the /roll command is resolved in a separate step from the inline rolls, we can reuse the check against the target to roll the dice again knowing how many met it and how many didn't.


Can we leverage tags without breaking it to indicate what is what?

For sure:

/roll [[?{number of dice}d10>?{target|4}[=number of successes]]]d10r<[[?{target}-1[=target-1]]]+(?{number of dice}-$[[0]])d[[?{target}-1[=target-1]]]

/roll commands can also have roll comments, so you could add

Successes:$[[0]]

to the end of the command do show it more clearly.

So it'd be

/roll [[?{number of dice}d10>?{target|4}[=number of successes]]]d10r<[[?{target}-1[=target-1]]]+(?{number of dice}-$[[0]])d[[?{target}-1[=target-1]]] Successes:$[[0]]
April 09 (3 months ago)

is there a way for it to work without it rerolling the command, and adding all of the numbers together instead of just the ones over that critical amount, and only rolling the d10s and not d4s

Short answer, no.

Longer answer, once a roll is processed (in this case, totaled or checked against the target), it's gone and can't be processed again. The way I did it here, I checked how many successes there are, and then used that to determine how many dice should be rolled, for dice we know that passed, and for dice we know to have failed, and it's these new dice we can add together for the total while staying true to the count of successes.

April 10 (3 months ago)
Gauss
Forum Champion


Nova said:

is there a way for it to work without it rerolling the command, and adding all of the numbers together instead of just the ones over that critical amount, and only rolling the d10s and not d4s


To add to Tuo's answer, what you want is achievable with a Pro account via a Mod (API Script). Most other attempts at something like this will be working around Roll20's limitation where you cannot process a roll multiple times. 

With a Mod (API Script) this becomes much easier to do.