Help with HP Damage and Chance to Drain MP Skill

I'm having some trouble trying to create a skill that Damges HP but also has a small percent chance to Drain MP -- I've looked at calling a state to do it and a common event, but can't quite figure out how to get it done with those. Any ideas?

Thanks.

(sorry, I bet this has already been addressed somewhere in the forums but I can't seem to find it)
when you say drain mp do you mean drain it from the enemy to you, heal a portion of the damage done as mp, instead of dealing hp damage deal mp damage and drain?
Sorry for the double post but I think found something that works for me:

I used Tsukihime's script Effect: State Action (it requires the Effects Manager script to work):

"This script allows you to force an action with your skill, depending on whether the enemy has a specific state applied or not."

First I applied an Add State (set it to x%) to my Damage HP skill and when that state is applied the script will force another skill which is the Drain MP skill.
when you say drain mp do you mean drain it from the enemy to you, heal a portion of the damage done as mp, instead of dealing hp damage deal mp damage and drain?
I would like to Damage the enemy's HP and have a % chance to Drain the enemy's MP to the player who delt the HP damage.

...I think that makes sense :dizzy:
use this in your damage formula

x = [y, b.mp].min;(b.mp -= x;a.mp += x) if rand(100) <= z;damage formula here

breakdown:

x, leave it alone

y, the amount of mp you want to drain

z, the % chance to drain mp - 1

damage formula here, your damage formula goes here.

example:

x = [10, b.mp].min; (b.mp -= x;a.mp += x) if rand(100) <= 9; 4 * a.mat - 2.b.mdf

this would have a 10% chance to drain 10 mp(or the remaining mp if the enemy has less than 10 left) from the enemy and restores it to the user of the skill

edit: havent tested this because i need to go out real soon so if it doesnt work reply and i'll get back to you.
use this in your damage formula

x = [y, b.mp].min;(b.mp -= x;a.mp += x) if rand(100) <= z;damage formula here

breakdown:

x, leave it alone

y, the amount of mp you want to drain

z, the % chance to drain mp - 1

damage formula here, your damage formula goes here.

example:

x = [10, b.mp].min; (b.mp -= x;a.mp += x) if rand(100) <= 9; 4 * a.mat - 2.b.mdf

this would have a 10% chance to drain 10 mp(or the remaining mp if the enemy has less than 10 left) from the enemy and restores it to the user of the skill

edit: havent tested this because i need to go out real soon so if it doesnt work reply and i'll get back to you.
Well, it doesn't seem to be working, but I do like the idea of having it in a formula rather than the script -- no rush if you're going out. Thanks for the help Xypher.
what doesnt work about it?
it doesn't drain MP from the enemy (I tried it at 99%)

this is what i used:

x = [10, b.mp].min; (b.mp -= x;a.mp += x) if rand(100) <= 99; 4 * a.mat - 2.b.mdf
do your enemies have mp

Edit: also i noticed i made a mistake in the example formula

it would be 4 * a.mat - 2 * b.mdf for the last section of the formula
Yes they do ( already made that mistake once before )
Ok sorry, I see what's happeing now!.

It is working! but it's not displaying the drain pop up (yanfly battle engine) that I've gotten use to seeing.
djm3, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-hp-damage-and-chance-to-drain-mp-skill.18524/