Setting Actor HP?

Status
Not open for further replies.

ZServ

Veteran
Veteran
Joined
Jun 16, 2014
Messages
260
Reaction score
71
Primarily Uses
I'm trying to adjust Actor's HP so that it scales with various buffs/debuffs. Here's the general gist:
Actor1 has an MHP of 100
They have 70 HP

If they have a debuff that makes MHP 75%, their HP should scale down to 35. If it's a buff that makes it 200%, then it should be 140 HP.

What I'd like to do is:
Take current HP, divide by max HP. This gives a percentage. We save this as a variable. Then, set their HP to be equal to MHP * variable. This is what it looks like thus far:

Code:
$gameActors.actor(1).gainHp($gameActors.actor(1).mhp*$gameVariables.value(39))
The problem is, this is gainHP. So, they'll actually be GIVEN that much HP, rather than adjusting their HP to that number. Any thoughts?
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
1.) I don't think I understand your math well:
Actor1 has an MHP of 100
They have 70 HP

If they have a debuff that makes MHP 75%, their HP should scale down to 35.
"If they have a debuff that makes MHP 75%, their HP should scale down to 35." --> why would the HP go down by half if the MHP goes down by a quarter?

Using your example:

"Take current HP, divide by max HP"
70 / 100 = 0.70 (or 70%)
"debuff that makes MHP 75%"
MHP = 100 * 0.75 = 75
"Then, set their HP to be equal to MHP * variable."
HP = 75 * 0.70 = 52.5

Am I missing something?

2.) If you want to set the HP rather than gain HP, use setHp() rather than gainHp()
 

Alisu

Veteran
Veteran
Joined
Apr 4, 2018
Messages
61
Reaction score
36
First Language
Finnish
Primarily Uses
RMMV
To clarify what you want to do. In case the MHP goes up or down, you want the actors to keep the same HP rate they had? So if actor has 70% health left, and their MHP changes, you still want them to have 70% left?

There is, by the way, command for .hprate() which returns the HP/MHP . Other than that, yes, go with .setHp(hp)
 

ZServ

Veteran
Veteran
Joined
Jun 16, 2014
Messages
260
Reaction score
71
Primarily Uses
1.) I don't think I understand your math well:


"If they have a debuff that makes MHP 75%, their HP should scale down to 35." --> why would the HP go down by half if the MHP goes down by a quarter?

Using your example:

"Take current HP, divide by max HP"
70 / 100 = 0.70 (or 70%)
"debuff that makes MHP 75%"
MHP = 100 * 0.75 = 75
"Then, set their HP to be equal to MHP * variable."
HP = 75 * 0.70 = 52.5

Am I missing something?

2.) If you want to set the HP rather than gain HP, use setHp() rather than gainHp()
To clarify what you want to do. In case the MHP goes up or down, you want the actors to keep the same HP rate they had? So if actor has 70% health left, and their MHP changes, you still want them to have 70% left?

There is, by the way, command for .hprate() which returns the HP/MHP . Other than that, yes, go with .setHp(hp)
I'm awful at math. Whoops! Oh well, you guys knew what I was looking for with .setHp. Thank you, a bunch <3
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top