Is it possible to set actor HP directly, even to a variable?

I'm looking for a way to change HP based on a the specific suit/armor my character wears, which is decided by a variable determining which one they have equipped. That armor also has different states (Worn, new, damaged) which changes the variable amount as well. I'd like the HP to automatically be changed and updated with it depending on if you take it off or put it back on. This doesn't have anything to do with actual system equipment or armor since it's all handled by different variables.

Is there a way to set HP to a variable in MV?
I've tried the simplest ways like
$gameActors.actor(1).hp = $gameVariables.value(22)

but it doesn't seem to work. There are obvious ways to add or subtract an amount to the actor's HP, but I don't want to add or minus, I want it precisely set to a number I choose.

Set HP.PNG

Is there any actual way to do this? I'm a little lost here.
Not sure what you want to achieve. You want the hp to change, or the max hp? And how does it update automatically? Is it a common event that is constantly called? We need more details.

Also, $gameActors is just the data for actors in general, not the hero in the party. It's like a prototype from which an actor is created when he is added to the party. The proper way to change the hp of an actor in the party is:

Code:
$gameParty.members()[partyId].hp = $gameVariables.value(22); 

// partyId being the id of the member, which is not the same as the actor id. 
// It's the order of the actors in the party.
There surely is some comand for it, but i dont know it, a workaround would be to use a mathematically formula.

If you want to set Player HP to 5000.

$gameVariables.value(22) - $gameActors.actor(1).hp
$gameActors.actor(1).hp + $gameVariables.value(22)

with numbers:

5000(Var22) - 2000(ActorHP) = 3000
2000(ActorHP) + 3000 = 5000

Whatever Value you want to set HP to, just substract the HP first, than add the rest of the Value to the HP.
Not sure what you want to achieve. You want the hp to change, or the max hp? And how does it update automatically? Is it a common event that is constantly called? We need more details.

Also, $gameActors is just the data for actors in general, not the hero in the party. It's like a prototype from which an actor is created when he is added to the party. The proper way to change the hp of an actor in the party is:

Code:
$gameParty.members()[partyId].hp = $gameVariables.value(22);

// partyId being the id of the member, which is not the same as the actor id.
// It's the order of the actors in the party.

I get a suit with 65 HP. (With a variable set to 65)
I want to immediately set the actor's HP to 65. (Whether it was 100, 1000 or 0 before)
I get a suit with 5 Hp. (With a variable set at 5)
I want to set the actor's HP to 5.

It would be updated thru a Parallel Processing event.
I'll try that code and get back to you.

There surely is some comand for it, but i dont know it, a workaround would be to use a mathematically formula.

If you want to set Player HP to 5000.

$gameVariables.value(22) - $gameActors.actor(1).hp
$gameActors.actor(1).hp + $gameVariables.value(22)

with numbers:

5000(Var22) - 2000(ActorHP) = 3000
2000(ActorHP) + 3000 = 5000

Whatever Value you want to set HP to, just substract the HP first, than add the rest of the Value to the HP.

Well yes, this is an easy way to add or subtract.
But I want to set the Actor HP to the variable.

So if the Game variable is 3000, I want to do a script command that sets the HP to 3000 because that's what the game variable amount is telling it too. Adding or subtracting is somewhat oblique to my goal.
On Page 1 of the Event commands, there is an option called change parameter.
Within this option, you can change an actor's MaxHP to the value stored in a variable.

For flexibility, the id of the actor can also be selected from a variable, as opposed to specifically handling for each character with multiple change parameter commands.
On Page 1 of the Event commands, there is an option called change parameter.
Within this option, you can change an actor's MaxHP to the value stored in a variable.

For flexibility, the id of the actor can also be selected from a variable, as opposed to specifically handling for each character with multiple change parameter commands.

I'm not looking to change the Max HP however. Just the regular HP;
If the variable I want to change the health into is 55, it should read 55/1000 by the end of it.

Also, $gameActors is just the data for actors in general, not the hero in the party. It's like a prototype from which an actor is created when he is added to the party. The proper way to change the hp of an actor in the party is:

Code:
$gameParty.members()[partyId].hp = $gameVariables.value(22);

// partyId being the id of the member, which is not the same as the actor id.
// It's the order of the actors in the party.



Alright, I attempted to use $gameParty.members()[partyId].hp and either I'm doing this completely wrong or something has just flat out gone wrong.
2.PNG

The HP remains completely unchanged after:
HP.PNG

I even tried not setting it to a variable but custom amount, in this case an hp of 16.

3.PNG
It flat out refused to budge the member in my party's hp.
At this point I'm pretty confused and flat out stuck.
Changing the HP is one of the options. I just used Max HP as an example because I wasn't sure if it would be more useful to you. Did you try it out?

Also, just use $gameActors.actor(actorID)._hp = $gameVariables.value(id). It just worked for me. Make sure you open your menu AFTER you do this to see the change updated (just in case)

EDIT: I just tested and confirmed that you won't see the update to HP while your menu is open. You need to close and open it to see the update, or refresh it in some way. I don't know the correct method to refresh/update menus, I've trying for a few minutes.
Changing the HP is one of the options. I just used Max HP as an example because I wasn't sure if it would be more useful to you. Did you try it out?

Also, just use $gameActors.actor(actorID)._hp = $gameVariables.value(id). It just worked for me. Make sure you open your menu AFTER you do this to see the change updated (just in case)

EDIT: I just tested and confirmed that you won't see the update to HP while your menu is open. You need to close and open it to see the update, or refresh it in some way. I don't know the correct method to refresh/update menus, I've trying for a few minutes.

Oh wow, that actually works.
I set it to the parallel processing event and it updated the HP every step. Apparently it was just the "_" I was missing then?

Thank you so much! That'll come in handy immensely as I work thru my project.
@BrandyMoon no problem, happy to help XD
I'm not looking to change the Max HP however. Just the regular HP;
I think you misunderstand what the values are. You NEED to change MaxHP for this to work.

HP is the current HP - the LEFT number of HP on the status screen.
MaxHP is tha maximum HP number that the player can be healed to - the RIGHT number of HP on the status screen.

If your parallel process changes HP, then it will heal the played to that HP number whenever it is processed - have your actor with the suit of 65 HP be damaged for 50 HP and the damage will vanish the moment the parallel process sets it to 65 again.
What you want is to change the MaxHP, because only that will allow your actor to be wounded with a lower number.

Original thread: https://forums.rpgmakerweb.com/threads/is-it-possible-to-set-actor-hp-directly-even-to-a-variable.110627/