tModLoader v2024.03
A mod to make and play Terraria mods
DamageClass Class Reference

DamageClass is used to determine the application of item effects, damage/stat scaling, and class bonuses. More...

Inherits ModType< TEntity, TModType >, and ILocalizedModType.

Inherited by VanillaDamageClass.

Public Member Functions

bool CountsAsClass (DamageClass damageClass)
 This is used to check if this DamageClass has been set to inherit effects from the provided DamageClass, as dictated by GetEffectInheritance More...
 
bool CountsAsClass< T > ()
 
virtual bool GetEffectInheritance (DamageClass damageClass)
 This lets you define the classes that this DamageClass will count as (other than itself) for the purpose of armor and accessory effects, such as Spectre armor's bolts on magic attacks, or Magma Stone's Hellfire debuff on melee attacks.
For a more in-depth explanation and demonstration, see ExampleMod's ExampleDamageClass.cs More...
 
virtual StatInheritanceData GetModifierInheritance (DamageClass damageClass)
 This lets you define the classes that this DamageClass will benefit from (other than itself) for the purposes of stat bonuses, such as damage and crit chance. This is used to allow extensive specifications for what your damage class can and can't benefit from in terms of other classes' stat bonuses. More...
 
virtual void SetDefaultStats (Player player)
 This lets you define default stat modifiers for all items of this class (e.g. base crit chance). More...
 
sealed override void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual bool ShowStatTooltipLine (Player player, string lineName)
 Overriding this lets you disable standard statistical tooltip lines displayed on items associated with this DamageClass. All tooltip lines are enabled by default. More...
 
- Public Member Functions inherited from ModType< TEntity, TModType >
virtual TModType Clone (TEntity newEntity)
 Create a copy of this instanced global. Called when an entity is cloned. More...
 
virtual bool IsLoadingEnabled (Mod mod)
 Allows you to stop Mod.AddContent from actually adding this content. Useful for items that can be disabled by a config. More...
 
virtual void Load ()
 Allows you to perform one-time loading tasks. Beware that mod content has not finished loading here, things like ModContent lookup tables or ID Sets are not fully populated. More...
 
virtual TModType NewInstance (TEntity entity)
 Create a new instance of this ModType for a specific entity More...
 
string PrettyPrintName ()
 
virtual void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed. More...
 
virtual void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual void Unload ()
 Allows you to safely unload things you added in Load. More...
 
virtual bool IsLoadingEnabled (Mod mod)
 Whether or not this type should be loaded when it's told to. Returning false disables Mod.AddContent from actually loading this type. More...
 
abstract void Load (Mod mod)
 Called when loading the type. More...
 
abstract void Unload ()
 Called during unloading when needed. More...
 
- Public Member Functions inherited from ModType< TEntity >
virtual TModType Clone (TEntity newEntity)
 Create a copy of this instanced global. Called when an entity is cloned. More...
 
virtual bool IsLoadingEnabled (Mod mod)
 Allows you to stop Mod.AddContent from actually adding this content. Useful for items that can be disabled by a config. More...
 
virtual void Load ()
 Allows you to perform one-time loading tasks. Beware that mod content has not finished loading here, things like ModContent lookup tables or ID Sets are not fully populated. More...
 
virtual TModType NewInstance (TEntity entity)
 Create a new instance of this ModType for a specific entity More...
 
string PrettyPrintName ()
 
virtual void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed. More...
 
virtual void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual void Unload ()
 Allows you to safely unload things you added in Load. More...
 

Protected Member Functions

sealed override void Register ()
 If you make a new ModType, seal this override. More...
 
- Protected Member Functions inherited from ModType< TEntity, TModType >
abstract TEntity CreateTemplateEntity ()
 
virtual void InitTemplateInstance ()
 Create dummy objects for instanced mod-types More...
 
override void InitTemplateInstance ()
 Create dummy objects for instanced mod-types More...
 
abstract void Register ()
 If you make a new ModType, seal this override. More...
 
virtual void ValidateType ()
 Check for the correct overrides of different hook methods and fields and properties More...
 
- Protected Member Functions inherited from ModType< TEntity >
abstract TEntity CreateTemplateEntity ()
 
