Been reviewing and searching google for a couple days watching videos and reading the different damage formula tutorials to no avail. I have been able to get most of the formula to work but whenever I try and add the if greater than b.def then else clauses it just goes to 0.
Goal: Roll a D20 + attack-10/2+Level/2 if greater than enemies defense (ac) then roll damage 1d4 +attack-10/2 +level/2 else 0
b.def >= Math.randomInt(20)+1 ((a.atk-10)/2) + ((a.level/2)) ? (Math.max((Math.random()*3) + 1 + ((a.atk–10)/2) + (Math.floor(a.level/2)))) : 0;
tried
b.def <= (Math.max((Math.random()*19) + 1 + ((a.atk-10)/2) + (Math.floor(a.level/2)))) ? (Math.max((Math.random()*3) + 1 + ((a.atk–10)/2) + (Math.floor(a.level/2)))) : 0 ;
Separately.
Tested and works fine rolling a D4
(Math.max((Math.random()*3) + 1 + ((a.atk-10)/2) + (Math.floor(a.level/2))))
Tested and works fine rolling a D20
(Math.max((Math.random()*19) + 1 + ((a.atk-10)/2) + (Math.floor(a.level/2))))
Just need the result of the D20 to compare with the defense of the enemy and if it fails then "miss" if not activate the D4 roll.
Thanks for your help. Apologies as I would assume that is easily answerable but I feel like I had used enough time searching before posting.
Goal: Roll a D20 + attack-10/2+Level/2 if greater than enemies defense (ac) then roll damage 1d4 +attack-10/2 +level/2 else 0
b.def >= Math.randomInt(20)+1 ((a.atk-10)/2) + ((a.level/2)) ? (Math.max((Math.random()*3) + 1 + ((a.atk–10)/2) + (Math.floor(a.level/2)))) : 0;
tried
b.def <= (Math.max((Math.random()*19) + 1 + ((a.atk-10)/2) + (Math.floor(a.level/2)))) ? (Math.max((Math.random()*3) + 1 + ((a.atk–10)/2) + (Math.floor(a.level/2)))) : 0 ;
Separately.
Tested and works fine rolling a D4
(Math.max((Math.random()*3) + 1 + ((a.atk-10)/2) + (Math.floor(a.level/2))))
Tested and works fine rolling a D20
(Math.max((Math.random()*19) + 1 + ((a.atk-10)/2) + (Math.floor(a.level/2))))
Just need the result of the D20 to compare with the defense of the enemy and if it fails then "miss" if not activate the D4 roll.
Thanks for your help. Apologies as I would assume that is easily answerable but I feel like I had used enough time searching before posting.