Loop an animation on an actor without interrupting the flow of battle

Hi there,

I am trying to do something a bit specific, and I am at a loss as to how to achieve it. Here is the idea:
I want a specific animation to be played on a loop while actors are in a specific state, and I want the animation to be different depending on which specific actor is in the given state.
For example, let's say that I want to give party-members an animated aura when they are in the "Empowered" state. But I want the aura to be a blue wave for Harold, and a red flame for Theresa.

The first steps were very easy, I have managed to loop animations based on states very easily thanks to Yanfly's Visual State Effects plugin, using the <State animation: x> notecard command. The animation plays continuously over the actor while the flow of battle continues, perfect.
But this does not allow me to give a different animations to different actors, so it's a partial solution to my problem.

Then, I found another way: using this plugin that allows parallel common events to run during battles (works like a charm), I made a common event that periodically checks for the "Empowered" state on Harold and, if Harold has this state, plays the "blue wave" animation. And it does the same for Theresa to give her the "red flame" aura. I then loop the aura using a wait command that matches the length of the animation, so that for as long as the characters are in the "Empowered" state, the animation will start over the very moment it ends.

To achieve this, I constructed my common event, that runs in parallel during combat, like this:
Code:
If : Harold is affected by Empowered
    $gameParty.members()[0].startAnimation(110, true, 0);
    End

If : Theresa is affected by Empowered
    $gameParty.members()[1].startAnimation(111, true, 0);
End

Wait : 200 frames

That works perfectly, except for one big problem: while the animation plays, everything else stops (unlike when using Yanfly's plugin), so I cannot have this animation loop in the background while the fight is happening.
I currently have no idea how to either:
- use Yanfly's plugin, but check for which actor is in the state and play a different animation based on that
- or how to update my common event so that the flow of battle does not stop while the animation is playing.

Any help is welcome.

Thank you!
use Yanfly's plugin, but check for which actor is in the state and play a different animation based on that
The easy solution (and I mean easy in that you can do it now without needing/waiting/potentially paying anyone else to write new code for you): have a different version of the state for each actor. Those different states have the appropriate animation ID for the Visual State Effects.

When it would be applied by a skill, use a Custom Apply notetag to see which actor it's going on and substitute the correct state ID.

Code:
<Custom Apply Effect>
if (target.actorId() == 1)
// Specify Harold's state's ID
    target.addState(15);
else if (target.actorId() == 2)
// Therese's state's ID
    target.addState(27);
// Remove the initial dummy state
target.removeState(stateId);
</Custom Apply Effect>

And, of course, if you can arrange the state IDs to be related to the actor IDs mathematically, you don't need a series of if/else statements, just one formula.

So say Harold's state is 15, Therese's is 16, etc.:
Code:
<Custom Apply Effect>
target.addState(target.actorId() + 14);
target.removeState(stateId);
</Custom Apply Effect>
Awesome! I managed to make both solutions work! I had already contemplated duplicating the state to have 3 versions with a different animation tied to them, what I was missing was how to check for the target's ID in order to apply the right state.

I changed my "Empowered" state to run the code you shared through <Custom Apply Effect> like you directed, so that when the character receives the state, they receive one of the other 3 versions of "Empowered" (the ones that loop the animation using <State animation: x>) based on their actor ID, and then the "Empowered" state that is only used to apply the custom effect is removed.
Is that indeed the way you intended for this solution to work?

Since, in my case, "Empowered" is a buff applied by a skill, I am wondering if there is no way to bypass the application of the first "Empowered" state by having the skill itself check for which state to apply based on target ID. Would that be possible? Like something equivalent to Custom Apply Effect that could go into a skill's notetags instead of a state's notetags but for the same result (checking which actor is targeted to apply to them the state that has the right animation tied to it).
Basically instead of: skill applies state > state applies new state based on actor ID and removes itself,
we would get: skill applies state based on actor ID (same thing but streamlined).
Is that possible?

Thanks a lot for your quick answer with a working solution, I was close to giving up on this.

Edit: I have managed to do what I describe in the paragraph above by putting the code in a <Before Eval> from the Skill score plugin notetag. It does the same thing, but directly from skill use instead of applying a state as a "bridge" of sort to run the code.

Original thread: https://forums.rpgmakerweb.com/threads/loop-an-animation-on-an-actor-without-interrupting-the-flow-of-battle.171443/