I tried to adapt my plugin EquipActor from MV to MZ, but after trying and making the adaptations, and a couple of code cleanings, in my tests, equiping or unequiping the piece of gear will work just as intended: Equip the piece of gear, the actor disappears, unequip it, the actor appears. But if you press optimize, even if there was no change at all, you will get that it tried to change gear to a inexistent actor.
Why is that?
Thread
In the default code it crashes in these functions:
Reproduction:
I left in the plugin instructions some of the things I tried and might help to solve the issue. I suggest using the demo so you save time setting things up.
[Edit]
I found out the issue. After clicking Optimize, or Clear, party members somehow become 9, starting from actor 1, ending in a null when using my plugin, and there's only 8 actors in the database and in the party.
I edited the function "loadFaceImages" to a slower version to place these console logs.
[/Edit]
Why is that?
Thread
In the default code it crashes in these functions:
Code:
Game_Actor.prototype.optimizeEquipments = function() {
const maxSlots = this.equipSlots().length;
this.clearEquipments();
for (let i = 0; i < maxSlots; i++) {
if (this.isEquipChangeOk(i)) {
this.changeEquip(i, this.bestEquipItem(i)); //only line that makes the game flow on commented
}
}
};
Game_Actor.prototype.clearEquipments = function() {
const maxSlots = this.equipSlots().length;
for (let i = 0; i < maxSlots; i++) {
if (this.isEquipChangeOk(i)) {
this.changeEquip(i, null); //only line that makes the game flow on commented
}
}
};
I left in the plugin instructions some of the things I tried and might help to solve the issue. I suggest using the demo so you save time setting things up.
[Edit]
I found out the issue. After clicking Optimize, or Clear, party members somehow become 9, starting from actor 1, ending in a null when using my plugin, and there's only 8 actors in the database and in the party.
I edited the function "loadFaceImages" to a slower version to place these console logs.
[/Edit]