I have a troop with big slime enemy and smaller slime enemies. The big slime has an attack that revives and/or heals the small slimes. I want the attack to affect 3 small slimes. Priority is that if any slime is dead it revives it (full hp) and if there are no more dead slimes then I want it to heal them starting with the one with the lowest hp.
I wrote some javascript (see below) for conditions depending on the amount of dead slimes. I guess what I'd want to add here is to sort the aliveMembers array depending on their current hp (lowest first) and then pick the first x (depending on condition) to heal. But I don't know how to sort it.
EDIT: Also realized that my array indexes should start at 0, instead of 1
I wrote some javascript (see below) for conditions depending on the amount of dead slimes. I guess what I'd want to add here is to sort the aliveMembers array depending on their current hp (lowest first) and then pick the first x (depending on condition) to heal. But I don't know how to sort it.
let aliveGuys = $gameTroop.aliveMembers()let deadGuys = $gameTroop.deadMembers()if (deadGuys.length == 0) {// HEAL THREE}if (deadGuys.length == 1) {deadGuys[1].removeState(1);deadGuys[1].gainHp(30);// HEAL TWO}if (deadGuys.length == 2) {deadGuys[1].removeState(1);deadGuys[1].gainHp(30);deadGuys[2].removeState(1);deadGuys[2].gainHp(30);// HEAL ONE}if (deadGuys.length >= 3) {deadGuys[1].removeState(1);deadGuys[1].gainHp(30);deadGuys[2].removeState(1);deadGuys[2].gainHp(30);deadGuys[3].removeState(1);deadGuys[3].gainHp(30);}EDIT: Also realized that my array indexes should start at 0, instead of 1