MV Need some help with a crash. Properties of null (reading 'removeCurrentAction')

So, just to preface this, I got like a metric ton of plugins and many of them custom. I got my plugin order correctly and all that, just to avoid the usual "Did you try turning it off and on again" questions. Either way, looking at the crash notification, none of them seem to even be in there so...

Here's the crash in question:
1779893308887.png

Now, I only saw this happen on a stream so I only got this one instance, but from what I *thought* it would be, is that it's probably a case where the enemy was stunned and then a force action happened (which happens every turn in this particular battle.)

Normally this would probably not an issue, but in my game, a stun doesn't actually "stun" the target in the classic RM sense, but rather does this:
1779893432356.png

And the forced action in question:
1779895566782.png

It really just applies a stacking state, increasing all dmg output the more it stacks.

So my guess was that the forced action runs on "last target", but due to the stun having cleared the actions, there are no targets, so the game crashes. But upon testing it, it looks like that's not the case. No matter if I set the forced action to last target or target the specific enemy, it seems to work fine, so I'm really not sure why this happens and I am not able to replicate it.

I can't think of any other relevant info. Looking at the video, the crash happens after the attack and after the character has already transformed back, so it looks like it's the enemies turn and the stun and forced action seem to be the only things that could be causing this, but if there's any more info needed lemme know.

Ah, and for anyone curious, here's the timestamp to said crash happening:
instead of clearing their action, you can try and set their action to a skill that doesnt do anything with user.currentAction().setSkill(x);and see if that has a different result

I'm really not sure why this happens and I am not able to replicate it.
its hard to say without knowing what you have, but i know how much of it is custom anyways. the way you'd get that crash i believe would be clearing the BattleManager's _subject or trying to get the next one after startAction() is called within processForcedAction(), but before processForcedAction() clears the action.
offhand, the same action start effects you use hooks into a point that'd be relevant, but clearing an action doesnt normally clear the subject too.

Either way, looking at the crash notification, none of them seem to even be in there so...
Im not sure whats going on with your trace, but it seems like all your js files are being compiled into one? main.js is like 10 lines long normally and yours... isnt. it wouldnt provide any plugin names like that if its the case.
i dont think this kind of error would cleanly point to its cause in the trace, but the first step would be undoing whatever's causing that if setAction() doesnt work or if you want to do more than fix this with a bandaid.
instead of clearing their action, you can try and set their action to a skill that doesnt do anything with user.currentAction().setSkill(x);and see if that has a different result


its hard to say without knowing what you have, but i know how much of it is custom anyways. the way you'd get that crash i believe would be clearing the BattleManager's _subject or trying to get the next one after startAction() is called within processForcedAction(), but before processForcedAction() clears the action.
offhand, the same action start effects you use hooks into a point that'd be relevant, but clearing an action doesnt normally clear the subject too.


Im not sure whats going on with your trace, but it seems like all your js files are being compiled into one? main.js is like 10 lines long normally and yours... isnt. it wouldnt provide any plugin names like that if its the case.
i dont think this kind of error would cleanly point to its cause in the trace, but the first step would be undoing whatever's causing that if setAction() doesnt work or if you want to do more than fix this with a bandaid.
Hmm, so maybe I'm not able to replicate because I'm doing the unencrypted playtest... Yes, I use custom encryption for my game and it should be the encrypted version mister streamer was playing. Guess the error trace is pretty useless then. Perhaps I should hit up coderman then to see if there's something funky going on with the encryption, because I can't seem to replicate this in playtest no matter what I do.
Hmmm, that processForcedAction (Yanfly Battle Core seems to use this in aliased method too) is like:

BattleManager.processForcedAction = function() {
if (this._actionForcedBattler) {
this._turnForced = true;
this._subject = this._actionForcedBattler;
this._actionForcedBattler = null;
this.startAction();
this._subject.removeCurrentAction();
}
};

Isn't a bandaid just putting that last line in conditional that the _subject exists?

Also, I only skimmed the plugins with Ctrl-F but in Battle Core in that startAction if the action doesn't exist (since you cleared it with your notetag) it uses endAction. And in that Battle Core endAction it can maybe manipulate the BattleManager subject so that it would be set to null with all those loadPreForceActionSettings and not sure if some base code line too.
EDIT: To be clear because that above method uses that startAction before the crash causing removeCurrentAction
Might be worth checking out this thread?
Basically it seems whenever a Force Action is triggered in a STB Battle after EVERYONE has performed an Action, the Error is caused. Force Action seems to work perfectly fine when triggered DURING the Turn as the Turn doesnt count as over till everyone finishes their Actions,
Even if you're not using Yanfly's STB plugin, it might still be the same underlying problem.
Well, if the way my stun works is the issue, I suppose I could just *not* force the action if the enemy is stunned. I just wasn't sure what the actual problem is since it just doesn't happen for me.

Original thread: https://forums.rpgmakerweb.com/threads/need-some-help-with-a-crash-properties-of-null-reading-removecurrentaction.183829/