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,145
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,937
Reaction score
14,774
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.

Latest Threads

Latest Profile Posts

..of the major old school series that began in the 80s- early 90s, I still haven't beaten 'a' Zelda game. Mario 64 was the first Mario I've beaten. I don't know if I should give that honor to Link to the Past or A Link Between Worlds(I currently own both). Well technically I've haven't beaten a Sonic either (Game Genie doesn't count =P).
headshot_headinfo.jpg
Time to add the "headshot" concept into the game so that people may actually aim at the heads when shooting zombies and get massive damage and armor-pen bonus as rewards. :kaojoy:
(The red area is just for visually debug purposes right now. But, it's possible that I will add something that displays the weak spots of enemies in the future.)
Worked on a cutscene skip domino effect using Maker Systems' script as the basis. Basically if I have a batch of cutscenes in a row on different maps, now when you skip one cutscene it will skip the entire set. No more spamming X to skip a scene every new map.

Oh and it will work regardless of where you do it from in the set. Convenient!
seems absolutely WILD to me now all the hundreds of hours of work I used to do in 2k(3) over a decade ago with a resolution of 320x240. that seems so insanely TINY now, seemed so normal at the time!
Playing Aroma Indosiar theme song.
Aroma is an Indonesian TV show about cooking. :)

Forum statistics

Threads
115,381
Messages
1,089,405
Members
150,089
Latest member
Vargass02
Top