Either an attack will be avoided or not... so if a defense is able to be used, just multiply the result by (n-1)/12, where n = the defense number or higher to avoid, to get the modified result.
Except the attack has double strike. The defense only works for the first strike. I'm trying to figure out the damage probabilities for the whole attack, not just the first strike.
don't use the doublestrike calculations but use the probabilities of each attack, add the damage values up and multiply their chances.
As DaveW mentioned: for the first attack you multiply each value given by the program with (n-1)/12 and for zero you additionally add (12-(n-1))/12.
The calculations are easy, but take some time to do and you should probably use excel.
For an extremely simple case: 1 die, no bonuses, doublestrike, 1 armor, defence 8+ (1 time use)
without defence:
0 damage --> 50%
1 damage --> 33,33%
2 damage --> 16.67%
For the first attack with defence this becomes:
0 damage --> 5/12 + 7/12*(0.5) = 70.833%
1 damage --> 7/12*(0.3333) = 19.444%
2 damage --> 7/12*(0.1667) = 9.7222%
Thus the chance for the entire attack:
Px(y): probability of attack x having y damage
0 damage: P1(0)*P2(0) --> 0.70833*0.5 = 35.4166%
1 damage: P1(0)*P2(1) + P1(1)*P2(0) --> 0.5*0.19444 + 0.3333*0.70833 = 33.33%
2 damage: P1(1)*P2(1) + P1(2)*P2(0) + P1(0)*P2(2) --> 0.3333*0.1944 + 0.1667*0.70833 + 0.5*0.09722 = 23.14%
3 damage: P1(1)*P2(2) + P1(2)*P2(1) --> 0.3333*0.09722 + 0.1667*0.19444 = 6.48%
4 damage: P1(2)*P2(2) --> 0.1667*0.09722 = 1.62%
35.4166 + 33.33 + 23.14 + 6.48 + 1.62 = 99.9866%. The difference is there due to bad rounding of the probabilities.
Average: 1.055 damage
variance: 0.593