Transforming the user of a skill?

If I wanted to make the USER (an enemy, always) of an action transform into a different enemy, what would be the proper usage to make that happen in a script call for a common event tied to the skill?

$gameTroop.members()[0].transform(2);

Above would specifically make the enemy with the first index in the troop transform into the enemy with the ID of 2. What can I replace that zero with to make it affect only the user of the skill? Or, since it's a common event, maybe the user of the last skill is a more apt description?

Would this be easier to do with a Yanfly Skill Core Post-Eval?
Uhm, you can use a script call in the damage formula, that reads the troop members ID, with a script call...

Untested, but I think it is this:
Code:
v[1] = user.index(); 0

Now the ID of the caster is stored in variable 1.
Replace 1 with the id of the variable you want to use.
Replace 0 with your battle formula, if you want to do damage to the caster.

Note: Make this a damaging skill, not a healing skill, or else it can't be cast when at full health. (Although, I don't know if this last statement is also true for enemies...)

Now you can do your script call, in the common event like this:
Code:
$gameTroop.members()[$gameVariables.value(1)].transform(2);
Replace 1 with the id of the variable used before.

This is all untested, but I am 99% sure this should work.
if you're already using a common event attached to the skill, then you can simply use the transform enemy event command. It's on page three right, a little below half of the list.

the only difficulty would be targeting, but you would have the same problem with the script command and there are several ways around like the one described above.
Appreciate the suggestion, but the skill in question does not deal damage, and I'd rather not have a 0 pop up every time the enemy uses it. However, using a variable to store the index of the user is an interesting principle, though. I may be able to utilize that during the action sequence before the eval for transforming the enemy is performed. Let's test.

Threw this in my action sequence...

JavaScript:
<action sequence: execute>
animation: user, 2
wait: user, 17
animation: all targets, action
wait: all targets, animation
variable: 45, = (user.index())
effect: all targets, 100%
</action sequence>

Then made a common event called by the skill which performed...

JavaScript:
$gameTroop.members()[$gameVariables.value(45)].transform(23);
$gameTroop.makeUniqueNames();

Looks like this worked! Win-win, not having to use the damage formula due to having action sequences instead. 😀

Thank you for your help!
if you're already using a common event attached to the skill, then you can simply use the transform enemy event command. It's on page three right, a little below half of the list.

the only difficulty would be targeting, but you would have the same problem with the script command and there are several ways around like the one described above.
True... However, doint it with scriptcalls is way more flexible.
Check this:
Code:
var Id = Math.ceil(Math.random()*3)+3;
$gameTroop.members()[$gameVariables.value(1)].transform(Id);

Once you start doing that kind of stuff, it is hard to go back to the hard-coded stuff. 😛
Once you start doing that kind of stuff, it is hard to go back to the hard-coded stuff. 😛
Agreed.
Using the action sequence pack to set the variable, was a good idea btw. That way you don't have to set a damage formula. It's a good, solid solution. I didn't think of that.

However, I think this line:
Code:
variable: 45, = (user.index())
should be :
Code:
variable: 45, = user.index()

But I don't think it will make a real difference. If it works, it works. 😛

Edit: I spoke too soon. I don't know how the action sequence pack reacts to javascript. Maybe putting it between () is indeed the right way to do it.
However, I think this line:
Code:
variable: 45, = (user.index())
should be :
Code:
variable: 45, = user.index()

But I don't think it will make a real difference. If it works, it works. 😛

Edit: I spoke too soon. I don't know how the action sequence pack reacts to javascript. Maybe putting it between () is indeed the right way to do it.
I'm using VE - Battle Motions, and in that plugin I think placing anything outside of the default things the variable sequence comes with requires the () around it (if we're trying to evaluate something). I actually didn't try it without it, though. Either way, it ain't broke so I ain't messin' with it lol
Wait... That notetag is not yanfly's action sequence pack? That surprises me. It looks a lot like it. 😛

Original thread: https://forums.rpgmakerweb.com/threads/transforming-the-user-of-a-skill.168681/