How to make a transform skill where the character heals a percentage of their current HP

rishellz

Villager
Member
Joined
Jan 12, 2014
Messages
12
Reaction score
0
First Language
English
Primarily Uses
I have a character who can transform into a bear mid battle. I've set this as a state and her max HP goes up by 160%.

I want to make it so that when she transforms, the percentage difference of her normal form's hp correlates to the new hp, if you get what I mean.

For example, say in normal form her max hp is 100 and she has been damaged so that her current hp now sits at 75. There is now a 25% difference between her current hp and her max hp. When she transforms into a bear her max hp will rise to 160. Currently all I can do is have her current hp stay at 75 or it all heals up to 160, but what I really want it to do is to increase up to 120 so that there is still only a 25% difference between max hp and current hp.

I tried having a common event where it sets a variable for her current hp and multiply that by 1.6 then to heal hp amount set to that variable, but it didn't accept decimals and it made her heal fully anyway.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
The common event is still the only way to go, but you need to work on the formula because all decimals are cut off when converting into integer variables.


Instead of multiplying by 1.6, you multiply by 160 and then divide by 100 - it's important that the multiplication is first and the division last to minimize the effect of the integer-cutoff.
 

rishellz

Villager
Member
Joined
Jan 12, 2014
Messages
12
Reaction score
0
First Language
English
Primarily Uses
That makes sense, but it's still not working.

I think my problem is it's healing her the amount of hp that it sets it to be, and not bringing her up to to that amount. 

Here is the event process:

If state bear is inflicted

-set variable hp to players hp

-control variable hp * 160

-control variable hp / 100

-change hp, player + variable hp
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
I think my problem is it's healing her the amount of hp that it sets it to be, and not bringing her up to to that amount.
That is correct, in change HP you always need to give the wanted difference.
Just add one more control variable, substracting the current player HP, before using change HP.
 

rishellz

Villager
Member
Joined
Jan 12, 2014
Messages
12
Reaction score
0
First Language
English
Primarily Uses
Thanks! It works! Now just one more thing... how can I reverse the effect when I transform back to regular form?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
back to the exact HP before: store the value in a variable before changing


back to a proportional part of the remaining HP: reverse the formula (multiply by 100, divide by 160)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top