MZ Is there a way to change states with a skill?

So, my thing here is that I want a skill that deals extra damage if the enemy has a specific state and replaces it with another state.

The extra damage is done, but add that other effect is the hard part for me, I tried with the Damage Formula (breaks the whole damage thing) and the Common Events (the state instantly rids off for some reason)

I don't mind using plugins or not, just help me
it should be doable with both the damage formula and a common event without problems.
if that didn't work for you, then you made a mistake.

just post screenshots of your common event and/or the damage formula used, and we can tell you where you went wrong.
just post screenshots of your common event and/or the damage formula used, and we can tell you where you went wrong.
This is the damage formula that I made, but idk where to put the state thing (when I do it, the damage just say 0)

if (b.isStateAffected(37)) { a.mat * 8 } else { a.mat * 5 }
JavaScript:
var v; if (b.isStateAffected(37)) { v = a.mat * 8 } else { v = a.mat * 5 }; ; v
Put your state thing between those two ; at the end.
JavaScript:
var v; if (b.isStateAffected(37)) { v = a.mat * 8 } else { v = a.mat * 5 }; ; v
Put your state thing between those two ; at the end.
Like this?
Should I put something on the V?

JavaScript:
var v; if (b.isStateAffected(37)) { v = a.mat * 8 } else { v = a.mat * 5 }; b.removeState(37) b.addState(38) ; v

I'm asking in case to be wrong (I'm not too good on these ones)
That looks good. I'm not sure what you mean by "something on the V". Though, now that you mention it, it's probably bad for it to be a V, as that conflicts with the v[4] syntax for referencing variables. I'd change the V to something else.

JavaScript:
var damage; if (b.isStateAffected(37)) { damage = a.mat * 8 } else { damage = a.mat * 5 }; b.removeState(37); b.addState(38) ; damage
replaces it with another state
you might want to move the state 37 removal and state 38 application inside of the if for the target having state 37. the formula will always remove state 37 and will always add state 38 regardless of the target having state 37
Ohh, right, good point. That means you need to put it between the 8 and the }.
Ohh, right, good point. That means you need to put it between the 8 and the }.
you mean like this?

JavaScript:
var damage; if (b.isStateAffected(37)) { damage = a.mat * 8 b.removeState(37); b.addState(38) } else { damage = a.mat * 5 } ; damage
Yeah. I'd add another semicolon before it too, to be on the safe side.
FINALLY, IT WORKED!

Thank you so much for your help!

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-way-to-change-states-with-a-skill.178459/