How to "freeze" TP change?

In my project, I'm using TP as a sort of "balance/poise" system. Us attacking restore poise, us getting attacked drop it.

I also changed stuff a bit, so using Guard option fully restores TP (Gain TP 100%). Now what I'm trying to do is to "freeze" TP when character is guarding. Currently, if I guard, my TP goes to max and I'm not moving for a turn, but each enemy attack still drops it by their value. It obviously isn't ideal, because if we decide to guard at 20 TP not to get off balance, but during our guard we get hit by 7 enemies, each taking 12 TP, we end up with less TP.

So my question is: How can I set the "Guard" state to freeze our TP from any chances that might happen to it during guard?
Since that is not how default TP act, I am afraid you have to give us information about how you handle those TP. How are you decreasing them?
you can't do that by default. Doing it exactly like you described will require a script.

there are a few workarounds however if you are willing to accept some quirks.

for example, common events are always executed at the end of a turn, no matter when the skill they belong to is executed.
so you could add a common event to the guard skill that identifies who guarded (needs a bit of tricks) and then sets the TP back to 100 at the end of the turn. The guard will still lose TP during the turn as usual, but it will be replaced at the end.
For TP control I'm using Dekita's Max TP Control script. I set ":take_dmg" in TP Type settings (~line 114) to "-20" for test purposes - every hit by enemy "gives" us -20 TP. And I'm willing to use scripts to fix that too.

@Andar I guess going with Common Event would work. I should add it as a condition in Troops, right? When end of turn, every turn, call common event?
@ekhartpl what Andar said is something different:
you could add a common event to the guard skill that identifies who guarded
The common event call is on the guard skill, not on the troop event. The troop event only restores actors TP pool at the end of each turn, but for it to know which actor was guarding, you have to somehow mark the actor who used the guard skill.

Spoiler: How to do it with common events and troop events
Adding a certain state that does absolutely nothing and then restoring TP to 100 to every actor with the said state is a possible solution. Of course, in order for your guard skill not to look weird, the skill should not restore the user's TP and simply replenish the TP pool at the end of the turn. If you do it this way, the skill becomes a simple dummy skill to mark those who need to recover TP and those who do not.

To mark down the actors when using the skill you can do something like this in the common event you call:
Code:
$game_party.members.each do |battler|
  $game_variables[pick_an_ID] = [] unless $game_variables[pick_an_ID].is_a?(Array)
  if battler.state?(your_guard_state_id) # this marks the actor unless it is already marked
    $game_variables[pick_an_ID] << battler unless $game_variables[pick_an_ID].include?(battler)
  end
end

At the end of each turn, you can replenish the TP pool to any character stored in your variable. The troop event should be like this:
Code:
$game_variables[pick_an_ID].each do |battler|
  battler.tp = 100 # replenish actor TP pool
end
$game_variables[pick_an_ID] = [] # reset guarding actors

Spoiler: EDIT: how to do it with a script
Alternatively you can alias the method in the script. If you add something like this to your scripts (below Dekita's script), it stops dealing TP damage to actors with the guard state:
Code:
class Game_Battler < Game_BattlerBase
  alias hrk_charge_tp_by_damage_old charge_tp_by_damage
  def charge_tp_by_damage(dmg)
    return if self.state?(your_guard_state_id)
    hrk_charge_tp_by_gamage_old(dmg)
  end
end
Had a few small problems, but managed to make it work with your help. Thanks a lot!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-freeze-tp-change.111239/