# [Solved] % of damage converted to MP gain?

Status
Not open for further replies.

#### Jenova

##### Because you are...a puppet!
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

#### Trihan

##### Speedy Scripter
Do you have any variance on the damage?

#### Jenova

##### Because you are...a puppet!
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?

#### Trihan

##### Speedy Scripter
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.

#### Jenova

##### Because you are...a puppet!
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>```

#### HumanNinjaToo

##### The Cheerful Pessimist
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

#### Jenova

##### Because you are...a puppet!
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.

#### Solar_Flare

##### Veteran
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.

#### Jenova

##### Because you are...a puppet!
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)`?

#### Aesica

##### undefined
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%>

#### Jenova

##### Because you are...a puppet!
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....

#### slimmmeiske2

##### Little Red Riding Hood

Status
Not open for further replies.

### Latest Profile Posts

I think my goal for MZ ... is to actually release a game and not have twenty technical demos and debugging projects. Let's see if I can manage that. ;o
I am starting to enjoy writing. I never thought I would enjoy it since my dyslexia was holding me back so much.
Thanks to the community here
For those interested chapter 2 and 3 are available to read here:
I'm having a fun time working with the MZ RTP. The waterfall hasn't changed, though, so I'm wondering if they didn't make a new one or if they forgot to put it in...

good progress on the typescript Definitions files almost done all the Manager and yet I still have to do the Battle Manager...who is seriously so much data lol
Are the export options for MZ known yet?