Getting actor HP as a percentage

Status
Not open for further replies.

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I need to be able to identify in battle if a particular actor's HP [actor ID = 2] is equal to or less than 35% of MHP using a troop event set to run every turn.

I can set a variable to MHP, and another to current HP but I cannot see anywhere in a conditional branch how to determine if the second variable is equal to or less than a percentage of the first variable.

Does anyone know if this can be done e.g. with a script call in the conditional?

Thanks.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,355
Reaction score
7,669
First Language
German
Primarily Uses
RMMV
mathematics

%HP = 100*HP/MHP

So use a series of control variable commands to calculate that number and then a conditional branch if %HP is higher than 35 or not
 
  • Like
Reactions: Kes

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Code:
Conditional Branch: Script: $game_actors[2].hp_rate <= 0.35
hp_rate is an existing method that will give you the current HP / max HP. It returns a value equal to or less than 1.

0.35 is 35%
 
Last edited:

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
I always use hp_rate for this kind of thing - like @Shaz suggested.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Andar Thanks, that works - though it took a while before the enemies stopped hitting everyone else except the one I wanted damaged so that I could test it.

@Shaz and @Wavelength Thaks for that info - it will make it much quicker for other instances where I need this.

[mod]Closing, as solved.[/mod]
 

HexMozart88

The Master of Random Garbage
Veteran
Joined
May 15, 2016
Messages
1,879
Reaction score
3,349
First Language
English
Primarily Uses
RMVXA
@Kes Psst. It's not closed.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@HexMozart88 Oops! It's been one of those mornings. Thanks for letting me know.

[mod]Really closing it this time.[/mod]
 
Status
Not open for further replies.

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