tModLoader v2024.08
A mod to make and play Terraria mods
NPC.HitInfo Struct Reference

Represents a finalized damage calculation for damage about to be applied to an NPC. This is the result of the all modifications done previously in a HitModifiers. More...

Public Attributes

bool Crit = false
 Whether or not the hit is a crit
 
DamageClass DamageType = DamageClass.Default
 The DamageType of the hit.
 
bool HideCombatText = false
 If true, damage number popups will not be shown for this hit.
 
int HitDirection = 0
 The direction to apply knockback in.
 
bool InstantKill = false
 If true, as much damage as necessary will be dealt, and damage number popups will not be shown for this hit.
Has no effect if the NPC is NPC.immortal
 
float Knockback = 0
 The amount of knockback to apply. Should always be >= 0.
Note that NPC.StrikeNPC(HitInfo, bool, bool) has a staggered knockback falloff, and that critical strikes automatically get extra 40% knockback in excess of this value.
 

Properties

int Damage [get, set]
 The amount of damage received by the NPC. How much life the NPC will lose.
Is NOT capped at the NPC's current life.
Will be 1 if InstantKill is set.
Cannot be set to less than 1.
 
int SourceDamage [get, set]
 The amount of damage 'dealt' to the NPC, before incoming damage multipliers, armor, critical strikes etc.
Use this to trigger effects which scale based on damage dealt, and also deal damage.
Cannot be set to less than 1.

Using this instead of Damage can prevent diminishing returns from NPC defense, double crits, or excessively strong effects if the NPC has a vulnerability to the weapon/projectile (like vampires and stakes).
Used by vanilla for dryad ward retaliation, and many sword on-hit projectiles like volcano and beekeeper
 

Detailed Description

Represents a finalized damage calculation for damage about to be applied to an NPC. This is the result of the all modifications done previously in a HitModifiers.