82 lines
No EOL
3.6 KiB
JavaScript
82 lines
No EOL
3.6 KiB
JavaScript
|
||
/*:ja
|
||
* @target MZ
|
||
* @author kurogoma knights
|
||
* @plugindesc 修正パッチ TorigoyaMZ_NotifyMessage_AddonGetItem
|
||
* @help 修正パッチ 主に減少通知とか
|
||
*/
|
||
|
||
(() => {
|
||
'use strict';
|
||
const script = document.currentScript;
|
||
const param = PluginManagerEx.createParameter(script);
|
||
|
||
const baseLoseSingleMessage = '\\c[2]\\name\\c[0] を失った…';
|
||
const baseLoseMultiMessage = '\\c[2]\\name\\c[0] ×\\count を失った…';
|
||
const baseLoseMoneyMessage = '\\gold\\c[4]\\G\\c[0] を失った…';
|
||
|
||
// 減少通知
|
||
Torigoya.NotifyMessage.Addons.GetItem.notifyLoseMoney = function(value) {
|
||
if (!this.isEnabled()) return;
|
||
|
||
const absValue = Math.abs(value);
|
||
const template = baseLoseMoneyMessage;
|
||
const notifyItem = new Torigoya.NotifyMessage.NotifyItem({
|
||
message: template.replace(/\\gold/, absValue),
|
||
icon: Torigoya.NotifyMessage.Addons.GetItem.parameter.baseGainMoneyIcon,
|
||
note: '<type:gainMoney>', // loseだけどgainのままじゃないと動かなさそうなので
|
||
});
|
||
Torigoya.NotifyMessage.Manager.notify(notifyItem);
|
||
};
|
||
|
||
// 減少通知
|
||
Torigoya.NotifyMessage.Addons.GetItem.notifyLoseItem = function(item, count) {
|
||
if (!this.isEnabled()) return;
|
||
if (!item) return;
|
||
if (item.itypeId === 3 || item.itypeId === 4) return; // 隠しアイテムは通知しない
|
||
|
||
const template =
|
||
count === -1
|
||
? baseLoseSingleMessage
|
||
: baseLoseMultiMessage;
|
||
if (!template) return;
|
||
|
||
const notifyItem = new Torigoya.NotifyMessage.NotifyItem({
|
||
message: template.replace(/\\count/, Math.abs(count)).replace(/\\name/, item.name),
|
||
icon: item.iconIndex,
|
||
note: '<type:gainItem>', // loseだけどgainのままじゃないと動かなさそうなので
|
||
});
|
||
Torigoya.NotifyMessage.Manager.notify(notifyItem);
|
||
};
|
||
|
||
// -------------------------------------------------------------------------
|
||
// Game_Interpreter
|
||
|
||
// お金取得時の処理に減少通知を追加
|
||
const upstream_Game_Interpreter_command125 = Game_Interpreter.prototype.command125;
|
||
Game_Interpreter.prototype.command125 = function(params) {
|
||
const value = this.operateValue(params[0], params[1], params[2]);
|
||
if (value < 0) Torigoya.NotifyMessage.Addons.GetItem.notifyLoseMoney(value);
|
||
return upstream_Game_Interpreter_command125.apply(this, arguments);
|
||
};
|
||
|
||
// アイテム取得時の処理に減少通知を追加
|
||
const upstream_Game_Interpreter_command126 = Game_Interpreter.prototype.command126;
|
||
Game_Interpreter.prototype.command126 = function(params) {
|
||
const value = this.operateValue(params[1], params[2], params[3]);
|
||
const item = $dataItems[params[0]];
|
||
if (value < 0) Torigoya.NotifyMessage.Addons.GetItem.notifyLoseItem(item, value);
|
||
return upstream_Game_Interpreter_command126.apply(this, arguments);
|
||
};
|
||
|
||
// 武器取得時の処理に減少通知は不要
|
||
|
||
// 防具取得時の処理に減少通知を追加
|
||
const upstream_Game_Interpreter_command128 = Game_Interpreter.prototype.command128;
|
||
Game_Interpreter.prototype.command128 = function(params) {
|
||
const value = this.operateValue(params[1], params[2], params[3]);
|
||
const item = $dataArmors[params[0]];
|
||
if (value < 0) Torigoya.NotifyMessage.Addons.GetItem.notifyLoseItem(item, value);
|
||
return upstream_Game_Interpreter_command128.apply(this, arguments);
|
||
};
|
||
})(); |