Percentage Healing while sleeping

Hi guys! 

Recently I've been wondering about the possibility of making a percentage healing whenever the player goes to sleep in an inn, bed... Basically, what i want is to heal the 100% of the maximum hp if the game difficulty is set to easy, heal a 75% of mhp if it's intermediate and heal a 50% if it's hard. I've been trying different ways but i'm short in ideas 🙁  Does someone know how could it be done? 

Thanks for reading!

SC Fúria
You could try something like this in the event :

Code:
◆Comment:// Easy Mode; Full Heal
◆If:gameDifficulty = 0
  ◆Script:$gameParty.members().forEach(function(member){
  :      :  member.hp = member.mhp;
  :      :};
  ◆
:End
◆Comment:// Intermediate Mode; 75% Heal
◆If:gameDifficulty = 1
  ◆Script:$gameParty.members().forEach(function(member){
  :      :  if (member.hp < (member.mhp * 0.75)) {
  :      :    member.hp = member.mhp * 0.75;
  :      :  }
  :      :};
  ◆
:End
◆Comment:// Hard Mode; 50% Heal
◆If:gameDifficulty = 2
  ◆Script:$gameParty.members().forEach(function(member){
  :      :  if (member.hp < (member.mhp * 0.50)) {
  :      :    member.hp = member.mhp * 0.50;
  :      :  }
  :      :};
  ◆
:End
Run through each member of the party and do the following for them:

  1. Store their HP in a variable (V1)
  2. Do a Recover All on the party member (so they get rid of states, knockout, etc.)
  3. Store their Max HP in another variable (V2), and multiply it by either 1.00, 0.75, or 0.50, depending on current difficulty
  4. Store their Max HP in yet another variable (V3)
  5. Compare V1 and V2.  If V1 is higher, subtract V1's value from V3.  Otherwise, subtract V2's value from V3.
  6. Reduce the party member's HP by the new, lower value of V3.
Well is it just one actor you want to have heal while sleeping in an inn, or the entire party? Or is your party just one actor?
If it's either of the former, then go with what @Wavelength said.
But if it's the last one, then a simple script call should do. I believe it's...


var player = $gameActors.actor(1);

player.gainHp(0.25*(player.mhp));


Just replace the '0.25' with '0.50' or '0.75' depending on what percent you want.

HOWEVER keep in mind you will get partial hit points through this method, so while it's simpler than the method mentioned above, use at your own risk. Same with ExHydra's I believe.
In the end I've solved it with variables, as Wavelength said. Thanks everyone! ^^
Run through each member of the party and do the following for them:

  1. Store their HP in a variable (V1)

  2. Do a Recover All on the party member (so they get rid of states, knockout, etc.)

  3. Store their Max HP in another variable (V2), and multiply it by either 1.00, 0.75, or 0.50, depending on current difficulty

  4. Store their Max HP in yet another variable (V3)

  5. Compare V1 and V2. If V1 is higher, subtract V1's value from V3. Otherwise, subtract V2's value from V3.

  6. Reduce the party member's HP by the new, lower value of V3.

How to put 1.00, 0.75, or 0.50 on variable control ? i cant put , or .
Necro-post notice: @Hunters12Closing this thread to prevent confusion.

But to answer your question real quick, what you can do is to multiply by 25, then divide by 100 in the next line. That's the same as multiplying by 0.25 🙂

Original thread: https://forums.rpgmakerweb.com/threads/percentage-healing-while-sleeping.67716/