help with yanfly enhanced tp plugin

I'm using the enhanced tp plugin but am looking to chance it slightly so that it works more like ffx in that in order to unlock a tp mode the user has to perform the action required for charging the tp gauge. I'm not sure if that makes sense so here's some examples.

the warrior mode charges the tp gauge when the actor deals damage to an enemy. I would like to make it so that in order to unlock this mode the actor must deal a total of a specified amount of damage (cumulative, not in a single battle)

the daredevil mode charges the tp gauge when the actor ends the turn with low hp. so in order to unlock the mode they would have to end, say 50 turns, with low hp.

anyone have any idea how to do this?
the warrior mode charges the tp gauge when the actor deals damage to an enemy. I would like to make it so that in order to unlock this mode the actor must deal a total of a specified amount of damage (cumulative, not in a single battle)

the daredevil mode charges the tp gauge when the actor ends the turn with low hp. so in order to unlock the mode they would have to end, say 50 turns, with low hp.

You're going to need to create a variable that keeps track of these data. I think total damage dealt is
$gameActors.actor(id).totalDamageDealt() --> Yanfly's battle statistics installed
You'd have to check an actor's hp after every battle (call a common event) and count the number of times they end the battle with low hp.

Then, when the variable reaches your desired amount, unlock tp mode (another common event)
I've got the battle stats plugin. I think I could deal with the ones that have a stat like total damage but I have no idea of how to track ending turns with low health or track how many times an ally has died in battle whilst the actor was in the battle.

I tried looking into the plugin script to see if I could find how the gauge is charged but I'm no good at JavaScript so couldn't really tell the bits I needed.
You don't need javascript.

Here's an example troop event, set to run every turn end:
Code:
◆If:Harold is in the party
  ◆Comment:Calculate Harold's percentage health
  :       :Check if less than 10%
  ◆Control Variables:#0011 = Max HP of Harold
  ◆Control Variables:#0012 = HP of Harold
  ◆Control Variables:#0012 *= 100
  ◆Control Variables:#0012 /= #0011
  ◆If:#0012 ≤ 10
    ◆Control Variables:#0013 += 1
    ◆Comment:Harold HP is low this turn, variable 13 + 1
    ◆
  :End
  ◆
:End
◆If:Harold is in the party
  ◆If:Harold is affected by Knockout
    ◆Comment:Harold dead, no increase
    ◆
  :Else
    ◆If:Mary is affected by Knockout
      ◆If:Mary Dead is ON
        ◆Comment:Don't double count!
        ◆
      :Else
        ◆Comment:A party member died.
        ◆Control Variables:#0014 += 1
        ◆Control Switches:#0011 Mary Dead = ON
        ◆
      :End
      ◆
    :End
    ◆
  :End
  ◆
:End
◆If:Mary Dead is ON
  ◆If:Mary is affected by Knockout
    ◆Comment:Mary is still dead
    ◆
  :Else
    ◆Comment:Mary was revived
    ◆Control Switches:#0011 Mary Dead = OFF
    ◆
  :End
  ◆
:End

Now just make sure to reset the switches whenever someone is revived (revival item/spell calls common event that resets switches).

Variable 13 stores the number of times Harold's life is in danger. Variable 14 stores the number of times he watched a party member die.

To check stuff on battle end instead of every turn, use a plugin that calls a common event. http://sumrndm.site/battle-end-events/
My only problem with that is there are 20 tp modes and I have 11 possible party members so that would end up being a huge troop event.
You only have to make that event once, and then copy/paste it into all troops. If you want it to be any simpler, you'll have to learn javascript. Loops and arrays could be very helpful there. There's nothing wrong with having a huge troop event.
What I mean is that the event already has a few lines and thats with only 2 tp modes for one actor. If I had to do checks for 11 actors and for 20 tp modes there wpuld be loads of lines in the troop event. This is why I asked in the JavaScript plugin support page. But thanks for the help.
Code:
var actorLowHpVariables = [1,2,3,4,5,6,7,8,9,10,11];
for (i = 0; i < actorLowHpVariables.length; i++) {
    if ($gameActors.actor(i).isBattleMember() && $gameActors.actor(i).hp/$gameActors.actor(i).mhp < 0.1) {
        $gameVariables.setValue(actorLowHpVariables[i], $gameVariables.value(actorLowHpVariables[i]) + 1);
    }
}

Here's the low HP one. Replace the numbers in actorLowHpVariables with the actual variables you want it stored in. Put this in troop event script call. Working on the dead one now.
The modes are as follows:

Comrade - ally takes damage
Warrior - actor damages enemy
Healer - heals ally/self
Breaker - deals mp damage
Booster - recovers ally mp
Slayer - actor kills enemy
Avenger - when ally is killed
Victor - wins battle
Coward - party escapes battle
Daredevil - ends turn with low hp
Caster - ends turn with low mp
Tactician - actor inflicts status on enemy
Victim - every turn end that actor is affected by status
Dancer - whenever actor evades an attack
Loner - when turn ends and actor is only party member alive

the others i won't use
Can you tell me what all the unlock checks are?
Can you tell me what all the unlock checks are?

that should be all of them
This is long enough that it'll likely turn into a plugin on it's own. Working on it now.
I thought it was a big ask! I massively appreciate your help here!

Original thread: https://forums.rpgmakerweb.com/threads/help-with-yanfly-enhanced-tp-plugin.85400/