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
6,002
Reaction score
5,642
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
3,818
Reaction score
1,448
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
6,002
Reaction score
5,642
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!
 

Latest Threads

Latest Posts

Latest Profile Posts

Took our dogs on a walk and someone asked if our smallest one was a gueanie pig ((however it's spelt))
I decided to create reboots of my games on RPG Maker MV. I'm happy. :biggrin:
So, as i finish setting up my items for part 1 of my game, I realized I forgot to finalize an ENTIRE category of items. Know which ones? The Fallen Feathers....BTW my game is called "Fallen Feather"
and_remember_tomorrow_exploding_puzzle_logo.jpg

Made some new friends, and blew up a puzzle... Happens. :LZSwink:
A new RPG Maker music pack is coming out soon! Below is a demo of one of the compositions in the pack, Heroic Battle. More details coming soon!

Forum statistics

Threads
111,148
Messages
1,058,705
Members
144,374
Latest member
strawbies
Top