Value Influence
Value Influences are used to make the value of a Complex Stat inherit from the values of other Complex Stats.
They can capture values from other stats in a string operation and calculate the result. The result will then be added to the Influenced Stat through an ID Value that will be automatically updated whenever a captured Stat value changes.
Composition
A Value Influence contains:
- The ID of the Value Influence, which will be used to modify the Value Set of the Target Stat
- The target Complex Stat that will be influenced
- The String Operation
- (Optional) A Curve that will transform the result X into the Y value
- (Optional) Custom Values used in the Operation
To learn more about String Operations, see String Operation.
Add Value Influences
Through the Default Values
SDV_Base structure contains the informations about Value Influences for each Stat.
It is present in both SDV_Minimal and SDV_Advanced (see Stat Default Values).
Adding Value Influences through the Default Values Table will register them under the ID "DefaultInfluence".
Through a custom structure (and Data Tables)
There are two types of Value Influence structures that you can use:
- ValueInfluence
- ValueInfluencesByID
ValueInfluence
This structure is useful if you already have an ID for your influence.
When designing a Perks system, I create a structure containing the Perk infos and an array of the ValueInfluence structure.
I can then create a Data Table from this new structure and fill the infos.
Here, "Perk_MyOtherPerk" will make the AttackPower inherit from 50% of the Strength value.
Since I already have the ID of the Perk, I don't need an additional ID for my Value Influences.
When I remove my perk, I then just have to call "RemoveValueInfluence" using the Perk ID.
ValueInfluencesByID
This structure is useful when you don't already have an ID for your Value Influence, or want to apply multiple IDs at the same time.
Manually
During gameplay, you can use AddValueInfluences() to add multiple influences in one function.
If you only want to target one Complex Stat, you can also use AddValueInfluenceToComplexStat().
If a Complex Stat already has a Value Influence under that ID, it will override it.
Split the structure pins to make the data more readable.
Remove Value Influences
You can remove a Value Influence by ID in every Stat with RemoveValueInfluences().
Or for a specific Stat with RemoveValueInfluenceFromComplexStat().
Adding Value Influences to Stats that don't exist
Adding Value Influences also work if the influenced Stat doesn't exist, or if the Stats used in the operation don't exist.
For example, consider the following Value Influence:
AttackPower = {Strength}
.
If Attack Power and Strength don't exist, then the Value Influence will remain "asleep".
- When the Attack Power stat is added, the AttackPower_FromStrength will update and return 0, since Strength doesn't exist.
- When the Strength stat is added, AttackPower_FromStrength will automatically update and return the value of Strength.