State that gradually decays on evasion, counterattack?

Hello, 

 I am currently working on a project where I would like to have a state that evades the next two attacks directed at

the user. I was wondering if there was a way it could be scripted for a state to gradually decay with the number of

times an actor evades? While on the topic it would be great to have the same option available for a state that adds 

counter rate to an actor.
Just to be absolutely clear -

You don't want this high evasion for 2 turns, but for 2 attacks targeted at that specific actor.  From what I've read about how damage is calculated, I think having it for 2 attacks from any enemy in a troop which may be several turns apart is going to be very difficult/impossible, but I could be wrong.

You ask for it to decay with the number of times an actor evades.

You need to specify what 'decay' means precisely.  e.g. do you mean that the percentage chance of this state working decreases?  If so, at what rate?  Or do you mean that it changes from 2 hits to one hit?  Is it only for this state's evasion, or for all that actor's evasions, including the ones automatically generated by the EVA stat?

You also say that it should be based on the number of times an actor evades.  How many is the number?  Does it start decaying after two evasions? Ten?
  You are correct. I was hoping to have the state erase after two attacks directed at the actor, not in two turns. By gradually decay I simply meant the number of times to evade going from 2 to 1 to 0 upon being attacked. 

  What I would ideally like to have is a scenario where a tank style class is using a move rotation revolving around target rate increase, guaranteed evasion for 2 attacks, and guaranteed counter for 2 attacks. It seems impossible to separate counter and 

evasion in this sense, or even have a state that erases on this conditions of evade or counter without scripting. 

  If that is not possible, just having a probability for a state to be erased upon being targeted, not taking damage, would be the 

next best thing I could think of. It would have a sense of randomness to it, but it would more or less be retaining the original idea behind the class.

 Thank you so much for the interest in this issue that I am having.

Edited to say the original plan was to have the state give 100% evasion, until the actor has evaded two times. After those two dodges 

had occurred, the actor would return to their original evasion rate as the state would have worn off. So there would be no need to differentiate between the states evasion rate and the actors base, as you were asking earlier.

Also, I found this script that removes states based on a number of times being hit. If there was a way to change that to number of times being targeted, that would solve the problem quite easily.

http://pastebin.com/GhUE2bNK

-----------------------

I was thinking, maybe running a random variable triggered common event with all enemy physical attacks would be an efficient way to remove the state 50% of the time, but I am not sure how to 

create a damage formula that would check target id before running the common event. I am sure this is much easier to do, and although it isn't the ideal solution, it would work for me.

-----------------------

Original thread: https://forums.rpgmakerweb.com/threads/state-that-gradually-decays-on-evasion-counterattack.41199/