Nerine

Veteran
Veteran
Joined
Oct 3, 2020
Messages
101
Reaction score
58
First Language
Polish
Primarily Uses
RMMZ
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.
 

Nerine

Veteran
Veteran
Joined
Oct 3, 2020
Messages
101
Reaction score
58
First Language
Polish
Primarily Uses
RMMZ

Htlaets

Veteran
Veteran
Joined
Feb 1, 2017
Messages
243
Reaction score
121
First Language
English
Primarily Uses
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?
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
2,040
Reaction score
1,518
First Language
Portuguese - Br
Primarily Uses
RMMZ
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...
 

Nerine

Veteran
Veteran
Joined
Oct 3, 2020
Messages
101
Reaction score
58
First Language
Polish
Primarily Uses
RMMZ
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.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,708
Reaction score
2,813
First Language
English
Primarily Uses
RMMZ
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.
 

Nerine

Veteran
Veteran
Joined
Oct 3, 2020
Messages
101
Reaction score
58
First Language
Polish
Primarily Uses
RMMZ
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
 

Nerine

Veteran
Veteran
Joined
Oct 3, 2020
Messages
101
Reaction score
58
First Language
Polish
Primarily Uses
RMMZ
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 credit me.
 */
((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);
 

Attachments

  • CommonEventEquipment.js
    1.7 KB · Views: 0
Last edited:

ThreeSixNine

Veteran
Veteran
Joined
Jan 22, 2019
Messages
309
Reaction score
252
First Language
English
Primarily Uses
RMMV
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?
 

Latest Threads

Latest Posts

Latest Profile Posts

Turning a specific vibe into reality is incredibly difficult. For instance, this song is one of the ones I listen to when working on my post apocalyptic project, and getting it's "feeling" into the game has been a real challenge.

I don't just wanna regurgitate the numbers I see, I wanna actually understand the calculations I'm making so I'm probably gonna make a post later with some calculations and what I THINK they mean to get some advice and corrections.

Edit: All (Most) of these will be tested in game prior. I just wanna make sure I understand what's going on under the hood if you will.
my girlfriend calls all my little chibi art cute lol... funny considering that wasn't the original art style of the game.
100 problems in RMMZ 100 more problems take one down pass it around 101 Problems in RMMZ
Made some progress on my game, mostly mapping. Learned quite a bit in the process!.

M6eUoTT.png

Forum statistics

Threads
113,775
Messages
1,077,349
Members
147,804
Latest member
scooterdoofus
Top