MZ how to create a skill that reduce target tp

hi there, I want to create a skill that can reduce target TP, I use VS plugin but since I dont understand JS so I can't make it 😅

can someone help me how to do it please?
use the following in the damage formula, no plugin needed at all:

b.tp -= tpdamage; 4*a.atk - 2*b.def

(replace tpdamage with any number you want, you can also replace the regular damage formula with anything or zero if you don't want any other damage)
use the following in the damage formula, no plugin needed at all:

b.tp -= tpdamage; 4*a.atk - 2*b.def

(replace tpdamage with any number you want, you can also replace the regular damage formula with anything or zero if you don't want any other damage)
somehow the tp does not decrease
Here's an example.
var formula = 37; b.gainTp(-formula);
Yea, tp is read-only, use gainTp to change the value.

(I was going to suggest a Gain TP effect if the value is constant, but it looks like the editor doesn't allow negative values there for some reason. 😴)

A little caveat about applying effects (e.g. gain TP) in the damage formula:
Note that the damage formula is only designed for calculating values, not for applying effects. Strange things might happen if you apply changes in the damage formula, e.g. force escape or add/remove a buff/state. For example, actors with an Auto Battle trait will evaluate the formulae of all available skills on all available targets to decide which skill to use. Plugins may also do stuff like that.

To avoid the damage formula problems, you could find a plugin that lets you run script before/after a skill hits, e.g. the <JS Post-Damage> skill notetag from VisuStella MZ Battle Core
Yea, tp is read-only, use gainTp to change the value.

(I was going to suggest a Gain TP effect if the value is constant, but it looks like the editor doesn't allow negative values there for some reason. 😴)

A little caveat about applying effects (e.g. gain TP) in the damage formula:
Yes, I want to avoid strange things. I try to write JS like this from peeping other thread
JavaScript:
<JS Post-Damage>

  if (target.tp >= 1) {

    target.gainTp(-1);

  }

</JS Post-Damage>
and it took me 1 hour for the code to work, lol

I appreciate you all for helping me. And one more thing, Is there a tutorial how to implement VisuStella JS?
VisuStella JS is just regular javascript. You can look into tutorials for that. I often recommend the one from w3school. There is also an excellent spreadsheet available that explains a lot of already existing functions of the RPG Maker engine and how to use them. You should find it by googling "RPG Maker MZ script call spreadsheet" or something like that.
VisuStella JS is just regular javascript. You can look into tutorials for that. I often recommend the one from w3school. There is also an excellent spreadsheet available that explains a lot of already existing functions of the RPG Maker engine and how to use them. You should find it by googling "RPG Maker MZ script call spreadsheet" or something like that.
ahh thankyou, I found it https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mz-plugin-creation-tutorial.128486/
I think that this might be the better script call list for you.
I think that this might be the better script call list for you.
Thanks for providing it. much appreciate it 😍
@Arthran provided the link I meant. Just didn't have it at hand 😅

Original thread: https://forums.rpgmakerweb.com/threads/how-to-create-a-skill-that-reduce-target-tp.151159/