MV Using Yanfly's buffs and states core and animated sv characters to change the sprite of an enemy when affected by a state.

So I wanted to make it so that when an enemy is affected with a state, their sprite would change. I would use the sideview sprites to animate the enemy but I want that sprite to change to a different one when the state is applied. I used the buffs and states core to change the actor faces when a state is applied so I assumed I might be able to do the same with sv enemies. My guess would be to do something like
<Custom Apply Effect> if target = enemy, if enemy id = x, set <Sideview Battler: filename>, else (repeat for other enemy id's)</Custom Apply Effect>
and do the same on removal but changing the sprites back to the original and using <Custom Remove Effect>.
I'm not sure if this would work, but if it does I don't know exactly how to input that code because I'm not great with js so if someone could point me in the right direction to do this that would be amazing.
The basic part of it is simple enough. However, the changing sprite part of it is more difficult. The Animated Sideview Enemies plugin doesn't include any functionality to change the image on the fly - the Sideview Battler thing you're referencing in your post is a notetag, not a plugin command.

So you (or someone) would have to write a function that changes the sideview graphic being looked at to the one you specify, then do all the steps to remove the battler and load it again and refresh the graphics.

You may find someone bored or intrigued enough to do all of that for you, but it's not me 😛

Or you may find someone who can think of a different method.

The other thing you could mess with is transforming the enemy - that is, you'd have a separate enemy in your database that's using the image you want, then you'd use the included functions to transform the target into the new enemy ID.

The tricks in that case would be making sure you check before and after so any damage dealt stays, and adding a variable to the enemy or the state to track which enemy it used to be so that it transforms back afterward.

wait nvm. just read the footnote about how this only works for static enemies and not animated 1s
The basic part of it is simple enough. However, the changing sprite part of it is more difficult. The Animated Sideview Enemies plugin doesn't include any functionality to change the image on the fly - the Sideview Battler thing you're referencing in your post is a notetag, not a plugin command.

So you (or someone) would have to write a function that changes the sideview graphic being looked at to the one you specify, then do all the steps to remove the battler and load it again and refresh the graphics.

You may find someone bored or intrigued enough to do all of that for you, but it's not me 😛

Or you may find someone who can think of a different method.

The other thing you could mess with is transforming the enemy - that is, you'd have a separate enemy in your database that's using the image you want, then you'd use the included functions to transform the target into the new enemy ID.

The tricks in that case would be making sure you check before and after so any damage dealt stays, and adding a variable to the enemy or the state to track which enemy it used to be so that it transforms back afterward.
After a little more research I found out that yanfly already added a new property for checking the sv sprites. I found that on this forum. After a little bit of extra scripting onto the example they gave I've got a pretty solid way to change the sv sprites for enemies. Now my giant mess of notes for every state will get even bigger but I think it's the last thing I needed.
JavaScript:
<Custom Apply Effect>
    //check if target is enemy
if (target.isEnemy()) {
    //check what enemy is targeted
if (target.enemyId() === 2) {
    //change sv sprite file
user._svBattlerName = "Actor1_2";
    //repeat for every enemy you want to be affected
} else if (target.enemyId() === 3) {
user._svBattlerName = "Actor1_3";
}
}
</Custom Apply Effect>
//repeat steps but with the "remove effect" tag and use the original sv sprites
//here the original for enemy 2 was Actor1_1 and enemy 3 was Actor1_4
<Custom Remove Effect>
if (target.isEnemy()) {

if (target.enemyId() === 2) {
user._svBattlerName = "Actor1_1";
} else if (target.enemyId() === 3){
user._svBattlerName = "Actor1_4";
}
}
</Custom Remove Effect>
1) I suspect you want target._svBattlerName, not user, otherwise it will be trying to access things that don't exist on an actor.

Judging from that, I'm guessing you haven't tested this yet, so:
2) Does this actually work? I wouldn't think that simply changing the filename stored on an enemy would do anything to redraw and refresh its sprite or I would've suggested it before.

3) You can make the remove effect much easier on yourself.
Code:
<Custom Remove Effect>
if (user.isEnemy())
    user._svBattlerName=$dataEnemies[user.enemyId()].sideviewBattler;
</Custom Remove Effect>
that should do the trick.
1) I suspect you want target._svBattlerName, not user, otherwise it will be trying to access things that don't exist on an actor.

yanflys apply/remove state notetags the user. is who the state is applied to not the person applying the state.
yanflys apply/remove state notetags the user. is who the state is applied to not the person applying the state.
Then he wants all of his checks to read if (user.isEnemy()) and user.enemyId()

I did forget that Buffs & States uses user and origin
2) Does this actually work? I wouldn't think that simply changing the filename stored on an enemy would do anything to redraw and refresh its sprite or I would've suggested it before.
Yup for the most part. The one weird issue is that for 1 frame it shows the entire sprite sheet for the enemy and after that frame it is using the changed sprite.

Original thread: https://forums.rpgmakerweb.com/threads/using-yanflys-buffs-and-states-core-and-animated-sv-characters-to-change-the-sprite-of-an-enemy-when-affected-by-a-state.140407/