State that changes opacity upon running out? Animation on running out state finishing?

I have a state that is essentially supposed to make a character disappear from combat for X turns. The skill that applies this state changes the targets opacity to 0 and the state makes it so they cannot move or be targeted. However, the problem is that I am not sure how to change the opacity back to 255 after the state runs out since the target simply remains invisible.


Another question, so I don´t make two threads, how do I have a state play a specific animation on the affected when it runs out while also waiting for the animation to finish? It´s a somewhat lenghty animation that is supposed to play once the state runs out but once the state runs out the animation plays but it instantly moves on to the turn of the next actor.
For your first thing, a <custom remove effect> tag from YEP_BuffsStatesCore is what you're looking for.

Custom remove effect plays when a state is removed, or when it fades due to state turns running out. A single line of code in one of these tags should be all you need to reset the opacity.

target.spriteOpacity(255,0)

So you'd use a tag like the following on your vanish state:
<Custom Remove Effect>
target.spriteOpacity(255,0)
</Custom Remove Effect>

If you want it to fade in, the 0 in that function is the number of frames the opacity change takes. Something like 20 will make it so that the actor doesn't randomly pop in.

Your second thing is a lot more complex. I had states doing animations (and waiting for them) in my old state workshop. Here is a link to a state that deals damage, and shows an animation, and waits for the animation to finish before continuing. The function setTimeout is what I used to do this. There's probably a way less complicated way to do it now, but it was 2016, and I didn't know any better.

Essentially you'd look at my code for the enflame state, specifically at the part where it defines animation timings, and then copy that to your liking with your own times and animation.
Thank you very much, I´ll use the upper one to make the skill work properly and try my best to get the lower thing to also work. Thank you very much for your help.

Original thread: https://forums.rpgmakerweb.com/threads/state-that-changes-opacity-upon-running-out-animation-on-running-out-state-finishing.117087/