# Percentage Healing while sleeping

Status
Not open for further replies.

#### SC Fúria

##### Villager
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?

SC Fúria

#### Ossra

##### Formerly Exhydra
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``````

Last edited by a moderator:

#### Wavelength

##### MSD Strong
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.

#### Allinardo

##### Dungeon Crawler
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.

Last edited by a moderator:

#### SC Fúria

##### Villager
In the end I've solved it with variables, as Wavelength said. Thanks everyone! ^^

#### SifDoge

##### Veteran
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 .

#### Attachments

• Screenshot_1.png
31.1 KB · Views: 10

#### Wavelength

##### MSD Strong

@Hunters12 , please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.

Closing 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

Status
Not open for further replies.

### Latest Profile Posts

Free tiles
HERE
I genuinely like the default MZ actor sprites, and the character creator. I think I will draw new headshots for them, but part of me doesn't want to replace the default sprites. But should I? I want to eventually release my game.
Someday, I hope they make a game where 95% of the animation budget went to turning valves and opening door animations, leaving every other animation looking like a CDI zelda cutscene.
programming at 12 years old: "I love how it works!"
programming at 18: "I love that it works."
programming at 25: "I love why it works."
programming at 30: "I love when it works."
programming at 50: "How did this work?"
Why can't I insert picture in this profile post? Only insert image -> by URL. No option to upload from my pc?