Bonus TP on attacking an enemy with a certain state.

Hello, thank you for reading this post ^^

I need to make a state that when applied to an enemy, makes the actor that attacked the enemy get bonus TP (either a flat rate, or a multiplier)

The most promising lead I have is the Punish Effect 8: Drain MP from Yanfly's Lunatic States: Punishment pack
The key differences being the fact that, obviously, it affects MP instead of TP, it is triggered by MP Damage instead of HP Damage, and it doesn't recover MP to the person who dealt the damage, but the person who cast the state.

The snippet from Yanfly's Lunatic States: Punishment Package that I'm referring to.
#----------------------------------------------------------------------
# Punish Effect No.8: Drain MP
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Best used with shock effect. Whenever user takes MP damage, the
# original caster of the state will heal MP based on MP damage dealt.
#
# Recommended notetag:
# <shock effect: drain mp x%>
#----------------------------------------------------------------------
when /DRAIN MP[ ](\d+)([%%])/i
return unless @result.mp_damage > 0
dmg = (@result.mp_damage * $1.to_i * 0.01).to_i
if $imported["YEA-BattleEngine"] && dmg > 0
Sound.play_recovery
text = sprintf(YEA::BATTLE::POPUP_SETTINGS[:mp_heal], dmg.group)
user.create_popup(text, "MP_HEAL")
end
state_origin.mp += dmg


However there might be a simpler solution to this problem that doesn't require the use of Lunatic States.
I would greatly appreciate any help!
Spoiler: charge tp by state
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Boost TP enemy state                   ║  Version: 1.00     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║   Add TP when attacking an enemy              ║    08 Sep 2024     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║       Gain tp when hitting an inflicted enemy                      ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║   This is a modification of Shaz's TP Add Factor                   ║
# ║   Add note tag on state that will cause the player to gain tp      ║
# ║   Player will gain tp when hitting an enemy with the state         ║
# ║     <tp_add_state: x>  X equals the amount of TP to add            ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 22 Nov 2024 - Script finished                               ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks:                                                ║
# ║   Roninator2                                                       ║
# ║   Shaz                                                             ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use:                                                      ║
# ║  Follow the original Authors terms of use where applicable         ║
# ║    - When not made by me (Roninator2)                              ║
# ║  Free for all uses in RPG Maker except nudity                      ║
# ║  Anyone using this script in their project before these terms      ║
# ║  were changed are allowed to use this script even if it conflicts  ║
# ║  with these new terms. New terms effective 03 Apr 2024             ║
# ║  No part of this code can be used with AI programs or tools        ║
# ║  Credit must be given                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

# ╔════════════════════════════════════════════════════════════════════╗
# ║                      End of editable region                        ║
# ╚════════════════════════════════════════════════════════════════════╝

class Game_ActionResult
  attr_reader :battler
end

class Game_Battler < Game_BattlerBase
  alias r2_tp_initialize initialize
  def initialize
    r2_tp_initialize
    @tp_mem = nil
    @tp_enm = nil
  end

  alias r2_tp_execute_damage execute_damage
  def execute_damage(user)
    @tp_mem = user
    @tp_enm = @result.battler.states
    r2_tp_execute_damage(user)
    @tp_mem = nil
    @tp_enm = nil
  end
 
  alias r2_charge_tp_damage_actor charge_tp_by_damage
  def charge_tp_by_damage(damage_rate)
    @tp_mem.tp_add_state(@tp_enm)
    r2_charge_tp_damage_actor(damage_rate)
  end
end

class Game_Actor < Game_Battler
  def tp_add_state(states=nil)
    value = 0
    return if states.empty?
    states.each { |st|
      st.note =~ /<tp_add_state:\s*(\d+)>/i ? value += $1.to_i : nil
     }
    self.tp += value
  end
end

class Game_Enemy < Game_Battler
  def tp_add_state(st)
  end
end
Spoiler: charge tp by state
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Boost TP enemy state                   ║  Version: 1.00     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║   Add TP when attacking an enemy              ║    08 Sep 2024     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║       Gain tp when hitting an inflicted enemy                      ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║   This is a modification of Shaz's TP Add Factor                   ║
# ║   Add note tag on state that will cause the player to gain tp      ║
# ║   Player will gain tp when hitting an enemy with the state         ║
# ║     <tp_add_state: x>  X equals the amount of TP to add            ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 22 Nov 2024 - Script finished                               ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks:                                                ║
# ║   Roninator2                                                       ║
# ║   Shaz                                                             ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use:                                                      ║
# ║  Follow the original Authors terms of use where applicable         ║
# ║    - When not made by me (Roninator2)                              ║
# ║  Free for all uses in RPG Maker except nudity                      ║
# ║  Anyone using this script in their project before these terms      ║
# ║  were changed are allowed to use this script even if it conflicts  ║
# ║  with these new terms. New terms effective 03 Apr 2024             ║
# ║  No part of this code can be used with AI programs or tools        ║
# ║  Credit must be given                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

# ╔════════════════════════════════════════════════════════════════════╗
# ║                      End of editable region                        ║
# ╚════════════════════════════════════════════════════════════════════╝

class Game_ActionResult
  attr_reader :battler
end

class Game_Battler < Game_BattlerBase
  alias r2_tp_initialize initialize
  def initialize
    r2_tp_initialize
    @tp_mem = nil
    @tp_enm = nil
  end

  alias r2_tp_execute_damage execute_damage
  def execute_damage(user)
    @tp_mem = user
    @tp_enm = @result.battler.states
    r2_tp_execute_damage(user)
    @tp_mem = nil
    @tp_enm = nil
  end
 
  alias r2_charge_tp_damage_actor charge_tp_by_damage
  def charge_tp_by_damage(damage_rate)
    @tp_mem.tp_add_state(@tp_enm)
    r2_charge_tp_damage_actor(damage_rate)
  end
end

class Game_Actor < Game_Battler
  def tp_add_state(states=nil)
    value = 0
    return if states.empty?
    states.each { |st|
      st.note =~ /<tp_add_state:\s*(\d+)>/i ? value += $1.to_i : nil
     }
    self.tp += value
  end
end

class Game_Enemy < Game_Battler
  def tp_add_state(st)
  end
end
Thank you so much!
It works like a charm!
Is there any way for me to repay you for your work? I would feel awful if you've done all this work for me without getting anything in return ^^;

Original thread: https://forums.rpgmakerweb.com/threads/bonus-tp-on-attacking-an-enemy-with-a-certain-state.171765/