[HELP] Event increasing HP up to 50% of health?

I'm trying to figure out how to create an event that will increase the players life by 50% of their max hp. so if they have 100 max HP and their health is below 50 then the event will heal the characters health up to 50hp. If they have 50 or more it won't do anything.

For the life of me I can't figure out how to do this with variables. because obviously at some point their max hp will be 300.

Any help is appreciated. Thanks guys!
Is this event meant to occur during a battle or on the map? And what does the player's MHP being 300 do; do you not want to heal them if it's that?
script condition

true if $game_actors[#].hp < ($game_actors[#].mhp / 2).to_iscript input:

$game_actors[#].hp += ($game_actors[#].mhp / 2).to_i
do so for each actor.

What I would do myself is add to the on_turn_end under game_battler

self.hp += (self.mhp / 2).to_i unless $game_interpreter.running?

when out of battle and a "click" ends (20 steps by default I think), it will add the 50% hp to each actor in party when out of battle.

Those are just a few ways to go about it.
Thanks for your reply!

This event needs to occur outside of battle.

This event should increase the players health up to 50% of their MHP see examples below:

Player's MHP = 100

Players current HP 22

Player activates event.

Playe'rs HP is now 50

-----------------------

Player's MHP = 100

Players current HP 60

Player activates event.

Playe'rs HP is still 60 because they're current HP is more than half of their MHP (100)

-----------------------

Player's MHP = 300

Players current HP 140

Player activates event.

Playe'rs HP is now 150

-----------------------

Player's MHP = 300

Players current HP 151

Player activates event.

Playe'rs HP is still 151 because their current HP s more than half of their MHP (150)
the problem with using an event is you have to single out each actor.

My first option will be your best option, but you have to repeat it for each actor.

Code:
condition actor 1 is in party  condition script: true if $game_actors[1].hp < ($game_actors[1].mhp / 2).to_i    script: $game_actors[1].hp += ($game_actors[1].mhp / 2).to_i  end branchend branchcondition actor 2 is in party  condition script: true if $game_actors[2].hp < ($game_actors[2].mhp / 2).to_i    script: $game_actors[2].hp += ($game_actors[2].mhp / 2).to_i  end branchend branch
and so on. it will also need to be a parallel event. Sometimes I find use of small waits to make sure the interpreter doesn't skip some steps.
If you don't want to repeat deilin's code for each actor and don't mind using a variable, use this script call:

Code:
while $game_variables[1] <= 4if $game_actors[1 + $game_variables[1]].hp < ($game_actors[1 + $game_variables[1]].mhp / 2).to_i $game_actors[1 + $game_variables[1]].hp += ($game_actors[1 + $game_variables[1]].mhp / 2).to_iend$game_variables[1] += 1end$game_variables[1] = 0
If you want to avoid scripts it might be possible to set it up through states, common events, and conditional branches. If that doesn't help let me know and I'll tell you more about what I'm thinking. =D
Just for the sake of completion you could do that using variables, but unfortunately you'd have to implement that for each individual actor:

- Set a variable to ActorX's MHP and divide it by 2

(Now you got the minimum target HP value)

- Subtract ActorX's current HP from it

(Now you got the missing amount of HP for that actor. If the result is negative, the actors HP is above the target value)

- If the result is positive (Conditional Branch), increase ActorX's HP by that amount

Edit: The "Change HP" event command does ignore dead actors. If you want to heal dead actors as well you have to remove the "Death" state first.

Original thread: https://forums.rpgmakerweb.com/threads/help-event-increasing-hp-up-to-50-of-health.40751/