Damage

Damage types are categorized into melee, ranged, magic weapons and since 1.2, summoning weapons. Different armor types and consumables provide bonuses for different types of weapons, summarized below.

Melee
Melee is a type of close ranged attacks. All melee weapons have no usable ammo. All melee weapons (with the exception of throw/spin and beam generating weapon types) attack with the player fairly close to the target.

Ranged
Ranged is a type of far ranged attacks. All ranged weapons (with the exception of the harpoon and the Piranha gun) have usable ammo. All ranged weapons attack with the player far away from the target.

Consumable Weapon Type
Consumable weapon types are a closer form of ranged weapons. They are usually a thrown weapon type that don't go as far as bullets

Magic
Magic is a special weapon type that has multiple different magical effects. Magic weapons require mana to be used. Some, such as the Rainbow Rod cast a controllable projectile. Others cast a spread of projectiles.

Summon
Summon is a relatively new type of damage dealt by summoning weapons such as the Pygmy Staff, Hydra Staff, Slime Staff, and Raven Staff. Summoning damage was introduced with the advent of the 1.2 update. The emergent nature of Summon damage makes it rather quirky compared to all the other damage types; The damage comes specifically from summoned creatures (minions) which function like pets but are able to deal damage and often have knockback. An item that increases summoned creature damage will benefit these items. Unlike the other damage types, this style is still fairly underdeveloped, and therefore subject to lack of support; for example, there isn't an emblem dedicated specifically to Summoning (though the Hercules Beetle gives the same damage benefits as well as increased knockback), and there are only four sets of armor that affect Summon damage, including Bee Armor, Spider Armor, Tiki Armor, and Spooky Armor.

Calculations
A weapon's damage stat is determined cumulatively such as:


 * 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 * [(Head + Chest + Legs + Set bonus)/100 + (Accessory1 + Accessory2 + .. + Accessory5 + AccMod1 + AccMod2 + .. + AccMod5)/100 + (Buff1 + Buff2+ ..)/100]


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

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 = 49 * (1 + 14/100) = 55.86

step2 = round(55.86) = 56

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

WeaponDamage = roundDown(110.88) = 110

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. Damage dealt is always at least 1.
 * DamageDealtToEnemy = WeaponDamage - (EnemyDefense/2)

In addition the outgoing damage is modified by a random factor e.g. for Flairon from probably between 0.85 and 1.15 (+- 15% damage, probably uniform distribution) at each hit (not the same for each weapon). 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:
 * FlaironMinDamage = round(WeaponDamage * 0.85 - (EnemyDefense/2))
 * FlaironMaxDamage = round(WeaponDamage * 1.15 - (EnemyDefense/2))

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