Need help with yanfly target core (hit foes with lowest hp)

Discussion in 'Javascript/Plugin Support' started by Nerdboy, Dec 29, 2017.

  1. Nerdboy

    Nerdboy Veteran Veteran

    Messages:
    78
    Likes Received:
    7
    Hi, i'm trying to create a skill that hits a foe or foes with the lowest hp, like a sniper skill. using yanfly lunatic mode target core.

    Here's what i have so far, its not working and the code seems right to me any help please?

    <Custom Target Eval>
    var lowestMember = foes.aliveMembers()[0];
    var lowestHP = lowestMember.hp;
    for (var i = 1; i < foes.aliveMembers().length; ++i) {
    var member = foes.aliveMembers();
    if (member.hp < lowestHP) {
    lowestHP = member.hp;
    lowestMember = member;
    }
    }
    targets.push(lowestMember);
    </Custom Target Eval>
     
    #1
  2. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,502
    Likes Received:
    949
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    The variable "i" is not doing anything in the loop.
    Code:
     var member = foes.aliveMembers()[i]
    I'm not familiar with the Yanfly scripts/notetags but I think that will get you closer.

    Please surround your code with the code tag for easy readability as well.
     
    #2
  3. Nerdboy

    Nerdboy Veteran Veteran

    Messages:
    78
    Likes Received:
    7
    thank you that did the trick, didnt see the i not in the loop at first it works now. great job!
     
    #3

Share This Page