Damage

Damage is the amount of health points subtracted from an entity's current health. It can be inflicted by a multitude of entities, most prominently weapons, enemies, and NPCs (and all related projectiles). Furthermore, it can be caused by environmental hazards (such as thorny bushes, traps, or lava) and game mechanics (such as fall damage, drowning, or debuffs). Damage can generally only be inflicted on entities with a health statistic, i.e., players, most enemies, and NPCs. Most damage sources additionally inflict knockback on the damaged entity.

When an entity receives damage, several calculations increasing or decreasing the amount of damage (depending on several factors; see below) are performed before the actual damage is applied to the entity. Therefore, the damage statistic of any damaging entity is usually only the average damage it inflicts. Most hits' damage deviates from this average number.

Damage inflicted by player-wielded weapons is categorized into five different types: melee, ranged, magic summon, and throwing. Accessories, buffs, and other damage-boosting or damage-decreasing effects often only affect one of these damage types. A few weapons as well as all other damaging entities are not categorized into any of the five types.

Melee
Melee weapons are used in close- to medium-ranged combat. Their defining trait is the fact that they do not consume ammunition or mana upon use. They are roughly categorized into swords, spears, flails, boomerangs, and. There are several other melee weapons not fitting any of these types.

In total, there are currently unique melee weapons.

Ranged
Ranged weapons are used in long-ranged combat. Their defining trait is the requirement of ammunition in order for the weapon to operate. They are roughly categorized into bows, repeaters, guns, and launchers. Note that Terraria classifies boomerangs as melee weapons and consumables as thrown weapons.

In total, there are currently unique ranged weapons. On the, the total number is only due to the differentiation of throwing weapons.

Magic
Magic weapons are used in medium- to long-ranged combat. Their defining trait is the consumption of mana upon every use. Due to their unusual and unique forms of attack, the majority of magic weapons can hardly be categorized into distinct types.

In total, there are currently unique magic weapons.

Summon
Summoning weapons include summon staffs and whips. Using a summon staff spawns a secondary character which will aid the player in battle by automatically attacking enemies. The summoned character is either mobile, i.e. following the player around (minion), or stationary, i.e. remaining at the location it was summoned at (sentry). Whips are close to mid range weapons which boost minion damage on hit enemies as well as marking them making minions focus on said enemies.

In total, there are currently unique summon weapons and 8 unique whips.

Throwing
Throwing weapons are used in medium-ranged combat. Their defining trait is the fact that they are generally consumed upon use. They stack in a player's inventory, with one unit being removed from the stack every time it is used to attack, leaving the slot empty when the last has been used. Many throwing weapons have a chance of being retrievable after being used.

Throwing is only considered a separate damage type on the. Throwing weapons deal ranged damage instead on the. In total, there are currently unique throwing weapons.

Player Invincibility
After being damaged, the player gets a period of time called an "invincibility frame" during which they cannot be damaged again. By default this is 2/3 of a second (40 ticks✅), but various equipment can extend this:


 * Use of a Cross Necklace or any of its upgrades will add another 2/3 of a second (40 ticks) after receiving any attack. (The Cross Necklace does not stack with its upgrades.)
 * If a Black Belt (or its upgrade the Master Ninja Gear, but the two do not stack) is worn, a successful dodge (10% chance) will trigger an invincibility frame and add another 2/3 seconds (40 ticks) to it. It also prevents damage from the attack (but not any debuffs associated with it). If combined with the Cross Necklace, this extends the invincibility to a full 2 seconds (120 ticks).
 * Hallowed armor similarly provides the Holy Protection buff; this is triggered by attacking an enemy, and when active, the next time the player would have taken damage, they instead get 2 seconds (120 ticks) of invincibility. This also stacks with the effects of the Cross Necklace and Black Belt, potentially granting 3 and 1/3 seconds (200 ticks) of invincibility.

Piercing Attacks against Enemies
Enemies get a similar but more limited effect from "piercing" and continuous attacks: Any damage source that can strike an enemy, and then remain able to cause damage afterwards.

