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

How to cap the number of dice rolled based on an attribute value

1759766435
Comuwayit
Pro
Marketplace Creator
I have a sheet I'm working on where you roll 2d6 for the base roll, but if you have any Stress Points you roll 1 additional d6 (that is calculated separately) for every 3 Stress Points that you have. My code for calculating the stress die is as follows; <input type="hidden" name="attr_stress_die" title="@{stress_die}" value="[[ceil(@{stress_points}/3)]]d6"> It does work for adding the stress die, however I cannot figure out how to make a limit on the number of stress die rolled. currently, there is no maximum of the number of additional stress die, but I need it to cap out at 3.  If anyone has any advice on how to handle this it would be much appreciated!
1759767502
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Use the group syntax and keep highest: <input type="hidden" name="attr_stress_die" title="@{stress_die}" value="[[{ceil(@{stress_points}/3),3}kl1]]d6"> Also, you may want to check your roll for whether you want ceil or floor. From your description, I'm not sure if you want it to be: 1 - 3 stress gives you one stress die or 3 - 5 stress gives you one stress die, with no stress die at 1 and 2 stress.
1759770927
Comuwayit
Pro
Marketplace Creator
That worked! And the way the system works is that you roll 1 Stress die when you have between 1 and 3 stress, 2 when you roll between 4 and 6 and 3 when you roll between 7 and 12. So ceiling is the one that works for this roller. thanks so much for the help!