How do you make a skill that drains both HP and MP?

I'm reposting this since the last time I asked this, I didn't get many answers, and the few answers I did get either needed me to get a paid plugin or were vague.

But yeah, it's exactly what it says on the tin. Is it possible to make a skill that drains both HP and MP from an enemy, preferably without a paid plugin?
you can do it with yanfly's skill core easily. If your skill does hp damage and draining, you can handle the mp damage and draining with a notetag

Code:
<Post-Damage Eval>
target.gainMp(-value);
user.gainMp(value);
</Post-Damage Eval>
you can do it with yanfly's skill core easily. If your skill does hp damage and draining, you can handle the mp damage and draining with a notetag

Code:
<Post-Damage Eval>
target.gainMp(-value);
user.gainMp(value);
</Post-Damage Eval>
So I followed your advice, and it works.

Code:
<Post-Damage Eval>
target.gainMp(Math.max(1, a.mat - b.mdf * 0.5));
user.gainMp(Math.max(1, a.mat - b.mdf * 0.5));
</Post-Damage Eval>

But now there are two problems. Firstly, the MP drainage doesn't have any variance to it, it just drains the same amount of MP every time I use the skill.

And second, the MP drainage falls into the decimals, but since the damage popups don't support decimals, I just get the following attachment. How do I fix these problems?
And second, the MP drainage falls into the decimals, but since the damage popups don't support decimals, I just get the following attachment. How do I fix these problems?
you can use Math.round() to round your formula
Code:
<Post-Damage Eval>
target.gainMp(Math.max(1, Math.round(a.mat - b.mdf * 0.5)));
user.gainMp(Math.max(1, Math.round(a.mat - b.mdf * 0.5)));
</Post-Damage Eval>

But now there are two problems. Firstly, the MP drainage doesn't have any variance to it, it just drains the same amount of MP every time I use the skill.
youd have to do a little math to introduce variance. in this one, you would only need to edit the first 2 lines if you would want to change anything

Code:
<Post-Damage Eval>
var damage = a.mat - b.mdf * 0.5;
var variance = .2;

damage = Math.ceil(damage + Math.random() * (damage*variance*2) - damage*variance);
target.gainMp(Math.max(1, -damage));
user.gainMp(Math.max(1, damage));
</Post-Damage Eval>

but, the "value" in the first one wasnt a placeholder. when you use "value" in that notetag, its a quick way to grab amount of damage being dealt. meaning, if your skill already has damage variance, value would also have variance calced into it. Math.round(value/4) for example would have resulted in 25% of damage dealt, variance and all
It works now, thanks for the help!

Original thread: https://forums.rpgmakerweb.com/threads/how-do-you-make-a-skill-that-drains-both-hp-and-mp.167804/