Recover MP is a skill is used? Status ailments?

Hello,

I want to let the player recover MP if they use a certain skill. For example, if I use normal attack instead of a skill, I'll gain, let's say 2MP, or 20% of total MP. What I've tried to do is add a.gainMp(Math.floor(a.mmp * 0.2)) in the damage formula. However, there are issues with this:
- If I miss, I will not recover any MP.
- If I have a skill that does damage to more than one target, I'll gain more than just 20% MP. This is not a big problem as the first one, but I'd like to know a workaround as well, just in case it's ever needed.

I also want to reward the player for evading an attack or inflicting status ailments on the enemy. For example, if I get lucky and evade an attack, I'll gain 2MP. This can also apply if the character manages to counterattack. Or if I use "Fire" and inflict "burn" status on an enemy, I'll gain 2MP. There should be a way to control how much MP is gained depending on how many targets are inflicted, too. Maybe I'll gain only 2MP, or maybe I'll gain 6MP if I managed to inflict burn on 3 enemies.

So, how am I able to do this? Will I need to request for a plugin?

Since we're on the subject, I'd like to ask this, too. How can I force an actor to start with less than maximum MP? So let's say an actor has 10MP maximum, but I'd like to force the player to start a battle with 7 or 8MP only. This disregard how much MP the player had at the end of the previous battle. So the player must always have 70-80% MP in the beginning of every battle. How can I do this? I have tried to use the plugins from Aesica and Trivel, but they recover 80% if the maximum MP, and add that to the amount of MP the actor has. That's slightly different from what I am trying to accomplish. Or perhaps I'm not using the note tags correctly.

Thanks in advance for any help!
01
For the MP gain, you could have this happen once (regardless of number of enemies hit or whether the attack missed everyone) by placing the MP gain in a Common Event that is attached to the skill. Traditionally you would have needed some way to mark who the skill user was if more than one Actor can use this skill, but I think MZ has an easier way to do this. There's a "Last: Actor ID to Act" option under Control Variables, and you can choose that Variable inside the Gain MP event command.

I feel like a plugin will be necessary for the other stuff, like MP gain on Evasion. You might be able to do it using very creative use of VisuStella's Skill Core, but I'm not totally sure. I plan to make a "Battle Effects" plugin for this kind of stuff eventually, but it's probably going to be a year or more before I get around to that one.
@Wavelength It seems that I can only recover a fixed number of MP and not percentage? Unless I'm missing something since I haven't used variables that much.
@Mr. Detective You would probably want to store the amount of mana gained into a variable.

This is a raw mockup on how the common event could look like:

mpgain.png



Edit: I just noticed that this would be problematic if multiple characters have access to the skill.
But since you use MZ, the solution provided by @Wavelength should still work.
Is it something like this? Then have this play when you use the skill you want?

aa.jpg
No, your eventing is wrong and I think you'll get some bizarre results where most of the time nothing happens and occasionally you'll have an actor you don't expect gaining an amount of MP you don't expect.
  • I don't think there's any reason to set a variable to Last Used Skill ID - you were probably looking for Last Actor ID to Act
  • Make sure you set the Actor ID and the (percentage of an) Actor's Max MP to separate Variables - otherwise, as you'll see if you follow the eventing, one will overwrite the other
  • If multiple actors can use this skill, you will need to branch the eventing based on the Last Actor ID to Act variable - for example, see below for an example if you set the Last Actor ID to Variable #5. If only Julius Tran can use this skill, then that line is fine and you can ignore this bullet point
Example of Branching:
Control Variables: Set Var #5 to Last Actor ID to Act
If Var #5 is equal to 1 (Julius is Actor #1)
....Control Variables: Set Var #1 to Julius' Max MP
End

If Var #5 is equal to 2 (Irma is Actor #2)
.... Control Variables: Set Var #1 to Irma's Max MP
End

If Var #5 is equal to 8 (Greg is Actor #8)
....Control Variables: Set Var #1 to Greg's Max MP
End

Control Variables: Divide Var #1 by 5
Change MP: Variable Actor (Variable #5), Increase by Variable Amount (Variable #1)
@ScorchedGround @Wavelength I'm still a little confused about these steps, but what's more important is that your method worked! Thanks a lot for the help! 😂

Also, it sounds very silly for me to say this right now, but... I can achieve the same result with a simple plugin command from Visustella in the action sequence steps. I just realized that. XD But I guess this can be useful for those who don't use it.

So for the other stuff, like gaining MP on evasion or inflicting a state, or starting a battle with a certain amount of MP, I really need to request for a plugin, right?
So for the other stuff, like gaining MP on evasion or inflicting a state, or starting a battle with a certain amount of MP, I really need to request for a plugin, right?
Probably.

Original thread: https://forums.rpgmakerweb.com/threads/recover-mp-is-a-skill-is-used-status-ailments.131639/