How to reduce the life of the actor by means of percentage?

TheBreaker24998

Veteran
Veteran
Joined
May 18, 2020
Messages
34
Reaction score
3
First Language
Español
Primarily Uses
RMMV
Hello everyone, I am doing an event where for example:

If the life of the actor is equal to 70%, something happens.


I tried to do it through variables and conditional derivations that the program offers me, but the life of the actor can only be decreased by means of points, not by percentages, such as:

if the actor's life equals 300, something happens

But I need it to be by percentage.

Is there a way to do it?

Thank you!

Something I forgot to mention:
The actor does not have a defined HP, since he must level up, therefore, if he levels up, his HP changes in value, therefore it is not known how much HP he will have when he executes that mission, that is why I need by means of percentage
 
Last edited:

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,984
Reaction score
1,446
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi!
You can discover it with a simple "rule of 3".

100% = 300
70% = x

Then you cross multiply the numbers.

x = (300*70) / 100
x = 210.
70% of the actor's hp is 210 points.
 

TheBreaker24998

Veteran
Veteran
Joined
May 18, 2020
Messages
34
Reaction score
3
First Language
Español
Primarily Uses
RMMV
[QUOTE = "Eliaquim, publicación: 1119715, miembro: 123037"]
¡Hola!
Puedes descubrirlo con una simple "regla de 3".

100% = 300
70% = x

Luego cruzas, multiplicas los números.

x = (300 * 70) / 100
x = 210.
El 70% del CV del actor son 210 puntos.
[/ CITAR]
I understand what you want to tell me, and it's fine, but there is a problem, it's something I forgot to mention, the actor can have any amount of HP, since the actor must level up, so if for example if the actor in the level 1 It has 300 hp, at level 2 it will increase its HP, it will be different from 300, it is a mission that will be in the middle of the game, it is a video game in which you must level up and have combat with enemies, therefore, that percentage is unknown, it is not known if the actor will have 300 hp or 400 or 500 when he performs that event, therefore what you tell me would not work :(
 

Aerosys

Veteran
Veteran
Joined
Apr 23, 2019
Messages
550
Reaction score
530
First Language
german
Primarily Uses
RMMZ
I think you can get the MaxHP by using a Variable Operation. Otherwise you can call a script snippet

const mhp = $gameParty.actors.get(1).mhp;
$gameVariables.setValue(1, mhp);

Havent checked this snippet as Im not at home. You may want to use others numbers than 1 from this example.
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
216
Reaction score
124
First Language
French
Primarily Uses
RMMV
If it's damage given by a skill, it's as easy as (b.mhp*30)/100 in the damage formula for 30% HP lost.
If the damage in formula is already occupied, try this: a.gainHp(0-(a.mhp*30)/100)); FORMULA and replace FORMULA with the damage formula you already have. This will remove 30% HP from the user of the skill, no matter who is targeted.

Through eventing:
First, set up a temporary variable. Any variable slot will do.
Set its value to the max HP of the actor that's going to lose HP.
Multiply that variable by 30.
Divide that variable by 100.
Select "Change actor HP", and decrease the HP of the actor you picked by the number contained by the variable.
 

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
340
Reaction score
106
First Language
English
Primarily Uses
RMMV
[QUOTE = "Eliaquim, publicación: 1119715, miembro: 123037"]
¡Hola!
Puedes descubrirlo con una simple "regla de 3".

100% = 300
70% = x

Luego cruzas, multiplicas los números.

x = (300 * 70) / 100
x = 210.
El 70% del CV del actor son 210 puntos.
[/ CITAR]
I understand what you want to tell me, and it's fine, but there is a problem, it's something I forgot to mention, the actor can have any amount of HP, since the actor must level up, so if for example if the actor in the level 1 It has 300 hp, at level 2 it will increase its HP, it will be different from 300, it is a mission that will be in the middle of the game, it is a video game in which you must level up and have combat with enemies, therefore, that percentage is unknown, it is not known if the actor will have 300 hp or 400 or 500 when he performs that event, therefore what you tell me would not work :(


Create a parallel common event, with the trigger being any switch you enable at the start of the game that is meant to always be on.
In the common event, do Control Variable, designate a variable (in this example, variable 1), choose Set, then choose Game Data, Actor, select the actor, then hit Max HP.
By doing this, you will now have the game constantly refreshing the value of the variable you designated for the actor's max HP, in this case, variable 1.

Now you can do what Eliaquim said, because you now have the value of the character's Max HP constantly refreshing to ensure it's accuracy, regardless of level.
 
Last edited:

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,984
Reaction score
1,446
First Language
Portuguese - Br
Primarily Uses
RMMZ
Ah, ok I get it.
But you can do all of this with variables.
1600152232882.png
 

Latest Threads

Latest Posts

Latest Profile Posts

Took a small break by playing VR. Latest update of these glasses unfortunately caused a little of trouble but it can be fixed with a manual operation.

Until You Fall is freaking awesome.
I am SO HYPED to share this trailer with everyone when its done. I almost want to tear up i had no idea how far i came along with Fallen Feather in these last 3 years.
how it looks from the top
Hike was successful guys! I made it to the top!
Add Film-like Visual Effects During Test-Play, Deploy Games with Electron | RPG Maker News #69

Forum statistics

Threads
112,187
Messages
1,066,460
Members
145,788
Latest member
Alavardo
Top