Main character may swap to any NPC

Hi everybody.

I have this main character who is a demon and I want an ability where he can become anyone he meets who is lower or same level as he. He literally should leave his old form to become the character he battles. Is this even possible in RPG maker MZ?

Think of it like this. He is a lvl 3 Elf mage, and faces a Level 3 Kobold Warrior (NPC). If he succeeds with the ”Soul Meld”, he keeps one of his Mage skills and his highest attribute (INT in this case), while mainly changing to a Kobold Warrior. Now he is a Kobold Warrior, with an extra skill; Magic Missile. Everytime he swaps, he keeps an additional skill and specc so at level 4, he meets a Human Cleric, which he Melds with. He keeps INT and STR, along with Magic Missile and Charge, and gets WISdom and ”Heal”, from the new char. Can this be done in RPG maker MZ and if so, how?
Best regards
Jonas, Sweden
He is a lvl 3 Elf mage, and faces a Level 3 Kobold Warrior (NPC). If he succeeds with the ”Soul Meld”, he keeps one of his Mage skills and his highest attribute (INT in this case), while mainly changing to a Kobold Warrior.
This can be done - the more you do it, the harder it will be to do by just events (to maintain efficiency you'll need to use some JavaScript), and the skill part may be challenging depending on how you want to do it (is it keeping a random skill from his existing class, the highest level one, is he choosing?).

Also note that by default there are no enemy levels, so there's no such thing as a Level 3 Kobold Warrior. If you're using a plugin that adds enemy levels, it may affect how you go about the rest of this.

The actual changing is simple, you just use the Event Command on tab 3 to Change Actor Images. You can use Control Variable to store the parameters of the enemy and Change Parameter on your actor. Again, it would be easier to do this part (and keep the highest value) in a script box. You'd then use the Event Command to Change Class to the class you've defined for that enemy type. I believe the default setting for this erases the skills you already know and sets them to what you should know in the level of your new class, so you just need to reassign the skills you've kept from previous classes.

The skill part is the most complicated - you need to track which skills he's kept. This can be done with Control Variable, but that only really works if there is a finite number of times your Soul Meld can be used, so you know what range of variables to reference. The easier way is to set up one variable as an array and then splice in the ID of each skill as you keep it - then, when you Meld into the next enemy, you forget every skill that isn't in that array.

As I said, the determining which skill to keep might be the trickiest part. You'll need to figure out how that works, and it might end up in you having to write a custom window that displays all skills that weren't already copied from a previous class, and choosing one, if that's how you want to go.

Original thread: https://forums.rpgmakerweb.com/threads/main-character-may-swap-to-any-npc.141631/