Mathematical Expressions

Calculating Stats with Advanced Expressions

A common example of deriving Stats is calculating a modifier based on an ability score. For example, if we were to take the target stat “Str,” for Strength, then calculate a modifier stat based on the “Str” stat, it will show the calculated score as the Strength Modifier.

Setting an expression as a stat value

floor(Str/2 - 5)

In the above example, Str (17) is being divided by 2, then subtracted by 5 to yield a Strength Modifier of 3. We also use the floor option to round it down in the event of a decimal.

You can use math functions anywhere you can use {}, including actions, chat messages, and display text.

Function Purpose Example Result
floor(x) Rounds down to the nearest whole number floor(3.5) 3
ceil(x) Rounds up to the nearest whole number ceil(3.5) 4
round(x) Rounds to the nearest whole number round(3.3) round(3.6) 3 4

Watch out for order of operations when using mathematical expressions, especially when combining them with checkboxes.

If a calculation would result in a decimal, the calculation will only show to the 2nd decimal.

If you are having issues with displaying calculated or derived Stats, make sure your target Stat’s name matches the name used in your formula, and ensure that target stat has an appropriate value.

Were you looking for more info on using Stats and Actions? Please check the Sheets documentation here:
Building Your Character with Stats and Actions

Embedded Rolls

Embedded rolls are rolls within stat experessions. This allows complex math to happen after the roll takes place, meaning the roll resolves, then math is applied to the roll results.

Some functional examples:

Purpose Example
An example where a d12 is rolled, then the results are multiplied by 10 {!(1d12) * 10}
An example taking the average of the two rolls { mean( !(1d20) , !(1d10) ) }
Calculate higher level D&D starting gold. {500 + !(1d10) * 25}
The rogue archetype feature Ear for Deceit, where the roll cannot be lower than 8 {!(1d20min8) + WisMod}