Damage formula doesn't work

Hello I'm desperately trying to get the skill with the following damage formula to work:

if(b.isStateAffected(11)){$gameVariables.setValue(137, 90);}(a.atk * 5 - b.def * 2 + v[137])

If the battler is inflicted by state 11, the damage should be +90.
The if case seems to work properly, but what doesn't work is the actual formula itself.
If state 11 is not inflicted the damage output will be "0" if it is, the damage is much lesser than expected.

So it seems that the bold hightlighted part of the formula doesn't work:
if(b.isStateAffected(11)){$gameVariables.setValue(137, 90);}(a.atk * 5 - b.def * 2 + v[137])

It uses only the "+v[137]" I really don't know why.
Unless you need to remember the bonus damage later on, it's much easier just to use a ternary operator:
Code:
a.atk*5 - b.def*2 + (b.isStateAffected(11) ? 90 : 0)
If that gives you the same problem we can start digging deeper.
If you are not using Yanfly Action Sequences, then the main problem is that the damage formula only uses the first line.

A way to get around that would be
if(b.isStateAffected(11)){
a.atk * 5 - b.def * 2 + 90;
}else{ a.atk * 5 - b.def*2; }
Many Thanks, now i remember I did have problems with battle formulas in the past regarding this, I will use the YanFly Plug-in.

Original thread: https://forums.rpgmakerweb.com/threads/damage-formula-doesnt-work.94668/