Need help with damage/recovery forumlas

Hello all,
I need some help making formulas for skills that restore the player's MP but damage the enemy's HP as well.
I've tried putting the MP regeneration effect into the parameter's, but the issue is that those parameter's are applied to the enemies. So when you try to use Flame Punch on the rat, it deals the fire damage but it recovers 6 MP on the rat. I'd like the damage to be dealt to the rat, but MP restored to the player.
1654486574160.png

Here is what I'm doing. The issue isn't so much as causing the MP regeneration, but it's doing both at the same time. Because those Effects are to the Target, and no way to change so they affect the Caster. Any advice on how to do this would be greatly appreciated!
Set your skill to target the enemy (enemies) and set type to HP damage. In skill formula put:

a.gainMp(amount); your actuall damage formula.

aJyv6Rs.png


explanation:
first we force skill to call a method gainMp(x) for user of spell (var a), then we pass actuall damage formula to parse and proceed with the skill.

NEVER CALL METHODS IN SKILL FORMULA AT THE END OF ACTUALL FORMULA, FIELD SKILL FORMULA MUST RETURN NUMBER, OTHERWISE SKILL WILL NOT WORK.
There are many threads about this to help you. Here's a good one:
Set your skill to target the enemy (enemies) and set type to HP damage. In skill formula put:

a.gainMp(amount); your actuall damage formula.

aJyv6Rs.png


explanation:
first we force skill to call a method gainMp(x) for user of spell (var a), then we pass actuall damage formula to parse and proceed with the skill.

NEVER CALL METHODS IN SKILL FORMULA AT THE END OF ACTUALL FORMULA, FIELD SKILL FORMULA MUST RETURN NUMBER, OTHERWISE SKILL WILL NOT WORK.
I had no ideas these methods were even a thing! I tried this out using this formula.
1654549709524.png


The formula after the semicolon is still the same, it's the damage. The player gains 25% of their maximum MP pool + 7. I learned that this method IS case sensitive, so a.gainMP does nothing, apart from a.gainMp, which works as intended.
The skill functions as intended, except
1654549736519.png

The player receives a remainder of MP. Is there a way to get rid of that ugly little decimal point? Something with the formula that can be done to automatically round a number up?
Is there a way to get rid of that ugly little decimal point?
a.gainMp(Math.round(MP formula)); damage formula
The player receives a remainder of MP. Is there a way to get rid of that ugly little decimal point?
There are several JavaScript functions to get rid of decimal points. Tiamat-86 gave you one - there are three described in the post I already linked you to, depending on how you want the rounding to work.

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-damage-recovery-forumlas.148267/