How to use if statements for damage formulas

I wanted to create a skill that deals damage that can be reduced by the enemy's defense, but if the user is faster than the enemy, the damage ignores their defense. Below is what I have so far, but it deals 0 damage on enemies that are slower than me, although it seems to work on enemies that are faster than me.

Code:
a.agi > b.agi ? 50 + (0.4*a.atk)*(0.8*a.agi) : (50 + ((0.4*a.atk)*(0.8*a.agi)) / b.def
You have a syntax error, mismatched brackets. (6 (, 5 )). Try this instead?
JavaScript:
a.agi > b.agi ? 50 + 0.4 * a.atk * 0.8 * a.agi : (50 + 0.4 * a.atk * 0.8 * a.agi) / b.def
You could also simplify 0.4 * 0.8 to 0.32 if you want.
I think it's because you're missing a parenthesis in your formula:

Code:
a.agi > b.agi ? 50 + (0.4*a.atk)*(0.8*a.agi) : (50 + ((0.4*a.atk)*(0.8*a.agi)) / b.def

( 50 + ( (0.4 * A.ATK) * (0.8 * A.AGI) ) / B.DEF

The parenthesis before 50 doesn't have a closing one.

Also ninja'd.
You may find this useful.

Yep it was the parenthesis. Thanks for catching that.
This thread is closed due to being solved. If you need it reopened, let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-use-if-statements-for-damage-formulas.168895/