tModLoader v2022.09
A mod to make and play Terraria mods
Terraria.ModLoader.StatModifier Struct Reference

Public Member Functions

 StatModifier (float additive, float multiplicative, float flat=0f, float @base=0f)
 
float ApplyTo (float baseValue)
 
StatModifier CombineWith (StatModifier m)
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
StatModifier Scale (float scale)
 

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)
 

Public Attributes

float Base
 Increase to the base value of the stat. Directly added to the stat before multipliers are applied.
 
float Flat
 Increase to the final value of the stat. Directly added to the stat after multipliers are applied.
 

Static Public Attributes

static readonly StatModifier Default = new StatModifier(1f, 1f, 0f, 0f)
 

Properties

float Additive [get]
 The combination of all additive multipliers. Starts at 1
 
float Multiplicative [get]
 The combination of all multiplicative multipliers. Starts at 1. Applies 'after' all additive bonuses have been accumulated.
 

Member Function Documentation

◆ operator*()

static StatModifier Terraria.ModLoader.StatModifier.operator* ( StatModifier  m,
float  mul 
)
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.

Parameters
m
mulThe factor by which the multiplicative modifier is scaled
Returns

◆ operator+()

static StatModifier Terraria.ModLoader.StatModifier.operator+ ( StatModifier  m,
float  add 
)
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.

Parameters
m
addThe additive modifier to add, where 0.01f is equivalent to 1%
Returns

◆ operator-()

static StatModifier Terraria.ModLoader.StatModifier.operator- ( StatModifier  m,
float  sub 
)
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.

Parameters
m
subThe additive modifier to subtract, where 0.01f is equivalent to 1%
Returns