virtual void InitTemplateInstance ()
 Create dummy objects for instanced mod-types More...
 
override void InitTemplateInstance ()
 Create dummy objects for instanced mod-types
 
abstract void Register ()
 If you make a new ModType, seal this override. More...
 
virtual void ValidateType ()
 Check for the correct overrides of different hook methods and fields and properties More...
 

Properties

static DamageClass Default = new DefaultDamageClass() [get]
 Default damage class for non-classed weapons and items, does not benefit from Generic bonuses
 
virtual LocalizedText DisplayName [get]
 This is the name that will show up when an item tooltip displays 'X [ClassName]'. More...
 
static DamageClass Generic = new GenericDamageClass() [get]
 Base damage class for all weapons. All vanilla damage classes inherit bonuses applied to this class. Accessories which benefit all classes provide bonuses via the Generic class
 
virtual string LocalizationCategory [get]
 The category used by this modded content for use in localization keys. Localization keys follow the pattern of "Mods.{ModName}.{Category}.{ContentName}.{DataName}". The Localization wiki pageexplains how custom ModType classes can utilize this. More...
 
static DamageClass Magic = new MagicDamageClass() [get]
 
static DamageClass MagicSummonHybrid = new MagicSummonHybridDamageClass() [get]
 This is a damage class used solely by vanilla forbidden storm. It scales with both magic and summon damage modifiers.
 
static DamageClass Melee = new MeleeDamageClass() [get]
 
static DamageClass MeleeNoSpeed = new MeleeNoSpeedDamageClass() [get]
 This is a damage class used by various projectile-only vanilla melee weapons. Attack speed has no effect on items with this damage class.
 
static DamageClass Ranged = new RangedDamageClass() [get]
 
static DamageClass Summon = new SummonDamageClass() [get]
 
static DamageClass SummonMeleeSpeed = new SummonMeleeSpeedDamageClass() [get]
 This is a damage class used solely by vanilla whips. It benefits from melee attackSpeed bonuses.
 
static DamageClass Throwing = new ThrowingDamageClass() [get]
 Class provided for modders who want to coordinate throwing accessories and items. Not used by any vanilla items.
 
int Type [get, set]
 The internal ID of this DamageClass.
 
virtual bool UseStandardCritCalcs [get]
 This lets you decide whether or not your damage class will use standard crit chance calculations. Setting this to false will also hide the critical strike chance line in the tooltip of any item that uses this DamageClass.
 
- Properties inherited from ModType< TEntity, TModType >
virtual bool CloneNewInstances [get]
 Whether to create new instances of this mod type via Clone(TEntity) or via the default constructor Defaults to false (default constructor).
 
TEntity Entity [get, set]
 
string FullName [get]
 The internal name of this, including the mod it is from. More...
 
virtual bool IsCloneable [get]
 Whether or not this type is cloneable. Cloning is supported if
all reference typed fields in each sub-class which doesn't override Clone are marked with [CloneByReference]
 
Mod Mod [get, set]
 The mod this belongs to. More...
 
virtual string Name [get]
 The internal name of this. More...
 
- Properties inherited from IModType
string FullName [get]
 => $"{Mod.Name}/{Name}" More...
 
Mod Mod [get]
 The mod this belongs to. More...
 
string Name [get]
 The internal name of this instance. More...
 
- Properties inherited from ModType< TEntity >
virtual bool CloneNewInstances [get]
 Whether to create new instances of this mod type via Clone(TEntity) or via the default constructor Defaults to false (default constructor).
 
TEntity Entity [get, set]
 
string FullName [get]
 The internal name of this, including the mod it is from. More...
 
virtual bool IsCloneable [get]
 Whether or not this type is cloneable. Cloning is supported if
all reference typed fields in each sub-class which doesn't override Clone are marked with [CloneByReference]
 
Mod Mod [get, set]
 The mod this belongs to. More...
 
virtual string Name [get]
 The internal name of this. More...
 
- Properties inherited from ILocalizedModType
abstract string LocalizationCategory [get]
 The category used by this modded content for use in localization keys. Localization keys follow the pattern of "Mods.{ModName}.{Category}.{ContentName}.{DataName}". The Localization wiki pageexplains how custom ModType classes can utilize this. More...
 

