Stacking TP

Hey,

I am using Yanfly scripts, so this is probably another thing that can be done via lunatic mode (if so I am all ears). Essentially, I have a Skill, it gains +1 TP each consecutive time it is used, but I want it to stack. For Example: +1 on the first use, +2 on the second, +3 on the third, on and on to a max of +20.

I've put it here because if it cant be done with Lunatic Mode (and I'm not sure it can), I will need a plugin.

EDIT: I'd also like a way to be able to Lower a Target's TP.
Maybe you can set the number of times a skill has been used as a variable, use that variable to multiply the skill's tp gain (before the TP is calculated, so it's not multiplying by 0 the first time), then reset the variable after battle. Should be possible I think. For lowering TP, I think you can use 'gainTp(value)' in the damage formula box and set it to negative? Haven't tried it personally but might do the trick.
For the TP stacking, do you want the stacks to be permanent, or to reset after each battle?
I want them to reset if they are not used consecutively. Like, if the actor uses any other skill or cant use a skill (because they are stunned or something and lose a turn or something), it resets back to 1.
Well, this can be done with lunatic mode.

Give the character who has that skill a passive state.

Then, on the skill, use the notetag:

Code:
<Post-Damage Eval>
user._skillStacks = user._skillStacks || 0;
user._skillStacks += 1;
var tpGain = user._skillStacks.clamp(1, 20);
user.gainTp(tpGain);
</Post-Damage Eval>

This'll cause the skill to gain tp based on how many times it has been used, upto 20.

For resetting the stacks if the skill is not used, the passive state is needed.

On the passive state, use the notetag:

Code:
<Custom Conclude Effect>
if (this.item().id !== x) {
user._skillStacks = 0;
}
</Custom Conclude Effect>

<Custom Turn Start Effect>
if (!user.canMove()) {
user._skillStacks = 0;
}
</Custom Turn Start Effect>

In the custom conclude effect, replace x in the first line with the id of the skill.
Youre a boss!!

**SOLVED**

Original thread: https://forums.rpgmakerweb.com/threads/stacking-tp.80063/