MV Force Action causing error with paralyzing State [Solved]

I have some bosses in my game that will perform an Action after hitting a certain percentage of their HP while I also have States in the game that can cause the Actor or Enemy inflicted to Act but have it cancelled before anything is done if the chance for it to happen is rolled. The chance calculation uses this notetag in the State:
<Custom Action Start Effect>
// Set the paralyze success rate.
var paralyzeRate = 0.5;
// Make a random number check to see if paralyze passes...
if (Math.random() < paralyzeRate) {
// If it does, play the paralyze animation on the target.
user.startAnimation(64);
// Check for the user's current action...
if (user.currentAction()) {
// And make the user consume its resources.
user.useItem(user.currentAction().item());
}
// Clear the user's actions making the user lose the actions.
user.clearActions();
// Get the log window from battle.
var logWindow = SceneManager._scene._logWindow;
// Check if the paralyze state has text in message 3
if (state.message3) {
// If it does, create a message based on it.
var msg = '<CENTER>' + user.name() + state.message3;
// Add the text to the log window to display in battle.
logWindow.addText(msg);
}
// Make the battle wait for the paralysis animation to finish playing.
BattleManager.actionWaitForAnimation();
// Clear the log window.
logWindow.push('clear');
}
</Custom Action Start Effect>

And it seems whenever it activates during a Force Action command in the Battle Events, it makes this error show up


Screenshot 2026-03-24 141520.png


So is there anyway I could fix this while still keeping the State acting the same way, I wouldnt mind if the Forced Action were to ignore the Paralyze Chance but I dont want it to just remove the State from the Enemy so it doesnt break the game, I'd just want it to like ignore the whole process for any Forced Actions if possible
The usual reason for this error message is that something has tried to pass undefined to JSON.parse. Based on the stack trace, it looks like something is trying to do Force Action on an actor, but BattleManager._action is undefined so YEP Battle Engine Core cannot memorise...hang on, I've seen this before. I'll go do a search~

👋 ...OK here's the thread:
Notably:

