YF Actor Transformation removes face image from menu only

Im not understanding why but if I open the menu my character has a empty face graphic.
Im trying to make a skill that is Trance and Actor Transformations combined.

TRANCE
Code:
<Custom Passive Condition>
// Check if the party is in battle.
if ($gameParty.inBattle()) {
  // Default the user's trance state to false.
  user._trance = user._trance || false;
  // Sets the condition for the user to be either in the trance state or if the user's TP matches the user's MaxTP.
  condition = user._trance || user.tp === user.maxTp();
} else {
  // Otherwise, the condition is false.
  condition = false;
}
// If the condition passes...
if (condition) {
  // And if the user isn't in the trance state...
  if (!user._trance) {
    // Then play an animation as the user enters trance.
    user.startAnimation(120);
  }
  // Set the user's trance state to true.
  user._trance = true;
  user.addState(81);
}
</Custom Passive Condition>

<Custom Regenerate Effect>
// Set the TP drain amount.
var tp = 10;
// Reduce the user's TP.
user.gainTp(-tp);
// If the user's TP is 0...
if (user.tp === 0) {
  // ...then turn off trance.
  user._trance = false;
}
<Custom Regenerate Effect>

TRANSFORM:
Also remove at end of battle checked.
Code:
<Custom Apply Effect>
// Check if user is an actor.
if (user.isActor()) {
  // Archive the previous settings.
  user._prevCharName = user._prevCharName || user._characterName;
  user._prevCharIndex = user._prevCharIndex || user._characterIndex;
  user._prevFaceName = user._prevFaceName || user._faceName;
  user._prevFaceIndex = user._prevFaceIndex || user._faceIndex;
  user._prevBattlerName = user._prevBattlerName || user._battlerName;
  // Check if the actor ID is 1.
  if (user.actorId() === 2) {
    // The filename of the character graphic without the file extension.
    var charName = 'tranceform';
    // The index of the character graphic used.
    var charIndex = 1;
    // The filename of the face graphic without the file extension.
    var faceName = 'tranceform';
    // The index of of the face graphic used.
    var faceIndex = 0;
    // The filename of the battler graphic without the file extension.
    var battlerName = 'tranceform';
  }
  // Changes the character image to the setting applied from above.
  user.setCharacterImage(charName, charIndex);
  // Changes the face image to the setting applied from above.
  user.setFaceImage(faceName, faceIndex);
  // Changes the battler image from the setting applied from above.
  user.setBattlerImage(battlerName);
  // Refreshes the user's appearance.
  user.refresh();
}
</Custom Apply Effect>

<Custom Remove Effect>
// Retrieve archived settings.
var charName = user._prevCharName;
var charIndex = user._prevCharIndex;
var faceName = user._prevFaceName;
var faceIndex = user._prevFaceIndex;
var battlerName = user._prevBattlerName;
// Changes the character image to the archived setting.
user.setCharacterImage(charName, charIndex);
// Changes the face image to the archived setting.
user.setFaceImage(faceName, faceIndex);
// Changes the battler image from the archived setting.
user.setBattlerImage(battlerName);
// Clear archived data.
user._priorityCharacterName = undefined;
user._priorityCharacterIndex = undefined;
user._prevFaceName = undefined;
user._prevFaceIndex = undefined;
user._priorityFaceName = undefined;
user._priorityFaceIndex = undefined;
user._prevFaceName = undefined;
user._prevFaceIndex = undefined;
user._priorityBattlerName = undefined;
user._prevBattlerName = undefined;
// Refreshes the user's appearance.
user.refresh();
</Custom Remove Effect>

<Custom Turn End Effect>
if (user.tp === 0) {
user.removeState(81);
}
</Custom Turn End Effect>
Bump
// Changes the face image to the archived setting.
user.setFaceImage(faceName, faceIndex);


This changes the face sprite of your character. It requires two things in order to work:
1- If the file name is not set in the variable faceName, such as "harrold", which an associated picture "harrold.png" in the img folder, then the face of your character will disappear.
2- If you are not properly setting up a value for the variable faceIndex, it will remain '0' (zero) and the face of your character will disappear.

My guess is that you are not setting one (or both) of these values when you are calling on your script.
// Changes the face image to the archived setting.
user.setFaceImage(faceName, faceIndex);


This changes the face sprite of your character. It requires two things in order to work:
1- If the file name is not set in the variable faceName, such as "harrold", which an associated picture "harrold.png" in the img folder, then the face of your character will disappear.
2- If you are not properly setting up a value for the variable faceIndex, it will remain '0' (zero) and the face of your character will disappear.

My guess is that you are not setting one (or both) of these values when you are calling on your script.

I dont get it because I have 3 images,
Icenick character sheet with "0" as default character sprite. "1" as the transformed state.
Icenick face sheet as default and Icenick2.png as transformed state. Both use "0" as the the face positions are expressions but the main is the first one.
Finally the battler is Icenick2.png and this works.


// The filename of the character graphic without the file extension.
var charName = 'Icenick';
// The index of the character graphic used.
var charIndex = 1;
// The filename of the face graphic without the file extension.
var faceName = 'Icenick2';
// The index of of the face graphic used.
var faceIndex = 0;
// The filename of the battler graphic without the file extension.
var battlerName = 'Icenick2';
Time to start the painful process of debugging.

Make a backup first and then modify your code to try a few things. The idea is to basically strip your code to the bare bones and then add a little at a time to see when it actually stops working.

1- In your case: remove the states, the variables, the conditions and everything else that doesn't have anything to do with changing the character sprite.

2- Modify the code to change the least parameters at once. For instance, create 3 face graphic sheets and set all face index to 0.

2- If that works, then you know you have some working code and you can then start adding your states and everything else one line at a time. If it doesn't work, then you know there's a problem somewhere else.
I really dont fully understand what you mean. I just have a state that adds the transformation how much can I remove?
I tried removing all lines of text relating to face change and naturally it works. I mean the face does not change graphic but when the battle is over the face is visable.
I really dont fully understand what you mean. I just have a state that adds the transformation how much can I remove?
I tried removing all lines of text relating to face change and naturally it works. I mean the face does not change graphic but when the battle is over the face is visible.

Actually upon further testing, the next battle is starting with the transformed battler sprite, none of this is working.. I spent too much time on this 🙁
I really don't understand.
Also I have YF turn order display and it doesnt seem possible to update the face graphic in the display to be the proper face.
I figured this out, finally it was the passive condition that was the problem, its as if it was consistently applying the transformation state, so I added a check in the custom regeneration tag. I also had to add custom victory/defeat/escape that remove the trance.

Original thread: https://forums.rpgmakerweb.com/threads/yf-actor-transformation-removes-face-image-from-menu-only.125230/