brainwashing-school/js/plugins/ITEM_double.js
2025-05-30 08:36:40 -05:00

38 lines
1.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*:
* @target MZ
* @plugindesc 指定したスイッチがONの時、メモ欄に<double>と書かれたアイテムを使用すると2つ消費する残りが1つの場合は1つ消費プラグイン
* @author
*
* @param switchId
* @text スイッチID
* @type switch
* @desc ダブル消費を有効にするスイッチのID
* @default 1
*
* @help
* アイテムのメモ欄に<double>と書いてください。
* 指定したスイッチがONの時、アイテム使用時に2つ消費します。
* ただし、残りが1つしかない場合は1つのみ消費されます。
*/
(() => {
const PLUGIN_NAME = "ManiacItemConsumption";
const params = PluginManager.parameters(PLUGIN_NAME);
// プラグインパラメータからスイッチIDを取得
const switchId = Number(params['switchId'] || 1);
// 元のloseItemを保持
const _Game_Party_loseItem = Game_Party.prototype.loseItem;
Game_Party.prototype.loseItem = function(item, amount, includeEquip) {
// 指定スイッチがON && メタタグ<double>が存在 && 消費量>0 の場合
if ($gameSwitches.value(switchId) && item && item.meta.double !== undefined && amount > 0) {
const count = this.numItems(item);
if (count > 1) {
// 残りが2個以上ある場合は2つ消費
return _Game_Party_loseItem.call(this, item, 2, includeEquip);
}
// 残りが1つの場合は通常amount(1)を消費
}
// 上記条件に当てはまらない場合はデフォルトの処理
return _Game_Party_loseItem.call(this, item, amount, includeEquip);
};
})();