MZ Random skill effects after targeting (states, transforming)?

I was experimenting with replicating a skill similar to this. Most of the effects seem easy enough to make through the action sequence, but some effects I'm kinda stuck on. Namely transforming random enemy units (temporarily or permanently), and giving either a random party member or a random troop member a state. Currently, the skill is set to just target anybody, since the skill's random rolls sometimes affect the party but also might hit the enemy troop instead. The way I've set it to roll random effects is through the default control variable command.

For the states part I partially found a solution that would do what I'm looking for (namely, this one), but it's for MV and doesn't seem to work in MZ like some other MV snippets/plugins do (doesn't give any errors, but has no effect either and doesn't take the party into account, it's possibly using some functions MZ doesn't recognize?).
For the transforming part, the issue I ran into is knowing how many troop members there are, and making enemies like bosses resistant to the effect.

Could anyone help me figure out how to pull these off (if it helps, I have most of VisuStella's plugins at my disposal),
whether it be through eventing it somehow or through any sort of code?
You could surely do this inside of action sequences as well, but you can just use some VisuStella Battle Core notetags. JS Pre-Apply makes code happen before a skill resolves, so if you just leave the damage and effects of the skill blank in the database, you can do whatever you want in there.

Code:
<JS Pre-Apply>
switch (Math.randomInt(6)) // Generates a number from 0 to 5
{
    case 0:
        // Put code here
        break;
    case 1:
        break;
// Etc.
}
</JS Pre-Apply>

For the specific effects, you just go to the pinned Script Call thread or do some Googling to see how to do them.

For the transforming part, the issue I ran into is knowing how many troop members there are
Code:
$gameTroop.aliveMembers().length

and making enemies like bosses resistant to the effect.
Depends on what "the effect" is. If it's like applying a state, you just give that enemy a trait of State Resist for that state.

If it's...I have no idea what you're talking about, but something else, you can always give them a <boss> notetag then check whether your would-be target has that.
Code:
if ($dataEnemies[enemy.enemyId()].meta.boss)

You'll get better/more specific answers if you say specifically what you're trying to do. Saying you want a skill "similar to" this other one doesn't tell us whether you want to rip off exactly all those effects or something else.
One of the effects listed on the site I linked is turning an enemy into a weak monster (imagine a chicken). This is the effect I want bosses to be immune to. 😴
One of the effects listed on the site I linked is turning an enemy into a weak monster (imagine a chicken). This is the effect I want bosses to be immune to. 😴
So put the transform effect in a state (there are tons of threads and a Tip & Trick for that) and make the enemy resist the state. I even said that 😛
I was originally going to try to use the transform event command, but yeah, I could probably do it that way. The reason I wanted to put the state to random party or troop member part in an action sequence is just personal preference though, I'm finding them more comfortable to read through in case I mess them up 😅 but the plugin commands for applying something to x target doesn't include for example "put animation on random troop member", only alive/dead/index/ID. This one
1691081257861.png

I'm not sure how to utilize if it specifically sometimes targets one side and sometimes the other.
It does work if the target's already set to random, but that'd give me less control over which side to apply it to.

Original thread: https://forums.rpgmakerweb.com/threads/random-skill-effects-after-targeting-states-transforming.159990/