This module aims to enhance roll formula capabilities in Foundry VTT. It provides a set of new functions and operators that can be used in roll formulas to make them more powerful and flexible, as well as new dice modifiers. Users familiar with coding languages will find many familiar constructs, such as ternaries and logic operations.
Examples
2d6xc=6
- Explode all dice rolls of 6 and sum their results.2d6xc<=3
- Explode all dice rolls below or equal to 3 and sum their results.2d6xc<3
- Explode all dice rolls below 3 and sum their results.2d6xc>=3
- Explode all dice rolls above or equal to 3 and sum their results.2d6xc>3
- Explode all dice rolls above 3 and sum their results.
Explode all dice rolls that match the target and sum their results.
Examples
2d6xrc=6
- Explode all dice rolls of 6 and sum their results, re-rolling the dice.2d6xrc<=3
- Explode all dice rolls below or equal to 3 and sum their results, re-rolling the dice.2d6xrc<3
- Explode all dice rolls below 3 and sum their results, re-rolling the dice.2d6xrc>=3
- Explode all dice rolls above or equal to 3 and sum their results, re-rolling the dice.2d6xrc>3
- Explode all dice rolls above 3 and sum their results, re-rolling the dice.
Explode all dice rolls that match the target and sum their results. Unlike Explode Compound, which only reroll the die once, recusive reroll will keep rolling as long as results meet the target.
Examples
2d6xp=6
- Explode all dice rolls of 6, subtracting 1 from the newly rolled dice result.2d6xp<=3
- Explode all dice rolls below or equal to 3, subtracting 1 from the newly rolled dice result.2d6xp<3
- Explode all dice rolls below 3, subtracting 1 from the newly rolled dice result.2d6xp>=3
- Explode all dice rolls above or equal to 3, subtracting 1 from the newly rolled dice result.2d6xp>3
- Explode all dice rolls above 3, subtracting 1 from the newly rolled dice result.
Explode all dice rolls that match the target, reducing the value of the extra rolled dice by 1.
Examples
2d6xrp=6
- Explode all dice rolls of 6, subtracting 1 from the newly rolled dice result and re-rolling the dice.2d6xrp<=3
- Explode all dice rolls below or equal to 3, subtracting 1 from the newly rolled dice result and re-rolling the dice.2d6xrp<3
- Explode all dice rolls below 3, subtracting 1 from the newly rolled dice result and re-rolling the dice.2d6xrp>=3
- Explode all dice rolls above or equal to 3, subtracting 1 from the newly rolled dice result and re-rolling the dice.2d6xrp>3
- Explode all dice rolls above 3, subtracting 1 from the newly rolled dice result and re-rolling the dice.
Explode all dice rolls that match the target, reducing the value of the extra rolled dice by 1. Unlike Explode Penetrating, which only reroll the die once, recusive reroll will keep rolling as long as results meet the target.
Examples
2d6mx=1
- Maximize all dice rolls of 1.2d6mx<=3
- Maximize all dice rolls below or equal to 3.2d6mx<3
- Maximize all dice rolls below 3.2d6mx>=3
- Maximize all dice rolls above or equal to 3.2d6mx>3
- Maximize all dice rolls above 3.
Artificially maximize all dice rolls that match the target to the maximum possible value.
Examples
2d6mn=6
- Minimize all dice rolls of 6.2d6mn>=3
- Minimize all dice rolls above or equal to 3.2d6mn>3
- Minimize all dice rolls above 3.2d6mn<=3
- Minimize all dice rolls below or equal to 3.2d6mn<3
- Minimize all dice rolls below 3.
Artificially minimize all dice rolls that match the target to the minimum possible value.
Examples
2d6set1=3
- Set all dice rolls of 3 to 1.2d6set1<=3
- Set all dice rolls below or equal to 3 to 1.2d6set3<3
- Set all dice rolls below 3 to 3.2d6set4>=3
- Set all dice rolls above or equal to 3 to 4.2d6set5>3
- Set all dice rolls above 3 to 5.
Artificially set all dice rolls that match the target to the provided value.
Examples
2d6s
- Sort all dice rolls in ascending order.2d6sa
- Sort all dice rolls in ascending order.2d6sd
- Sort all dice rolls in descending order.
Sort all dice rolls in either ascending or descending order based on their result.
Examples
2d6u
- Roll 2d6 and keep only unique results.
Re-roll all dice results that are duplicate of previous results, keeping only unique values. If more dice are rolled than faces are available, re-roll dices from left to right until all values have been encountered at least once.
Rounds a
to the nearest integer. Optionally, rounds to the specified number of decimal places specified by precision
, rather than to the closest whole number.
Rounds a
down to the nearest integer. Optionally, rounds to the specified number of decimal places specified by precision
, rather than to the closest whole number.
Rounds a
up to the nearest integer. Optionally, rounds to the specified number of decimal places specified by precision
, rather than to the closest whole number.
Exponential term of the form aᵇ
.
Remainder of the division of a
by b
.
Returns last argument, if all arguments are truthy. Supports arbitrary number of arguments.
Returns first truthy argument, or 0
if all are falsy. Supports arbitrary number of arguments.
Returns first truthy argument if only one argument is truthy, otherwise 0
, otherwise returns false
.
Returns 0
if a
is truthy, otherwise returns 1
.
Returns 1
if a
is an odd number, otherwise returns 0
.
Returns 1
if a
is an even number, otherwise returns 0
.
Returns b
if a
is truthy, otherwise returns c
.
Returns b
if a
is null
or undefined
, otherwise returns a
.
Returns b
if a
is truthy, otherwise returns 0
.
Returns 1
if a
is equal to b
, otherwise returns 0
.
Returns 1
if a
is not equal to b
, otherwise returns 0
.
Returns 1
if a
is greater than b
, otherwise returns 0
.
Returns 1
if a
is greater than or equal to b
, otherwise returns 0
.
Returns 1
if a
is less than b
, otherwise returns 0
.
Returns 1
if a
is less than or equal to b
, otherwise returns 0
.
Bitwise AND operation between a
and b
.
Bitwise OR operation between a
and b
.
Bitwise XOR operation between a
and b
.
Bitwise NOT operation on a
.
Bitwise left shift operation on a
by b
bits.
Bitwise right shift operation on a
by b
bits.
Bitwise zero-fill right shift operation on a
by b
bits.
Returns the value at position index
, or fallback
if index
is out of bounds.
Returns 1
, if the provided value
lies between min
and max
(exclusive), otherwise returns 0
.