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 syntax to create 'groups' of dice adding up to specified X value and count as successes

September 12 (4 years ago)

So I'm planning at some point to run 7th Sea Second Edition, and part of the mechanic of the dice of that system is the concept of achieving raises on your dice rolls.

A raise is defined as a 'set' of dice that add up to 10, using d10s - so for example if I were to roll:
10, 9, 7, 3, 2, 1
I would have 3 raises: (10), (9+1), (7+3) which are the game's equivalent of successes.

I made a test game, seeing that there was a 7th Sea Second Edition character sheet but that set making functionality is not built into the die roller. Is that something that the base dice rolling of roll20 supports, and if not is it something I could programmatically create using the API?

September 12 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter

If assigning the dice in sets correctly is important, and not just using a single total divided by 10, you wont be able to do it with a standard macro.

You can do it with a custom API, but it might have some tricky logic and probably isnt straightforward.

September 12 (4 years ago)

Unfortunately, yes the set making part is important, you can't just divide the total by 10, for example if I were to roll:

10, 9, 9, 7

That adds up to 35 but my sets of 10 or more are (10) and (9+7) with a 9 left over (which cannot be added to anything to make 10 or more), which gives only 2 sets where division by 10 would imply 3.

September 13 (4 years ago)

Edited September 13 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter

While trying to figure this out, I remembered I had bashed my head against this problem before. Its actually very tricky, and the ability to count values that dont exactly match 10, but can be any number above 10, makes it even more so.

If Jakob or Aaron see this, they might come up with an exact solution, but the answer I gave in the previous thread can help make things easier:

But you can approximate it without using the API. If you add up the total and divide by 10 or 15, rounding down, this will tell you the maximum possible number of raises. You can then quickly check manually if that is accurate - by sorting the output, and pairing high dice with low dice mentally.

it will always be the calculated number or 1 less, I think, and the more dice you roll, the more likely it will be accurate. 

So, just make a normal roll, add sd to sort from highest to lowest to make the manual counting easier, and just divide the number of dice by 2 to find the maximum it can be. It will usually be that or 1 less.

Your example 10,9,9,7 works out to 2 for example, exactly half the number of dice. 

September 13 (4 years ago)

That's the issue with such a large forum, I had no idea there had already been a thread discussing this!

That certainly helps to know and I'm going to be running another campaign before I even pick up 7th Sea to run so mayhaps I can have a play with the API myself and see if I can't find make anything work.

Time to read the documentation, let's see if it allows me to pass the results of a given dice roll into a function as an array - that would be the starting point of the problem.

September 13 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter

I'm in a rush right now, but yes, you can do that starting point - its very easy. The hard part is the algorithm you'll have to create to count the sets.

September 13 (4 years ago)

Yup, I've got a basic thing that iterates through each of them and adds them one after another - now the hard part - building the logic that skips numbers until it finds the lowest possible sum to make 10+ :D