I'm looking for a way to make a skill only target the ally(ies) with the lowest HP
Any help with this is greatly appreciated.
Yanfly has a plugin that allows a skill to target via parameters that should work fairly well.
I want to say it was called "Selection Control" or something like that. If I am remember correctly it allows you to assign priority based upon parameter levels, by notetags.
That would probably be the easiest way to accomplish what you want.
I have looked through the selection and targeting plugins by yanfly, but I can't seem to figure out how to achieve the effect. I really just need it for one skill, a heal that targets the two lowest hp members. I think there may be a way to do it with yanflys script but I think I would need to use the lunatic tags and I don't really know anything about how to use them.
I hope i can bump this now... still want to add this skill in. If someone knows how to do this using selection control or targeting plugins lunatic note tags, or could maybe point me in the right direction I would be very grateful. I think this would be a great thing for a lot of games.
I'll have a look at Yanfly's Target Core. It should be possible with the <Custom Target Eval> lunatic mode notetag, just have to figure out the right way to do it.
This works for targeting the ally with the lowest HP:
<Custom Target Eval>
var lowestMember = allies.aliveMembers()[0];
var lowestHP = lowestMember.hp;
for (var i = 1; i < allies.aliveMembers().length; ++i) {
var member = allies.aliveMembers();
if (member.hp < lowestHP) {
lowestHP = member.hp;
lowestMember = member;
}
}
targets.push(lowestMember);
</Custom Target Eval>
I'm not sure how to apply the concept to multiple allies, though. Maybe someone with more experience in Javascript can help.
A (rather dirty) workaround could be the following:
Create one skill "Heal lowest" with the above notetag.
Create another skill "Heal lowest twice" (or whatever name you want). This will be the skill the actor uses. No notetag required for this one.
Create a common event that uses the "Force Action" command twice with the "Heal lowest" skill.
Have the "Heal lowest twice" skill call the common event.
Hope that helps a bit 🙂
Found a different solution, after spending some more time learning Javascript:
<Custom Target Eval>
var members = [];
for (var j = 0; j < allies.aliveMembers().length; ++j) {
members.push(allies.aliveMembers()[j]);
}
for (var k = 0; k < 2; ++k) {
if (members.length > 0) {
var lowestMember = members[0];
var lowestHP = lowestMember.hp;
for (var i = 1; i < members.length; ++i) {
var member = members;
if (member.hp < lowestHP) {
lowestHP = member.hp;
lowestMember = member;
}
}
targets.push(lowestMember);
members.splice(members.indexOf(lowestMember), 1);
}
}
</Custom Target Eval>
If there are less than two allies alive, this skill will only heal once.
You can change the 2 in "for (var k = 0; k < 2; ++k)" to a different value if you want to heal more than just two allies with lowest HP.
Thank you so much, that worked perfectly!