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

Nerdboy

Veteran
Veteran
Joined
Jan 4, 2017
Messages
78
Reaction score
7
Primarily Uses
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>
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,627
Reaction score
1,061
First Language
English
Primarily Uses
RMMV
<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>
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.
 

Nerdboy

Veteran
Veteran
Joined
Jan 4, 2017
Messages
78
Reaction score
7
Primarily Uses
thank you that did the trick, didnt see the i not in the loop at first it works now. great job!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Setup a system to cull enemies that are too far from the player to matter, and to spawn new ones just outside of view. Take that lag! :LZSexcite:
That trope is alive more than ever, not so much elemental Crystal's but gathering magical objects or doing "task" to unlock this oddly specific thing is everywhere, I saw it saw it in the IT 2 remake, avengers and every season of supernatural
It's raining...in winter :")
I was stunned-STUNNED-to find that I have been working on my current project since November. It feels like so much less time than that.
Stream will be live shortly with some art! Going to do a recolor, then start on a new monster! Feel free to drop by!

Forum statistics

Threads
93,712
Messages
914,864
Members
123,316
Latest member
Ceoxy-
Top