Hi !
Working on my project, I tried to have a character with a passive that makes him use a potion on an ally when they're at low hp, like 20% max HP, at the end of the turn.
I did the skill from YEP's Auto Potion which works as intended as a skill itself. Now I searched a bit for the "ally at 20% hp" thing on the forum but only found "lowest hp ally" which is different.
I tried to tweak this code I found here : https://forums.rpgmakerweb.com/index.php?threads/targetting-lowest-hp_rate-party-member.153664/
And added a force action at the end to use the item. This works but since I'm not good with code and all that I don't know how, or even if it's possible, to change it to use the skill only if the ally is under 20% max HP.
Does anybody have an idea or a workaround to this ?
Working on my project, I tried to have a character with a passive that makes him use a potion on an ally when they're at low hp, like 20% max HP, at the end of the turn.
I did the skill from YEP's Auto Potion which works as intended as a skill itself. Now I searched a bit for the "ally at 20% hp" thing on the forum but only found "lowest hp ally" which is different.
I tried to tweak this code I found here : https://forums.rpgmakerweb.com/index.php?threads/targetting-lowest-hp_rate-party-member.153664/
Code:
<Custom Turn End Effect>
var lowestMember = $gameParty.aliveMembers()[0];
for (var i = 1; i < $gameParty.aliveMembers().length; ++i) {
var member = $gameParty.aliveMembers()[i];
if (member.hpRate() < lowestMember.hpRate()) {
lowestMember = member;
}
}
And added a force action at the end to use the item. This works but since I'm not good with code and all that I don't know how, or even if it's possible, to change it to use the skill only if the ally is under 20% max HP.
Does anybody have an idea or a workaround to this ?