Instruction
Add equip/remove common events to weapons and armor via notetags. Ex:
<EquipCE Event: 1 onequip>
<EquipCE Event: 2 onremove>
The preceding lines will run common event ID 0001 on equip and common event ID 0002 on remove for the weapon or armor tagged.
The event does not run until menu is closed. If the item is equipped or removed multiple times before closing the menu only the last event will run.
Compatibility
Should be compatible with most everything but let me know if you encounter issues.
Use Case Examples
Want to make a cursed ring? Sprint shoes? Teleportation wand? You can do all these things and more with EquipCE.
Known Bugs
- If you switch from an item having onremove to an item having onequip only one of the common events will run.
Using Tsukihime's CommonEventQueue will fix this.
http://himeworks.com/2015/10/common-event-queue-mv/
Version 1.02
- Event runs immediately by closing out the main menu.
Script v1.02
Spoiler
/*=============================================================================
* Gilgamar - Equip Common Event
* By Gilgamar
* G_EquipCE.js
* Version: 1.02
* Free for commercial and non commercial use.
*=============================================================================*/
var Imported = Imported || {};
Imported.G_EquipCE = true;
var EquipCE = {};
/*:
* @plugindesc v1.02 Enable equipment common events.
* @author Gilgamar
*
* @help
* ============================================================================
* Introduction
* ============================================================================
* Enables weapon and armor equip/remove common events via notetags. Ex:
*
* <EquipCE Event: 1 onequip>
* <EquipCE Event: 2 onremove>
*
* The precedling lines will run common event ID 001 on equip and common event
* ID 002 on remove for the weapon or armor tagged.
*
* The event does not run until menu is closed. If the item is equipped or
* removed multiple times before closing the menu only the last event will run.
*
* ============================================================================
* Changelog
* ============================================================================
* Version 1.02:
* - Added SceneManager.goto(Scene_Map) after common event so the event will
* run immediately on equip/remove
*
* Version 1.01:
* - Moved event check into Game_Actor.changeEquip() so it works on optimize
*
* Version 1.00:
* - Enables weapon and armor equip/remove common events via notetags
*/
//=============================================================================
// Notetags
//=============================================================================
EquipCE.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!EquipCE.DataManager_isDatabaseLoaded.call(this)) return false;
DataManager.processEQUIPCENotetags1($dataWeapons);
DataManager.processEQUIPCENotetags1($dataArmors);
return true;
};
DataManager.processEQUIPCENotetags1 = function(group) {
// Check if function called more than once
if (DataManager.processEQUIPCENotetags1.calledTimes++ > 1) return;
var note1 = /<(?:EQUIPCE EVENT):[ ](\d+)[ ](ONEQUIP)>/i;
var note2 = /<(?:EQUIPCE EVENT):[ ](\d+)[ ](ONREMOVE)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
// console.log(notedata)
obj.commonEvents = [];
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(note1)) {
obj.commonEvents.push({
eventId: parseInt(RegExp.$1),
occurs: 'onequip'
});
} else if (line.match(note2)) {
obj.commonEvents.push({
eventId: parseInt(RegExp.$1),
occurs: 'onremove'
});
}
}
}
// console.log(group)
};
DataManager.processEQUIPCENotetags1.calledTimes = 0;
//=============================================================================
// EquipCE Functions
//=============================================================================
EquipCE.changeEquip = function(item, occurs) {
if (!item) return;
for (var i = 0; i < item.commonEvents.length; i++){
var commonEvent = item.commonEvents;
if (commonEvent.occurs === occurs) {
// console.log(commonEvent)
$gameTemp.reserveCommonEvent(commonEvent.eventId);
SceneManager.goto(Scene_Map);
}
}
}
EquipCE.onEquip = function(item) {this.changeEquip(item, 'onequip')}
EquipCE.onRemove = function(item) {this.changeEquip(item, 'onremove')}
//=============================================================================
// RPG Maker Overrides
//=============================================================================
EquipCE.Game_Actor_changeEquip = Game_Actor.prototype.changeEquip;
Game_Actor.prototype.changeEquip = function(slotId, item) {
var oldItem = this.equips()[slotId];
var newItem = item;
EquipCE.Game_Actor_changeEquip.call(this, slotId, item);
if (this.equips()[slotId] === newItem) {
// Change equip succeeded or same item equipped
EquipCE.onEquip(newItem); // Check equip events
EquipCE.onRemove(oldItem); // Check remove events
}
};
// Game_Actor.prototype.changeEquip = function(slotId, item) {
// if (this.tradeItemWithParty(item, this.equips()[slotId]) &&
// (!item || this.equipSlots()[slotId] === item.etypeId)) {
// this._equips[slotId].setObject(item);
// this.refresh();
// }
// };
* Gilgamar - Equip Common Event
* By Gilgamar
* G_EquipCE.js
* Version: 1.02
* Free for commercial and non commercial use.
*=============================================================================*/
var Imported = Imported || {};
Imported.G_EquipCE = true;
var EquipCE = {};
/*:
* @plugindesc v1.02 Enable equipment common events.
* @author Gilgamar
*
* @help
* ============================================================================
* Introduction
* ============================================================================
* Enables weapon and armor equip/remove common events via notetags. Ex:
*
* <EquipCE Event: 1 onequip>
* <EquipCE Event: 2 onremove>
*
* The precedling lines will run common event ID 001 on equip and common event
* ID 002 on remove for the weapon or armor tagged.
*
* The event does not run until menu is closed. If the item is equipped or
* removed multiple times before closing the menu only the last event will run.
*
* ============================================================================
* Changelog
* ============================================================================
* Version 1.02:
* - Added SceneManager.goto(Scene_Map) after common event so the event will
* run immediately on equip/remove
*
* Version 1.01:
* - Moved event check into Game_Actor.changeEquip() so it works on optimize
*
* Version 1.00:
* - Enables weapon and armor equip/remove common events via notetags
*/
//=============================================================================
// Notetags
//=============================================================================
EquipCE.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!EquipCE.DataManager_isDatabaseLoaded.call(this)) return false;
DataManager.processEQUIPCENotetags1($dataWeapons);
DataManager.processEQUIPCENotetags1($dataArmors);
return true;
};
DataManager.processEQUIPCENotetags1 = function(group) {
// Check if function called more than once
if (DataManager.processEQUIPCENotetags1.calledTimes++ > 1) return;
var note1 = /<(?:EQUIPCE EVENT):[ ](\d+)[ ](ONEQUIP)>/i;
var note2 = /<(?:EQUIPCE EVENT):[ ](\d+)[ ](ONREMOVE)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
// console.log(notedata)
obj.commonEvents = [];
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(note1)) {
obj.commonEvents.push({
eventId: parseInt(RegExp.$1),
occurs: 'onequip'
});
} else if (line.match(note2)) {
obj.commonEvents.push({
eventId: parseInt(RegExp.$1),
occurs: 'onremove'
});
}
}
}
// console.log(group)
};
DataManager.processEQUIPCENotetags1.calledTimes = 0;
//=============================================================================
// EquipCE Functions
//=============================================================================
EquipCE.changeEquip = function(item, occurs) {
if (!item) return;
for (var i = 0; i < item.commonEvents.length; i++){
var commonEvent = item.commonEvents;
if (commonEvent.occurs === occurs) {
// console.log(commonEvent)
$gameTemp.reserveCommonEvent(commonEvent.eventId);
SceneManager.goto(Scene_Map);
}
}
}
EquipCE.onEquip = function(item) {this.changeEquip(item, 'onequip')}
EquipCE.onRemove = function(item) {this.changeEquip(item, 'onremove')}
//=============================================================================
// RPG Maker Overrides
//=============================================================================
EquipCE.Game_Actor_changeEquip = Game_Actor.prototype.changeEquip;
Game_Actor.prototype.changeEquip = function(slotId, item) {
var oldItem = this.equips()[slotId];
var newItem = item;
EquipCE.Game_Actor_changeEquip.call(this, slotId, item);
if (this.equips()[slotId] === newItem) {
// Change equip succeeded or same item equipped
EquipCE.onEquip(newItem); // Check equip events
EquipCE.onRemove(oldItem); // Check remove events
}
};
// Game_Actor.prototype.changeEquip = function(slotId, item) {
// if (this.tradeItemWithParty(item, this.equips()[slotId]) &&
// (!item || this.equipSlots()[slotId] === item.etypeId)) {
// this._equips[slotId].setObject(item);
// this.refresh();
// }
// };
Script v1.01
Spoiler
/*=============================================================================
* Gilgamar - Equip Common Event
* By Gilgamar
* G_EquipCE.js
* Version: 1.01
* Free for commercial and non commercial use.
*=============================================================================*/
var Imported = Imported || {};
Imported.G_EquipCE = true;
var EquipCE = {};
/*:
* @plugindesc v1.01 Enable equipment common events.
* @author Gilgamar
*
* @help
* ============================================================================
* Introduction
* ============================================================================
* Enables weapon and armor equip/remove common events via notetags. Ex:
*
* <EquipCE Event: 1 onequip>
* <EquipCE Event: 2 onremove>
*
* The precedling lines will run common event ID 001 on equip and common event
* ID 002 on remove for the weapon or armor tagged.
*
* The event does not run until menu is closed. If the item is equipped or
* removed multiple times before closing the menu only the last event will run.
*
* ============================================================================
* Changelog
* ============================================================================
* Version 1.01:
* - Moved event check into Game_Actor.changeEquip() so it works on optimize.
*
* Version 1.00:
* - Enables weapon and armor equip/remove common events via notetags
*/
//=============================================================================
// Notetags
//=============================================================================
EquipCE.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!EquipCE.DataManager_isDatabaseLoaded.call(this)) return false;
DataManager.processEQUIPCENotetags1($dataWeapons);
DataManager.processEQUIPCENotetags1($dataArmors);
return true;
};
DataManager.processEQUIPCENotetags1 = function(group) {
// Check if function called more than once
if (DataManager.processEQUIPCENotetags1.calledTimes++ > 1) return;
var note1 = /<(?:EQUIPCE EVENT):[ ](\d+)[ ](ONEQUIP)>/i;
var note2 = /<(?:EQUIPCE EVENT):[ ](\d+)[ ](ONREMOVE)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
// console.log(notedata)
obj.commonEvents = [];
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(note1)) {
obj.commonEvents.push({
eventId: parseInt(RegExp.$1),
occurs: 'onequip'
});
} else if (line.match(note2)) {
obj.commonEvents.push({
eventId: parseInt(RegExp.$1),
occurs: 'onremove'
});
}
}
}
console.log(group)
};
DataManager.processEQUIPCENotetags1.calledTimes = 0;
//=============================================================================
// EquipCE Functions
//=============================================================================
EquipCE.changeEquip = function(item, occurs) {
if (!item) return;
for (var i = 0; i < item.commonEvents.length; i++){
var commonEvent = item.commonEvents;
if (commonEvent.occurs === occurs) {
console.log(commonEvent)
$gameTemp.reserveCommonEvent(commonEvent.eventId)
}
}
}
EquipCE.onEquip = function(item) {this.changeEquip(item, 'onequip')}
EquipCE.onRemove = function(item) {this.changeEquip(item, 'onremove')}
//=============================================================================
// RPG Maker Overrides
//=============================================================================
// Game_Actor.prototype.changeEquip = function(slotId, item) {
// if (this.tradeItemWithParty(item, this.equips()[slotId]) &&
// (!item || this.equipSlots()[slotId] === item.etypeId)) {
// this._equips[slotId].setObject(item);
// this.refresh();
// }
// };
EquipCE.Game_Actor_changeEquip = Game_Actor.prototype.changeEquip
Game_Actor.prototype.changeEquip = function(slotId, item) {
var oldItem = this.equips()[slotId];
var newItem = item;
EquipCE.Game_Actor_changeEquip.call(this, slotId, item);
if (this.equips()[slotId] === newItem) {
// Change equip succeeded or same item equipped
EquipCE.onEquip(newItem); // Check onEquip events
EquipCE.onRemove(oldItem); // Check onRemove events
}
};
* Gilgamar - Equip Common Event
* By Gilgamar
* G_EquipCE.js
* Version: 1.01
* Free for commercial and non commercial use.
*=============================================================================*/
var Imported = Imported || {};
Imported.G_EquipCE = true;
var EquipCE = {};
/*:
* @plugindesc v1.01 Enable equipment common events.
* @author Gilgamar
*
* @help
* ============================================================================
* Introduction
* ============================================================================
* Enables weapon and armor equip/remove common events via notetags. Ex:
*
* <EquipCE Event: 1 onequip>
* <EquipCE Event: 2 onremove>
*
* The precedling lines will run common event ID 001 on equip and common event
* ID 002 on remove for the weapon or armor tagged.
*
* The event does not run until menu is closed. If the item is equipped or
* removed multiple times before closing the menu only the last event will run.
*
* ============================================================================
* Changelog
* ============================================================================
* Version 1.01:
* - Moved event check into Game_Actor.changeEquip() so it works on optimize.
*
* Version 1.00:
* - Enables weapon and armor equip/remove common events via notetags
*/
//=============================================================================
// Notetags
//=============================================================================
EquipCE.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!EquipCE.DataManager_isDatabaseLoaded.call(this)) return false;
DataManager.processEQUIPCENotetags1($dataWeapons);
DataManager.processEQUIPCENotetags1($dataArmors);
return true;
};
DataManager.processEQUIPCENotetags1 = function(group) {
// Check if function called more than once
if (DataManager.processEQUIPCENotetags1.calledTimes++ > 1) return;
var note1 = /<(?:EQUIPCE EVENT):[ ](\d+)[ ](ONEQUIP)>/i;
var note2 = /<(?:EQUIPCE EVENT):[ ](\d+)[ ](ONREMOVE)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
// console.log(notedata)
obj.commonEvents = [];
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(note1)) {
obj.commonEvents.push({
eventId: parseInt(RegExp.$1),
occurs: 'onequip'
});
} else if (line.match(note2)) {
obj.commonEvents.push({
eventId: parseInt(RegExp.$1),
occurs: 'onremove'
});
}
}
}
console.log(group)
};
DataManager.processEQUIPCENotetags1.calledTimes = 0;
//=============================================================================
// EquipCE Functions
//=============================================================================
EquipCE.changeEquip = function(item, occurs) {
if (!item) return;
for (var i = 0; i < item.commonEvents.length; i++){
var commonEvent = item.commonEvents;
if (commonEvent.occurs === occurs) {
console.log(commonEvent)
$gameTemp.reserveCommonEvent(commonEvent.eventId)
}
}
}
EquipCE.onEquip = function(item) {this.changeEquip(item, 'onequip')}
EquipCE.onRemove = function(item) {this.changeEquip(item, 'onremove')}
//=============================================================================
// RPG Maker Overrides
//=============================================================================
// Game_Actor.prototype.changeEquip = function(slotId, item) {
// if (this.tradeItemWithParty(item, this.equips()[slotId]) &&
// (!item || this.equipSlots()[slotId] === item.etypeId)) {
// this._equips[slotId].setObject(item);
// this.refresh();
// }
// };
EquipCE.Game_Actor_changeEquip = Game_Actor.prototype.changeEquip
Game_Actor.prototype.changeEquip = function(slotId, item) {
var oldItem = this.equips()[slotId];
var newItem = item;
EquipCE.Game_Actor_changeEquip.call(this, slotId, item);
if (this.equips()[slotId] === newItem) {
// Change equip succeeded or same item equipped
EquipCE.onEquip(newItem); // Check onEquip events
EquipCE.onRemove(oldItem); // Check onRemove events
}
};
Script v1.00
Spoiler
/*=============================================================================
* Gilgamar - Equip Common Event
* By Gilgamar
* G_EquipCE.js
* Version: 1.00
* Free for commercial and non commercial use.
*=============================================================================*/
var Imported = Imported || {};
Imported.G_EquipCE = true;
var EquipCE = {};
/*:
* @plugindesc v1.00 Enable equipment common events.
* @author Gilgamar
*
* @help
* ============================================================================
* Introduction
* ============================================================================
* Add equip/remove common events to weapons and armor via notetags. Ex:
*
* <EquipCE Event: 1 onequip>
* <EquipCE Event: 2 onremove>
*
* The preceding lines will run common event ID 001 on equip and common event
* ID 002 on remove for the weapon or armor tagged.
*
* The event does not run until menu is closed. If the item is equipped or
* removed multiple times before closing the menu only the last event will run.
*
* ============================================================================
* Changelog
* ============================================================================
* Version 1.00:
* - Enables weapon and armor onequip/onremove common events via notetags
*/
//=============================================================================
// Notetags
//=============================================================================
EquipCE.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!EquipCE.DataManager_isDatabaseLoaded.call(this)) return false;
DataManager.processEQUIPCENotetags1($dataWeapons);
DataManager.processEQUIPCENotetags1($dataArmors);
return true;
};
DataManager.processEQUIPCENotetags1 = function(group) {
// Check if function called more than once
if (DataManager.processEQUIPCENotetags1.calledTimes++ > 1) return;
var note1 = /<(?:EQUIPCE EVENT):[ ](\d+)[ ](ONEQUIP)>/i;
var note2 = /<(?:EQUIPCE EVENT):[ ](\d+)[ ](ONREMOVE)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
// console.log(notedata)
obj.commonEvents = [];
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(note1)) {
obj.commonEvents.push({
eventId: parseInt(RegExp.$1),
occurs: 'onequip'
});
} else if (line.match(note2)) {
obj.commonEvents.push({
eventId: parseInt(RegExp.$1),
occurs: 'onremove'
});
}
}
}
console.log(group)
};
DataManager.processEQUIPCENotetags1.calledTimes = 0;
//=============================================================================
// EquipCE Functions
//=============================================================================
EquipCE.checkEvent = function(sceneEquip, occurs){
var slotId = sceneEquip._slotWindow.index()
var itemId = sceneEquip.actor()._equips[slotId].itemId()
var item = $dataArmors[itemId]
if (!item) return;
for (var i = 0; i < item.commonEvents.length; i++){
var commonEvent = item.commonEvents;
if (commonEvent.occurs === occurs) {
console.log(commonEvent)
$gameTemp.reserveCommonEvent(commonEvent.eventId)
}
}
}
//=============================================================================
// RPG Maker Overrides
//=============================================================================
EquipCE.Scene_Equip_onItemOk = Scene_Equip.prototype.onItemOk
Scene_Equip.prototype.onItemOk = function() {
EquipCE.checkEvent(this, 'onremove');
EquipCE.Scene_Equip_onItemOk.call(this);
EquipCE.checkEvent(this, 'onequip');
};
* Gilgamar - Equip Common Event
* By Gilgamar
* G_EquipCE.js
* Version: 1.00
* Free for commercial and non commercial use.
*=============================================================================*/
var Imported = Imported || {};
Imported.G_EquipCE = true;
var EquipCE = {};
/*:
* @plugindesc v1.00 Enable equipment common events.
* @author Gilgamar
*
* @help
* ============================================================================
* Introduction
* ============================================================================
* Add equip/remove common events to weapons and armor via notetags. Ex:
*
* <EquipCE Event: 1 onequip>
* <EquipCE Event: 2 onremove>
*
* The preceding lines will run common event ID 001 on equip and common event
* ID 002 on remove for the weapon or armor tagged.
*
* The event does not run until menu is closed. If the item is equipped or
* removed multiple times before closing the menu only the last event will run.
*
* ============================================================================
* Changelog
* ============================================================================
* Version 1.00:
* - Enables weapon and armor onequip/onremove common events via notetags
*/
//=============================================================================
// Notetags
//=============================================================================
EquipCE.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!EquipCE.DataManager_isDatabaseLoaded.call(this)) return false;
DataManager.processEQUIPCENotetags1($dataWeapons);
DataManager.processEQUIPCENotetags1($dataArmors);
return true;
};
DataManager.processEQUIPCENotetags1 = function(group) {
// Check if function called more than once
if (DataManager.processEQUIPCENotetags1.calledTimes++ > 1) return;
var note1 = /<(?:EQUIPCE EVENT):[ ](\d+)[ ](ONEQUIP)>/i;
var note2 = /<(?:EQUIPCE EVENT):[ ](\d+)[ ](ONREMOVE)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
// console.log(notedata)
obj.commonEvents = [];
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(note1)) {
obj.commonEvents.push({
eventId: parseInt(RegExp.$1),
occurs: 'onequip'
});
} else if (line.match(note2)) {
obj.commonEvents.push({
eventId: parseInt(RegExp.$1),
occurs: 'onremove'
});
}
}
}
console.log(group)
};
DataManager.processEQUIPCENotetags1.calledTimes = 0;
//=============================================================================
// EquipCE Functions
//=============================================================================
EquipCE.checkEvent = function(sceneEquip, occurs){
var slotId = sceneEquip._slotWindow.index()
var itemId = sceneEquip.actor()._equips[slotId].itemId()
var item = $dataArmors[itemId]
if (!item) return;
for (var i = 0; i < item.commonEvents.length; i++){
var commonEvent = item.commonEvents;
if (commonEvent.occurs === occurs) {
console.log(commonEvent)
$gameTemp.reserveCommonEvent(commonEvent.eventId)
}
}
}
//=============================================================================
// RPG Maker Overrides
//=============================================================================
EquipCE.Scene_Equip_onItemOk = Scene_Equip.prototype.onItemOk
Scene_Equip.prototype.onItemOk = function() {
EquipCE.checkEvent(this, 'onremove');
EquipCE.Scene_Equip_onItemOk.call(this);
EquipCE.checkEvent(this, 'onequip');
};
Terms of use and Credits
Free to use in any project.
Credit me as Gilgamar if you use this!