First, roll 1d12.
(Why a d12? Because d12s are cool, and they aren't used nearly enough. Stick with a d6 if you must, it doesn't really make any difference.)
Then modify the roll as follows:
- ± AC score
- ± DEX modifier
- ± any magical bonus/penalty for armour
Three modifiers to a roll are too many for regular off-the-cuff calculation, in my opinion. But in this case they'd generally only have to be worked out once and noted on one's character sheet.
If you wanted to go that way, you could also build in modifiers for long/short/heavy/light weaponry as well, though that might start getting a bit convoluted.