ComputedStat
A computed stat is used to define stats whose value is derived from other
stats (either base or calculated). Please be wary of circular
dependencies between stats.
Computed stats values can still be overridden by the user or by a mechanic.
A computed stat with a modifier override (such as with the addToStat
effect) will still calculate the value of the computed stat, and then add
the appropriate modifier to it. If a value override (such as the one created
as a result of the setStat effect) is used instead, the computed stat will
not be calculated, using that overridden value + any overridden modifiers
in lieu of it.
Example computed stat
{
"id": "passive_perception",
"name": "Passive perception",
"abbreviation": "PP",
"type": "calculated",
"value_type": "integer",
"components": {
"type": "add",
"components": {
"type": "list",
"components": [
{
"type": "constant",
"value": 10,
"value_type": "integer"
},
{
"type": "stat",
"stat": "perception"
}
]
}
}
},
{
"id": "perception",
"name": "Perception",
"type": "calculated",
"value_type": "integer",
"components": {
"type": "add",
"components": {
"type": "list",
"components": [
{
"type": "stat",
"stat": "wisdom_modifier"
},
{
"type": "stat",
"stat": "proficiency_bonus"
}
]
}
}
},
{
"id": "wisdom_modifier",
"name": "Wisdom",
"abbreviation": "WIS",
"type": "calculated",
"value_type": "integer",
"components": {
"type": "divide",
"rounding_method": "down",
"components": {
"type": "list",
"components": [
{
"type": "add",
"components": {
"type": "list",
"components": [
{
"type": "stat",
"stat": "wisdom_score"
},
{
"type": "constant",
"value": -10,
"value_type": "integer"
}
]
}
},
{
"type": "constant",
"value": 2,
"value_type": "integer"
}
]
}
}
},
{
"id": "wisdom_score",
"name": "Wisdom",
"abbreviation": "WIS",
"type": "base",
"value_type": "integer",
"default_value": 8
}
JSON Format
{
"type": "ComputedStat",
"id": ...,
"name": ...,
"plural": ...,
"abbreviation": ...,
"type": ...,
"value_type": ...,
"sub_value_type": ...,
"default_value": ...,
"components": ...
}
Fields
| Field | Type | Required | Description |
|---|---|---|---|
id | String | ✓ | The id for this type instance. This should be unique. |
name | String | ✓ | The name for this type instance. |
plural | String | Optional. The plural form of the name for this type instance (e.g: "Items" if the name is "Item"). | |
abbreviation | String | Optional. Abbreviation of the name for this type instance (e.g: "STR" for Strength). | |
type | StatType | ✓ | The type of the stat (base or calculated) |
value_type | ValueType | ✓ | The value type for this stat |
sub_value_type | ValueType | Optional field. Set only for array valueTypes. Represents type of the array (e.g: for an array of strings, we should set value_type as array and sub_value_type as string) | |
default_value | dynamic | ✓ | The default value for the stat. Has to conform to the given value_type. Using null is highly discouraged |
components | StatFormulaComponent | ✓ | The stat formula components to compute the value for this stat. |