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?
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.
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
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.