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

[Script] Critical Hits

Sheet Author
API Scripter
The base Roll20 system doesn't let any rolls depend on the results of other rolls, while many games do have rolls which depend on others. Generally, this crops up with attacks and critical hits. To use this script, simply use the !r command along with inline rolls. You can tag rolls as "hit" or "dam", along with a name. One roll tagged as "dam" is dependent on the previously tagged "hit" with the same name. In addition, a "hit"-tagged roll can have a crit range set. The crit range looks at the total of the roll, rather than simply the dice, to try and accommodate as many game systems as possible. A "dam"-tagged roll can have an addition tagged onto the critical result; the additional value is used only if the ADD flag is used in the script settings. Examples: !r [[d20+7]]{hit:test,27} vs. AC !r [[3d8]]{dam:test} frost damage !r [[d20]]{hit:test} [[d6]]{dam:test,add:5} !r [[d20]]{hit:test,18} !r [[d10+2]]{dam:test,2d6} A player can use multiple different tag names, and pair them in any order. Using a "hit" tag will overwrite any existing tagged result with that name, and using a "dam" tag will clear an existing result (if there is no existing result, it's treated as though it's not a crit). Tag names are stored separately for different players. The additional value on a "dam" tag is only correctly parsed if it's in the format "M", "dN", or "XdN". SCRIPT SETTINGS DEFAULT_CRIT should be set to the most common maximum value of a to-hit roll. BEHAVIOR should be set to a combination of the behavior bitfield variables. Either set it to one of the other behavior variables, or several of them together combined using bitwise OR. The script as-posted shows an example of this: "critrolls.MAXIMIZE|critrolls.ADD" which gives the behavior of D&amp;D 4e, which maximizes the normal rolls, and then adds some value on top of that. If you add additional behavior variables, they must be powers of 2 (eg: 8, 16, 32, etc.) in order for the ability to combine them as a bitfield to function. <a href="" rel="nofollow"></a>
Now that sounds like an awesome script Brian!