tModLoader v2024.11
A mod to make and play Terraria mods
|
Public Member Functions | |
StatModifier (float additive, float multiplicative, float flat=0f, float @base=0f) | |
float | ApplyTo (float baseValue) |
Use this to apply the modifiers of this StatModifier to the baseValue . You should assign the value passed in to the return result. For example: More... | |
StatModifier | CombineWith (StatModifier m) |
Combines the components of two StatModifiers. Typically used to apply the effects of ammo-specific StatModifier to the DamageClass StatModifier values. | |
override bool | Equals (object obj) |
override int | GetHashCode () |
StatModifier | Scale (float scale) |
Scales all components of this StatModifier for the purposes of applying damage class modifier inheritance.This is NOT intended for typical modding usage, if you are looking to increase this stat by some percentage, use the addition (+ ) operator. | |
Static Public Member Functions | |
static bool | operator!= (StatModifier m1, StatModifier m2) |
static StatModifier | operator* (float mul, StatModifier m) |
static StatModifier | operator* (StatModifier m, float mul) |
The multiply operator applies a multiplicative effect to the resulting multiplicative modifier. This effect is very rarely used, typical effects use the add operator. More... | |
static StatModifier | operator+ (float add, StatModifier m) |
static StatModifier | operator+ (StatModifier m, float add) |
By using the add operator, the supplied additive modifier is combined with the existing modifiers. For example, adding 0.12f would be equivalent to a typical 12% damage boost. For 99% of effects used in the game, this approach is used. More... | |
static StatModifier | operator- (StatModifier m, float sub) |
By using the subtract operator, the supplied subtractive modifier is combined with the existing modifiers. For example, subtracting 0.12f would be equivalent to a typical 12% damage decrease. For 99% of effects used in the game, this approach is used. More... | |
static StatModifier | operator/ (StatModifier m, float div) |
static bool | operator== (StatModifier m1, StatModifier m2) |
Static Public Attributes | |
static readonly StatModifier | Default = new() |
float StatModifier.ApplyTo | ( | float | baseValue | ) |
Use this to apply the modifiers of this StatModifier to the baseValue . You should assign the value passed in to the return result. For example:
damage = CritDamage.ApplyTo(damage)
could be used to apply a crit damage modifier to a base damage value
Note that when using this to calculate the final damage of a DamageClass make sure to use Player.GetTotalDamage(DamageClass) not Player.GetDamage(DamageClass) to account for inherited damage modifiers such as Generic damage.
For help understanding the meanings of the applied values please make note of documentation for:
The order of operations of the modifiers are as follows:
baseValue | The starting value to apply modifiers to |
|
static |
The multiply operator applies a multiplicative effect to the resulting multiplicative modifier. This effect is very rarely used, typical effects use the add operator.
m | |
mul | The factor by which the multiplicative modifier is scaled |
|
static |
By using the add operator, the supplied additive modifier is combined with the existing modifiers. For example, adding 0.12f would be equivalent to a typical 12% damage boost. For 99% of effects used in the game, this approach is used.
m | |
add | The additive modifier to add, where 0.01f is equivalent to 1% |
|
static |
By using the subtract operator, the supplied subtractive modifier is combined with the existing modifiers. For example, subtracting 0.12f would be equivalent to a typical 12% damage decrease. For 99% of effects used in the game, this approach is used.
m | |
sub | The additive modifier to subtract, where 0.01f is equivalent to 1% |