Charge TP by damage suffered

Hello, I was wondering if I could make an edit to the way TP is handled. I know how to make it so that TP is not charged at all when characters take damage (just comment "self.tp += 50 * damage_rate * tcr" within Game_Battler), but what if I want to create a particular ability or piece of equipment that makes it so a character DOES gain TP when damaged, but only if they possess said ability/Feature or piece of equipment?

My idea is like this:

#--------------------------------------------------------------------------# * Charge TP by Damage Suffered#-------------------------------------------------------------------------- def charge_tp_by_damage(damage_rate) if $game_actors[x].armors.include?($data_armors[x]) self.tp += 50 * damage_rate * tcr end...I got "$game_actors[x].armors.include?($data_armors[x])" from looking at conditional branch handling in the Interpreter. However, I don't think this will work, because it can't reference individual actors. If it works at all, then it would probably allow everyone to gain TP when damaged if just one actor is equipped with this special item, or has the ability as a Feature or something.

Any way to individualize this effect?

EDIT: Would it be possible to create an entirely new Feature within the code to handle this, called with Shaz's Dynamic Features script, for example?

EDIT 2: I got it to work!!... Sort of. Here's what I added:
 

def charge_tp_by_damage(damage_rate) if $game_actors[1].armors.include?($data_armors[2]) or $game_actors[1].armors.include?($data_armors[3]) $game_actors[1].tp += 50 * damage_rate * tcr end #if $game_actors[2].armors.include?($data_armors[2]) #$game_actors[2].tp += 50 * damage_rate * tcr #end endNote the "or" case; you can even add this effect to multiple articles of equipment. And as you can see by my commented lines, it can be applied to multiple actors.

But here's the catch: For some reason, with this script modification, whenever the actor attacks while equipped with the defined armor, they gain 100 TP instantly. Why on earth is that happening? 🙁

EDIT 3: Oh, wow... even when the enemy targets the actor but misses, the actor gains TP.
AND... wow again. At the end of the turn, the actor's TP jumped to 100 for no reason.

Sooo... this doesn't work as well as I thought. ;_;

Anyone have a solution?

EDIT 4: Um... hi again. In case anyone's still reading this, I was able to do what I want with a combination of Yanfly's TP Manager and Base Troop Events scripts (the latter checks to see if every actor has or doesn't have the equipment in question, then changes their TP Mode accordingly; I have the TP Mode option hidden in my game, however, because I'm only using it for this purpose).

I remember how I made Evasion a visible stat on the menus in RPG Maker XP. I was so happy and so proud of myself. I also tried to make a double attack skill on my own in XP; I tried really, really hard, but in the end all the glimmers of hope were for naught.

Similarly, I was quite excited when this seemed to work at first, but I guess it just wasn't meant to be. But that's okay. 🙂

I guess this can be closed now, and by the way, thanks for all the 30-some views! 🤣

Original thread: https://forums.rpgmakerweb.com/threads/charge-tp-by-damage-suffered.25929/