# Formula Syntax and Functions

The syntax is very straight forward and closely follows your basic algebraic notation. You can add, subtract, multiply, divide, use parenthesis, and unary plus/minus. (All numbers are integers.) Precedence order is the same as your basic algebra with multiplication occurring before addition and subtraction. However, the use of parenthesis will override this. Dice are represented as Ax# where A = number of dice to roll and x# represents the type of die (d2, d6, e8, etc.). A few examples are likely to provide the easiest explanation.

• 4d6+3
Roll 4 d6 dice, sum them, add 3 to the result
• (4d6+3)*2
Roll 4 d6 dice, sum them, add 3 to the result. Then multiply this value by 2.
• 5*4d6+3
Multiply 5 times the sum of 4 d6 dice then add 3 to the result
• 4+min(3d8, 12)
Roll 3 d8 dice, sum them, take the smaller of this and the number 12. Add that value to 4.

## Operators:

• - subtraction
• * multiplication

## Math Functions:

The following functions are supported in the equations you create.

• min(<expression1>, <expression2>)
Return the minimum of the two expressions.
• max(<expression1>, <expression2>)
Return the maximum of the two expressions.
• div(<expression1>, <expression2>)
Divide expression 1 by expression 2 and return the value rounded up at one-half.
• floor(<expression1>, <expression2>)
Divide expression 1 by expression 2 and return the largest integer not greater than the result.
• ceil(<expression1>, <expression2>)
Divide expression 1 by expression 2 and return the largest integer not less than the result.

The div, floor, and ceil functions will return an integer value. The expression div(1, 4) will divide 1 by 4 and return 0. 1/4 = .25 which is rounded to zero. As a result, 4 * div(1/4) = 0 and not 1 The following example should help to make this clear:

Expression Div Floor Ceil
1/4 (0.25) 0 0 1
2/4 (0.5) 1 0 1
3/4 (0.75) 1 0 1
4/4 (1) 1 1 1

## Dice Throws:

Make the throws of a die vary depending on a calculation. For example: 4d6 will throw the d6 4 times and sum the results. If you wanted to make that "4" a calculated value, you can use the "ThrowDx" function.

ThrowDx(<expression1>)

ThrowEx(<expression1>)

replace the "x" with the die you want to use. This must be one of the die we currently support.

ThrowD6(4) is equivalent to 4d6.

Where this really comes in handy is when coupled with the variables and constants feature. Consider a Global Constant of "Level". The following would adjust the number of d6 you throw based on the character level. Change the "Level" constant and your calculations adjust automatically.

ThrowD6(Level + 4)

The ThrowEx works the same way just with exploding dice.

## Conditional Logic:

The following work just like functions but are meant to provide some control over the flow of execution. Depending on the how the conditional evaluates, true or false, a different set of results can occur. This can be a very powerful tool to help build complex equations. When combined with the Global Constants and (for Custom Dice Sets) Local Variables, the possibilities are virtually endless.

These functions will be of the form:

Ifxx(<expression1>, <expression2>, <expression True>, <expression False>)

• Ifeq – if (expression1 equals expression2) do expression-True else do expression-False
• Ifne – if (expression1 not equal expression2) do expression-True else do expression-False
• Ifgt – if (expression1 greater than expression2) do expression-True else do expression-False
• Ifge – if (expression1 greater than or equal expression2) do expression-True else do expression-False
• Iflt – if (expression1 less than expression2) do expression-True else do expression-False
• Ifle – if (expression1 less than or equal expression2) do expression-True else do expression-False

The following example should help to make this clear:

ifeq(1d6, 6, 2d10, 0)

This example will first evaluate the 1d6 roll. If it rolls a six, then the 2d10 will be evaluated and that will be the result. Otherwise, if the 1d6 is not a six, then the result will be zero.