How to make a contagious state?

When an enemy is inflicted with the state

An actor attacks with the normal attack skill

Then I would like the actor to also get the state because he "touched" the infected enemy.

I tried Yanflys Damage formular:

<damage formula>

if (target.isStateAffected(7)) {if (target.result().missed) {} else {battler.addState(7)}}

</damage formula>

It works, however it is always applied if an infected enemy is hit, even if the attack missed. Anyone know how to solve this...?!
I think it should be (user.result().missed || user.result().evaded), then add state to the user by using user.addState(7).
Thank you! It works now.

One other thing, maybe I can ask directly here:

When I inflict an enemy with a state, he should have that state for 2 turns.
When I use the same skill again, he gets inflicted another time, so 2 additional turns will be added. He will have this state for 4 turns now.

Is there a way to prevent the states to add up? It should be only 2 turns, no matter how many times the inflicting skill is used on the enemy...
Are you using Yanfly's Buffs & States Core? If yes, go to plugin parameters, set Reapply Rules to 1 or 2 (Choose one which fits your game design most). There are also three note tags to control reapply rule of a state:
<Reapply Ignore Turns>: State turns will neither be reset nor added when applying the same state.
<Reapply Reset Turns>: State turns will be reset when applying the same state.
<Reapply Add Turns>: State turns will be added when applying the same state.
Are you using Yanfly's Buffs & States Core? If yes, go to plugin parameters, set Reapply Rules to 1 or 2 (Choose one which fits your game design most). There are also three note tags to control reapply rule of a state:
<Reapply Ignore Turns>: State turns will neither be reset nor added when applying the same state.
<Reapply Reset Turns>: State turns will be reset when applying the same state.
<Reapply Add Turns>: State turns will be added when applying the same state.
thank you!!! <3

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-a-contagious-state.86662/