AddToStat
This effect allows you to add to the value of a particular stat. Even though
you could always use the setStat effect instead by manually adding to the
value to set, it is always recommended to use this effect for additions
(or subtractions) as this will set a modifier override as opposed to a value
override. Modifier overrides will act separate from value overrides and are
most likely what you want.
For example, let's say that a player with intelligence = 10 equips two items. The first item adds one adds 1 to their intelligence, and the player then equips a second item that sets their intelligence to 20. There are two potential outcomes:
- The intelligence is 21
- The intelligence is 20
If you'd want the app to behave as in (1), then you'd want to use an
addToStat effect for the first item, and a setStat effect for the second
one. This way, the modifier (+1) will always be applied, regardless of if
the stat is later modified in other ways.
If you want the app to behave as (2), then you want to use setStat (and
use a max aggregation type).
Finally, remember that modifier overrides only clash with modifier
overrides, and value overrides only clash with value overrides. This means
that, going back to the previous example, if the player equips another item
that adds a +3 to their intelligence, the first item and the last will
clash, and which modifier/s prevail will depend on the aggregation type (for
aggregation type max, the +3 will prevail, for min the +1, for sum
we'll end up with a +4, etc). If the +1 was set with an aggregation type
that is different from the one used in the effect that added the +3, then
the user will be prompted to see how they want to choose to resolve the
clash.
JSON Format
{
"type": "addToStat",
"stat": ...,
"meta_stat": ...,
"value": ...,
"aggregation_type": ...,
"calculated_aggregation_type": ...
}
Fields
| Field | Type | Required | Description |
|---|---|---|---|
stat | String | Stat to affect. Either stat or meta_stat need to be present. If both are present, stat will take priority. | |
meta_stat | StatFormulaComponent | Stat to affect. Either stat or meta_stat need to be present. If both are present, stat will take priority. meta_stat should only be used if the stat to affect needs to be calculated in runtime, as it impacts app performance. This stat formula must return a string. | |
value | StatFormulaComponent | ✓ | The formula for the value that should be added to the stat. The value this stat formula returns must have the same type as the one declared in the value_type (and sub_value_type, if appropriate) for the stat specified in stat or meta_stat. |
aggregation_type | AggregationType | The aggregation type for the override resulting from the execution of this effect. See AggregationType for more details. If both aggregation_type and calculated_aggregation_type are omitted, the override will use none as the default aggregation type. | |
calculated_aggregation_type | StatFormulaComponent | To be used when the aggregation type should be calculated in runtime. Otherwise, use aggregation_type. If aggregation_type is also defined, this property will be ignored. This stat formula must return a string value matching one of the AggregationType values. |