MZ Help with Conditional Branch script call For MP recovery on enemy being hit

I need a simple script command (for a common event) that checks if an enemy is hit by a (specific) attack.

Any help would be appreciated.

this is what I have been trying to work with: $gameTroop.members()[$gameTemp.lastActionData(5)].result().isHit()


I do believe this is incorrect, but I can't find much other information on this. But it has been about 6 hours now and no luck.

(sorry if I posted this in the wrong area, I tried not to)

What I want is for an attack to recover a set amount of MP for the attacker when the enemy his successfully hit by the attack.

** I know I post a lot, I try and space things out as best I can but this is by far the best place to go, so have this ducky:

1_CMRZGM79wdvyRbASOue9RA.png
What I want is for an attack to recover a set amount of MP for the attacker when the enemy his successfully hit by the attack.
it might be possible that the result has already been cleared by the time the common event played. a cleared result would get you a false on that isHit check

since you want the recovery to be done on hit, its a situation where you could put the mp recovery within the damage formula. the formula only gets ran on hits.
Ideally you'd use a plugin like Turan's Eval Tags or visustella's battle core to avoid a specific potential issue with it being in the formula, but if youre not using auto battling actors you sidestep the technical drawback.

try it out
Code:
a.gainMp(20); a.atk*4 - b.def*2
it might be possible that the result has already been cleared by the time the common event played. a cleared result would get you a false on that isHit check

since you want the recovery to be done on hit, its a situation where you could put the mp recovery within the damage formula. the formula only gets ran on hits.
Ideally you'd use a plugin like Turan's Eval Tags or visustella's battle core to avoid a specific potential issue with it being in the formula, but if youre not using auto battling actors you sidestep the technical drawback.

try it out
Code:
a.gainMp(20); a.atk*4 - b.def*2

That seems to work pretty well. And that's extremely useful knowledge.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-conditional-branch-script-call-for-mp-recovery-on-enemy-being-hit.179095/