MV YEP Skill Condition Question

I have a skill which I would like to be visible, but greyed out (aka disabled) until the condition is met to enable it; that condition being that ANY enemy's HP must be 20%=<. My JS is OK, but not great. Am I on the right track here, or can someone give me the solution? lol :eswt:

Code:
<Custom Show Eval>
  if (gameTroop.aliveMembers.hp =< (0.2 * gameTroop.aliveMembers.mhp)) {
    enable = true;
  } else {
    disable = false;
  }
</Custom Show Eval>

I'm sure I'm way off here, but hopefully this will clue a more advanced scripter as to what I'm trying to do. TIA
I dont know how exactly, but =< is wrong one which is <=

operators:
lower or equal <=
higher or equal >=
equal ==
strictly ===

which might be the basic, so if you swap the operator, it might work.
This should do it;

JavaScript:
<Custom Show Eval>
  if ($gameTroop.aliveMembers().some(enemy => enemy.hpRate() <= 0.2)) {
    visible = true;
  } else {
    visible = false;
  }
</Custom Show Eval>

edit notes with some explanations;
- The Custom Show Eval has the internal "visible" variable, which you must use. The skill is shown depending on whether or not that variable is true or false

- to reference the current enemies, use "$gameTroop.aliveMembers()", not "gameTroop.aliveMembers"

- the "some()" function can be applied to any array or object. It will go through every element and return true if any element meets the condition you set inside the function,
--- > in this case, "enemy => enemy.hpRate() <= 0.2)"

- hpRate() is the basic function of rmmv to get the current % health of a battler.
--- > to be fair, your approach would also have worked, but why not use the dedicated function if there is one right?



edit again:

You wanted it grey out instead of disappearing right?
Then you should use "<Custom Requirement>" instead, like so:

JavaScript:
<Custom Requirement>
if ($gameTroop.aliveMembers().some(enemy => enemy.hpRate() <= 0.2)) {
    value = true;
} else {
    value = false;
};
</Custom Requirement>

it's the same, except that we use "value" instead of "visible" now.

Hope this helps!

Original thread: https://forums.rpgmakerweb.com/threads/yep-skill-condition-question.155099/