So I am trying to implement DnD style dice rolls into damage calculation, and the formula I have works, except for one slight issue that I cannot seem to figure out. I have implemented a multiple hits system into the formula as well, but it doesn't appear to be working. I still do damage, even if I hit 0 times. Here is the formula:
V[1] = 1st 1d20
V[2] = 1d8
V[3] = 2nd 1d20
V[4] = # successful hits
V[1] = 1st 1d20
V[2] = 1d8
V[3] = 2nd 1d20
V[4] = # successful hits
Code:
v[1] = Math.floor(Math.random() * (21 - 1)) + 1; v[2] = Math.floor(Math.random() * (9 - 0)) + 0; for(i = 0; i < Math.floor(a.agi / 16) + 1; i++) { v[3] = Math.floor(Math.random() * (21 - 1)) + 1; if(v[3] >= 8) { v[4] = v[4] + 1; } } if(v[1] + (a.atk / 4) >= b.def) { ((v[2] + a.atk / 4) - b.def) * v[4]; } else if(v[1] + (a.atk / 4) < b.def) { 0; } else if(v[1] = 1) { 0; } else if(v[1] = 20) {v[4] = Math.floor(a.agi / 16) + 1; (v[2] + a.atk / 4) * v[4]; }