## Formula Data

You can use certain variables and functions in formula data, to automatically calculate certain character attributes.

As a quick reference for most variables, you can also hover over certain parts of your character sheet, or some item sheets.

## How to Read

In the following documentation, any time you see something like `{str,dex,con}`

,
that means you can substitute any value separated by a comma within the
curly braces.

For example, if something says `@abilities.{str,dex,con}.mod`

, that means
you can enter one of the following:

`@abilities.str.mod`

`@abilities.dex.mod`

`@abilities.con.mod`

## General Data

The following variables are always available for formulas, unless specified otherwise.

Variable | Description |
---|---|

`@details.level.value` |
Total amount of class levels of the character |

`@attributes.hd.total` |
Total Hit Die of the character |

`@abilities.{str,dex,con,int,wis,cha}.mod` |
Ability modifier |

`@abilities.{str,dex,con,int,wis,cha}.total` |
Total ability score |

`@abilities.{str,dex,con,int,wis,cha}.value` |
Base ability score |

`@attributes.hp.value` |
The current hit points of the character, excluding temporary hit points |

`@attributes.hp.max` |
The maximum hit points of the character |

`@attributes.hp.temp` |
The current temporary hit points of the character |

`@attributes.hp.nonlethal` |
The amount of non-lethal damage on the character |

`@attributes.bab.total` |
Base Attack Bonus |

`@attributes.cmb.total` |
Combat Maneuver Bonus |

`@attributes.init.total` |
Initiative bonus (or penalty) |

`@attributes.acp.total` |
Armor Check Penalty, which is a positive value |

`@attributes.ac.normal.total` |
Armor Class |

`@attributes.ac.touch.total` |
Touch AC |

`@attributes.ac.flatFooted.total` |
Flat-footed AC |

`@attributes.savingThrows.{fort,ref,will}.total` |
Saving Throw bonus (or penalty) |

`@attributes.cmd.total` |
Combat Maneuver Defense |

`@attributes.cmd.flatFootedTotal` |
Flat-footed CMD |

`@attributes.sr.total` |
Spell Resistance |

`@size` |
Creature size (as a number between -4 and 4) |

There are also some more dynamic variables, such as specific class levels
and skills bonuses.

To see what you need to enter for those kinds of values, open a class

and hover over the level, or hover over a skill.

### Damage Formulas

Some items (such as weapons, feats and spells) can have Damage Formulas and
Effect Notes.

The following variables are available for these formulas:

Variable | Description |
---|---|

`@critMult` |
The critical hit multiplier, which is always `1` on a normal hit, and whatever is set as the item’s critical multiplier on a critical hit |

`@ablMult` |
The bonus ability multiplier, which is usually `1` , but can also be `0.5` , `1.5` , or `2` (and maybe other values in the future), depending on what’s set up |

`@critCount` |
What critical damage iteration we’re currently at. For normal damage, this equals `0` . For the first critical damage iteration, this equals `1` , the second `2` and so on. |

### Spell Formulas

Spells have the following variables added to what’s useable in their formulas:

Variable | Description |
---|---|

`@cl` |
Caster Level of the spellbook (also available for the Concentration formula) |

`@sl` |
Spell Level of the spell |

### Buff Formula

Buffs have the following variables added to what’s useable in their formulas:

Variable | Description |
---|---|

`@item.level` |
The buff’s level |

## Math

You can also apply some math functions to formulas.

Together with nested die (which can be obtained from the Roll Extended module
(see Home)), this can create some useful functionality.

Every function of the JavaScript Math
object is available, save for the random
function. You shouldn’t put `Math.`

in front of the function name.

Some examples:

Expected Location | Formula | Effect |
---|---|---|

Any | `max(3, @attributes.hd.total)` |
Returns the total number of hit die, but always at least 3 |

Spell | `(max(1, floor(@cl / 2)))d6` |
Rolls a number of d6 equal to half your Caster Level, but roll at least 1 dice |

## Functions

There is another function for use in formulas besides those from the JavaScript Math object.

`sizeRoll(c, s[, size[, crit]])`

**Available Since**: 0.43

This function will take 2 to 4 parameters.

The first parameter (`c`

), is the amount of die you are going to throw.

The second parameter (`s`

), is the sides per die you are going to throw.

The third parameter (`size`

), is the target size, which defaults to 0 (Medium).

The fourth parameter (`crit`

), is the critical multiplier, which defaults to 1.

The way this function works is it takes the first two parameters (`c`

and `s`

),
which should represent the die as if a Medium creature would roll them,
then takes the third parameter (if given) to changes the original die to account
for the size changes (see https://www.d20pfsrd.com/bestiary/rules-for-monsters/universal-monster-rules/#Table_Natural_Attacks_by_Size)

For example, if you have a Longsword (a 1d8 damage weapon for Medium creatures),
but you want to roll the damage as if you were Huge (2 size categories higher
than Medium), you would insert `sizeRoll(1, 8, 2)`

. It then outputs a number as
if you rolled 3d6, effectively (since 1d8 becomes 3d6 for Huge creatures).

You can also combine this with the `@size`

variable to automatically change the
die based on the actor’s size. An example: `sizeRoll(1, 6, @size-1)`

, to roll
the die as if you were a creature of 1 size smaller than you actually are.

Note that this function will not be multiplied on critical hits automatically.
If that is desired, you will need to enter that in the fourth parameter, like
`sizeRoll(1, 8, 0, @critMult)`

.

## Notes

Certain fields allow you to put in notes, which will be shown on roll messages.

These include the CMB notes on the `Attributes`

tab of your character sheet,
the Concentration and Caster Level notes in your character’s spellbooks,
the Notes sections of skills, the Save notes in the `Defense`

tab,
the Attack and Effect notes on certain items (like weapons, feats and spells),
and Context notes on the `Changes`

tab on certain items (like buffs).

These notes can have inline rolls included, which will be rolled at the appropriate time.

To create an inline roll in these fields, put the formula between double square brackets. Here’s some examples:

Note | Example Output |
---|---|

`[[1d6]] Strength penalty for [[1d4]] rounds` |
`5 Strength penalty for 2 rounds` |

`DC [[10 + floor(@classes.fighter.level / 2) + @abilities.wis.mod]]` |
`DC 14` |