MZ Need help with plugin

So a good while back i had help setting up a script that gave the character a state when TP reached 100(max).

The plugin script goes like this-

Game_BattlerBase.prototype.setTp = function(tp) {
if (this.isActor() && this._tp === 100)
{this.addState(11)}
this.refresh();

};

It was working fine and then suddenly doesn't. I have no idea what made it stop working. I have checked and the state is still in [#0011] but it doesn't even cause any state. It seems to behave as if the script doesn't even exist. Any ideas of what could be going on would be appreciated
It was working fine and then suddenly doesn't. I have no idea what made it stop working.
did you install an additional plugin or change your plugin load order? the way i see it, chances are youre overwriting your customized function.
if new plugin alter it, you can modify yours, if the function exist.

JavaScript:
let alias_setTp = Game_BattlerBase.prototype.setTp;
Game_BattlerBase.prototype.setTp = function(tp) {
   if (this.isActor() && this._tp === 100) this.addState(11);
   this.refresh();
};
alias_setTp.call(this)

wrapping it and below others will add this function still.
you might need to alias it before than check the TP.

but it really depends what plugin alter it.

let alias_setTP is also safer if you have your own import function, so
it wont override any with the same name or stack error if exist.
did you install an additional plugin or change your plugin load order? the way i see it, chances are youre overwriting your customized function.
I have removed all other plugins and it still doesn't work. It just continues to ignore it completely and not apply the state when the characters TP reaches 100. I've tested it multiple time with and without it, both with it being the only plugin, and nothing seems to work. I'm baffled seeing as it worked perfectly before.
I figured out the issue. It's insanely frustrating how a single misplaced line of code can send everything into chaos lol. But it seems to all be functioning again. I added the other plugins and it still works so hopefully that is that

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-plugin.179446/