Need help with battle mechanic

So I am trying to create a battle system where every action uses two meters, you drain sources from on and it fills the other. I am currently trying to get this working before doing any heavy design work. I am currently testing this by having a basic attack that costs 10 TP and restores 10 MP. Problem arises in how this maker handles attack effects. My initial though was I could just have the attack cost 10 TP and have the attack effect restore 10 MP, but this affects the actor that is being acted upon, restoring the enemies MP not the party members, which makes sense from a coding perspective but is limiting in regards to what I want to do. Does anyone on here know how to get this idea to work? Also does anyone know how to stop characters from gaining TP when hit by an enemy, as that will be the next challenge in getting this mechanic ironed out? Thanks in advanced!
To stop TP-Gain from Damage, you'll need a plugin or an engine edit.


Other than that, you can use the damage formula coding to restore the MP to the user in addition to making damage on the target.


There is a topic about using the damage formula, please search for it
I will look into that, sound useful, thanks. That engine edit shouldn't be too hard. I have been poking around in the script and data files to remedy my problem. So basically if I find the engine damage formula it should have the tp gain built into it and I can remove it...I assume. I had taken to using the skills file in the data folder and editing it to have mp cost values that were negative to resolve my initial issue but your solution sounds like it might be quicker than scrolling through that file for every skill. Though I really feel like this tool needs to be able to accept negative values for costs and whatnot, it's a pretty standard rpg thing to do.
To have an attack gain your MP by using 10 TP, you put it in your Damage Formula, or use a plugin like Yanfly's action sequences.

To do this with the Damage Formula,
Use the code a.gainMP(); in your Damage Formula.
Here's an example from my project.

a.gainMp(Math.floor(a.mmp * 0.4)); a.atk * 2 - b.mdf
 

[Italics is the formula used to determine the value. In this case it'd be 40%]
What follows the Semi-colon is the actual damage the attack would deal.

So your case would be:

a.gainMp(10); [whatever your damage formula is]

That having been said, if you use this, and you MISS, you don't gain any MP either.

To get around that without making every attack that increases your MP by consuming TP "Certain Hit", you'd need to use a plugin.
[Yanfly's Battle Engine and Action Sequence 1 has that functionality rather straight forward]

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-battle-mechanic.49845/