After being struck by such an attack, the enemy cannot take damage from another such attack for a brief period, usually 1/6 of a second (10 ticks✅). Thus, when in lava or when pierced by a persistent weapon such as a Vilethorn, they can take damage at most 6 times a second. However, for multi-segmented enemies (usually worm types), this resistance applies to each segment separately, so such attacks can still strike multiple segments of a single enemy. (Note that worm-type enemies are immune to lava in any case.)

On the, this also applies to almost any missile, beam, or other attack which can pass through an enemy to strike other enemies behind it. This can sharply limit the effects of rapid-fire guns and bows, and those which fire multiple projectiles. Most minions are considered to have piercing attacks, which can also hinder the efficiency of piercing weapons used alongside them. This problem is remarkably present with the Spider and the Stardust Dragon Staves. A few advanced weapons have special behavior:


 * The Last Prism can attack 12 times per second instead of only 6.
 * Luminite Bullets do not cause such invulnerability frames, but do respect them when caused by other attacks.

Calculations
The damage that a player-wielded weapon deals upon hit is determined cumulatively:


 * Step 1: Apply weapon modifier
 * step1 = BaseDamage * (1 + WeaponModifier/100)


 * Step 2: Round to the nearest number
 * step2 = round(step1)


 * Step 3: Apply all other mods (Armor, Accessories, Accessory Modifier, Buffs) added up
 * step3 = step2 * [1 + (Head + Chest + Legs + Set bonus)/100 + (Accessory1 + Accessory2 + .. + Accessory5 + AccMod1 + AccMod2 + .. + AccMod5)/100 + (Buff1 + Buff2+ ..)/100]
 * Note, for ranged weapons the calculation is slightly different, the Arrow/Bullet/Rocket damage is multiplied with other mods (round down after each calculation), so it will be like this:
 * step3 = (step2 + Arrow/Bullet/Rocket) * [1 + (Head + Chest + Legs + Set bonus)/100 + (Accessory1 + Accessory2 + .. + Accessory5 + AccMod1 + AccMod2 + .. + AccMod5)/100 + (Buff1 + Buff2+ ..)/100]


 * Step 4: Round down
 * WeaponDamage = roundDown(step3)


 * Step 5: For Bows and Repeaters, the Archery Potion will additionally add 20% damage of them (round down after calculation).
 * WeaponDamage = roundDown(1.2*step4)

For example, Godly Dao of Pow with Turtle Armor, Menacing Warrior Emblem, Menacing Avenger Emblem, Menacing Destroyer Emblem, Menacing Mechanical Glove and Menacing Celestial Stone equipped, Well Fed active:

step1 = 63 * (1 + 14/100) = 71.82

step2 = round(71.82) = 72

step3 = 72 * [1 + (6+8+0+0)/100 + (15+12+10+12+10+4+4+4+4+4)/100 + (5)/100] = 72 * [1.98] = 142.56

WeaponDamage = roundDown(142.56) = 142

Careful: Only use the modifiers which have an influence on the specific weapon (e.g. don't use magic damage bonus for a melee weapon).

Damage done to an enemy is depending on the enemies defense and whether there is a related banner nearby.
 * EnemyDamageReduction = roundUp(EnemyDefense * 0.5)

So,
 * DamageDealtToEnemy = WeaponDamage - EnemyDamageReduction without a banner;
 * And DamageDealtToEnemy = 1.5*WeaponDamage-EnemyDamageReduction with a banner in normal mode,
 * Or DamageDealtToEnemy = 2*WeaponDamage-EnemyDamageReduction with a banner in Expert mode,

Damage dealt is always at least 1.

In addition the outgoing damage is modified by a random factor, 0.85~1.15, (but some types of damage, like the Slime Mount, will not be affected by this), The damage is rounded to the nearest whole number. So you can compute the minimal and maximal damage dealt to an enemy with your weapon:
 * MinDamage = round(WeaponDamage * 0.85 - EnemyDamageReduction)
 * MaxDamage = round(WeaponDamage * 1.15 - EnemyDamageReduction)

At critical hits you are dealing double damage
 * CriticalMinDamage = MinDamage * 2
 * CriticalMaxDamage = MaxDamage * 2