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:

Base damage * [1 + Weapon modifier/100 + (Head + Chest + Legs + Set bonus)/100 + (Accessory1 + Accessory2 + Acessory3 + Accessory4 + Accessory5 + AccMod1 + AccMod2 + AccMod3 + AccMod4 + AccMod5)/100]

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:

50 * [1 + 15/100 + (6+8+0+0)/100 + (15+12+10+12+10+4+4+4+4+4)/100]  = 50 * [1 + 15/100 + 14/100 + 79/100]   = 50 * [1 + .15 + .14 + .79]   = 50 * 2.08   = 104

Note: Damage always rounds to the nearest whole number, which alters modifiers' percentages accordingly. It rounds down for .5 damage or less and up for anything above .5 damage.

Damage dealt by a weapon is calculated with a few more variables but is always at least 1 for a successful hit. For critical hits:

(WpnDmgStat * Crit) - (def/2) +/- random modifier = Damage Dealt

If the attack fails the critical chance check:

WpnDmgStat - (def/2) +/- random modifier = Damage Dealt

The random modifier seems to be between 0 and 2. It seems to merely be there to add some variance in Damage Dealt and the Damage Stat of your weapon is thus an average of the possible Damage Dealt. You'll notice this is true because generally when you attack the same mob multiple times you'll get a different amount of damage dealt each hit. A maximum damage for a monster is 1253