How to get the user of a skill to gain TP if affected by a state?

Hello all. I'm looking to have a singular skill, called "Bide," cause the user of the skill to gain TP if they are affected by particular state. Ideally, I just want the one skill to work regardless of the actor that uses it.

My first attempt at a solution was to use a common event in this manner:
JavaScript:
if('user'.isStateAffected('id')) {
'user'.gainTp(5);
}

I'm unsure as to what to place for 'user.' Would this even be possible? Is there a way to possibly write this in the damage formula? Or as part of an action sequence?
This thread describes how to achieve various effects in your damage formula, including gainTp():

If there's a possibility that your actor will be using autobattle, or that this skill can be used by enemies, you wouldn't want to use the damage formula. In that case, you'd want to use Yanfly's Buffs & States Core.
This thread describes how to achieve various effects in your damage formula, including gainTp():

If there's a possibility that your actor will be using autobattle, or that this skill can be used by enemies, you wouldn't want to use the damage formula. In that case, you'd want to use Yanfly's Buffs & States Core.
Ah! I had completely forgotten about this thread. I managed to get it to work as a damage formula. Thank you!

As an additional question, do you know how to hide the damage number popup when using a damage formula like this?
Can you give the context for your question?

If you're putting this into a damage formula for a skill that doesn't actually do damage, and you want to hide the 0...that's not the correct usage for the damage formula and you should be using a plugin notetag instead.
My mistake. For full context, I am trying to make a skill that all of my 8 actors would have. The skill, "Bide," is supposed to essentially "rush" a regeneration state by granting the effect of the state over 1 turn (in this case, a gain in TP) then ticking the state down a turn.

I technically already had a solution for this by storing the target actor id like so:
Code:
Control Variables : #0001 Target Actor = BattleManager._action._subjectActorId

Then running if statements to change the TP, MP, and HP of the actor using the skill for all of the states that might apply. Lastly using notetags via Yanfly's Buffs and States Core to increment the states down upon using the skill.

What I wanted to try was to see if I could accomplish the same effect without using as many if statements and such. I had never really used damage formulas for things other than just damage and my javascript knowledge is still pretty limited so I wanted to see if there was easier way to go about it.
Lastly using notetags via Yanfly's Buffs and States Core to increment the states down upon using the skill.
If you already have the plugin and you already have the notetag where you're doing stuff, just put the above code in there 🤣
Code:
user.gainTp(5);
before or after the line to decrement the state counter. No need to introduce the damage formula when you already have a way to run code.

But...if the skill just has a scope of User so you're not targeting someone else with it...why not simply put 5 into the TP Gain field of the skill's database entry?
But...if the skill just has a scope of User so you're not targeting someone else with it...why not simply put 5 into the TP Gain field of the skill's database entry?
Because the 5 TP was just an example, what I actually need depends on which regen state I have is applied to the actor. But I more or less had that part figured out already, so that wasn't really the point.
If you already have the plugin and you already have the notetag where you're doing stuff, just put the above code in there
I wasn't entirely aware that was something that was possible, hence why I was using a common event. I was only really using notetags presented outside the Lunatic Mode section of the plugin description because I didn't think I had a good enough grasp of javascript to actually use the rest. But if it's actually possible to just reference the 'user' within the notetags and still achieve what I want, I suppose I'll do that. So I appreciate the heads up.
Okay! For future tips, the more specific you are in the original question, the more helpful responses you'll get with fewer back and forth posts. 🙂 It's best not to worry too much about an example that's not in your game or how you think it might work, just describe exactly what you want to achieve and we'll get you going.

The best way to do the regen will depend on how your states are set up and whether they're mutually exclusive (an actor can only have one at a time). But if you want to pop up some screenshots, we can help you make sure this is working in a logical and efficient way.

But if it's actually possible to just reference the 'user' within the notetags and still achieve what I want, I suppose I'll do that.
How are you changing the turns on the state, if you're not doing user._stateTurns[ID]-- ?
For future tips, the more specific you are in the original question, the more helpful responses you'll get with fewer back and forth posts.
Very fair. I'll be more specific in the future. Thank you for the help!

How are you changing the turns on the state, if you're not doing user._stateTurns[ID]-- ?
Buffs and States core has a skill notetag <State x Turns: -y>.
Good call! I'm so accustomed to doing stuff through code that I don't recall everything you're given regular notetag options for.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-get-the-user-of-a-skill-to-gain-tp-if-affected-by-a-state.160517/