making variable mp cost

I have a skill which removes a few select states.  Everything works fine but I would like the mp cost to go up.  Specfically, I would like the total mp cost to be the base cost (as set when making the skill) multiplied by the number of different states removed from the target.  I am hoping there is a way to just do this in the damage/formula line but I am not sure of the right script calls.
There are a couple of issues with what you're describing.


You can't calculate the MP cost until know how many states will be removed.


You won't know how many states will be removed until you select the target.


You can't select the target until you select the skill.


You can't select the skill unless you know how much MP it's going to cost, and ensure your actor has that much available.


You've got yourself into a loop there, see?


In addition, it's possible that OTHER states will be applied to the target before the skill is cast and takes effect, so even if you COULD calculate the MP cost up front, it may actually cost more than what was quoted.


You might just set it to the minimum amount (for one state), and in the description, indicate that it costs that much per state removed, then when looking at the damage formula, figure out how many states they have that need to be removed, how many you can afford to remove, and remove the smallest number. I don't think the damage formula will be long enough for that, so you'll either have to use a common event instead, or have a method scripted to take care of it, then just call that method in the damage formula.
Here is the basic idea of what you are after for the formula line, just for your information :

Code:
t=a.current_action.item.mp_cost;a.mp-=((t*b.states.size)-t);return 0# Line by line explanation :# Grabs the MP cost of the current action performed by 'a', the current actor and stores the information in variable 't'.t=a.current_action.item.mp_cost# Lowers the MP of the current actor by 't' times the amount of states being removed from 'b', the target. a.mp-=((t*b.states.size)-t)# Since the skill has already been activated, the actor has already expended the base MP cost. So, minus that# base cost from the equation so there is no double-dipping.# Returns zero as the end result of the formula, ensuring that the damage type of the skill is not inflicted upon the target.return 0
However, this will not update the displayed cost of the skill. That, along with all of the issues that Shaz spoke of in the previous post.
you can do it the other way around, only reduce MP if there's a state removed by the skill... 

first, make the MP cost to 0

then when you need to set up a common event which you will run when you use the skill

 -> this CE will check if the target has the states to be removed, count them and calculate MP cost

 -> now it checks if you have enough MP

 -> if not, it won't remove the states, if yes, the states are removed

or

first, make the MP cost to 0

then when you need to set up a common event which you will run when you use the skill

 -> this CE will check if the target has the states to be removed

 -> for each state to be removed, check if the user has enough MP to remove that particular state

 -> if yes, remove state and reduce MP, then move on to the next state

that's the closest thing you can get to it I believe... though you will run into the possibility of the user casting the spell not realizing that it won't have any effect, or that he won't have enough MP...

Original thread: https://forums.rpgmakerweb.com/threads/making-variable-mp-cost.18083/