State that changes sideview actor and enemy sprites.

Goal:

I need this flying state to change the sv_actor sprite sheet when applied and then change it back when removed.

I also need this to work with enemies somehow.
I'm currently using Visustella's Battle Core to support enemies with sv_actor sprites.

Background:

I'm working on a flying mechanic for side view battles.
I've created a state called "Flying" (ID 13) which affects both actors and enemies.

The visual aspect currently relies on Visustella's Visual State Effects, specifically the hover notetags.
This is working reliably, but the hover effect is intended as a placeholder.

Its not ideal mostly because the sideview sprites are animated for ground based attacks. So I'll be drawing or commissioning flying variants of each actor and enemy that's capable of flying.


References:
In July there was a post about states changing sv_actor. Kes made a great suggestion there - though it only pertains to actors and it does a little more than I'm concerned with at the moment since I'm not using portraits or faces.

Code:
<JS On Add State>
  if (target.isActor()) {
    target._prevCharName ??= target._characterName;
    target._prevCharIndex ??= target._characterIndex;
    target._prevFaceName ??= target._faceName;
    target._prevFaceIndex ??= target._faceIndex;
    target._prevBattlerName ??= target._battlerName;
    const charName = "[name of sprite sheet]";
    const charIndex = [actor index, starting at 0 for player];
    const faceName = "[name of the face sprite sheet]";
    const faceIndex = [whereabouts on that sprite sheet it is, starting at 0];
    const battlerName = "[name of new battler sheet]";
    target.setCharacterImage(charName, charIndex);
    target.setFaceImage(faceName, faceIndex);
    target.setBattlerImage(battlerName);
    target.refresh();
  }
</JS On Add State>

<JS On Erase State>
  const charName = target._prevCharName;
  const charIndex = target._prevCharIndex;
  const faceName = target._prevFaceName;
  const faceIndex = target._prevFaceIndex;
  const battlerName = target._prevBattlerName;
  target.setCharacterImage(charName, charIndex);
  target.setFaceImage(faceName, faceIndex);
  target.setBattlerImage(battlerName);
  delete target._prevCharacterName;
  delete target._prevCharacterIndex;
  delete target._prevFaceName;
  delete target._prevFaceIndex;
  delete target._prevBattlerName;
  target.refresh();
</JS On Erase State>

Any guidance or assistance would be greatly appreciated here.

Thanks 🙂
Is it just the idle motion that changes? How many motions (i.e. sets of three frames) do you want to make flying specific? I'm currently sinking my teeth in Lib's BattleMotionMZ.js. It allows for:

a: having more frames per motion
b: have additional motions

It takes a little studying but the flexibility is quite nice, and so far it seems to work well with VS Battlecore. In the below case (which I've just quickly assembled for the purposes of explaining) a twentieth motion has been added to show that the character is "sick". If you now create a state for "sick", and in the notes place the tag <motionSP1>, it will run this motion instead while the battler is in this state.

To the right of each motion, a color code is needed, to specify what kind of motion this is, and also what the frame interval is:
#ffff0c: pingpong loop with a frame interval of 12 (5 fps)
#ff0005: one-way no loop with a frame interval of 5 (12 fps)
#00ff0a: loop with a frame interval of 10 (6 fps)

I'm still in the middle of testing all this but it does look to be compatible with BattleCore so far.

testactor1_lib.png

Original thread: https://forums.rpgmakerweb.com/threads/state-that-changes-sideview-actor-and-enemy-sprites.160144/