Potential TP Mechanic?

Hello,

I've been trying to see if this mechanic would work:

The player starts at 100 TP. Each time an enemy attacks, their TP goes down (at the same rate as it goes up by default). When they hit 0 TP, they'll gain access to a skill that they can only see when they're at 0 TP. They use the skill, and their TP goes back up to 100.

I tried to find a way to use variables to do this, but I couldn't find an option to tie the variable to TP.

So is there a way this could be done, either via changing how the TP works or by making a variable reversely tied to TP?

Thank you for your time.
Moon-auto states

TP configurator

Although keep in mind this system gives bearly infinite TP, and so needs balancing

The moon autostates can apply a state when tp reaches 0 with the learn skill command. When tp is above zero, the state goes away as well as the skill
Thank you for the script, it looks like it'll come in handy   🙂

However, I'm still a bit confused as to how I'd go about setting up the tp so each attack decreases it. (If it's important, I'm using Falcao's Pearl ABS Liquid v3) I tried editing the code at 742 in Game_Battler, but the tp doesn't drop each time the enemies attack me.

The code there normally looks like this: "    self.tp += 50 * damage_rate * tcr", but I tried editing it to "    self.tp -= 50 * damage_rate * tcr"

Is it not working because I'm using the ABS? Or is there something else I haven't done yet?

Edit: Ok I tried attaching the tp to a variable, but it didn't work, probably because my game has a few characters you can play as.

Edit 2: I checked to see if it was the ABS, nothing seems to change the tp. Most of the stuff that calls the tp is just using it to implement the on-screen HUD. That's somewhat of a relief.

Edit 3: I tried something that was mentioned by Maliki79 in this post: http://forums.rpgmakerweb.com/index.php?/topic/18199-tp-manipulation/

In the damage formula for the attack skill, I have my damage formula set as if b.tp >= 0; b.tp -= 15; end; a.atk * 4 - b.def * 2

This makes the player start off at 88 tp. The tp does go down, but it won't go below 3. And for some reason it jumped up to 4 a couple hits before I died.

Any tips on how to fix this issue?

Edit 4: I set the formula to if b.tp >= 0; b.tp -= 20; end; a.atk * 4 - b.def * 2

Now the player starts off at 100 tp, it actually goes down to 0 tp, and it stays at 0 tp.

Only problems are that the skill and state I wanted to show up don't show up, and the player isn't taking any damage.

Edit 5: Well, since my copy of Ace has bit the dust, I'm going to be switching to MV. Now to see if this can be done in MV...

Original thread: https://forums.rpgmakerweb.com/threads/potential-tp-mechanic.46375/