Changing TP to a variable?

Hey guys I'm pretty new to the RM scene and I just had a quick question. I want a type of 'Limit Break' system in my game. The easiest way to accomplish this seems to be to use TP to me. Now I know I can go in and adjust the TP given for certain actions like basic attack and skills. But is there a way to set this to a variable? For instance, each attack can increase it by 2-6? And also a way to change the amount of TP I get when taking damage to the same 2-6 formula?

Also, not sure if this is possible without a plugin, but is there a way to make it so that I retain the TP earned after each battle?

Thanks for any help! 🙂
Retain after battle is easy:
Actors >> Traits >> Special Flag >> Preserve TP.
You can use this in conjunction with a Common Event set to parallel process to have a 'Start At 0' thing too.

You can't directly set TP gain to a Variable.

For Attacking user.gainTp([JavascriptforwhateverVariablegoeshere]);Damage Formula in the damage formula works, but you need something to randomize that.
TBQH, I'd just use Yanfly's Action Sequences, and then have a Common Event that randomizes a Variable, then use a "TP Variable [##]: User".

For Defending...? You'll need a Plugin.
 
Changing TP to a Variable?



Use Scriptevent


newValue = $gameActors.actor(ID).tp;


$gameVariables.setValue( ID, newValue);


scriptpic6545641678.png

Original thread: https://forums.rpgmakerweb.com/threads/changing-tp-to-a-variable.51095/