MZ - Common Event on Equip/Unequip

● ARCHIVED · READ-ONLY
Started by ResidentDeviant 15 posts View original ↗
  1. I'm looking for a plugin that would allow me to run a common event when the armour/weapon is equipped and unequipped.


    Or at least something that will allow me to change the looks of a character when he equips a different armor/weapon, without constantly running a parallel event.
  2. Nerine said:
    Thanks, but these are MV plugins and I'm looking for an MZ plugin.
    Oh, right, my bad. You might be able to get it to work with fossil, though?
  3. Htlaets said:
    Oh, right, my bad. You might be able to get it to work with fossil, though?
    I would like to avoid that.
  4. Hi there!
    Well, I have a plugin that will let you execute a common event every time you close the menu.
    And with this, you can make conditional branches to check the actor's equipment and execute the action you want.
    Eli Quit Menu Common Event

    It's halfway the path... If you have a lot of changes to be made for each armor/weapon that will leave you with a lot of conditional to do yet...
  5. Eliaquim said:
    Hi there!
    Well, I have a plugin that will let you execute a common event every time you close the menu.
    And with this, you can make conditional branches to check the actor's equipment and execute the action you want.
    Eli Quit Menu Common Event

    It's halfway the path... If you have a lot of changes to be made for each armor/weapon that will leave you with a lot of conditional to do yet...
    Thank you, I'm already using it. But I would really like to find a plugin that lets you run a common event or script when you equip/unequip item.
  6. Nerine said:
    Thank you, I'm already using it. But I would really like to find a plugin that lets you run a common event or script when you equip/unequip item.
    The issue here is that Scene_Equip has no interpreter, so it would have to work like the "common event" effect in items does and return the player to the map after changing equipment in order to call said event.
  7. Trihan said:
    The issue here is that Scene_Equip has no interpreter, so it would have to work like the "common event" effect in items does and return the player to the map after changing equipment in order to call said event.
    It makes things harder, and I know there was a plugin for MV that allowed you to run a script whenever item was equipped/unequipped, but I don't want to add FOSSIL just to run 1 plugin. So I'm wondering if anybody knows something similar for MZ
  8. Well, since there wasn't a plugin, I was looking I decided to make one myself, not a greatest plugin, since I just search through rmmz files and try to look for solution, but it works. Actually, this is the first plugin I wrote, so I bet there are tons of stuff you could improve.


    JavaScript:
    //=============================================================================
    // RPG Maker MZ - Common Event Equipment
    //=============================================================================
    
    /*:
     * @target MZ
     * @plugindesc Common events / JS snippets when equipping or unequipping items.
     * @author Nerine
     * @help
     *     To use plugin put these tags in weapon/armor notes:
     *
     *     <onEquip: id, id, id>
     *
     *     <onUnequip: id, id, id>
     *
     *     <onEquipJS>
     *     code
     *     code
     *     </onEquipJS>
     *
     *     <onUnequipJS>
     *     code
     *     code
     *     </onUnequipJS>
     *
     * Terms of use:
     *   Free to use and modify, as long as you don't claim you wrote this code.
     */
    ((alias) => {
        Game_Actor.prototype.changeEquip = function(slotId, item) {
            let previous = this._equips[slotId].object();
            alias.apply(this, arguments);
            let current = this._equips[slotId].object();
            if (previous && current !== previous) {
                if (typeof previous.meta.onUnequip !== 'undefined'){
                    previous.meta.onUnequip.replaceAll(" ", "").split(",").forEach(index => $gameTemp.reserveCommonEvent(index));
                }
                if (previous.note.contains("<onUnequipJS>") && previous.note.contains("</onUnequipJS>")) {
                    eval(previous.note.split("<onUnequipJS>")[1].split("</onUnequipJS>")[0]);
                }
            }
            if (item && current === item) {
                if (typeof item.meta.onEquip !== 'undefined') {
                    item.meta.onEquip.replaceAll(" ", "").split(",").forEach(index => $gameTemp.reserveCommonEvent(index));
                }
                if (item.note.contains("<onEquipJS>") && item.note.contains("</onEquipJS>")) {
                    eval(item.note.split("<onEquipJS>")[1].split("</onEquipJS>")[0]);
                }
            }
        };
    })(Game_Actor.prototype.changeEquip);
  9. Nerine said:
    It makes things harder, and I know there was a plugin for MV that allowed you to run a script whenever item was equipped/unequipped, but I don't want to add FOSSIL just to run 1 plugin. So I'm wondering if anybody knows something similar for MZ
    @Nerine I was wondering if you had any other information about the MV plugin that would run a script on equip/unequip?
  10. I think this is exactly what I've been looking for! I want to add an event to an accessory (a torch) so when equipped it gives the player a light effect. But I am completely new and a noob with this, so I don't suppose you could share an example picture for me?
  11. ThreeSixNine said:
    I was wondering if you had any other information about the MV plugin that would run a script on equip/unequip?
    I Googled "rpg maker mv eval on equip" and found this result.

    There's also one by Hime that just calls a common event, if that's all you want to do.
  12. Deadlyspud said:
    I think this is exactly what I've been looking for! I want to add an event to an accessory (a torch) so when equipped it gives the player a light effect. But I am completely new and a noob with this, so I don't suppose you could share an example picture for me?
    I'm unable to do it right now, but I don't think it's that hard to figure it out on your own. But if you really need an example you'd have to wait till the new year.
  13. I love this, it's just what I needed!