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

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top