Add a state to a player if they attack an enemy

I looked around a bit and I'm not sure how to word it, so maybe that's why i can't find anything, but is there a way to have an enemy have a state, which then, in turn, gives a different state to the player if they attack the enemy in battle?

For example, an enemy would have a poisonous state, which if you attack, has a chance, (or certainty) to inflict the poisoned state on you.

-Thanks
I have a plugin that does this; if no-one else posts another way I could clean it up and post it for others to use. It might be a little more than what you need, perhaps, but I did use it to make the disease state infectious.
b.isStateAffected(x) ? a.addState(y); damage formula : damage formula

Add this to damage formula for the attack skill. this is simple but probably only feasible if you just want the normal attack skill to have the effect.

If you would like potentially any skill to have this effect it would more efficient to use a plugin maybe.
Yeah, I was considering whether to mention that as an alternate option. However, your syntax is wrong. It would be more like this:

JavaScript:
b.isStateAffected(x) ? a.addState(y) : void(); formula

Or:

JavaScript:
if(b.isStateAffected(x)) a.addState(y); formula

Basically, you can't put a semicolon ( ; ) in the middle of a ternary if statement ( ? : ) under any circumstances.
Oops, thanks
Thanks, guys the formula worked perfectly!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/add-a-state-to-a-player-if-they-attack-an-enemy.124226/