Healing item does more healing if favorite item?

I was looking at




// Heal 50 HP for actor ID 1
Game_Interpreter.prototype.changeHp.call(
this, $gameActors.actor(1), 50, false
);

Would this be the script if I wanted to call a Common event and restore extra HP if the recovery item is a favorite?

But I didn't want just 50. I was hoping like to add a %?
Then make it a percent. $gameActors.actor(1).hp/2 is half of actor 1's hit points. If you want a percentage of their max hp, then use mhp instead of hp.

If you're only healing and not damaging, I would recommend using gainHp that you see in all of the threads about damage formulae, rather than the interpreter's method.

To make sure you don't get decimals anyplace, put the number inside of Math.floor(). So to heal actor 1 for half of her max HP,
Code:
$gameActors.actor(1).gainHp(Math.floor($gameActors.actor(1).mhp/2));
If you're only healing and not damaging, I would recommend using gainHp that you see in all of the threads about damage formulae, rather than the interpreter's method.

To make sure you don't get decimals anyplace, put the number inside of Math.floor(). So to heal actor 1 for half of her max HP,
Code:
$gameActors.actor(1).gainHp(Math.floor($gameActors.actor(1).mhp/2));

Yes, just extra healing. Like if the player eats an apple and gets 50Hp from it, an extra 50HP )or whatever percentage)

So if I wanted 10% healing would it be this? (Or just any Xnumber)
$gameActors.actor(1).gainHp(Math.floor($gameActors.actor(1).mhp/0.1));

What about
$gameActors.actor(1).gainHp(10%); //
So if I wanted 10% healing would it be this? (Or just any Xnumber)
$gameActors.actor(1).gainHp(Math.floor($gameActors.actor(1).mhp/0.1));
That's incorrect math. Dividing by a decimal will make a number larger.

To represent 10% of X, you would do X*.1, or X/10.
What about
$gameActors.actor(1).gainHp(10%); //
1 - 10% of what? If I ask you to charge me 10%, or give me 10%, or make me 10%, what would that mean? 😛

2 - Per my previous post, the correct way to represent a percentage is through division or multiplication. If there was a way to get it by using the percent symbol that we use in writing, I would've said so. In programming languages, that symbol is used to perform modulo arithmetic, which is not what you want - I'm not sure why you're trying to hare off in a different direction when the example I provided is pretty simple to work with 😉
Not directly an answer to the question, but as an alternative you could also include the bonus in your damage formula and skip the common event:

(Original formula) * (b === $gameActors.actor(1) ? 1.1 : 1)

(Original formula) + (b === $gameActors.actor(1) ? b.mhp * 0.1 : 0)


(the first increases the items damage/healing by 10% against the first actor, the second adds 10% of the actors maximum health to the effect instead, like in ATT_Turans example)



Another useful trick might be to reserve certain element rates for use in damage formulas:

(Original formula) * b.elementRate(15)

Modifies the result by the targets element rate for element 15 (which could be an element that only the first actor and whoever else favors the item have positive rates for).

Original thread: https://forums.rpgmakerweb.com/threads/healing-item-does-more-healing-if-favorite-item.148162/