modifying the function of TP

Id like to change how TP works but i cant find it to even try to patch something together.

Id like reaching max TP (100/100) to cause death and id also like to give enemies TP.

Any pointers on what to do or scripts to use would be appreciated
Enemies have TP by default and abide by TP cost restrictions.

This should kill anyone with max TP at the end of a turn.
Code:
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  A battler class with methods for sprites and actions added. This class 
# is used as a super class of the Game_Actor class and Game_Enemy class.
#==============================================================================
class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Alias: Regenerate TP
  #--------------------------------------------------------------------------
  alias :die_regenerate_tp :regenerate_tp
  def regenerate_tp
    die_regenerate_tp
    add_state(death_state_id) if tp_rate == 1
  end
end
Thanks looks good

Original thread: https://forums.rpgmakerweb.com/threads/modifying-the-function-of-tp.92428/