$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 Profile Posts

Tomorrow is Thanksgiving, and I'm so excited! I've been exploring MZ a little, and I just downloaded Effekseer to make new animations. I have experience in 3D animation software, so I'll be pretty good at the whole "particle" thing. My first game on MZ will be Fantasy Force--starring a griffin, a dragon, and a pegasus fighting against the Dragon of Darkness.
currently listening to Driftwood Gaming streaming some MZ dev time and it's delightful! had no idea they were this entertaining, love it
In quarantine, will be tested soon. This year is really something... special.
I was at another orientation yesterday and I realized I'll be working with an old friend! We met at the local water park a few years back and it was so nice to see her again! We had a chat, and next week when I officially start, I'll see if maybe we can trade our Zoom IDs so we can talk!
I made some sideview closets for MV!
You can find them in my MV resource thread.

Forum statistics

Threads
105,514
Messages
1,014,343
Members
137,198
Latest member
mmc1980
Top