Formulas

Formulas are expressions that calculate a number dynamically, often based on a character’s attributes or other values.
Instead of using a fixed number, formulas can reference fields like {Strength} or {Level} to produce results that update automatically when those values change. Eg:

{Level} * 10          // 10 times Level
({Strength} - 10)/2  // D&D 5e STR modifier
max({STR}, {DEX}, 1)  // max between STR, DEX, or 1
{Level} = 1 ? 8 : 5  // If Level is 1, return 8; otherwise, return 5
lookup({Level}: 0, 2,2,2,2,3,3,3,4,4,5) // Pick the value from the list at index {Level}

Formulas are used to automate calculations throughout the game, keeping numbers accurate and reducing manual work.
They can be used to automatically compute Attributes, evaluate Effect Arguments, or item stats like Weapon Damage.

Features:

1) References

Type an attribute's name to reference it in a formula, such as Strength.
This is evaluated during play at the active Character's total Strength value. In the case of multiple words, use { } to delimitate the attribute's name: {Strength Modifier}

2) Numeric Operators: + - * /

{Strength} + 10

3) Functions:

  • min, max: returns the minimum/maximum of a series of values

    min({Strength}, {Level} + 2, 1)

  • count: counts the number of non-zero values:

    count({STR}, {DEX}, {CON})

  • sign: returns -1, 0 or 1, depending of the number is negative, zero, or positive

    sign({STR})

  • lookup: return the value at a given index from an array (starting with 0)

    lookup({Level}:0,1,5,10,20,50)
    - For Level = 0 will return 0
    - For level = 1 will return 1
    - For level = 2 will return 5
    ...
    - For level > 5, will return 50

4) Player Input

Sometimes you want the Player to modify an attribute in a certain way;
For example, in D&D, you want the Player to toggle the Proficiency of an attribute, and automatically add (or not) a certain pre-computed value to the attribute's final value.
To do this, you can use the character x to denote the Player-given Input to be used in a formula.
ex: Acrobatics = STR + Proficiency*x will assign Acrobatics the value of attribute STR, and add Proficiency, multiplied by the player Input This means with a 0 Proficiency, Acrobatics will be just STR, and with an Input of 1 (toggle on), the Proficiency value is added too.

If you need to reference another Attribute's input, you can do so by typing .x after its name: Acrobatics.x
This will return the given-user input value of that field; in this case, this may be 1 if the Player has set Acrobatics Proficiency to 1, or 0 otherwise.
.x will always return zero if the referenced attribute does not take an Input in its Formula.

5) Conditional Operator: ?

Condition ? ResultIfTrue : ResultIfFalse

Evaluate a simple condition, and return a different result based on whether the condition is true or false.

{Level} = 1 ? 8 : 5 – if Level = 1, return 8, otherwise return 5

6) Dice Operators:

You can reference dice and or Dice Attributes in your formulas.
Be aware that dice values, such as d8 will be evaluated on the spot, so you will get a random value between 1 and 8 when using d8 in your formula.
Instead, you can use Dice operators for Dice Attributes to extract deterministic values from Dice Attributes.

min({Hit Dice}) or count({Hit Dice}) - minimum amount your Hit Dice can roll or the number of dice in that dice pool (since a die can roll a minimum of 1)
max({Hit Dice}) - maximum amount your Hit Dice can roll (a 4d8 will return 32)
avg({Hit Dice}) - the average amount for this Hit Dice, rounded up
roll({Hit Dice)} - a random value rolled by your attribute

Info

Use Paranthesis ( ) to enforce order of operations when uncertain

Info

Avoid Dividing to a reference! Users may override values to zero and division by zero will cause issues.

Tip

For further assistance with writing the correct formula for your games, contact us and we'll help you out!