Track TP Gained

Hey all,

I'm working on an interesting class concept and need a way to track TP gained throughout the combat.

In my game concept, all TP is gained through either actions or state interactions, and is always a set amount(no random amounts), so at worst, I can just change a variable whenever TP is gained and track it that way, but before I go about modifying every state and action related and potentially messing things up, I wanted to ask if there was an easier/more elegant way to do this.
What plugins are you using to modify TP? Namely, to shut off TP gain from damage. That plugin might have a way to help you do this.
What plugins are you using to modify TP? Namely, to shut off TP gain from damage. That plugin might have a way to help you do this.
Just Yanfly's Enhanced TP.
I'm not seeing anything in Enhanced TP that would help here. However, you could put into each TP mode an increase to a variable equal to the number that TP is increased by.

gained through either actions
You might be able to use Passive States with the Buffs & States core to accomplish this. Your "TP" state would check various On Action Effects to see if TP was increased and then increase a variable the same way. I'm not sure if this covers 100% of everything you'd want to do.

state interactions
This one sounds harder to accomplish with the above.

What might make the most sense is to make a new plugin that modifies whatever section of code handles TP changes and add in a line that increases a variable when TP is increased. I don't know exactly where that is in the code, though.
Would it need to track TP gain on each battler or TP gain as a whole?
Does the tracking need to persist between battles?
@kirbwarrior

I haven't found a way inside that plugin that would help as well. I'm not sure what you mean by "TP State" though.

I've never written a plugin, don't know if I can do that but I'll try examining the code for the plugin and see if I can figure something out.


@Maliki79

It would need to track TP gain on a single, specific battler. And no, I don't want it to be persistent. Just track it throughout an instance of combat and then reset.
All done!

Just add the below plugin to your game:
Mal_TPCounting

To get any battlers count, just code:
JavaScript:
this._TPCount;

Where this can be a, b or whatever you need to identify the battler.
(Resets at the beginning of each encounter.)

Hope this helps!
All done!

Just add the below plugin to your game:
Mal_TPCounting

Oh wow, I certainly didn't expect you to make a plugin. Thank you!

On an initial test, it seems to work without issue.

Not just wanting to plug it in and call it a day, I'm trying to understand how it works. If it's no trouble, I'd like to ask a few questions.

So, the first block of code creates the _TPCount property for our actor if I'm not mistaken.

The second block does the same for enemies. As enemies in my game don't utilize TP and there's no need to keep track of it, I assume I don't need this part of the code and could potentially remove it without issue.

The third block resets the value to 0 on battle start. The same function could be accomplished by a passive state, most likely, but it's certainly handy to have it handled by the plugin itself.

The next two blocks are the main function. Checking the .gainTp method of our battler, if they return a positive value, our count for TPCount increases by the same value.

What I'm not sure here is the difference between .gainTP and .gainSilentTp. What exactly does the .gainSilentTp method does here?
The gain silent tp is a separate function the game uses when a PC gets hit. It grants to based on calculations but is it's own thing, which is why it needed to be added here.
Everything else you had figured out.
I'm not sure what you mean by "TP State" though.
My apologies for being unclear, you'd make a new Passive state that is hidden from the player (low priority, no icon, etc). This state tracks certain events that can modify TP and modifies a variable the same way.

However, it looks like you got a plugin that does this better, so don't worry about this route.

Original thread: https://forums.rpgmakerweb.com/threads/track-tp-gained.173589/