Convert HP into percent

Hello,

I've been looking for two days how to transform hero's HP in percentage.

My project is to display pictures on map (screen that breaks) when hero's HP are less than or equal to 50%, 40%, 20%, etc ...
I don't understand if it's possible.
$game_actor[ID].hp_rate Returns a value between 0.00 and 1.00 where 0.00 is 0% and 1.00 is 100%.
$game_actor[ID].hp / $game_actor[ID].mhp will give you this rate as well.

So as a conditional:
$game_actor[ID].hp_rate < 0.5 Is the actor's HP less than 50%?
$game_actor[ID].hp_rate < 0.2 Is the actor's HP less than 20%?
Hmm... Where did I fail ?

462203erreur.gif
Use parenthesis not brackets, also I would set it as a parallel event and then set a variable name Actor1Health with java script. Set the variable to:
Math.round(($gameActors.actor(1).hp / $gameActors.actor(1).mhp)*100)

Then all you have to do is say if Actor1Health is less than fifty do this:



Actually I found a much easier way to do this it already has code to do this in troops.
Thanks but it isn't MV 🙂

I do this, with the same error :
941493toujourspas.gif
Sorry, just make it plural. $game_actors[1].hp_rate I forget sometimes since I rarely use script calls this way.
It will be fine ! Very interesting. Thread resolved. ; )
report it if you want it closed (as per forum rules)

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/convert-hp-into-percent.79135/