$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,955
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,955
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,955
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

Finished that egg-sitting mini-game I mentioned here a couple weeks back. Now to fix the weather system so it doesn't rain indoors while you're playing it. >.> A simple fix in itself; leave it to me to take it as an excuse to completely revamp the time/weather/lighting system from scratch.
I'm really tempting to pre order cyberpunk 2077... should I do it or not :/ I really want to play the game but don't want to take a big hit to my saving because of it
So I need to come up with quite a few action sequences.
Was stressing about this plugin earlier, but pretty happy with how its looking now! Purple makes it pop more too!! :)

Forum statistics

Threads
105,485
Messages
1,014,073
Members
137,131
Latest member
Ssven10k
Top