33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
/*:
|
|
* @target MZ
|
|
* @plugindesc When a specified switch is ON, items tagged <maniac> consume two when used (but still usable if only one remains).
|
|
* @author uroom
|
|
*
|
|
* @param switchId
|
|
* @text Switch ID
|
|
* @type switch
|
|
* @desc The ID of the switch that enables double consumption for <maniac> items.
|
|
* @default 1
|
|
*
|
|
* @help
|
|
* Place <maniac> in an item's note box.
|
|
* When the configured switch is ON, using the item will consume two units.
|
|
* If only one unit remains, it will consume that one and still apply the effect.
|
|
*/
|
|
(() => {
|
|
const PLUGIN_NAME = "ManiacItemConsumption";
|
|
const params = PluginManager.parameters(PLUGIN_NAME);
|
|
const switchId = Number(params['switchId'] || 1);
|
|
|
|
const _Game_Party_loseItem = Game_Party.prototype.loseItem;
|
|
Game_Party.prototype.loseItem = function(item, amount, includeEquip) {
|
|
if ($gameSwitches.value(switchId) && item && item.meta.maniac !== undefined && amount > 0) {
|
|
const count = this.numItems(item);
|
|
// If more than one item, consume two; otherwise consume the last one
|
|
if (count > 1) {
|
|
return _Game_Party_loseItem.call(this, item, 2, includeEquip);
|
|
}
|
|
}
|
|
return _Game_Party_loseItem.call(this, item, amount, includeEquip);
|
|
};
|
|
})();
|