[RMVX] Recharge Skill by modern algebra problem

The script works fine but I got a mysterious error that only occurs in one ability. (or maybe more than one)

Screenshot and modern algebra's Recharge Skill script is attached. Please help!

The ability includes "confuse" effect, which enrages the caster and unable to control.

http://rmrk.net/index.php?topic=41079.0

EDIT; I have discovered that loosing control of the actor after casting will trigger errors.And so are the following scenarios;

-then gains confusion, charm, berserk, silence, incapacitated and any states that blocks the access of skills.

-died by attack reflect, HP sacrafice ability, suicide skills, or when the actor itself dies.

error - Copy.jpg

error.jpg
I've moved this thread to Script Support. Please be sure to post your threads in the correct forum next time. Thank you.

@all: please take notice that this is a script for VX, not VX Ace

Please provide a LINK to the original page of the script. We do not want reposts of scripts here for a lot of reasons, including that it is against the wishes of most scripters and that we need to be able to check the original posts for updates and more. I removed your attached script
Bump

Original thread: https://forums.rpgmakerweb.com/threads/rmvx-recharge-skill-by-modern-algebra-problem.44235/