Defense

Defense is a statistic that determines the decrease in damage taken per hit. The player's defense can be increased by wearing armor and accessories, and temporarily boosted by various buffs, tile entities, and permanent upgrades. Damage taken by players is reduced by half / / of their defense, rounded down. Enemies also have a defense statistic.
No hit can be reduced below 1 damage, regardless of defense (with the exception of a player whose multiplayer ally is wearing a Paladin's Shield).
Some forms of damage are impossible to reduce through defense, e.g. damage from health-draining debuffs like Cursed Inferno or from drowning in water. Damage taken from lava, however, can be reduced through defense.
== Players ==
Defense gives a flat reduction in damage, i.e. damage is reduced by a fixed amount per hit (as opposed to a multiplicative damage reduction, which would reduce damage by a percentage). It is calculated after the general damage randomization. 
The formula is:net dmg = ⌊attack dmg - def × factor⌋, where factor is 0.5 in Classic Mode, 0.75 in , and 1 in .
=== Examples ===
Atk. dmg	Def.	Net damage	Net damage	Net damage
Atk. dmg	Def.	Classic 	Expert 	Master
40 	20 	30 	25 	20
40 	30 	25 	17 	10
75 	20 	65 	60 	55
75 	30 	60 	52 	45
== Enemies ==
Enemies have a defense statistic just like players do, but they do not gain more protection from defense in Expert Mode or Master Mode. They will always reduce incoming damage by 50% of their defense: net dmg = ⌊attack dmg - def × 0.5⌋.
Critical hits against enemies will double the net damage value. In other words, the crit damage multiplier is taken into account after the attack's damage has already been reduced by defense.
=== Examples ===
Weapon		 	 	
 		1	1	1
 		 	 	
== Boosts ==
=== Armor and accessories ===
A player's defense score can be increased by equipping armor and accessories. Armor usually consists of three items, granting an additional bonus if all pieces match, the set bonus, which may increase the defense score further. Some accessories grant direct defense boosts (see the following table), but all accessories can also be reforged to a maximum of +4 defense per accessory.
See armor for detailed defense information about every piece of armor.
Item	Acc. defense
Item	Accessory defense
 	3
 	3
 	4
 	4
 	4 7
 	0 30
=== Buffs and debuffs ===
Buffs and debuffs can temporarily alter a player's or an enemy's defense. Currently, there is no buff increasing enemies' defense. A player's defense cannot be reduced to fall below 0.
Buff/Debuff	Buff/debuff defense
 	2
 	3
 	4
 	5
 	8
 	8
 	−4
 	−4
 	/
 	−40
 	
== Armor penetration ==
Armor penetration is a hidden player statistic that determines the amount of the enemy's defense portion that is ignored when dealing damage to it. For instance, a Pixie normally has defense. If the player has the Shark Tooth/Stinger Necklace equipped, then the Pixie will be taken to have defense instead.
The following items grant armor penetration:
Item	Item	Armor penetration
 	12 	
In addition, the projectiles of certain weapons and accessories have their own armor penetration stat, which is added to the player's armor penetration when inflicting damage upon an enemy with them:
Item	Item	Armor penetration
 	25 	
 	50 	
 	30 	
 	25 	
 	10 	
 	10 	
 	10 	
 	25 	
 	20 	
 	10 	
== Maximum defense ==
The highest possible defense can be attained using the setups described in the following sections.
On , the maximum possible defense is 186 / / , while on , it is 181 / / . The setups are the same:
=== ===
The maximum possible defense is 165 / :
=== ===
The maximum possible defense is 128:
== Trivia ==
* Although not possible in-game, if a piece of armor were to gain a modifier, it would apply the effects just like an accessory would. For example, a set of Warding modified armor would add 12 defense total; each piece adding 4 defense to the total.
* Damage dealt by enemies is doubled in and tripled in compared to normal mode. This means that despite the higher factors of defense in those modes, defense is still generally less effective than in normal mode.
* If the player somehow has negative defense, they will take more damage according to the damage taken added with half / / amount the defense.
== See also ==
* Damage reduction
== References ==