Code:
$gameParty.members().reduce((lowestMember, member) => member.hp < lowestMember.hp ? member : lowestMember);
Syntax only works with MV 1.6 or above, but can be slightly modified to work with older versions:
Code:
$gameParty.members().reduce(function(lowestMember, member) { return member.hp < lowestMember.hp ? member : lowestMember });
The
reduce method can be called on any Array. You pass in a function that accepts two parameters which will be called on every element in the Array. The first is an accumulator, the second is the current element in the Array. Whatever the function returns becomes the accumulator. When all elements have been iterated on, the accumulator is returned.
If you don't provide an accumulator as a second argument, along with your function, then the accumulator starts as the first element in the Array.
Since we don't provide one, the accumulator will start as the first party member. Then, for each subsequent member, if they have less HP than the current accumulator (lowestMember), that member is returned and thus becomes the accumulator. Otherwise, the current accumulator is returned.
The result of the code is the lowest-health member. I don't know how Yanfly's noteboxes work, so you'll have to figure out how to assign that value somehow.