First off, I tried:
a.mdf >= (Math.randomInt(20) + 1 + b.luk) ? 4 + b.addState(14) : 4
this works if i just have numbers and no state, otherwise this returns 0 for me
I tried using b.addstate(14), and it did not apply state. I tried b.addstate(14); 100 and it gave me damage, but no state
Are you trying to apply the state to the actor or the enemy that is targeted?
If your trying to add it to the enemy then why not use the Effects, Add state option?
This is one will add the state to the actor (user) then deal damage to the enemy.
a.addState(29); a.atk * 1.2 - b.def
The damage formulas are designed only to read a value, not to do anything. While it might be possible to do something as you wish, misuse of a functionality is never a good way.
The conditional operator condition ? ifTrue : ifFalse is only for single-statement operands. For multiple statements, use a full if (condition) { ifTrue } else { ifFalse } block, e.g.
if (a.mdf >= Math.randomInt(20) + 1 + b.luk) { b.addState(14); 4 } else { 4 }
Since the result is always 4, though, this can be simplified:
if (a.mdf >= Math.randomInt(20) + 1 + b.luk) { b.addState(14); } 4
Note: if an actor with the Autobattle trait has this skill, the formula will be evaluated whenever they consider using it. This is one reason the skill formula box should generally only be used to calculate the damage/heal value, rather than do things (e.g. apply a state).
[Edit: corrected a.addState -> b.addState.]
Great! Happy RPG Making~ 😂