The Mana Conversion state is a state that gives battlers a special effect as long as the state is active.
When the battler performs an attack and successfully damages a target, a proportion of the damage will be converted to MP that the attacker will receive.
So for example, if you attacked a slime for 100 damage, and 20% of the damage is converted to MP, then you will receive 20 MP from that attack!
To create your own mana conversion state, simply install the State Damage Modifiers plugin and then note-tag your states with
var mpGain = Math.floor(d * 0.2); a.gainMp(mpGain); return d;
This note-tag tells the game that the state’s effect should only be applied when the battler performs an attack.
Let’s look at what the formula is doing:
var mpGain = Math.floor(d * 0.2);
Here, we take `d`, which represents the “damage value”, and multiply it by 0.2. This is basically taking 20% of the damage.
We take the “floor” of it because otherwise it will be a decimal value. You should always round your values if your game only works with whole numbers.
This means the “attacker” will gain the specified amount of MP. It is recommended to use this method for gaining MP because the game will automatically display the MP gain popup as well.
Finally, we return the original damage value since we haven’t changed it and the plugin requires you to return a damage value.
If successful, you should be able to damage the target AND restore MP at the same time.