MV Reward the healer who removes a state

Hi everybody, I hope you can help me:

What is the problem?

Lets say I have a poisoned Harold and a healer Lucius and I want to reward Lucius with TP for removing Harold poison.

It means Lucius should receive TP if he effectively removes Harold poison.

Then Lucius should not receive TP in these cases:
  • if poison expires
  • if antidote fails
  • if Harold is not poisoned
What have I tried?

My first attempt was using YEP Skill Core and <After Eval> tag, which lets me get the origin (lucius), but doesn't let me get the state removed.
Code:
<After Eval>
// Antidote skill notetag
if(target.wasStateAffected(2)) // <- nope
   user.gainTp(20);
</After Eval>

My second attempt was using YEP Buffs&States Core and <Custom Remove Effect> tag, which lets me get the state removal, but doesn't let me get the healer.
Code:
// Poison state notetag
<Custom Remove Effect>
   healer.gainTp(20); // <- nope
</Custom Remove Effect>

Do you know any way to achieve this?

Thank you in advance!
You cannot invent a new function or variable and hope it will work. They need to be defined first.

I would try something along the following lines: (I am currently not on my PC and can't actually test it)

JavaScript:
<Before Eval>
  a._targetWasAffected = b.isStateAffected(2);
</Before Eval>

<After Eval>
  if (a._targetWasAffected && !b.isStateAffected(2))
    a.gainTP(20);
</After Eval>
Oh, I didn't know you can store variables in a tag and then using them on another tag, I going to try this and let you know.

Original thread: https://forums.rpgmakerweb.com/threads/reward-the-healer-who-removes-a-state.147189/