$gameVariables.value(20)._hp works but not $gameVariables.value(20).gainHp(6000);

Antera

Villager
Member
Joined
Jan 15, 2017
Messages
38
Reaction score
5
First Language
EN & FR
Primarily Uses
Hello,

Could you please help me with JS and explain to me why $gameVariables.value(20)._hp = 4000; works but not
$gameVariables.value(20).gainHp(4000); ?

Should I do something like this ?
var tmpActor = new Actor($gameVariables.value(20).actorid);
tmpActor.gainHp(4000);

Actor is taken in the formula box of the item. It's an object (when I display \V[20] I got [Object object]) and called in the common event :

ppp1.png ppp2.png

Many many thanks !
 

Antera

Villager
Member
Joined
Jan 15, 2017
Messages
38
Reaction score
5
First Language
EN & FR
Primarily Uses
I had hope changing the formula to :
$gameVariables.setValue(20,b.id);

And the script to :
$gameActors.actor($gameVariables.value(20)).gainHp(2000);

But error :-(
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
The problem is that gainHp only recovers HP, it doesn't affect max. This actually does work, but the actor would have to be damaged for you to notice the effect.

There's a reason item effects don't have an option to raise max HP: it's not that easy. The thing is, Game_Battler's mhp property returns params(0), which is a function that among other things takes paramBase(0) as its base value, which actually gets its value from the array of stats associated with the character's current class.

What you want to do is add to the battler's _paramPlus[0] variable instead, which will make their max HP higher.
 

Antera

Villager
Member
Joined
Jan 15, 2017
Messages
38
Reaction score
5
First Language
EN & FR
Primarily Uses
There's a reason item effects don't have an option to raise max HP
Well items do have an effect to grow max HP .itemEffectGrow()
Effects > Other > Grow > Max HP
add to the battler's _paramPlus[0] variable
Oh yes ! Thank you !
So : $gameVariables.value(20)._paramPlus[0] += 2000;

EDIT, needed to refresh() the actor object to see the change :

$gameVariables.value(20)._paramPlus[0] += 2000;
$gameVariables.value(20).refresh();
$gameVariables.setValue(20,0);
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
Ah, yeah, sorry. You could use the battler's addParam(0) function, which internally just adds to _paramPlus and refreshes.
 

Antera

Villager
Member
Joined
Jan 15, 2017
Messages
38
Reaction score
5
First Language
EN & FR
Primarily Uses
Ah, yeah, sorry. You could use the battler's addParam(0) function, which internally just adds to _paramPlus and refreshes.
Thanks, perfect !
Feels good to use code instead of those preset options

PS : I cant use V[41] or $V[41] instead of $gameVariables.value(41) ? I have error with both but I read that it was possible
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
Try a small v, it's case-sensitive.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Hey everyone! Not sure how many people know about Cafofo Music on Itch.io, but I highly recommend their Sound Effects! It is amazing quality AND quantity and best of all, they are having a 50% sale! I can't express how much I love sales.
Wow.... My last map GIF got 47 likes, 16 retweet and 2,105 views on Twitter in 24 hours. My game thread here's only got 3k views in 6-7 months. I guess building my Twitter was insanely worth it. :LZSexcite:
working hard working hard working hard >:)
Do you have an audio you want me to animate? If so send me the youtube link and I’ll animate it.
Okay, so I'm working on Draft 2 of my game's script.
Will try to keep you guys posted, if you're interested!

Forum statistics

Threads
105,593
Messages
1,014,860
Members
137,258
Latest member
WhimsicalFae
Top