$#K+DicePlus


DicePlus

Some values that you edit are called DICEPLUS fields. This means that they are text fields which let you specify the actual value in typical ADnD dice terms.


Some valid examples:



1d20

1d4 + 2

10

5 + level * 3

1d4 + 2 * level

3d6 + 2 * Elf

(dexterity == 18) * "Cleric/Fighter" * level



A DICEPLUS field is evaluated using the usual mathematical operator precedence. A typical way to specify a value in ADnD is to state '1 die 4 plus 3 per level' which on paper is represented as '1d4 + 3/level'. In DICEPLUS format this would be '1d4+3*level'. The '/' is treated as mathematical division rather than a concept of 'per level'. In order of evaluation, this expression can be stated as


get current character level

multiply level by 3

roll 1d4

add the two results together


You can use parentheses to specify the order in which the terms are evaluated. (1d4+3)*level can be different than 1d4+(3*level).


A DICEPLUS field can contain keywords that are evaluated at runtime. For instance, '1d4+3*level' will evaluate 'level' to be a character's current level and then multiply that by 3.


To specify a random dice roll, use the XdY syntax, where


xdy: x=num dice, 'd' is a keyword, y is num sides on each dice.


Example: 1d4 for 1 die 4


These are the mathematical operators allowed in a DICEPLUS expression. This table is from the code that compiles the DicePlus expression and contains information you don't need. The first column is the priority (precedence) of the operator. Lower numbers are evaluated last; higher numbers first are evaluated first. When two operators have the same priority, they are evaluated left-to-right. You can see, for example, that multiplication (45) will be done before addition (40). The second and third columns might provide hints as to what the operators do. The fourth column provides the characters you use in the expression.


The 'MIN' and 'MAX' operators might be confusing. 'MIN' means the final value has a 'minimum' value. The operator selects the larger of two values. For example:


5 |< 2d6


Means that the final value has a minimum of 5. If 2d6 is less than 5 then the value is 5. If 5 is less than 2d6 then the value is 2d6. You might think that 'MIN' selects the 'minimum' value. But it is the opposite. It enforces a 'minimum' value by selecting the larger of two values. Similarly, 'MAX' enforces a 'maximum' value.


A neat way to throw 3d6 three times and take the largest:


3d6 |< 3d6 |< 3d6


{2, CTKN_MIN, COP_MIN, "|<" }, //RDR

{2, CTKN_MAX, COP_MAX, ">|" }, //RDR

{5, CTKN_LOR, COP_LOR, "||" }, //RDR

{7, CTKN_LXOR, COP_LXOR, "^^" }, //RDR

{10,CTKN_LAND, COP_LAND, "&&" }, //RDR

{15,CTKN_BITOR, COP_BITOR, "|" }, //RDR

{20,CTKN_BITXOR, COP_BITXOR, "^" }, //RDR

{25,CTKN_BITAND, COP_BITAND, "&" }, //RDR

{30,CTKN_ISEQUAL, COP_ISEQUAL, "==" }, //RDR

{30,CTKN_NOTEQUAL, COP_ISNOTEQUAL, "!=" }, //RDR

{35,CTKN_LESS, COP_LESS, "<" }, //RDR

{35,CTKN_LESSEQUAL, COP_LESSEQUAL, "<=" }, //RDR

{35,CTKN_GREATER, COP_GREATER, ">" }, //RDR

{35,CTKN_GREATEREQUAL, COP_GREATEREQUAL, ">=" }, //RDR

{40,CTKN_PLUS, COP_PLUS, "+" }, //RDR

{40,CTKN_MINUS, COP_MINUS, "-" }, //RDR

{45,CTKN_GEAR, COP_TIMES, "*" }, //RDR

{45,CTKN_SLASH, COP_SLASH, "/" }, //RDR

{45,CTKN_PERCENT, COP_PERCENT, "%" }, //RDR

{ 0,CTKN_OPENPAREN, COP_ILLEGAL, "(" }, //RDR

{ 0,CTKN_CLOSEPAREN, COP_ILLEGAL, ")" } //RDR



You can also use unary '-' and '+' to specify the sign of a number, such as '-1' for negative one.


There are several possible keyword types allowed in a DICEPLUS expression. They are evaluated at runtime in the context of the currently active character. You can use a race name, class name, skill name, or the literals 'level', 'class', 'race', 'male', and 'female'. These keywords are not case-sensitive. Some keywords have the '-' or '/' tokens in them, such as 'Half-Elf' and 'Cleric/Fighter'. In such situations you must enclose the keyword in quotes, as in '1d4 + "Half-Elf"'. If you do not, then the '-' and '/' tokens will be interpreted as the mathematical operators subtraction and division. To be recognized as a token for which runtime substitution can be made, the race/class/skill keywords must match one of the defined values in your races.txt, baseclass.txt, or ability.txt files.


If portions of the DICEPLUS expression cannot be understood, those portions will be ignored. An expression such as '10 + jerk * 11' will always be 10 because the 'jerk * 11' cannot be understood.


You can limit the final result of a DICEPLUS expression by using '|<' to specify minimum, or '>|' to specify maximum. Example: '1d4+2 |< 2 >| 9'. That will limit the '1d4+2' to a minimum of 2 and maximum of 9. You can write the same expression as '2 |< 1d4+2 >| 9'. The default limit is -999 to 999.



$ DicePlus

# DicePlus

K DicePlus

+ Editor_General:000