Mana Regen on Hit & Magic Imbue

Hello everyone!

I wanted to ask you guys for some help to design a couple of skills. I'm relatively new to RM, using plugins designed by some of the great guys in the community but can't make my own.

I'm making a character that is primarily a spellcaster, however mana will be limited in this game. I wanted him to have a way to get mana back while doing regular attacks (with the basic "attack" command). I don't want him to "leech" mana off the enemy, seeing as how this should work against enemies with or without mana. Also, I was planning on having him recover a set amount of mana with each hit he lands (misses shouldn't count), something like 5% of his total mana (which perhaps will be increased with a passive later on). This should be a state this character passively has; I can see how I can make that happen with Yanfly's plugin, but I can't seem to design the state.

Another ability I wanted to design was a skill that would provide him with a buff. This buff would be some sort of an "imbue", in which his basic attacks would change to the element of the buff (Let's say Imbue: Fire will make his attacks fire elemental). I'd also like for this to add a part of the character's Magic Attack to his Physical Attack (for example, 10% of his M.Atk would be added to his Atk for the damage formula). I could do this for a skill formula in a simple way, but I want this to be applied to the attack command particularly. This imbue would last for a number of hits or a set amount of turns, whichever happens first (let's say 5 attacks or 5 turns). I can do the turns part for the state, but not the number of attacks part. Also, is there a way to make it so that you lose a set amount of mana with each attack while you're imbued?

Thank you everyone. If this goes beyond simple configuration and requires a plugin, let me know which one I should get. Once again, thank you all!
You say that you are using Yanfly's plugin. As there are about 200 of these, the name and a link to the web page where it can be seen would be a great help - it would save an awful lot of guessing!
You can do that to your attack skill with a formula in the skill window. You would want something like,

a._paramPlus[x]+=y;a.atk * 4 - b.def * 2

Here x is the parameter so for Magic point it should be 1 and y is the amount you want it to return each attack.
Hope that helps.

Edit:
For the part about sapping mana when imbued you can use a formula like this.

if (b.isStateAffected(z)) { (a._paramPlus[x]-=y;(a.atk * 3 ) - b.def * 2) } else {(a._paramPlus[x]+=y;a.atk * 3) - b.def * 2}

That is similar to the one above but z = the state id of your imbue.

Adding your magic stat would look something like,

(a.atk * 3 + a.mag * 1) - b.def * 2

Original thread: https://forums.rpgmakerweb.com/threads/mana-regen-on-hit-magic-imbue.81398/