Advance Damage formula - addstate

I was not sure where to post this question.
I am trying to use the Damage Formula to apply a state if the condition is meant.
Like so.
b.mdf > 7 ? 0 : addState(57)
But I believe this is a MV thing and not an Ace thing.
Basically what I am doing is: Charm Person. If the target has 7 or lower Wisdom(MDF) that target is charmed.

Although this is working fine.
b.mhp > 100 ? 50 : 100
If the target has 100 or more MaxHP than the target will only take 50 damage.
How do I add states in this way?
Code:
if b.mdf <= 7; b.add_state(57); end; 0
How do I add states in this way?
Damage formulas normally refer to Game Battler. And in such you have to specify which battler you are referring to.
a = actor
b = enemy
And it would be reverse for the enemy.

and TheoAllen has the answer for you
Code:
if b.mdf <= 7; b.add_state(57); end; 0
Thank you very much.
stay safe.
Hello, this is a splendid idea and I am looking to do this very same thing, however it doesn't appear to be working for Me.

I've been typing it as;
a.atk * 4 - b.def * 2 if b.b.def <= 7; b.add_state(2); end; 0

And putting it in the Formula box even tried it in the Note box but nothing works.
First of all, I missed that this is a necro post,
Second,
I normally would do those like this.
dam = a.atk * 4 - b.def * 2; if b.def <= 7; b.add_state(2); else dam = 0; end; dam

This seems to be what you want. Do damage if the def <= 7 and add state.

Remember the end has to be the formula a.atk * 4 - b.def * 2. So if you put that into a local variable then you just specify that local variable at the end. but set it to zero if the condition is not true.
Many Thanks, Roninator2.
and I apologize for Necroposting.

Original thread: https://forums.rpgmakerweb.com/threads/advance-damage-formula-addstate.121907/