Skill that applies a random weakness

By weakness I mean increasing the element rate so the target takes more damage from that element. I tried doing this with a skill that called a common event which controlled a variable by setting a random number, and then giving a conditional branch for each number which would apply a separate state, but I quickly realized setting a state on an enemy through this way is troublesome unless it's the entire troop. Otherwise you have to select which enemy "slot" it is in the troop rather than going off whichever one the skill targeted.

Is there a way to do this in notetags with javascript (and if so can someone help out with that) or is this a custom plugin situation? Or am I overlooking another method of doing this?

I'm using many VisuStella plugins but I think the only ones that would apply here is the Battle Core and possibly the ElementStatus Core and SkillsStates Core, but I don't think so.
If you have the skill add one random state that applies the elemental weakness, you can do that with Visu's Battle Core.

(You can change it to post damage if you want it to be a damaging skill, but not benefit from the debuff)
<JS Pre-Damage>
//Let's say you have five states of element debuffing, stating at state 40
var statePicker = Math.floor(Math.random() * 5) + 40;
target.addState(statePicker);
</JS Pre-Damage>
Ah, now that you've suggested it, it seems like an obvious solution. Looking too closely at the situation, I guess. Thank you!
you can also go with this, since this checks whether the skill misses or not.
the "1,4,7,9,12" is the ID of the states could be in any order and the "5" in Math.randomInt is the amount of states you want to be randomized

<JS Pre-Damage>
if (b.result().isHit()) {
b.addState([1,4,7,9,12][Math.randomInt(5)]);
}
</JS Pre-Damage>

or if you dont need any conditions applied to it, just having this also works:

<JS Pre-Damage>
b.addState([1,4,7,9,12][Math.randomInt(5)]);
</JS Pre-Damage>

Original thread: https://forums.rpgmakerweb.com/threads/skill-that-applies-a-random-weakness.166338/