Using Stats in Effects, Statwatchers, and Triggerables
Contents |
Modifying Dynamic Stats
Manipulation of stats on units is done through the Add/Set/Clear Stat effects. Clear stat resets the stat to the stat's default value.
Open up the Data Editors->Affixes and look at ADD_ANY_200 for a typical example.
- EffectName - This must be set to the name of the stat as set in the Stat Editor
- Effect - Add Stat, Remove Stat, or Clear Stat
- Activation - Set to Dynamic or potentially Transfer (if you want to add the stat to someone else on application)
- Min - Minimum value to add to stat/set stat to. Does not affect Clear Stat.
- Max - Maximum value to add to stat/set stat to. Does not affect Clear Stat.
- Chance - % Chance of this effect activating on application
- Duration - Add/Set/Clear Stat will instantly add to/set/clear the stat. For Add Stat, setting a duration will override the remaining time before the stat's Increment Value is triggered (i.e. if a stat normally increments by -1 after 5 seconds, setting a duration of 10 will cause it to increment by -1 in 10 seconds instead and then return to the normal 5 second cycles afterwards.
Using Stats to Modify Effect Strength
Effects can look for stats on the unit they are being applied to or being applied by and use them to modify their effect value. Let's take a look at the RAILMAN_FORCEFIELD affix.
- StatName - Enter the name of the stat that you want to use to modify the effect value
- StatPercent - Enter the percent value of that stat that you wish to use
- StatSourceType - Select the whose stat should be used (the creator of the effect, or the recipient) and whether the stat value should be checked against on every update or to use the stat value at the moment the effect was initially applied
- StatModifierIsBonus (offscreen in pic) - Setting this to TRUE adds the Stat Modified Value to the Base Value. Otherwise the Total Value is just the Stat Modified Value.
So the Stat Modified Value used will be the following:
Stat Modified Value = Base Value * Stat Value * StatPercent / 100
In this example, Effect Level is used to boost the knock back resistance value. Let's say the skill is rank 5 and specifies to apply RAILMAN_FORCEFIELD as a level 2 affix, yielding a level 2 Effect Level. Since the StatPercent is 100 and the Base Value is 5, we get
Stat Modified Value = 5 * 2 * 100 / 100
Stat Modified Value = 10
Note: Effect Level is a special case Static Stat that is not declared in the Stats Editor
In this example the Stat Modified Value + Base Value = 10 + 5 = Total 15 Percent Knock Back Resistance
Walking through the second effect as an example, the Forcefield shield adds a 60 value shield and uses railmanbonus at 50 StatPercent and has StatModifierIsBonus set to true (60 is 60% of the Shield Buffer graph at the effect's level). Railmanbonus is the amount of charges we had available when we casted the charge, added to the unit as a stat in the Forcefield skill. Let's say we had a full 5 charge bar.
Stat Modified Value = 60 * 5 * 50 / 100
Stat Modified Value = 150
So our bonus value for a full 5 charge bar is 150% of the Shield Buffer graph at the level of the skill.
Total Shield Buffer Effect = 150 + 60
Total Shield Buffer Effect = 210
Essentially the skill reads "For every charge, add half of the base strength of the shield to the total effect"
Using Stats in Skills and Triggerables
Statwatchers
Statwatchers can be used in Skills and Triggerables as conditionals. The event or affix will only be activated or applied if the conditions of the statwatchers attached the event or affix are met.
- Stat - Which primary stat to watch (blank if comparing against a flat value)
- Target Type - Whose stat we are looking at (Self, Enemy, flat value, etc.)
- Value - If (primary) Target Type is set to Value, enter the value to use here
- Watch Type - How you'd like to compare the stat (equal to, greater than, etc.)
- Secondary Stat - Which secondary stat to compare against (blank if comparing against a flat value)
- Secondary Target Type - Whose stat we are looking at
- Secondary Value - If Secondary Target Type is set to Value, enter the value to use here
In Retaliate's case, the skill is limiting to hitting a specific monster only once in a specific time frame. In order to achieve this, we apply a flag named BERSERKERRETALIATE on any enemy we damage, which you can see in the Skill->Level1->Affix foldout being applied via BERSERKER_RETALIATE_FLAG.
To prevent the next hit from triggering, on Skill->Statwatcher we check if the BERSERKERRETALIATE is set. So Stat is BERSERKERRETALIATE, Target Type is Enemy, Watch Type is Equal to. We want to compare against 0, so the secondary stat is blank, secondary target type is VALUE, and the secondary value is 0. Now whenever we attempt to cast this skill, if the BERSERKERRETALIATE flag is switched on, the skill will not execute.
Note that the BERSERKERRETALIATE stat has a Duration of 1 and an increment value of -1 (and a max value of 1), so after 1 second of being applied any enemy who we had hit will be able to be hit again with this skill.
If the Statwatcher was attached to the affix instead (Skill->Level1->Event_Start->Affixes->Statwatcher), then the skill would execute and the event would be applied, so the target would take damage regardless as often as the skill is triggered. The BERSERKER_RETALIATE_FLAG affix would only be added once a second, however.
Triggerable Stat Events
Triggerables watch events akin to Statwatchers checking stats, however they are triggered when the specified event occurs rather than as part of a user activated ability as Statwatchers work. Triggerables can watch for any Add/Clear/Reduce Stat event, meaning that you can use them in tandem to check for state changes. Take a look at any of the ITEM_SLAYER_X_Y triggerables for examples of this (used for Augmented Weapons).
In Torchlight 2, Augmented Weapons add stats to themselves whenever the corresponding event (kill monster x in this case) happens. So to actually augment the weapon, we watch for an add stat event. The triggerable's Statwatcher then checks if we've killed enough monsters, and if we have, it adds the augmentation via a new Affix.
Additionally, Triggerable descriptions can display stat values by adding <stat:STATNAME> into the description string, which in this case allows us to display your current Kill X/Y monsters progress.