Detailed Description

DamageClass is used to determine the application of item effects, damage/stat scaling, and class bonuses.

New classes can be created and can be set to inherit these applications from other classes.

For a more in-depth explanation and demonstration refer to ExampleMod's ExampleDamageClass.cs

.

Member Function Documentation

◆ CountsAsClass()

bool DamageClass.CountsAsClass ( DamageClass  damageClass)

This is used to check if this DamageClass has been set to inherit effects from the provided DamageClass, as dictated by GetEffectInheritance

Parameters
damageClassThe DamageClass you want to check if effects are inherited by this DamageClass.
Returns
true if this damage class is inheriting effects from damageClass , false otherwise

◆ CountsAsClass< T >()

Type Constraints
T :DamageClass 
T :CountsAsClass 
T :ModContent.GetInstance<T>() 

◆ GetEffectInheritance()

virtual bool DamageClass.GetEffectInheritance ( DamageClass  damageClass)
virtual

This lets you define the classes that this DamageClass will count as (other than itself) for the purpose of armor and accessory effects, such as Spectre armor's bolts on magic attacks, or Magma Stone's Hellfire debuff on melee attacks.
For a more in-depth explanation and demonstration, see ExampleMod's ExampleDamageClass.cs

Return true for each DamageClass you want to inherit from

Parameters
damageClassThe DamageClass you want to inherit effects from.
Returns
false by default - which does not let any other classes' effects trigger on this DamageClass.

Reimplemented in MeleeNoSpeedDamageClass, SummonMeleeSpeedDamageClass, and MagicSummonHybridDamageClass.

◆ GetModifierInheritance()

virtual StatInheritanceData DamageClass.GetModifierInheritance ( DamageClass  damageClass)
virtual

This lets you define the classes that this DamageClass will benefit from (other than itself) for the purposes of stat bonuses, such as damage and crit chance. This is used to allow extensive specifications for what your damage class can and can't benefit from in terms of other classes' stat bonuses.

Parameters
damageClassThe DamageClass which you want this DamageClass to benefit from statistically.
Returns
By default this will return StatInheritanceData.Full for DamageClass.Generic and StatInheritanceData.None for any other.

Reimplemented in DefaultDamageClass, GenericDamageClass, MeleeNoSpeedDamageClass, SummonMeleeSpeedDamageClass, and MagicSummonHybridDamageClass.

◆ Register()

sealed override void DamageClass.Register ( )
protectedvirtual

If you make a new ModType, seal this override.

Implements ModType< TEntity >.

◆ SetDefaultStats()

virtual void DamageClass.SetDefaultStats ( Player  player)
virtual

This lets you define default stat modifiers for all items of this class (e.g. base crit chance).

Parameters
playerThe player to apply stat modifications to

Reimplemented in GenericDamageClass.

◆ SetupContent()

sealed override void DamageClass.SetupContent ( )
virtual

If you make a new ModType, seal this override, and call SetStaticDefaults in it.

Reimplemented from ModType< TEntity >.

◆ ShowStatTooltipLine()

virtual bool DamageClass.ShowStatTooltipLine ( Player  player,
string  lineName 
)
virtual

Overriding this lets you disable standard statistical tooltip lines displayed on items associated with this DamageClass. All tooltip lines are enabled by default.

To disable tooltip lines you should return false for each of those cases.

Parameters
playerThe player to apply tooltip changes to
lineNameThe tooltip line to change visibility for. Usable values are: "Damage", "CritChance", "Speed", and "Knockback"

Reimplemented in SummonDamageClass, and SummonMeleeSpeedDamageClass.

Property Documentation

◆ DisplayName

virtual LocalizedText DamageClass.DisplayName
get

This is the name that will show up when an item tooltip displays 'X [ClassName]'.

This should include the 'damage' part. Note that vanilla entries all start with a space that will need to be trimmed if used in other contexts.

◆ LocalizationCategory

virtual string DamageClass.LocalizationCategory
get

The category used by this modded content for use in localization keys. Localization keys follow the pattern of "Mods.{ModName}.{Category}.{ContentName}.{DataName}". The Localization wiki pageexplains how custom ModType classes can utilize this.

Implements ILocalizedModType.