Reworking the TP system?

I'm trying to change basically the entire base of the TP system and I'm having issues in getting it to work.
Essentially I want the TP to increase when the player is damaged equal to the amount of damage that the player took, and no other way. Is there an easy way to achieve this or should I look at other ways to achieve the same effect?
you'll need a script for that, but I think yanfly had made a TP script where you could modify the formula however you would like.
Moved to: RGSS3 Script Requests
Is this what you are looking for?
https://yanflychannel.wordpress.com/rmvxa/gameplay-scripts/tp-manager/
Code:
class Game_Battler
  def charge_tp_by_damage(damage_rate)
    self.tp += damage_rate
  end

  def on_damage(value)
    remove_states_by_damage
    charge_tp_by_damage(value)
  end
end

Original thread: https://forums.rpgmakerweb.com/threads/reworking-the-tp-system.99463/