Setting Actor HP?

Status
Not open for further replies.

ZServ

Veteran
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
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?

"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
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
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?

"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

Status
Not open for further replies.

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).

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.
(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.