MV Game crashing when using the Battle Equip Command while having a Summon on the field

Hi! So I'm in a unique bind that I want to resolve as it's one of the last things in the way of implementing a game mechanic I want to have in my game.

For context, my game features SRD's Summon Core plugin, Yanfly's Item Augments and Equip Customize plugin, and the two Equip Command plugins for battles coded by Jeneeus Guruman and Maliki79 (prefer these two as Yanfly's Equip Battle Command takes away the battle hud UI ^^"). I'm implementing a mechanic that allows players to change out their augments or weapons mid-battle as some enemies can absorb specific types of damage. (I currently don't have a cooldown timer for playtest purposes). I also have a mechanic for one of the characters to be able to summon a spirit so long as the character is conscious.

1740512940883.png


Now I can open the equip menu just fine when it's just the party on screen. But once I get the summon out and I select the equip option. I get this.

1740512813835.png


I can confirm that is only happens once the summon comes onto the field. I've also tried this with Yanfly's Battle Equip Command plugin and it's the same result. So I'm hoping to get some insight on this so I can potentially write up some code to work around this problem.

And for those curious, this is how I have the plugins laid out in respect to each other.
1740513110766.png
your yanfly plugins are in the wrong order.

please sort them into the correct order as given on yanfly's website, then start a new game to test again.
is that all YEP plugin or do you have more?

as Andar said, go to YEP website or use the plugin in my spoiler to check
for the correct order as its quite useful to manually sort them.

as it only shows the plugins you use and set it correctly.
I've got a lot more YEP plugins; I specifically named the ones in my post as they were the most relevant. I also have HIME and MOG plugins as well.

is that all YEP plugin or do you have more?

as Andar said, go to YEP website or use the plugin in my spoiler to check
for the correct order as its quite useful to manually sort them.

as it only shows the plugins you use and set it correctly.
I'm definitely using that plugin to get them sorted and see if that fixes it. Thank you!

Alright plugins are sorted... and the problem persists.

1740520782096.png


Here's the full list of what I have in terms of YEP plugins.
1740520886072.png
I didn't say, but I gave it a fifty/fifty whether the reordering would solve the problem or not.

But unfortunately since that hadn't helped, you most likely need a compatibility patch for the summon core.

The problem with summons during battle is that a lot of battle plugins require additional data - and set that data only during battlesetup.
so any summon from later in battle often misses that additional data.

and to solve that problem, the missing data parts need to be added to the summon function so that the rest of the plugins can work correctly.
But no plugin programmer can prepare for all possible combination of battle plugins, that is why many complex battleplugins have their own summon functions.

SRD did a relatively good job making his summon plugin compatible to most cases, but your combination of equip plugins seem to have stumped it.
I see. That's definitely a shame, but good to know all the same. Alas, the summoning skill is an important element story wise so I'm definitely gonna need to either find a work around by making my own code or remove the change augment idea altogether. :/

Fortunately, only one party member throughout the game gets the summon ability and it's even taken away at one point, so once I get this figured out, it'll be smooth sailing from there.
I have not tested it, but I would assume the problem is that the summons are referenced by their summoner and keep a reference to their battler sprite, which is incompatible with the games JsonEx format (which is used on the equipment screen to create a temporary copy of the actor to calculate the stats for the equipment preview).

You could try to fix this by removing the sprite reference from the copies with an extra plugin:
JavaScript:
/*:
 * @plugindesc Fix a crash when SRD's summons enter the equipment screen
 * @author Another Fen
 * @help Should be placed below SRD_SummonCore.
 */
// ==============================================================================

Object.defineProperty(Game_Summon.prototype, "_battleSprite", {
    set: function(value) {
        Object.defineProperty(this, "_battleSpriteHiddenValue", {
            writable: true,
            value: value,
        });
    },
    get: function() { return this._battleSpriteHiddenValue; }
});

Edit: Replaced the plugin (see post #11).
I'll give this a try and let you know how it goes!

EDIT: I still got the same error message :elswt:
If you tried to validate the result in battle test mode, did you save your project first? (I am not sure if this is still an issue with MV, but previous editors would not reflect changes to code in test play unless the project was saved).

If this does not work, you could try running this plugin. It wont fix the issue, but it should print the chain of properties that lead to the incompatible object to the console, in hopes that this might give a clue:
Spoiler
JavaScript:
let JsonExErrorObjectStack = undefined;

const JsonExEncodeBeforeErrorObject = JsonEx._encode;
JsonEx._encode = function(value, circular, depth) {
    try {
        return JsonExEncodeBeforeErrorObject.call(this, value, circular, depth);
    } catch(e) {
        JsonExErrorObjectStack = JsonExErrorObjectStack || [];
        JsonExErrorObjectStack.push(value);
        if (depth == 0) {
            let result = "Error during stringification:\nProperty chain:\n";
            for (let i = 1; i < JsonExErrorObjectStack.length; i++) {
                let source = JsonExErrorObjectStack[i];
                let target = JsonExErrorObjectStack[i - 1];
                let keys = Object.keys(source).filter(k => source[k] === target);
                result += JSON.stringify(keys) + "\n";
            }
            if (value.isActor && value.isActor()) {
                result += "\nCaused by actor " + value.actorId() + " : " + value.name();
            } else {
                result += "\nCaused by unknown object.";
            }
            console.log(result);
            JsonExErrorObjectStack = undefined;
        }
        throw e;
    }
};
I did save the project first before testing. :elswt:

But I'll definitely try this out. The better understanding of where it's getting tripped up, the easier time coming up with a counter measure will be. Thanks for taking the time in making these plugins btw.

EDIT:

Okay I implemented this plugin and I tested it out on both the summoner and the summon as they are the ones who cause the bug to happen; I tried it with the other party members and it doesn't happen with them.

For the summoner I get this:
1740674498448.png


For the summon I get this:
1740674415625.png


Funny enough it also changes the error message in the console since the plugin is calling what is causing the crash.
1740674654260.png

Fortunately it's just calling the properties here.

So it seems like it's got to do with the battle sprites for the summon in correlation to the YEP core engine's SceneManager?
This certainly looks like the cloning process is still trying to copy the battler sprite (_battleSprite) of the summon. The first plugin was supposed to prevent that (and did for me when I tried it).

Edit:
Okay, apparently I just completely misremembered how Javascripts properties work. Sorry for the detour. I replaced the plugin from the first post, this should hopefully work now. :]
I have to recheck why my test on the console did not cause an error.


For the summon I get this
Not sure if this is relevant, but from what I have seen I would assume that all equipped items on the summon are lost once it disappears (in case you were planning to leave that option in).
The equipment on the summon is locked to the character so that way it doesn't get unequiped, intentionally or accidentally. The summon cannot be customized in that way ^^"
1740704139759.png


And THE CODE WORKS! IT DOESN'T CRASH NOW WHEN THE SUMMON'S OUT! 😀
1740704063644.png


Tysm!!

Original thread: https://forums.rpgmakerweb.com/threads/game-crashing-when-using-the-battle-equip-command-while-having-a-summon-on-the-field.175810/