All of the information presented below is gathered and derived from the stated rules found in Chapter 9: Combat, of the Player's Handbook for 5th Edition D&D, starting with page 189. Any additional rules (or effects, like from spells) cite their origin.
Attack Bonus
There are four parts that get added together:
- Your Ability Modifier
- For most Melee weapons, this is Strength; for most Ranged weapons, this is Dexterity; for attack-roll spells, this is your Spellcasting Ability (typically Intelligence, Wisdom, or Charisma)
- The notable exception to this rule is the Finesse property, which when found on a weapon explicitly allows you to choose between Dexterity or Strength when you choose to make the attack, and use the same modifier for the Damage roll as well. In the core game, this property only appears on Melee Weapons.
- Also, thrown weapons typically count as melee weapons, even if they may be used at range; check the weapon's statblock for possible exceptions to this rule.
- Another notable exception is special class features or spells that allow alternative ability modifiers. For example, a Druid casting Shillelagh [Player's Handbook, 275] gains the ability to use Wisdom for both their attack and damage, instead of Strength or Dexterity, but only on certain weapons.
- Similarly, a Hexblade Warlock [Xanathar's Guide to Everything, 55] uses Charisma instead of Strength or Dexterity for their weapon attack and damage rolls, provided the weapon they're using matches the requirements of their Patron.
- Your Proficiency Bonus
- This applies if you have proficiency in the weapon. Simple as that. For Martial classes like Fighters, Barbarians, or Paladins, they gain proficiency in every single weapon in the game, meaning they always get their Proficiency Bonus. For other classes, you need to check the proficiencies their class grants.
- There are also, theoretically, "Exotic Weapons" which no class gains proficiency in by default, and for which a character would not receive their proficiency bonus unless they gain proficiency in it through some means; the core game does not contain any such weapons though.
- For spells, you nearly always have proficiency in spellcasting, and therefore gain this bonus. There may be a few edge cases where this might not be true, but they are rare and only worth mentioning as a curiosity.
- Special modifiers on the weapon itself
- Some magic weapons confer bonuses to the Attack Roll, Damage Roll, or Both. A +1 Weapon [DMG, 213], for example, confers a +1 bonus to both rolls.
- Buffs/Other Effects
- The spell Bless [PHB, 219], for example, adds a d4 roll to any attack roll the target makes.
So for example, a level 5 Fighter wielding a +1 Rapier (has the Finesse property), with a Strength Score of 16 and a Dexterity of 18, would have the following bonus for their Attack Roll:
- Ability Modifier: +3 if they use Strength, or +4 if they use Dexterity
- Proficiency: Fighters gain proficiency in Rapiers, so +3 for a Level 5 character
- Magic Weapon: Weapon is a +1 Rapier, so +1.
- Total: +7 with Strength; +8 with Dexterity
Damage Bonus
- Your Ability Modifier
- Same as above: Strength for melee, Dexterity for Ranged, Strength or Dexterity for weapons that have the Finesse property (though it must be the same ability that was used to make the attack roll), Intelligence/Wisdom/Charisma for features that allow this modifier to be replaced by a different stat.
- Spells do NOT gain this damage bonus unless the character has a specific feature that allows their spells to benefit, like the Evocation Wizard [PHB, 117] or the Agonizing Blast Warlock feature [PHB, 110]; or if the spell specifically says so, like with Green Flame Blade [Sword Coast Adventurer's Guide, 143] specifically saying that you are allowed to add your spellcasting modifier to the damage produced by the spell.
- NOT your Proficiency Bonus
- You never add your Proficiency Bonus to your damage rolls, even if you have proficiency in the weapon or spell. The only exception is if you have a class feature, or a feature obtained from some other source, that says so. For example, Necromancy Wizards have a class feature, Undead Thralls [PHB, 118] that allows their summons (specifically those created by necromancy magic) to add the wizard's proficiency bonus to their damage rolls.
- Special Modifiers
- Some magic weapons confer bonuses to the Damage Roll, Attack Roll, or Both. A +1 Weapon [DMG, 213], for example, confers a +1 bonus to both rolls.
- Buffs/Other Effects
- For example, the spell Divine Favor [PHB, 234] allows the target to add 1d4 Radiant Damage to all their Damage Rolls produced by Weapon Attacks.
So using the Fighter example from above, assuming they took the Dueling Fighting Style (which confers a +2 bonus to Damage rolls when a character is not wielding more than one weapon and only wields that weapon in one hand), their Damage Bonus would be:
- Ability Modifier: +3 if they use Strength, or +4 if they use Dexterity
- Magic Weapon: +1
- Buffs/Other Effects: The Dueling Fighting Style adds +2 to damage rolls for one-handed weapons if the character is not wielding another weapon, so +2
- Total: +6 for Strength; +7 for Dexterity
Note that for damage, Proficiency was explicitly not added. Proficiency is generally not added to damage rolls unless some feature expressly says it should.
Additionally, it is important to remember that with Finesse weapons, the fighter has the choice of which modifier to use, but they have to use the same modifier for both attack and defense. So they could not, for example, choose to use Strength for the Attack roll and Dexterity for the Damage roll.
A few other Examples
- Level 5 Wizard casting Fire Bolt, Intelligence 18
- Attack Roll: 1d20 + 4 (Intelligence) + 3 (Proficiency) == 1d20 + 7
- Damage Roll: 2d10 (Firebolt)
- Level 10 Evocation Wizard casting Fire Bolt, Intelligence 20
- Attack Roll: 1d20 + 5 (Intelligence) + 4 (Proficiency) == 1d20 + 9
- Damage Roll: 2d10 (Firebolt) + 5 (Intelligence, Empowered Evocation [PHB, 117])
- Level 13 Rogue wielding a Longsword, Dexterity 20, Strength 10
- Attack Roll: 1d20 + 0 (Strength) + 0 (Non-Proficiency) == 1d20
- Damage Roll: 1d8 (or 1d10 if wielding with two hands) + 0 (Strength) == 1d8 or 1d10
- Level 13 Rogue wielding a Rapier, Dexterity 20, Strength 10
- Attack Roll: 1d20 + 5 (Dexterity) + 5 (Proficiency) == 1d20 + 10
- Damage Roll: 1d8 + 5 (Dexterity) + 7d6 (Sneak Attack for Finesse Weapon and having an adjacent ally) == 1d8 + 5 + 7d6