Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // IsiahEquipCommonEvents
- //=============================================================================
- /*:
- *
- * @author Isiah Brighton
- * @plugindesc v1.00 Allows common events to be called when changing equipment
- *
- * @help
- *
- * ============================================================================
- * Weapon and Armor Notetags
- * ============================================================================
- *
- * <Equip Common Event X>
- * Replace X with the common event ID. When this equipment is equipped, it will
- * execute the common event with that ID.
- *
- *
- * <Unequip Common Event X>
- * <Remove Common Event X>
- * Replace X with the common event ID. When this equipment is removed, it will
- * execute the common event with that ID.
- *
- *
- * ============================================================================
- * Note about common events in the menu
- * ============================================================================
- *
- * RPG Maker MV does not traditionally support common events inside a menu.
- * For that reason, some Event Commands are not supported within this system.
- *
- * That means if a player equips and then unequips an item, or equips 2 items,
- * they will not execute properly. So these types of commands should be
- * avoided.
- *
- * All commands *should* execute properly except:
- * -The Message category of commands (Show Text, Show Choices etc)
- * -The Movement category
- * -The Picture category
- * -Map category
- * -Battle category
- *
- * Additionally, while the Wait command works, I recommend against using it as
- * the player still has input during this time, and if they exit the menu the
- * common event will stop processing.
- *
- * Finally, the Show Message command works once the player returns to the map,
- * but only the first message is shown.
- *
- *
- * If the player's equipment is changed outside of the menu, such as on the
- * map or in battle, the common events should execute normally.
- *
- *
- * ============================================================================
- * Version History
- * ============================================================================
- *
- * v1.0 - Finished plugin
- *
- */
- var Isiah = Isiah || {};
- Isiah.Game_Actor_changeEquip = Game_Actor.prototype.changeEquip;
- Game_Actor.prototype.changeEquip = function (slotId, item)
- {
- var oldEquip = this._equips[slotId].object();
- Isiah.Game_Actor_changeEquip.call(this, slotId, item);
- if (this._equips[slotId].object() != oldEquip)
- {
- if (oldEquip && oldEquip._unequipCommonEvent)
- Isiah.__callCommonEventOnMenu(oldEquip._unequipCommonEvent);
- if (item && item._equipCommonEvent)
- Isiah.__callCommonEventOnMenu(item._equipCommonEvent);
- }
- };
- Isiah.__callCommonEventOnMenu = function (commonEventId)
- {
- if (SceneManager._scene instanceof Scene_MenuBase)
- {
- this.__interpreter = new Game_Interpreter();
- this.__interpreter.setup($dataCommonEvents[commonEventId].list);
- }
- else
- $gameTemp.reserveCommonEvent(commonEventId);
- };
- Isiah.__Scene_MenuBase_update = Scene_MenuBase.prototype.update;
- Scene_MenuBase.prototype.update = function ()
- {
- Isiah.__Scene_MenuBase_update.call(this);
- this.updateIsiahInterpreter();
- };
- Scene_MenuBase.prototype.updateIsiahInterpreter = function ()
- {
- if (Isiah.__interpreter)
- {
- Isiah.__interpreter.update();
- }
- };
- Isiah.EquipCommon_isDatabaseLoaded = DataManager.isDatabaseLoaded;
- DataManager.isDatabaseLoaded = function ()
- {
- if (!Isiah.EquipCommon_isDatabaseLoaded.call(this)) return false;
- if (!Isiah.loaded_EquipCommon)
- {
- DataManager.processIsiahCommonEventNotetags($dataWeapons);
- DataManager.processIsiahCommonEventNotetags($dataArmors);
- Isiah.loaded_EquipCommon = true;
- }
- return true;
- }
- DataManager.processIsiahCommonEventNotetags = function (group)
- {
- var note = /<equip common event (\d*)/i;
- var unequipNote = /<unequip common event (\d*)/i;
- var unequipNote2 = /<discard common event (\d*)/i;
- for (n = 1; n < group.length; n++)
- {
- var obj = group[n];
- var notedata = obj.note.split(/[\r\n]+/);
- for (var i = 0; i < notedata.length; i++)
- {
- var line = notedata[i];
- if (line.match(note))
- {
- obj._equipCommonEvent = RegExp.$1;
- }
- else if (line.match(unequipNote) || line.match(unequipNote2))
- {
- obj._unequipCommonEvent = RegExp.$1;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement