MZ Need help making finishing move skills

Hello,
I'm using RMMZ with VS core plugins and I am a little stuck with making "finishing move" skills.
By finishing move I mean are only enabled when the target HP is < a certain %.
Minimum I want the skill to accomplish:

-ONLY be enabled (but still visible) when I have the requisite resource AND when the target HP is < a certain % (I believe I can achieve this with VS skillsandstatescore notetag <Enable Any Switches: x,x,x> and set the switch(s) to ON as a Battle Condition for each troop).

-ONLY able to be used on a target that has < a certain %. (Not sure how I can achieve this).

-I want this skill to work even with multiple enemies (let's assume a max of 5) on the battlefield, but ONLY able to be used on an enemy that's HP is < a certain %.

So far since I'm assuming a max of 5 enemies on the battlefield at a time. I'm using 5 switches, one for each enemy. Then I've created 5 event pages on each Troop Battle Event. Each event page conditions is Enemy HP <= 10% and when that happens they turn their affected switch ON. Those switches are then used in
VS skillsandstatescore notetag <Enable Any Switches: x,x,x>
Is this the most efficient way? I still need the skill to be able to be selected and only be able to select the target with < a certain % HP.

Anyone have any advice?
Thanks!
You're horrendously overthinking this. You don't need to use switches or battle events, at least not for enabling it:

<JS Skill Enable>
enabled = user.canPaySkillCost($dataSkills[id of skill]) && $gameTroop.members().some(member => member.hpRate() < 0.1);
</JS Skill Enable>

Unfortunately there's no way to restrict targeting using VS plugins, but you may be able to find a plugin elsewhere that allows it.
You're horrendously overthinking this. You don't need to use switches or battle events, at least not for enabling it:

<JS Skill Enable>
enabled = user.canPaySkillCost($dataSkills[id of skill]) && $gameTroop.members().some(member => member.hpRate() < 0.1);
</JS Skill Enable>

Unfortunately there's no way to restrict targeting using VS plugins, but you may be able to find a plugin elsewhere that allows it.
Thank you very much, that is WAY easier than what I was trying to do lol.
Yes I will still need to find a way to restrict targeting as you can "cheat" and use the skill on an enemy who's HP is higher than 10% once an enemy's HP is <10%.
Thanks again!
The best I can do for you with the VS plugins is having it deal its damage to a random enemy with less than 10% HP.
The best I can do for you with the VS plugins is having it deal its damage to a random enemy with less than 10% HP.
With the code you gave me:

<JS Skill Enable>
enabled = user.canPaySkillCost($dataSkills[id of skill]) && $gameTroop.members().some(member => member.hpRate() < 0.1);
</JS Skill Enable>

do you know of a way to make it ignore a dead enemy?

EDIT: by ignore I mean not be enabled anymore.
Change members() to aliveMembers().
Change members() to aliveMembers().
Worked like a charm! Thank you very much!
Some awesome people helped me on Driftwood Gamings discord and referred me to this thread https://forums.rpgmakerweb.com/index.php?threads/caethyrils-mz-plugins.125657/ which has a plugin called Cae_OnUseEffects.
This plugin has a notetag for target filtering and can accept JS.
I used this notetag on the skill
<target filter: return target.hpRate() < 0.1;>
and it works perfectly. It won't even let you hover over a target that's HP is > 10%.
I just wanted to say thank you so much for all of the help Trihan!
I thought I remembered a plugin that did this, and of course it's a Caethyril one. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/need-help-making-finishing-move-skills.137127/