Regarding Yanfly Buffs & States Core

(Plugin in question found here):


Is anyone aware of a way to use this plugin to allow for the creation of a state used by the user to be removed after the action of an opponent is taken? The concept I have in mind is an evasion skill that, when used, grants 100% evasion for the next incoming attack onto the one with the state on them, but also to have it be removed as soon as that happens.
You could add a state (State B ) to the opponent that is removed after one action, and have the remove effect be to remove all instances of the original state (State A) from the user. Though this only works if only one actor can use the skill.
Can you give me more detail about your skill and states? I think i can help you. As far as i know, you just want your target to gain a state with +100% Evasion but also remove it after the first attack, regardless if it is a hit or missed/evaded one, right?
I want the user of the skill to be granted 100% evasion. Then, when an opponent targets you for an attack, you will evade it. IMMEDIATELY after you evade, the state is removed, or, if it lasts for 2 or more evaded attacks, it counts down and is removed when all "charges" are removed.
(if the difference in doing that is significant, let's just work on getting it to work once)

Example:
>You use Evasion.
>enemy attacks, hits another party member.
>effect persists because user was not targeted
>you attack
>enemy attacks you this time
>you evade the attack
>the state is now removed, as it's expiration condition has been met

Also, yes, the effect will be removed after the attack is evaded, so it'd be removed regardless of whether the attack lands or not, since in this case, it wouldn't.
Okay i get it. This is very simple since you are using Yanfly's Buffs & States Core.
For your Evasion state, if you want your state to be removed only after 1 attack, simply put this piece of codes below into the state's note box:
Code:
<Custom Deselect Effect>
target.removeState(x); //Change X into your Evasion state ID.
</Custom Deselect Effect>
If you want it to be removed after 2 or 3 (3 for example) attacks, i have another piece of codes for you:
Code:
<Custom Apply Effect>
user._attackCount = user._attackCount || 0;
</Custom Apply Effect>

<Custom Deselect Effect>
target._attackCount += 1;
if (target._attackCount >= 3){
target.removeState(x); //Change X into your Evasion state ID.
target._attackCount = undefined;
}
</Custom Deselect Effect>

<Custom Remove Effect>
user._attackCount = undefined;
</Custom Remove Effect>
Thank you very much sir. I had actually figured out which tags to use (that is, I knew I needed "custom deselect effect"), but idk the code, so I had no idea what went in between, lol.
Hmmm..... neither one seems to work. If I use the first one, the skill is activated, but no state is ever applied. If I completely remove the note tags, it works fine, however it obviously lacks the proper removal timing. If I use the longer one, the state is applied, but it doesn't do anything, as if it's effects are entirely negated. Here's a screenshot of the setup (the code is just copy/pasted from what you said, with the X changed to the state ID)
Spoiler
My apologies! I have just forgotten about Deselect. Right after you apply the state, it counts as a hit and will remove that state via "target.removeState(x)". Looks like i gotta change it a bit.
Here is the 3-attack one:
Code:
<Custom Apply Effect>
target._attackCount = target._attackCount || 0;
</Custom Apply Effect>

<Custom Deselect Effect>
target._attackCount += 1;
if (target._attackCount >= 4){ //Why 4? Because like i said, when you apply your state, it counts as the first hit so we have to set it 4 for 3 other hits
target.removeState(x); //Change X into your Evasion state ID.
target._attackCount = undefined;}
</Custom Deselect Effect>

<Custom Remove Effect>
target._attackCount = undefined;
</Custom Remove Effect>

And about the 1-attack one, just change the 4 in "if (target._attackCount >= 4)" into 2.
Excellent, it works now! But it doesn't seem to count down turns (set it to 2, had it go off 5 times)
I have tested mine and it works fine. The state is removed after a hit. Did you forget to change X into your state ID?
I did not, which unfortunately must means there's another problem somewhere with a plugin...... great, those are never fun to troubleshoot
Here is my state's Note tag in case you want to compare:
Code:
<Custom Apply Effect>
target._attackCount = target._attackCount || 0;
</Custom Apply Effect>

<Custom Deselect Effect>
target._attackCount += 1;
if (target._attackCount >= 2){
target.removeState(28); 
target._attackCount = undefined;
}
</Custom Deselect Effect>

<Custom Remove Effect>
target._attackCount = undefined;
</Custom Remove Effect>
Still not working, could it have anything to do with the duration in turns that I set? I would imagine it would've just overwritten that, am I supposed to set it to 0 0?


From what I can see, there are no plugin incompatibilities, I turned off every other plugin that even mentions "state" that ISN'T a yanfly plugin, and it still isn't working. Well, it's working, but it isn't removing after the first attack against the user.
I don't think it is about the duration in turns. My state also had 4-turn duration, but it still worked just fine. Well, let's try another way then. I bet your skill has its Hit Type "Certain Hit", since it is a kind of buff, right? And Evasion only allows you to evade Physical attacks, right?

Here is another simple note tag which removes your state when your actor gets hit by skill with Hit Type "Physical Hit". By this way, the state will not removes itself upon skill use, but only be removed when your actor gets hit by Physical Attacks:
Code:
<Custom Deselect Effect>
if (this.isPhysical()){
target.removeState(28);
}
</Custom Deselect Effect>

What i gave you before was a bit more complicated, which meant the states would be removed even when your actor get hit by Magical, Physical or even Certain Hits.
still nothing man. how frustrating.....
by the way, while testing this, I did find out something else I don't really like. if you press the Right direction arrow, it lets you "pass" on your turn. is there a way to remove or remap that? If it could be remapped, I'd like it to just Attack instead. (idk if it matters, but I'm using yanfly's ATB battle system)
So strange there...! My state here is working without a problem. I bet you have already changed my State 28 to yours, right?
And about your other issue, it is caused by Yanfly's Battle Status Window plugin. Find it and you will see some parameters in "Actor Switching" section.
I toggled it off, however.... is there any chance you know how it could be remapped? I found another plugin I'd been in need of, another yanfly one at that, that calls the status screen in battle to let you look at your stats, as well as state info. Thing is, it is placed on the "fight/escape" menu, it would be mighty useful to be able to have it much more easily accessible by just pressing Right (I use the option to start right at the attack/skill/item command window instead of having to choose "fight" first every single time, and because of that, a player would not likely ever find out about the status window, or often forget about it)
I also wanted to remap it, but still got no idea yet. Maybe you can dig into his codes and change something there.

Original thread: https://forums.rpgmakerweb.com/threads/regarding-yanfly-buffs-states-core.83249/