Skill target most damaged party members

Joined
Dec 15, 2014
Messages
91
Reaction score
47
First Language
English
Primarily Uses
RMMV
Is there a way to make a skill target the two actors with most missing HP? I got help with a notetag a while back but it only takes current HP into consideration, which means that if I have two party members with 100 Max HP but 75 current HP, and one party member with 50 Max HP, one of the people healed will be the 50 HP actor even though she hasn't taken any damage.

This is the notetag -

<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>
 

JGreene

Veteran
Veteran
Joined
Oct 24, 2015
Messages
395
Reaction score
297
First Language
English
Primarily Uses
RMMV
You would have to make a var for the percentage of hp left on each actor.

var hppercent = Math.ceil(member.hp / member.mhp)

A formula like that, but change "member" to your defined var.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
533
Reaction score
235
First Language
English
Primarily Uses
RMMV
You don't need to do that calculation yourself, MV provides it for you.

JavaScript:
member.hpRate()
You may still want the Math.ceil call.

JavaScript:
Math.ceil(member.hpRate())
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top