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

TheBreaker24998

Villager
Member
Joined
May 18, 2020
Messages
25
Reaction score
2
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,605
Reaction score
956
First Language
Portuguese - Br
Primarily Uses
RMMV
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

Villager
Member
Joined
May 18, 2020
Messages
25
Reaction score
2
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
347
Reaction score
323
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
114
Reaction score
65
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
233
Reaction score
48
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,605
Reaction score
956
First Language
Portuguese - Br
Primarily Uses
RMMV
Ah, ok I get it.
But you can do all of this with variables.
1600152232882.png
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Ami
--- Diary ---

M.Mage: It's the F.Mage's Diary. While she isn't here,i can read it.

May, 10: I'm hurt after the battle with the Minotaur. But luckily,F.Healer heal me with her Heal-2. That why,i Fall in Love with her.

M.Mage: Eh???
So... some of my Desktop hardware has kicked it apparently (still trying to figure out what and how at the moment :/ ) .... yay?
Stream will be live shortly with some Darkest Dungeon! Feel free to drop by!
Made a HUGE (YYOOOOJJ) Update to Monstructs and moving towards a Steam Early Access release!

Forum statistics

Threads
104,224
Messages
1,004,809
Members
135,740
Latest member
Animalblack
Top