Heal player per life percentage

mogneto

Gureito Eventer
Member
Joined
Oct 2, 2016
Messages
18
Reaction score
6
First Language
Portuguese
Primarily Uses
RMMV
Morning, Night or Evening to all of you!

Well, I was trying to do this script thing and I have a problem here.

$gameActors.actor(1).gainHp(0.04*(m.mhp));

So I want this script call to heal my actor for 4% of his HP when the script is active. Sadly this doesn't happen
when I use this command, but it happens if I use number values instead, just like this:

$gameActors.actor(1).gainHp(100);

What did I do wrong?
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
The shortcut for "user" is a, and the shortcut for "target" is b... not m. If you are doing this outside of a battle formula, you need to reference the object (so $gameActors.actor(1) in your case) rather than use a shortcut.
 

mogneto

Gureito Eventer
Member
Joined
Oct 2, 2016
Messages
18
Reaction score
6
First Language
Portuguese
Primarily Uses
RMMV
Mr. Wavelength, you're a god.

What you told me was very helpful. For your contribuition, you've been honored.
Again, you have my thanks.
 

mogneto

Gureito Eventer
Member
Joined
Oct 2, 2016
Messages
18
Reaction score
6
First Language
Portuguese
Primarily Uses
RMMV
I'm also trying to round up my heal, because sometimes it comes with decimal values.

tried to do something like this but it didn't work.

var m = $gameActors.actor(2)

Math.round($gameActors.actor(2).gainHp(0.04*(m.mhp)));
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,892
Reaction score
1,026
First Language
Dutch
Primarily Uses
RMMV
dont use m.mhp on the end, just mhp can do because m.mhp has no strings.
if mhp dont work, use ._mhp, i dont see why you use var though.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
I'm also trying to round up my heal, because sometimes it comes with decimal values.

tried to do something like this but it didn't work.

var m = $gameActors.actor(2)

Math.round($gameActors.actor(2).gainHp(0.04*(m.mhp)));
It's a logic error. gainHp() doesn't return a value, so you won't be able to round it. Try:

$gameActors.actor(2).gainHp(Math.round(0.04*(m.mhp)));

or, to ensure you're always rounding up:

$gameActors.actor(2).gainHp(Math.ceil(0.04*(m.mhp)));
 

mogneto

Gureito Eventer
Member
Joined
Oct 2, 2016
Messages
18
Reaction score
6
First Language
Portuguese
Primarily Uses
RMMV
It's a logic error. gainHp() doesn't return a value, so you won't be able to round it. Try:

$gameActors.actor(2).gainHp(Math.round(0.04*(m.mhp)));

or, to ensure you're always rounding up:

$gameActors.actor(2).gainHp(Math.ceil(0.04*(m.mhp)));
It worked pretty fine! Thank you all guys!
 

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,848
Messages
1,016,974
Members
137,562
Latest member
visploo100
Top