The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Roll20 Dice Specification

Order of Operations

While the Roll20 dice engine does support basic math and functions such as floor() and ceil(), it is first and foremost a dice engine, and so it has its own order of operations. This means that putting parentheses inside of your dice formula will not always affect the outcome of the roll (for example, you can't force a variable to be interpreted before a macro). Here is the general order of operations:

The roll is executed: first, dice are rolled for any dice (e.g. "2d6" is rolled; including any special dice such as dropped or exploding), then the result of that roll is substituted into the formula. Next, floor() and ceil() functions are executed. Finally, the entire remaining formula is evaluated, including observing proper math order of operations (parentheses first, then multiplication/division, then addition/subtraction).

Types Of Dice

Roll20 supports more than just your standard polyhedrons when rolling dice, below are the available die types you can use in your games.

Basic Roll NdX

Rolls N traditional (almost, you can have any number of sides that you want) dice with X sides per die. N must be greater than or equal to 0 and X must be greater than or equal to 1.

Fate/Fudge Roll NdF

Rolls N Fate/Fudge dice. These dice have three sides with values of -1, 0, and 1.

Computed Dice Roll (N+Y)dX/Nd(X+Y)

Computes the number of dice to roll or the number of sides on the dice based on the mathematical expression in the parentheses. Dice computation can be used with both Basic and Fate dice.

Roll Modifiers

Modfiers that can change the behavior or outcome of dice rolls. Each modifier states which Types Of Dice it can be applied to in parentheses after the modifier name. Rolls can have multiple modifiers applied to a single roll to allow for complex dice expressions.

B - Basic Roll
F - Fate/Fudge Roll

Many modifiers compare each die to a target number to decided if the modifier action should be applied. We'll call this a Compare Point or CP for short in the roll modifiers below. A Compare Point consists of an optional compare operation <,=,> and a target number. If the operation is not specified = is assumed and for most modifiers the entire Compare Point can be left off for the default behavior.

  • Example Compare Points

  • 3 - If the roll is equal to 3

  • >2 - If the roll is greater than or equal to 2

  • <18 - If the roll is less than or equal to 18

Target Number / Successes (B,F) - CP

Normally when you perform a roll, Roll20 reports back the total value of all the dice rolled, plus any modifiers. Some game systems, though, work by rolling a set of dice versus a target number, and then adding up the total number of successes instead.

  • 3d6>3 - Roll 3 d6's and count one success for each roll of 3 or higher

  • 10d6<4 - Roll 10 d6's and count one success for each roll of 4 or less

Failures (B,F) - fCP

Some systems build on success checks by also including failures. Failure checks only work when a success check is already being done and each failure subtracts one from the total number of successes.

  • 3d6>3f1 - Roll 3 d6's and count one success for each roll of 3 or higher and one failure for each 1

  • 10d6<4f>5 - Roll 10 d6's and count one success for each roll of 4 or less and one failure for each roll of 5 or more

Exploding Dice (B,F) !CP

Exploding dice, also known as &quot;rule of 6&quot; or &quot;rule of 10s&quot; depending on your gaming system, rolls an additional die if the maximum is rolled. If the additional roll is also the maximum number the additional rolls keep on going! The Compare Point can be specified to change the exploding trigger.

  • 3d6! - Rolls 3d6 and explodes every time a 6 is rolled

  • 3d6!>5 - Rolls 3d6 and explodes every time a 5 or 6 is rolled

Compounding Dice (B,F) !!CP

Shadowrun (and some other systems, such as 7th Sea and L5R) use a special style of exploding dice where the the additional rolls for each dice are added together as a single &quot;roll&quot;. To do this, just use two exclamation marks instead of one. With the compounding exploding rolls a single roll can be infinitely high! The Compare Point can be specified to change the exploding trigger.

  • 5d6!! - Rolls 5d6 and compound every time a 6 is rolled

  • 5d6!!5 - Rolls 5d6 and compound every time a 5 is rolled, 6's will be treated as a normal roll

Penetrating Dice (B,F) !pCP

HackMaster (and some other systems) use a special style of exploding dice where the additional rolls for each dice have 1 subtracted from the roll. To do this, add a p after the exclamation mark. A die can penetrate multiple times but the modifier is only ever -1 to each additional die.

  • 5d6!p - Rolls 5d6 and explode with a -1 modifier every time a 6 is rolled

  • 5d6!p>5 - Rolls 5d6 and explode with a -1 modifier every time a 5 or higher is rolled.

Keep / Drop Dice (B,F) khN/klN/dhN/dlN

Some game systems ask you to roll a large number of dice, and then either drop a certain number (N) of the lowest rolls, or keep only a certain number (N) of the highest rolls. Roll20 supports this type of roll through the d and k commands, respectively. The optional h/l parameter can either be h to keep or drop the highest N dice or l to keep or drop the lowest N dice. If not specified when keeping rolls the high rolls will be kept and when dropping rolls the low rolls will be dropped.

  • 8d100k4 - Roll 8 d100's and keep the four largest rolls.

  • 8d100kl4 - Roll 8 d100's and keep the four smallest rolls.

  • Example Drop Rolls

  • 8d100d4 - Roll 8 d100's and drop the four smallest rolls.

  • 8d100dh4 - Roll 8 d100's and drop the four largest rolls.

Rerolling Dice (B,F) rCP

Several systems require that certain dice be reroll, for example brutal weapons in D&amp;D 4e require any 1s or 2s to be re-rolled and the original die value ignored. The reroll modifier can be specified multiple times to allow rerolling at multiple Compare Points. By default the dice will continue to reroll until the result is inside the defined parameters. Optionally you can set the results to only reroll once regardless of the outcome.

  • Example Rerolls

  • 2d10r<2 - Roll 2 d10's and reroll any time a 2 or lower is rolled

  • 8d6r - Roll 8 d6's and reroll any time a 1 is rolled

  • 8d6r2r4r6 - Roll 8 d6's and reroll any time a 2, 4, or 6 is rolled

  • 2d6ro<2 - Roll 2 d6's and reroll anything less than 2 but only once

'''Special Case: Reroll Once (B,F) roCP'''

In some systems (such as D&D 5E) you want to reroll dice below a certain value, but you only want to reroll the dice one time each. To do that, just use ro instead of r.

  • Example Reroll Once Rolls

  • 2d10ro<2 - Roll 2 d10's and reroll any time a 2 or lower is rolled, but only up to one time per dice.

Sorting Dice (B,F) sa/sd

You may want to see your results in either ascending or descending order. The sorting modifier does just this. The order parameter is optional and specifies the order to sort with a for ascending and d for descending. Sorting defaults to ascending if order is not specified.

  • 8d6s - Roll 8 d6's and sort the results in ascending order

  • 8d6sd - Roll 8 d6's and sort the results in descending order

Order of Operations for Modifiers

Modifiers are applied in the following order:

Exploding, Compounding, Penetrating, Rerolls

These are applied while the dice are still rolling. imagine that you roll some exploding 6d6 on your table and the instant one of them settles as a 6 another die is rolled

Keep, Drop, Success, Failure, Sorting

These are applied after all of the dice have "settled" and all of the result values are known.

Rounding Rolls and Math Functions

You may want to use rounding in your roll formulas to emulate mechanics such as "half a level, rounded down to the nearest level." Roll20 provides several functions to accomplish this:

  • floor() which will always round the number down (e.g. 5.7 becomes 5)

  • ceil() which will always round the number up (e.g. 5.1 becomes 6)

  • round() which will always round to the nearest whole number (e.g. 4.4 becomes 4 and 4.5 becomes 5).

  • abs() will calculate the absolute value of the roll

You can use these functions almost anywhere in your roll formulas (around a single math expression, groups of math expressions, or even the entire roll).

Grouped Rolls

This section is not yet implemented

Mutliple rolls can be perfomed within a group via curly braces using a comma to seperate the sub-roll expressions {3d6+3d4+5, 2d8+4}. Grouped Rolls have their own set of Group Modifiers which perform actions across the whole group.

Grouped Roll Modifiers

Modfiers that can change the behavior or outcome of grouped rolls. Grouped Rolls can have multiple modifiers applied to a group roll to allow for complex dice expressions.

Keep / Drop khN/klN/dhN/dlN

To apply a keep or drop modifier across multiple types of dice wrap the roll in a group. With a single Sub-Roll in the group the keep/drop operation is applied across all rolls. To choose the best or worse roll expression multiple sub-groups can be used. In this case the keep/drop operation is applied to the final result of each subgroup.

  • {4d6+3d8}k4 - Roll 4 d6's and 3 d8's, out of those 7 dice the highest 4 are kept and summed up.

  • {4d6+2d8, 3d20+3, 5d10+1}d1 - Roll each of the three sub-roll expressions and total them up. Drop the sub-roll expression with the lowest total and sum the other two totals as the result.

Target Number / Successes (B,F) - CP

The same concept as when using on Dice Rolls but with different behavor for a group. For a Grouped Roll with a single sub-roll expression the success check is done after the remaining math expressions have been totaled into each roll. Single sub-roll groups are also useful when doing a success check on a roll that has another Compare Point enabled modifer. For a Grouped Roll with a multiple sub-roll expression the success check is applied to the esult of each sub-roll expression.

  • {3d20+5}>21 - Roll 3 d20's, for each roll add 5 and then count a success for each result of 21 or more.

  • {2d6!}>4 - Roll 2d6 exploding and count a success for each roll of 4 or greater.

  • {4d6+2d8, 3d20+3, 5d10+1}>40 - Roll each of the three sub-roll expression and total them up. Count one success for each sub-roll total of 40 or more.

Failures (B,F) - fCP

Failure checks on groups work just like success checks.

  • {3d20+5}>21f<10 - Roll 3 d20's, for each roll add 5 and then count a success for each result of 21 or more and count a failure for each result of 10 or less.

  • {2d6!}>4f1 - Roll 2d6 exploding and count a success for each roll of 4 or greater and a failure for each roll of 1.

  • {4d6+2d8, 3d20+3, 5d10+1}>40f<10 - Roll each of the three sub-roll expression and total them up. Count one success for each sub-roll total of 40 or more and one failure for each sub-roll total of 10 or less.

License

This text was copied from <https://wiki.roll20.net/Dice_Reference> and has been slightly modified to match the library it was shipped with. The original test and this modified version are licensed under <http://creativecommons.org/licenses/by-nc-sa/3.0/>.