Help Recovery HP on battle end if battle member has x state

I'm looking for a snipped that allows me to restore hp of target battle member at the end of battle if it has x(261 in my db) state on it

I tried putting something like this into process_victory but it doesn't work

    if $game_party.battle_members[0].state?(261)      $game_party.battle_members[0].hp = $game_party.battle_members[0].mhp    elsif $game_party.battle_members[1].state?(261)      $game_party.battle_members[1].hp = $game_party.battle_members[1].mhp    elsif $game_party.battle_members[2].state?(261)      $game_party.battle_members[2].hp = $game_party.battle_members[2].mhp        elsif $game_party.battle_members[3].state?(261)      $game_party.battle_members[3].hp = $game_party.battle_members[3].mhp    end  I also tried Common Event on Battle End script and Base Troop Events v1.00 but i can't find a way.

I'm using Victory Aftermatch, Mog Battle Cry, Command Autobattle and DoubleX RMVXA Bug Fix v1.05b to YSA Battle System: Classical ATB that aliases process_victory.
  
There is no need to use scripts for this - it can be done by events alone.

1) Make a switch "After battle"

2) Make a common event, set to parallel process and conditioned on that switch "After Battle"

3) Inside the common event, check and change whatever you want (conditional branch "actor has state" etc)

4) at the end of the common event, the very last command, has to be "control switch After Battle OFF".

5) In every troop (or if using base troop events then in that troop only) place an troop event that on turn 0 control switch "After Battle" ON.

Unless your scripts change the engine, parallel processes won't work during battlescreen - which means the common event can only start after battle has ended, even if the switch was turned at the beginning. And since the CE turns itself off, it will run exactly once after each battlescreen.
Yes you're right... it take me a bit more time, but better to do something with common events instead using another script..
Thank you for fast answer

Original thread: https://forums.rpgmakerweb.com/threads/help-recovery-hp-on-battle-end-if-battle-member-has-x-state.41911/