Creating Dynamic Stats
Dynamic stats are user-created storage variables that can be attached to units. Examples in vanilla Torchlight II include weapons with kill counters (10/20 goblins killed), state flags for Berserker and Embermage charged states, and charge counters for Engineer skill usage. They are accessed the same ways Static stats, but their values can also be set as well via the Add Stat/Set Stat/Clear Stat effects.
Here's an example arbiteravatar Dynamic Stat that is used to check if the Embermage's full charge bar effect is in place.
The internal name of the stat. When using the Add Stat/Set Stat/Clear Stat effect, you will use this name to reference the stat. When referring to a stat in the UI, it will show up as _DY_[internal name].
The unique ID of this stat. Generated by the editor.
The display name of the stat.
The value type of this stat. Can be an integer (-1,0,1,2...), a float, or a bool. The PREDEFINED_X types are used for Static Stats, not Dynamic Stats.
- For the arbiteravatar stat, we want TYPE_BOOL since we just need to know if it's on (TRUE) or off (FALSE).
The initial value of this stat when it gets created. Generally this value won't be used as if a unit has no stat, a check against the stat will return the default value. Defaults to 0, 0.0f, or FALSE.
The default value of this stat used if we're checking against a stat, but the unit does not have that stat applied. Defaults to 0, 0.0f, or FALSE.
The minimum value of this stat. Defaults to 0 or 0.0f. TYPE_BOOL does not use this value. Be sure to set this value if you want to allow negative values.
The maximum value of this stat. Defaults to 100 or 1.0E+38. Type_BOOL does not use this value.
When the duration timer reaches 0, the current value of this stat will be incremented by the Increment Value. For bools, a value of 1 will flip between TRUE and FALSE, and a value of 0 will do nothing. Defaults to 0, 0.0f, or FALSE.
- Arbiteravatar turns off after 7 seconds, so we set it to true to flip the value after the duration.
Duration is the length of time before the Increment Value is applied to the current value. When the current value hits the default value, Increment Values will no longer be applied.
- In this example arbiteravatar will not flip to TRUE 7 seconds after flipping to FALSE.
[No longer used]
Max time is the length of time for which the stat can be active. Must have Timed checked and the stat cannot have a duration. If Refreshes is checked, then the time elapsed towards max time is reset when the value is changed (unless is it reset to the default value). No longer a relevant setting.
Checking this box causes the current value of the stat to be saved to the unit it is placed on when exiting the game.
- Since charge states aren't saved out, arbiteravatar does not need to be set to save.
[No longer used]
Checking this box causes the value to be updated even if no duration is set on the stat. No longer a relevant setting.
Checking this box causes the remaining duration (time until reapplying Increment Value) to reset when the stat's value is set.
- Arbiteravatar isn't really affected here, but if we were to reapply the Charge mode then the 7 second countdown would refresh rather than ending prematurely 7 seconds after first entering the Charge mode.
Used to signal that it was a integer with value 0 or 1. Use TYPE_BOOL instead or a TYPE_INTEGER with max value 0