[Solved] % of damage converted to MP gain?

So the way I did it in my game is:

var dmg = (a.atk * 1.5) - b.def; a.gainMp(Math.floor(dmg * 0.1)); dmg

This would mean that i would gain back 10% of my damage done as MP right?

So why is it, when I do 100 somthing damage, i only get back like 6 MP?

Since when is 6 10% of 100?

What am i doing wrong? lol
Do you have any variance on the damage?
Do you have any variance on the damage?

Yep. And does that affect the MP gain? can I have the MP gain always be 10% of the damage delt without being affected by variance?
The problem is that the variance is calculated after the damage formula is, so your MP gain from just doing it that way is pretty much always going to be based on the raw value. Short of getting rid of variance in attacks entirely, your best bet is using Yanfly's Skill Core plugin and adding the MP restoration as a Post-Damage Effect notetag.

The alternative if you don't want to go down that route is setting the variance in the database itself to 0% and incorporating the variance calculation into your damage formula, but that still won't account for things like elemental weaknesses.
The problem is that the variance is calculated after the damage formula is, so your MP gain from just doing it that way is pretty much always going to be based on the raw value. Short of getting rid of variance in attacks entirely, your best bet is using Yanfly's Skill Core plugin and adding the MP restoration as a Post-Damage Effect notetag.

The alternative if you don't want to go down that route is setting the variance in the database itself to 0% and incorporating the variance calculation into your damage formula, but that still won't account for things like elemental weaknesses.

So apperently I have no idea how to use the Lunatic Mode in the Skill Core.

What I have (and dosnt work) is:

<Post-Damage Eval> value = a.gainMp(Math.floor(dmg * 0.1)) </Post-Damage Eval>
You don’t want to reset the value, that does nothing post damage. You want to use the value as the +MP.

var magic = value
user.gainMp(magic)

something like this ^^
substitute ‘magic’ for any word you want
You don’t want to reset the value, that does nothing post damage. You want to use the value as the +MP.

var magic = value
user.gainMp(magic)

something like this ^^
substitute ‘magic’ for any word you want

Thank you for that. I feel we are getting somewhere, but this still wont allow for MP gain. Tried looking into console to see if any errors popped up and I got nothing.

My current eval

Code:
<Post-Damage Eval>
var magic = value;
user.gainMp(Math.floor(magic * 0.1));
</Post-Damage Eval>

I feel like I am doing something wrong. Lol. I really suck at this.
With that formula, you need to do at least 10 damage before you gain any MP. Is that what you want?

Side note: you don't need the variable, just user.gainMp(value) should be enough.
With that formula, you need to do at least 10 damage before you gain any MP. Is that what you want?

Side note: you don't need the variable, just user.gainMp(value) should be enough.

See, thats what I am talking about. No idea what I am doing.

What I wanted was to have a percentage of ANY damage the main attack does (10%) to be converted to mp gain.

Lets say I do 100 damage. 10 of the damage will be given to me as mp gain.

Would that just be user.gainMp(value * 0.1)?
I know you use a few of my plugins, so if AES_BattleCore is one of them, you can take advantage of its manual variance function via the formula box. Just make sure you set the formula box variance to 0%, then...

Formula box:
Code:
c = Aesica.BattleCore.variance(YOUR_DAMAGE_FORMULA_HERE, 0.1); a.gainMp(Math.floor(c * 0.1)); c

This way, the variance will be calculated as part of the damage formula, not afterward so the rest should work as expected.

Edit: There's also Yanfly's lifesteal (is that still a free plugin?) where it's as easy as putting a note tag in the skill:

<MP Life Steal: 10%>
I know you use a few of my plugins, so if AES_BattleCore is one of them, you can take advantage of its manual variance function via the formula box. Just make sure you set the formula box variance to 0%, then...

Formula box:
Code:
c = Aesica.BattleCore.variance(YOUR_DAMAGE_FORMULA_HERE, 0.1); a.gainMp(Math.floor(c * 0.1)); c

This way, the variance will be calculated as part of the damage formula, not afterward so the rest should work as expected.

Edit: There's also Yanfly's lifesteal (is that still a free plugin?) where it's as easy as putting a note tag in the skill:

<MP Life Steal: 10%>

I have this weird thing where if I think about something a lot it will happen and I was literally just thinking about you because I know your plugins are so Yanfly compatible so i figured maybe you had something in one of your plugins with the same kind of features.

I looked and sadly could not find it. Thank you for telling me.

Definatly will look into the MP life steal. I thought it was only HP so that didn't even occur to me.

EDIT: MP life steal totally worked. Thank you for being a lifesaver, once again. LMAO. What would I do without this community....

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-of-damage-converted-to-mp-gain.123904/