I came up with something that might solve the problem (just theory, I haven't tested it). Save the following code as a .js file (Save As > File Type: All Files, Filename: whateverYouLike.js), import as a plugin, and make sure to load it immediately after Battle Engine Core in the Plugin Manager~
Spoiler: A fix?
JavaScript:
// Place immediately below YEP_BattleEngineCore in the Plugin Manager

// Override - "no action" failsafe to avoid JSON.parse failure
BattleManager.setPreForceActionSettings = function() {
  return {
    subject: this._subject,
    action: this._action ? JsonEx.makeDeepCopy(this._action) : undefined,  // <- edit 1 of 1
    actionList: JsonEx.makeDeepCopy(this._actionList),
    targets: this._targets.slice(),
    allTargets: this._allTargets.slice(),
    indTargets: this._individualTargets.slice(),
    phaseSteps: JsonEx.makeDeepCopy(this._phaseSteps),
    returnPhase: this._returnPhase,
    phase: this._phase,
    conditionFlags: JsonEx.makeDeepCopy(this._conditionFlags),
    trueFlags: JsonEx.makeDeepCopy(this._trueFlags)
  }
};

// Override - do not restore "no action"
BattleManager.loadPreForceActionSettings = function() {
    var settings = this._forceActionQueue[0];
    if (settings) {
      this._forceActionQueue.shift();
      if (!settings.action) return false;  // <- edit 1 of 1
      this.resetPreForceActionSettings(settings);
      return this._subject && this._subject.isAppeared();
    } else {
      return false;
    }  
};

There are probably various things that can cause it, this "fix" treats the symptom, not the cause.
I believe it did fix something? But the error seems to be different now?
I forgot to mention I use STB so im confused as to why the other ones appear in the error message?
Im pretty sure im supposed to have ATB and CTB turned on still despite not using them in my game, right?


1774458353700.png
Im pretty sure im supposed to have ATB and CTB turned on still despite not using them in my game, right?
yanfly's battle systems are mutually exclusive. if you have one, youre not supposed to be running the others
yanfly's battle systems are mutually exclusive. if you have one, youre not supposed to be running the others
Oh! Ok! Well I got rid of them but it seems this still shows up, just without those systems there now?
1774460681115.png
Oh! Ok! Well I got rid of them but it seems this still shows up
from here, share a complete screenshot of your plugin manager to confirm the load order. i believe that something may be happening out of order.

also confirm that in yanfly's battle engine core plugin parameters you have STB selected as your battle system as well. no need to show a screenshot of it, but just make sure its on STB
from here, share a complete screenshot of your plugin manager to confirm the load order. i believe that something may be happening out of order.

also confirm that in yanfly's battle engine core plugin parameters you have STB selected as your battle system as well. no need to show a screenshot of it, but just make sure its on STB
Ok so I got all of them from top to bottom? I've got quite a lot of em... but mainly I think it would just be the Battle Plugins causing the issue, just figured I show all of them anyway

Im thinking the "BattleEngineFix" one at the very bottom needs place somewhere else perhaps but idk where exactly? Maybe that's it?
Screenshot 2026-03-25 180411.png
Screenshot 2026-03-25 180426.png
Screenshot 2026-03-25 180440.png
Screenshot 2026-03-25 180452.png
Screenshot 2026-03-25 180512.png
Screenshot 2026-03-25 180526.png
Screenshot 2026-03-25 180600.png
Im thinking the "BattleEngineFix" one at the very bottom needs place somewhere else perhaps but idk where exactly? Maybe that's it?
try it immediately after the battle core engine
try it immediately after the battle core engine
Same error happens sadly...
i was hoping it would have been just where it was being loaded.

I tried just the battle engine core and the buffs and states core to get the initial error, and tried Cae's fix to be sure its the right issue. I also use the fix in my main project with many other plugins without an issue. if you disable every plugin besides those 3, can you confirm whether or not you get the crash? if not, then then youd have to reenable your plugins until you find the first plugin that the issue presents itself when enabled.

also, you do have a few yanfly plugins out of order like the passive state plugin being high and the base param plugin being low, but I dont think theyd be contributing to the error. I'd reorder them if i were you
i was hoping it would have been just where it was being loaded.

I tried just the battle engine core and the buffs and states core to get the initial error, and tried Cae's fix to be sure its the right issue. I also use the fix in my main project with a many other plugins without an issue. if you disable every plugin besides those 3, can you confirm whether or not you get the crash? if not, then then youd have to reenable your plugins until you find the first plugin that the issue presents itself when enabled.

also, you do have a few yanfly plugins out of order like the passive state plugin being high and the base param plugin being low, but I dont think theyd be contributing to the error. I'd reorder them if i were you
Ah okay I'll reorder those, also I'll see what I can do with the 3 plugins
i was hoping it would have been just where it was being loaded.

I tried just the battle engine core and the buffs and states core to get the initial error, and tried Cae's fix to be sure its the right issue. I also use the fix in my main project with a many other plugins without an issue. if you disable every plugin besides those 3, can you confirm whether or not you get the crash? if not, then then youd have to reenable your plugins until you find the first plugin that the issue presents itself when enabled.

also, you do have a few yanfly plugins out of order like the passive state plugin being high and the base param plugin being low, but I dont think theyd be contributing to the error. I'd reorder them if i were you
I turned off every plugin except YEP Core Engine, Battle Engine, STB Battle, Buff States, and the plugin suppose to fix stuff like you said and got this error? A bit different from the other one but it still gives an error the same way as before
1774493937182.png
That looks to me like the same error as the one in the first post of this thread, without my plugin.

My plugin overrides setPreForceActionSettings, so I think it's impossible to get the error trace in your screenshot if you are actually using my plugin and loading it after YEP_BattleEngineCore? 😅

Ideas:
  1. Did you save your project to apply Plugin Manager changes before testing?

  2. Maybe you saved the plugin incorrectly. If a plugin causes a syntax error when the game attempts to load it, then that plugin will silently be skipped/disabled. Try the attached file instead?

  3. If you press F8 or F12 during playtest, it should show the dev tools window. That window has a Console tab. Detailed error information should show here, including non-fatal errors that would otherwise go unnoticed. So a screenshot of the Console tab might be helpful. 👋
That looks to me like the same error as the one in the first post of this thread, without my plugin.

My plugin overrides setPreForceActionSettings, so I think it's impossible to get the error trace in your screenshot if you are actually using my plugin and loading it after YEP_BattleEngineCore? 😅

Ideas:
  1. Did you save your project to apply Plugin Manager changes before testing?

  2. Maybe you saved the plugin incorrectly. If a plugin causes a syntax error when the game attempts to load it, then that plugin will silently be skipped/disabled. Try the attached file instead?

  3. If you press F8 or F12 during playtest, it should show the dev tools window. That window has a Console tab. Detailed error information should show here, including non-fatal errors that would otherwise go unnoticed. So a screenshot of the Console tab might be helpful. 👋
Okay I did both 1 and 2 correctly, as for 3 here is the screenshot of the console for when the error occurs? It seems to say it's YEP's Core Engine rather than the Battle Engine I believe with the thing on the far right?
1774581990306.png
It seems to say it's YEP's Core Engine rather than the Battle Engine I believe with the thing on the far right?
YEP_CoreEngine is unrelated: it modifies the error-reporting method to show the trace in-game, that's why it's showing there.

The error seems to be back to what it was in post #5, which is promising. This error makes me think that the BattleManager.startAction method is setting the current _subject to null, because this is the core method (rpg_managers.js) giving rise to the error (comments by me):
JavaScript:
BattleManager.processForcedAction = function() {
    if (this._actionForcedBattler) {                // if true, forced battler is not null
        this._turnForced = true;
        this._subject = this._actionForcedBattler;  // so cannot be null here
        this._actionForcedBattler = null;
        this.startAction();                         // so must be set null here
        this._subject.removeCurrentAction();        // to cause that error here
    }
};
You're manipulating the action via the <Custom Action Start Effect> tag of Buffs & States Core, which hooks into startAction. However, I don't see you doing anything obvious to change the battle manager subject in that notetag, and the code itself seems to be straight from Yanfly's Paralyze Tips & Tricks article...

That said, the STB plugin is unsupported. You could try testing:
  1. With only 3 plugins turned on (for the Paralyze notetag):
    • YEP_BattleEngineCore, my fix, and YEP_BuffsStatesCore.
  2. With only 4 plugins turned on (STB system enabled):
    • YEP_BattleEngineCore, my fix, YEP_X_BattleSysSTB, and YEP_BuffsStatesCore.
(Note that you can press Ctrl+A in the Plugin Manager to select all plugins, then right-click -> Turn OFF to turn them all off at once. I suggest testing in a copy of your project, rather than the real thing. Alternatively you could try to reproduce the relevant setup in a new project, without all the extra plugins & content complicating things.)
  • If it errors out even in case 1, then I'm not sure what's happening. 😅
  • If it works in case 1 but not in case 2, I'd guess it's an issue with forced actions in STB?
  • If it works in case 1 and case 2, check your other plugins. I'd start with battle-related stuff.
As always, remember to save your project to apply Plugin Manager changes before testing, and make sure you Yanfly's plugins are loaded in the recommended order, listed on Yanfly's site:

It's also possible you are using outdated or edited core scripts. More info below in case you want to check that~
Spoiler: info on how to check/update core scripts
  • Choose Game -> Open Folder from the editor's menu bar;
  • Open the js subfolder there;
  • Open e.g. rpg_core.js in any text editor (Notepad is sufficient).
  • You'll see something like this at the top, unless it's really old:

    //============================================================================= // rpg_core.js v1.6.2 //=============================================================================
Functionally, I don't think the core scripts have changed since v1.6.1? If you're using an older version, or if you have edited any core script files at any point, you can update your project by carefully following the instructions in this announcement:
Maybe someone else has more ideas. Either way, good luck! 👋
YEP_CoreEngine is unrelated: it modifies the error-reporting method to show the trace in-game, that's why it's showing there.

The error seems to be back to what it was in post #5, which is promising. This error makes me think that the BattleManager.startAction method is setting the current _subject to null, because this is the core method (rpg_managers.js) giving rise to the error (comments by me):
JavaScript:
BattleManager.processForcedAction = function() {
    if (this._actionForcedBattler) {                // if true, forced battler is not null
        this._turnForced = true;
        this._subject = this._actionForcedBattler;  // so cannot be null here
        this._actionForcedBattler = null;
        this.startAction();                         // so must be set null here
        this._subject.removeCurrentAction();        // to cause that error here
    }
};
You're manipulating the action via the <Custom Action Start Effect> tag of Buffs & States Core, which hooks into startAction. However, I don't see you doing anything obvious to change the battle manager subject in that notetag, and the code itself seems to be straight from Yanfly's Paralyze Tips & Tricks article...

That said, the STB plugin is unsupported. You could try testing:
  1. With only 3 plugins turned on (for the Paralyze notetag):
    • YEP_BattleEngineCore, my fix, and YEP_BuffsStatesCore.
  2. With only 4 plugins turned on (STB system enabled):
    • YEP_BattleEngineCore, my fix, YEP_X_BattleSysSTB, and YEP_BuffsStatesCore.
(Note that you can press Ctrl+A in the Plugin Manager to select all plugins, then right-click -> Turn OFF to turn them all off at once. I suggest testing in a copy of your project, rather than the real thing. Alternatively you could try to reproduce the relevant setup in a new project, without all the extra plugins & content complicating things.)
  • If it errors out even in case 1, then I'm not sure what's happening. 😅
  • If it works in case 1 but not in case 2, I'd guess it's an issue with forced actions in STB?
  • If it works in case 1 and case 2, check your other plugins. I'd start with battle-related stuff.
As always, remember to save your project to apply Plugin Manager changes before testing, and make sure you Yanfly's plugins are loaded in the recommended order, listed on Yanfly's site:

It's also possible you are using outdated or edited core scripts. More info below in case you want to check that~
Spoiler: info on how to check/update core scripts
  • Choose Game -> Open Folder from the editor's menu bar;
  • Open the js subfolder there;
  • Open e.g. rpg_core.js in any text editor (Notepad is sufficient).
  • You'll see something like this at the top, unless it's really old:

    Code:
    //=============================================================================
     // rpg_core.js v1.6.2
     //=============================================================================

Functionally, I don't think the core scripts have changed since v1.6.1? If you're using an older version, or if you have edited any core script files at any point, you can update your project by carefully following the instructions in this announcement:
Maybe someone else has more ideas. Either way, good luck! 👋
I tried out everything here and it seems to be entirely related to STB as it worked in case 1 with it turned off and started giving the error again upon STB being turned back on. Also I checked rpg_core and it's that exact version in the screenshot so im not using an older one!
I didn't read all that so maybe pointless, but if the error has something to do with you clearing the actions, you can instead try to set the actions to some skill that does nothing
I didn't read all that so maybe pointless, but if the error has something to do with you clearing the actions, you can instead try to set the actions to some skill that does nothing
Ooo! Maybe that could work! Although, I have no idea how to do that without breaking stuff...
Try replacing:

if (user.currentAction()) {
user.useItem(user.currentAction().item());
}
user.clearActions();

with (replace ID with your skill id):

if (user.currentAction()) {
user.useItem(user.currentAction().item());
user.currentAction().setSkill(ID);
}

(If your dudes use multiple actions you need to change the skill for all, but you can try it like that)
Try replacing:

if (user.currentAction()) {
user.useItem(user.currentAction().item());
}
user.clearActions();

with (replace ID with your skill id):

if (user.currentAction()) {
user.useItem(user.currentAction().item());
user.currentAction().setSkill(ID);
}

(If your dudes use multiple actions you need to change the skill for all, but you can try it like that)
I tried this and the game doesnt cause an error anymore! But it also makes the paralyze state not paralyze anymore...

Original thread: https://forums.rpgmakerweb.com/threads/force-action-causing-error-with-paralyzing-state-solved.183002/