Damage formula help

I'm looking for some possibly advanced damage formula help. I am trying to use the Damage Formulas 101 guide, but I can't seem to get it right. Here is what I have so far:

b.elementRate(23) >== 1 ? a.addState(67); (a.atk * a.atk / b.def * 2) : (a.atk * a.atk / b.def * 2)

What I want is to check if the enemy is weak to element 23, then the user of the skill gets state 67 if the enemy is weak. And I want the damage done to be the same either way. Basically, if the user hits an enemy weakness, they get a state added. Any advice? When I use the skill like this it just does 0 damage and no states are added.
b.elementRate(23) >== 1 ? a.addState(67),(a.atk * a.atk / b.def * 2) : (a.atk * a.atk / b.def * 2)

it could be as simple as replacing the ; but i haven't tested it.
b.elementRate(23) >== 1 ? a.addState(67),(a.atk * a.atk / b.def * 2) : (a.atk * a.atk / b.def * 2)

it could be as simple as replacing the ; but i haven't tested it.
That did not work :\
b.elementRate(23) > 1 ? a.addState(67) : a.atk * a.atk / b.def * 2;

I got this to check a weakness and add the state, but it doesn't do damage if the element is right. It only does damage when the enemy is not weak.
b.elementRate(23) > 1 ? a.addState(67) : a.atk * a.atk / b.def * 2;

I got this to check a weakness and add the state, but it doesn't do damage if the element is right. It only does damage when the enemy is not weak.
how about this?
if (b.elementRate(23) > 1) {a.addState(67)}; a.atk * a.atk / b.def * 2;
otherwise you could swap them around since there is a priority in how these are handled
a.atk * a.atk / b.def * 2; if (b.elementRate(23) > 1) {a.addState(67)};
That did not work. But good news, I got it to work 😀 I had to use 2 separate damage formulas - one for the state and 1 for the damage. So it ended up being:

b.elementRate(6) > 1 ? a.addState(67) : a.atk * a.atk / b.def; b.elementRate(6) > 1 ? a.atk * a.atk / b.def * 2 : a.atk * a.atk / b.def;

EDIT: Actually the first one DID work... I just didn't try it and I edited the second one... so I'm gonna use your code because it is simpler 🙂 Thank you!!!
Just a few pointers as to why your original formula didn't work:
Code:
b.elementRate(23) >== 1 ? a.addState(67); (a.atk * a.atk / b.def * 2) : (a.atk * a.atk / b.def * 2)

1 - >== is not a valid operator. == is the boolean "is equal to," and >= is the mathematical "greater than", but there's no such thing as >== - that made your code error out immediately.

2 - the ternary operator takes one command in each part. You can't put multiple statements separated by a semicolon. You could force this to work by putting the two statements with a comma in between, but the whole ternary thing is kinda pointless since you're using the same damage formula regardless. This also prevented your code from running.

3 - It didn't break your code, but these parentheses are meaningless. There's no reason to put parentheses unless you are grouping math contrary to the order of operations.

Original thread: https://forums.rpgmakerweb.com/threads/damage-formula-help.145591/