Command reference
TraitExpression
Command words: te, traitexpression
Permission: Admin
The Trait Expression command is used to work with Trait Expressions, which are used in numerous points of the code to do mathematical formulas that can also parse the traits (i.e. skills and attributes) of a character.
Examples of trait expressions might include damage formulas for weapons, the length of time someone can hold their breathe, caps for skills, etc.
Trait expressions can be edited with the following syntax:
te list - shows all trait expressions
te show <id> - shows a particular trait expression
te edit <id> - begins editing a trait expression
te edit - an alias for te show <editing id>
te close - stops editing a trait expression
te clone <id> - clones an existing expression and then begins editing the clone
te new <name> - creates a new trait expression
te test <which> <who> [<parameters>] - evalute a trait expression for someone to test it
te set name <name> - edits the name of this trait expression
te set formula <formula> - edits the formula for the expression
te set parameter <which> <trait> - adds a new parameter named referring to the specified trait
te set branch <which> - toggles branching of an existing parameter
te set improve <which> - toggles improvement of a particular parameter
te set trait <which> <trait> - sets the trait for a particular parameter
te set delete <which> - deletes a particular parameter
You can use the following filters with the te list command:
+<keyword> - formula or name should include the keyword
-<keyword> - formula and name should not include the keyword
*<keyword> - one of the parameters of the formula should be the named skill/attribute
Using parameters
The heart of the formulas is parameters. Each parameter has a name, and when the formula is evaluated by the engine that parameter will be replaced with an actual value. For example, you might have a parameter called strength and at evaluate time, it points to the strength attribute of the character the expression is about.
There are two options for working with parameters:
1) You can add them at the top level, as per te set parameter
2) You can refer to them directly in the formula with the syntax name:id, e.g. strength:1
There is also a special parameter called variable, which some parts of the code will substitute with a skill value (or something else). This is the case with expressions for weapon checks for example, where the weapon skill will be substituted for the variable parameter.
Additionally, you can mimic the effects of the nobranch and noimprove flags with type 2 variables by using syntax like the following: sorcery:123{nobranch,noimprove}.
Finally, all of these parameters can be reused. So once you've done str:1 earlier in a formula, simply refering to str later in the formula will be sufficient.
Special Functions
There are a number of special functions you can use (varname in the below stores the outcome in a variable that can be referred back to, it can otherwise be something perfunctory):
{varname race=race names/ids split by commas} - 1 if the character is any of the listed races, 0 otherwise
{varname culture=culture names/ids split by commas} - 1 if the character is any of the listed cultures, 0 otherwise
{varname merit=merit names/ids split by commas} - 1 if the character has any of the listed merits, 0 otherwise
{varname role=role names/ids split by commas} - 1 if the character has any of the listed roles, 0 otherwise
{varname class=class names/ids split by commas} - 1 if the character has is any of the listed classes, 0 otherwise
Formula Functions
You can also use the following functions in your formula:
dice(num,sides) - a random dice roll, e.g. dice(1,6) rolls a 6-sided dice
xdy - e.g. 2d6 - a shorthand for doing dice(x,y)
rand(min,max) - a random whole number between min and max
drand(min,max) - a random decimal number between min and max
not(num) - if num is exactly 0, then returns 1. Otherwise returns 0.
abs(num) - Returns the absolute value of a specified number
acos(num) - Returns the angle whose cosine is the specified number
asin(num) - Returns the angle whose sine is the specified number
atan(num) - Returns the angle whose tangent is the specified number
ceiling(num) - Returns the smallest integer greater than or equal to the specified number
cos(num) - Returns the cosine of the specified angle
exp(num) - Returns e raised to the specified power
floor(num) - Returns the largest integer less than or equal to the specified number
IEEERemainder(num,div) - Returns the remainder resulting from the division of a specified number by another specified number
ln(num) - Returns the natural logarithm of a specified number
log(num,base) - Returns the logarithm of a specified number
log10(num) - Returns the base 10 logarithm of a specified number
max(num1,num2) - Returns the larger of two specified numbers
min(num1,num2) - Returns the smaller of two numbers
pow(num,power) - Returns a specified number raised to the specified power
round(num,figures) - Rounds a value to the nearest integer or specified number of decimal places
sin(num) - Returns the sine of the specified angle
sqrt(num) - Returns the square root of a specified number
tan(num) - Returns the tangent of the specified angle
truncate(num) Calculates an integral part of a number
in(num1,num2,...,numn) - Returns whether an element is in a set of values
if(cond,truevalue,falsevalue) - Returns a value based on a condition
Examples
Here are some examples of plausible trait expressions applying the above:
1) 27
This formula would return 27 every single time
2) axes:37{nobranch}
This would substitute the character's value for axes (skill 37), and not permit it to branch if they don't have it
3) 1d10+truncate(str:1/10)
This would roll 1 ten-sided dice and add +1 for every 10 whole points of strength the character had
4) {ismartial class=warrior,paladin,barbarian,rogue,monk}*{str:1}+{isarcane class=mage,sorcerer,warlock}*{int:2}
This would use the value of a character's strength if they were a martial class, or intelligence if they were arcane
5) swimming:45 + {value merit=Natural Swimmer}*50
This formula combines swimming with a +50 bonus if they have the natural swimmer merit (likely to be a trait expression for a check)
6) listening:12 + {value merit=Good Ears}*30 + {elf race=Elf}*50
This formula combines the listening skill, a +30 bonus for the merit Good Ears, and an additional +50 bonus for the Elf race
7) min(99, (2 * dex:4) + (1 * str:1) + (2 * wil:5))
This formula is probably a skill cap combining 2*dex, str, and 2*wil, with a cap of 99
Permission: Admin
The Trait Expression command is used to work with Trait Expressions, which are used in numerous points of the code to do mathematical formulas that can also parse the traits (i.e. skills and attributes) of a character.
Examples of trait expressions might include damage formulas for weapons, the length of time someone can hold their breathe, caps for skills, etc.
Trait expressions can be edited with the following syntax:
te list - shows all trait expressions
te show <id> - shows a particular trait expression
te edit <id> - begins editing a trait expression
te edit - an alias for te show <editing id>
te close - stops editing a trait expression
te clone <id> - clones an existing expression and then begins editing the clone
te new <name> - creates a new trait expression
te test <which> <who> [<parameters>] - evalute a trait expression for someone to test it
te set name <name> - edits the name of this trait expression
te set formula <formula> - edits the formula for the expression
te set parameter <which> <trait> - adds a new parameter named referring to the specified trait
te set branch <which> - toggles branching of an existing parameter
te set improve <which> - toggles improvement of a particular parameter
te set trait <which> <trait> - sets the trait for a particular parameter
te set delete <which> - deletes a particular parameter
You can use the following filters with the te list command:
+<keyword> - formula or name should include the keyword
-<keyword> - formula and name should not include the keyword
*<keyword> - one of the parameters of the formula should be the named skill/attribute
Using parameters
The heart of the formulas is parameters. Each parameter has a name, and when the formula is evaluated by the engine that parameter will be replaced with an actual value. For example, you might have a parameter called strength and at evaluate time, it points to the strength attribute of the character the expression is about.
There are two options for working with parameters:
1) You can add them at the top level, as per te set parameter
2) You can refer to them directly in the formula with the syntax name:id, e.g. strength:1
There is also a special parameter called variable, which some parts of the code will substitute with a skill value (or something else). This is the case with expressions for weapon checks for example, where the weapon skill will be substituted for the variable parameter.
Additionally, you can mimic the effects of the nobranch and noimprove flags with type 2 variables by using syntax like the following: sorcery:123{nobranch,noimprove}.
Finally, all of these parameters can be reused. So once you've done str:1 earlier in a formula, simply refering to str later in the formula will be sufficient.
Special Functions
There are a number of special functions you can use (varname in the below stores the outcome in a variable that can be referred back to, it can otherwise be something perfunctory):
{varname race=race names/ids split by commas} - 1 if the character is any of the listed races, 0 otherwise
{varname culture=culture names/ids split by commas} - 1 if the character is any of the listed cultures, 0 otherwise
{varname merit=merit names/ids split by commas} - 1 if the character has any of the listed merits, 0 otherwise
{varname role=role names/ids split by commas} - 1 if the character has any of the listed roles, 0 otherwise
{varname class=class names/ids split by commas} - 1 if the character has is any of the listed classes, 0 otherwise
Formula Functions
You can also use the following functions in your formula:
dice(num,sides) - a random dice roll, e.g. dice(1,6) rolls a 6-sided dice
xdy - e.g. 2d6 - a shorthand for doing dice(x,y)
rand(min,max) - a random whole number between min and max
drand(min,max) - a random decimal number between min and max
not(num) - if num is exactly 0, then returns 1. Otherwise returns 0.
abs(num) - Returns the absolute value of a specified number
acos(num) - Returns the angle whose cosine is the specified number
asin(num) - Returns the angle whose sine is the specified number
atan(num) - Returns the angle whose tangent is the specified number
ceiling(num) - Returns the smallest integer greater than or equal to the specified number
cos(num) - Returns the cosine of the specified angle
exp(num) - Returns e raised to the specified power
floor(num) - Returns the largest integer less than or equal to the specified number
IEEERemainder(num,div) - Returns the remainder resulting from the division of a specified number by another specified number
ln(num) - Returns the natural logarithm of a specified number
log(num,base) - Returns the logarithm of a specified number
log10(num) - Returns the base 10 logarithm of a specified number
max(num1,num2) - Returns the larger of two specified numbers
min(num1,num2) - Returns the smaller of two numbers
pow(num,power) - Returns a specified number raised to the specified power
round(num,figures) - Rounds a value to the nearest integer or specified number of decimal places
sin(num) - Returns the sine of the specified angle
sqrt(num) - Returns the square root of a specified number
tan(num) - Returns the tangent of the specified angle
truncate(num) Calculates an integral part of a number
in(num1,num2,...,numn) - Returns whether an element is in a set of values
if(cond,truevalue,falsevalue) - Returns a value based on a condition
Examples
Here are some examples of plausible trait expressions applying the above:
1) 27
This formula would return 27 every single time
2) axes:37{nobranch}
This would substitute the character's value for axes (skill 37), and not permit it to branch if they don't have it
3) 1d10+truncate(str:1/10)
This would roll 1 ten-sided dice and add +1 for every 10 whole points of strength the character had
4) {ismartial class=warrior,paladin,barbarian,rogue,monk}*{str:1}+{isarcane class=mage,sorcerer,warlock}*{int:2}
This would use the value of a character's strength if they were a martial class, or intelligence if they were arcane
5) swimming:45 + {value merit=Natural Swimmer}*50
This formula combines swimming with a +50 bonus if they have the natural swimmer merit (likely to be a trait expression for a check)
6) listening:12 + {value merit=Good Ears}*30 + {elf race=Elf}*50
This formula combines the listening skill, a +30 bonus for the merit Good Ears, and an additional +50 bonus for the Elf race
7) min(99, (2 * dex:4) + (1 * str:1) + (2 * wil:5))
This formula is probably a skill cap combining 2*dex, str, and 2*wil, with a cap of 99