Changing how much TP is gained from taking damage?

I'd like my characters to gain a fixed amount of TP every time they take damage, like 1-2 TP, or 1-2% of the amount of damage they've taken. How can I do this? Do I need a plugin? Apparently, this can be done in MV by editing a certain file, but I can't find it in MZ.

Thanks in advance for any help!
073.gif
by default, you can only change the percentage of TP by damage with the trait "TP charge rate".
that does not require any editing of any file, or any javascript at all.

for other changes, you'll need a plugin to change the calculations.

Apparently, this can be done in MV by editing a certain file,
Editing corefiles is always a bad idea due to the possible consequences. The plugin manager exists for a reason after all.
that edit should have been written as a plugin, because all plugins are simply self-contained edits to the engine.
http://www.yanfly.moe/wiki/Enhanced_TP_System_VisuStella_MZ

Control tp gen in various ways and assign tp modes per class/Character if you like.
If all you want to do is that, there's no need to shell out ten bucks for a complex plugin. The function is in the exact same place it was in MV (in fact, it's exactly the same as it was in MV). Starting on line 3842 of rmmz_objects you have:
Code:
Game_Battler.prototype.chargeTpByDamage = function(damageRate) {
    const value = Math.floor(50 * damageRate * this.tcr);
    this.gainSilentTp(value);
};

As Andar said, don't edit the file directly. Copy that function, edit it how you like, then include it as a plugin.
Game_Battler.prototype.chargeTpByDamage = function(damageRate) {
const value = Math.floor(50 * damageRate * this.tcr);
this.gainSilentTp(value);
};

Thanks! So... how exactly does this formula work? Half of amount of damage taken and... what? 50 is 50%, right? So, if I put 10, the characters will gain 1 TP for every 100 points of damage taken. No idea what the rest is.
020.gif
Thanks! So... how exactly does this formula work? Half of amount of damage taken and... what? 50 is 50%, right? So, if I put 10, the characters will gain 1 TP for every 100 points of damage taken. No idea what the rest is.
If you open the file I specified for you in a text editor and search for the words, you can see how it's used pretty easily without coding knowledge needed.

The names of the variables are basically exactly what they sound like - damageRate is what percentage of the actor's Max HP was taken by the attack (in decimal format, of course); this.tcr is the actor's TP Charge Rate that you can modify in the editor, its base value is 1.

Math.floor just means it rounds down any decimal results.
Lemme drop the actual number here.

Your max HP is 1000
You get damaged by 500
The damage rate = 50%

The maximum amount of TP you can get is 50 (if we ignore the TP charge rate), the value is hardcoded in the formula. The damage rate = 50%
> You get 25 TP by taking 50% damage of your max HP

By default, the TP charge rate is 100%, which means no modification.
If you change the TP charge rate in the actor/weapon/class/state traits, then the final result will be multiplied.

So, if the damage rate is 50% and TP charge rate is, for example, 200%
Do this math
> 50 x 50% x 200%
how exactly does this formula work?
do you see the this.tcr part of the formula?
that is the TP Charge Rate that I mentioned in the second post on this topic.

so unless you want to completely change the entire formula, there is no need to edit the code at all, you can simply change the factor by adding the appropiate TCR value to each battler - even giving different TCR to different actors if desired.
Thanks for the responses, guys.

I'll play around with the formula.
47
Will come back if I have any more question.

Original thread: https://forums.rpgmakerweb.com/threads/changing-how-much-tp-is-gained-from-taking-damage.141705/