MV Allow common events to run during equip scene.

I have a set of common events that need to run after an item is equipped. It would be unreasonable to put the full logic into the On Equip Execute, so I want to use a common event. The issue is, I want the actor images to update immediately and not wait for the equip scene to close. Is there a plugin that lets common events run during the Equip scene?

Also, is there a plugin with an execute for all equipping an unequipping? I could only find ones that tie it to individual equipment.
there is a scriptcall to unequip all of it.

Eliaquim have a plugin I think that runs a common event after the menu
is closed, but after equiped directly? I don't know exactly.
The menu scenes don't have interpreters which are required to execute common events.

I would rewrite those common events as scripts. Scripts could be easily called from events and as long as you don't do things like showing a message or displaying pictures it's quite easy to convert them.
The menu scenes don't have interpreters which are required to execute common events.

I would rewrite those common events as scripts. Scripts could be easily called from events and as long as you don't do things like showing a message or displaying pictures it's quite easy to convert them.
A solution I worked out is simply closing and reopening the menu every time the player equips something. The issue is that acquiring a new character immediately opens that menu, because they have things equipped by default.
Hey,

If you don't actually care about features like showing messages or waits (which would probably require changes to the equip menu itself), you could maybe try to set up your own interpreter:

JavaScript:
let id = 127;  // Common Event ID
let interpreter = new Game_Interpreter();
interpreter.setup($dataCommonEvents[id].list);
interpreter.update();  // Advance the event command execution by one frame
// (The previous step would need to be repeated if the event contains waits)
// (i.e. if interpreter.isRunning() still returns true)
if (interpreter.isRunning()) {
  console.warn("Interpreter got interrupted. The rest of the event may get skipped.");
}

If you just need a lot of code space and want code to be executed after any equipment change by any actor, an alternative might be to put your code into a plugin instead:
Spoiler
JavaScript:
/*:
 * @author
 * <Author Field>
 *
 * @plugindesc
 * <Short Plugin Description Field>
 *
 * @help
 * <Help Text Field>
 * <Usually a User Manual>
 *
 */

// New function to handle equipment changes:
Game_Actor.prototype.onAfterEquipmentChange = function(oldEquips) {
 
    // TODO: Add Code Here. You can use...
    // this          : the actor whose equipment changed.
    // this.equips() : Array with the actors currently equipped items
    // oldEquips     : Array with the actors previously equipped items
 
};


// Modify the "refresh" function to call "onAfterEquipmentChange" when needed:
// ("refresh" is called after the actors parameters or trait objects change)
Game_Actor.prototype.refresh = (alias => function() {
    alias.call(this);
    let expectedEquips = this._equipsBeforeLastOAEC || [];
    if (
        expectedEquips.length !== this._equips.length ||
        expectedEquips.some((item, i) => item.object() !== this._equips[i].object())
    ) {
        this._equipsBeforeLastOAEC = JsonEx.makeDeepCopy(this._equips);
        this.onAfterEquipmentChange(expectedEquips.map(item => item.object());
    }
})(Game_Actor.prototype.refresh);

If you do want to use other event features, it might be helpful to change the equipment scene as well.

Edit: Removed a comment: $gameActors.actor(X) will recursively create new actors when called during that actors creation and should be used carefully on equipment change.
A way to recognize a non-temporary real actor might be:
let actorId = this.actorId();
if (!$gameActors._data[actorId] || this === $gameActors.actor(actorId)) { ... }
Hey,

If you don't actually care about features like showing messages or waits (which would probably require changes to the equip menu itself), you could maybe try to set up your own interpreter:

JavaScript:
let id = 127;  // Common Event ID
let interpreter = new Game_Interpreter();
interpreter.setup($dataCommonEvents[id].list);
interpreter.update();  // Advance the event command execution by one frame
// (The last step may need to be repeated if the event contains waits)
// (=> interpreter.isRunning() still returns true)

If you just need a lot of code space and want code to be executed after any equipment change by any actor, an alternative might be to put your code into a plugin instead:
Spoiler
JavaScript:
/*:
 * @author
 * <Author Field>
 *
 * @plugindesc
 * <Short Plugin Description Field>
 *
 * @help
 * <Help Text Field>
 * <Usually a User Manual>
 *
 */

// New function to handle equipment changes:
Game_Actor.prototype.onAfterEquipmentChange = function(oldEquips) {
 
    // TODO: Add Code Here. You can use...
    // this          : the actor whose equipment changed.
    // this.equips() : Array with the actors currently equipped items
    // oldEquips     : Array with the actors previously equipped items
 
    // Note: Temporary actors used for equipment preview will also trigger this
    // function. When you need to determine whether an actor is real, you can use
    // if (this === $gameActors.actor(this.actorId())) { ... }
 
};


// Modify the "refresh" function to call "onAfterEquipmentChange" when needed:
// ("refresh" is called after the actors parameters or trait objects change)
Game_Actor.prototype.refresh = (alias => function() {
    alias.call(this);
    let expectedEquips = this._equipsBeforeLastOAEC || [];
    if (
        expectedEquips.length !== this._equips.length ||
        expectedEquips.some((item, i) => item.object() !== this._equips[i].object())
    ) {
        this._equipsBeforeLastOAEC = JsonEx.makeDeepCopy(this._equips);
        this.onAfterEquipmentChange(expectedEquips.map(item => item.object());
    }
})(Game_Actor.prototype.refresh);

If you do want to use other event features, it might be helpful to change the equipment scene as well.
The main things I needed were conditional checks and changing actor images. The event first checks what actor is being updated, then their "outfit" slot, then their "hat" slot. Each variation has a different set of actor images.

Original thread: https://forums.rpgmakerweb.com/threads/allow-common-events-to-run-during-equip-scene.178510/