Is it possible to make it so that a state, when inflicted, automatically cancels other states?

I would like to do it through the State directly, not a skill doing for instance:
Add State X
Remove State Y

More like, when (or if) the State X is inflicted, State Y is automatically cancelled.
I recall it was possible to do this on XP but not sure about MZ.
I might be wrong but I think you can just add a State Resist on that state for the one you want to have be cancelled?
LunarWingCloud is right, state resistance can actually cancel the resisted states. But the drawback is it is also resisting the state. So you can't have X cancels Y AND Y cancels X OR reapply Y.

I believe VS has a function to execute custom code when a state is applied. You can try to play around with that.
So you can't have X cancels Y AND Y cancels X OR reapply Y.

Yep, I'd like this exactly.
Eg:
Inflicting Wet cancels Burning.
But inflicting Burning cancels Wet.
And so on.
Yep, I'd like this exactly.
Eg:
Inflicting Wet cancels Burning.
But inflicting Burning cancels Wet.
And so on.
Sounds pretty doable to me, tbh. Apologies since I don't use MZ, but in MV you can just use a <Custom Apply Effect> note-tag and then add conditionals to check if x state is applied; if so, do x, else do y. Then it's just a matter of using target.addState(n); or w/e you want to happen. At least that's how I imagine it in my head lol. Unfortunately, I'm away from my PC atm so I'm not able to confirm this rn.
MZ it would be skill/state core's JavaScript Notetags: On Add/Erase/Expire
Thanks. I looked into it and this should be this:

<JS On Add State>
code
</JS On Add State>

Which code should I use to remove state X to the target?
Thanks. I looked into it and this should be this:

<JS On Add State>
code
</JS On Add State>

Which code should I use to remove state X to the target?
target.removeState(n);
edit: Again, apologies if MZ is different.

Original thread: https://forums.rpgmakerweb.com/threads/is-it-possible-to-make-it-so-that-a-state-when-inflicted-automatically-cancels-other-states.144331/