Making an enemy possess an ally after that ally was hit by a certain skill?

I'm currently working on a possession based rpg and I have a certain enemy that enters a state where they can leave their body, and then they can cast a skill that will instantly KO an ally. The planned behavior after that is that the enemy would transform into a different enemy that has the sprite of the ally as well as a combination of skills from the old enemy and the ally that was possessed. The issue is, I'm not sure how to initiate that transformation call after the the skill has been cast and the ally passes out. Should it be via a script call in the skill notetag? Or a common event? How would I grab the index of the enemy that called that skill as well as the ally who got hit by it?
1713220270696.png

1713220339458.png




(Ideally what would happen after the possession goes through)
1713220399958.png
You need some plugin for sure, and script calls/plugin calls.
The basic is to have some way to catch the information, who the enemy attacked, so you can know which Sprite to change.
The later, is, you acctually want the enemy have the ally skills and stats? Because if yes, I think it's another case.
I don't know MZ programming, but to make something similar effect but very different of what you want. With Battle AI from Visustella, try to create an AI, so if an ally have state "possession". He do x things.
But no changing sprites for the enemy, and the character stays alive... If so, you need something like Skill and states core, and make some skill that remove the state, and apply a "<remove state>" JS that apply death state on your character.

Very confusing tho...

Original thread: https://forums.rpgmakerweb.com/threads/making-an-enemy-possess-an-ally-after-that-ally-was-hit-by-a-certain-skill.167776/