MV Actor Transformation/Class Changing (Implementing WildShape)

This could mostly be an issue of simply not knowing what the arguments are, but I am currently attempting to implement D&D 5E's WildShape as a mechanic the player can use. To accomplish this, I am using Yanfly's Battle Engine Core, Buff's and States Core, and SumRndmDde's Skill Extender.

The Skill itself has a custom cost, and the Skill Extendor allows the player to select the creature for the Actor to transform into.
36883cfdebfc74a3b21df38108f2ff90.png


The actual transformation is done using the code presented by one of Yanfly's Tips and Tricks, the shortened version being used here:
<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() === 30) { // The filename of the character graphic without the file extension. var charName = '$Nature'; // The index of the character graphic used. var charIndex = 2; // The filename of the face graphic without the file extension. var faceName = 'Nature'; // The index of of the face graphic used. var faceIndex = 2; // The filename of the battler graphic without the file extension. var battlerName = 'Great Owl'; } // 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>

This code effectively is applied to a State that is assigned to an actor, which changes the images used while the state is in effect. When the state wears off, the images return to normal.

However, for my purposes, I need to have the actor change Class as well to match with their transformation. While this can be initially changed when the State is applied with a common event in the Skill's traits, I do not know how to change the Class back when the State is no longer applied. This would optimally keep the levels the same between changes. I suspect it would simply be a matter of either activating a Common Event in the Custom Remove Effect section or having the Class be archived above. I am afraid I just don't know what the arguments for doing so would be, or if I simply just have my theory wrong.

While not the main issue, I also hope to apply at least two other attributes to the skill:

Saving the Actors current health, so if their transformed state is removed by death/etc, they revert back to the condition they were in before.

Ideally, the ability to have the Actor break the state using a skill, both inside and out of battle. I admitidly probably wont be using this attribute for a current project, but I think this could aid in potential puzzlemaking down the line.

Appologies again for the long post, I'm afraid I'm not too good with Javascript yet and only get so much time to work on my game. Any help would be appreciated honestly.
To change the class in the <Custom Apply Effect> and <Custom Remove Effect>use:
JavaScript:
user.changeClass(classId, true);
Replace the classId with the ID of the class you want to change to, obviously. The parameter true tells the engine to keep the current EXP.

To save the current health in a variable you can use (again in the notetags):
JavaScript:
$gameVariables.setValue(X, user.hp);
This will store the current HP in Variable X so you can access it later through events or however you want. If you only need it inside these notetags you can also simply store them like Yanfly stored the previous image etc :
JavaScript:
user._prevHp = user.hp;
This is because of a quirk of javascript: You are setting an attribute of an object where the attribute previously didn't exist? Well it exists now. No worries. That can be a surprise if you're coming from more strict programming languages. And this sentence won't make any sense if you have no previous programming experience and don't know what objects and attributes are in that context.

For a skill to break the Wildshape you don't need any fancy plugin work. You can simply have a skill remove a specified state (Effects -> State -> Remove State).
To change the class in the <Custom Apply Effect> and <Custom Remove Effect>use:
JavaScript:
user.changeClass(classId, true);
Replace the classId with the ID of the class you want to change to, obviously. The parameter true tells the engine to keep the current EXP.

To save the current health in a variable you can use (again in the notetags):
JavaScript:
$gameVariables.setValue(X, user.hp);
This will store the current HP in Variable X so you can access it later through events or however you want. If you only need it inside these notetags you can also simply store them like Yanfly stored the previous image etc :
JavaScript:
user._prevHp = user.hp;
This is because of a quirk of javascript: You are setting an attribute of an object where the attribute previously didn't exist? Well it exists now. No worries. That can be a surprise if you're coming from more strict programming languages. And this sentence won't make any sense if you have no previous programming experience and don't know what objects and attributes are in that context.

For a skill to break the Wildshape you don't need any fancy plugin work. You can simply have a skill remove a specified state (Effects -> State -> Remove State).
Thank you very much! It looks like this is working as intended, but I am having some trouble figuring out how to implement death as a removal condition.

I also seem to be having a bug that I do not know how to diagnose. It says the issue is with YEP AutoPassiveStates , and the errors are shown after look like they have to do with SumRndmDde's HUD Maker .

91d707cd4bd52071f1e1a44d12761d58.png



I am unsure if it is necessarily involved with the current bit of coding, but if it is, I'm afraid I don't know what I'm doing.
Unexpected token u in JSON is an error that 99% of the time is because there's an error somewhere in a notetag. By the looks of the errors, it's trying to access actor properties and can't because there isn't an actor in existence at the time.
This seem like two unrelated errors to me.
Unexpected token u in json: It actually tells you the exact place where the error occurs: In the file YEP_AutoPassiveStates.js in line 233. Since that line is responsible for parsing the parameter 'Actor Passives List' my first step would be to check if that parameter is set up correctly.

SRD_HUDMaker tries to access properties of undefined. I have not used the HUDMaker myself, so I don't have any actual experience. However note how these errors are not red. This to me indicates that these are the result of console.log instead of actual uncaught errors running wild. It could well be that the HUDMaker is aware that it can be loaded before the actors exist and simply handles that error by not displaying the HUD element and logging the event.
If you want to ensure that the actor exists before you try to display some property of them, then you can add if (actor) as a condition to show these HUD elements.
Sorry for how long this took, I believe this is an error outside of the current Skill being worked on.

Looking at the parameters list for YEP_AutoPassiveStates, I am not seeing the error, as I have not edited them.

6a9864b802fe2d2c800a6ec7a02b6a89.png


Should a separate thread be made for this error? I did a couple of test runs without the Wildshape State applied and it seems irrelevant.
Huh, this is weird. Everything seems in order with the parameters. Maybe @Trihan 's hunch was right and there is an error in some notetag somewhere? Either way, if this error is unrelated to the skill this thread is about I suggest opening a new one.

Original thread: https://forums.rpgmakerweb.com/threads/actor-transformation-class-changing-implementing-wildshape.142915/