72 lines
2.4 KiB
JavaScript
72 lines
2.4 KiB
JavaScript
//=============================================================================
|
||
// KN_StateNotify.js
|
||
//=============================================================================
|
||
|
||
/*:ja
|
||
* @target MZ
|
||
* @plugindesc ステート解除時の通知
|
||
* @author kurogoma knights
|
||
*
|
||
* @help
|
||
* ステートが解除されたときに通知を表示します。
|
||
* (TorigoyaMZ_NotifyMessageプラグインが必要)
|
||
*
|
||
* @param excludeStates
|
||
* @text 通知除外ステート
|
||
* @desc 通知を表示しないステートID(カンマ区切り)
|
||
* @type string
|
||
* @default 1,2,3
|
||
*/
|
||
|
||
(() => {
|
||
'use strict';
|
||
|
||
const script = document.currentScript;
|
||
const pluginName = script.src.split('/').pop().replace(/\.js$/, '');
|
||
const parameters = PluginManager.parameters(pluginName);
|
||
|
||
const EXCLUDE_STATES = (parameters['excludeStates'] || '1,2,3')
|
||
.split(',')
|
||
.map(id => parseInt(id.trim()))
|
||
.filter(id => !isNaN(id));
|
||
|
||
//=============================================================================
|
||
// Game_Battler - ステート解除時の通知
|
||
//=============================================================================
|
||
|
||
const _Game_Battler_removeState = Game_Battler.prototype.removeState;
|
||
Game_Battler.prototype.removeState = function(stateId) {
|
||
const hadState = this.isStateAffected(stateId);
|
||
|
||
_Game_Battler_removeState.call(this, stateId);
|
||
|
||
// ステートが実際に解除された場合、通知を表示
|
||
if (hadState && this.isActor()) {
|
||
this.notifyStateRemoved(stateId);
|
||
}
|
||
};
|
||
|
||
Game_BattlerBase.prototype.notifyStateRemoved = function(stateId) {
|
||
// 除外リストに含まれる場合はスキップ
|
||
if (EXCLUDE_STATES.includes(stateId)) {
|
||
return;
|
||
}
|
||
|
||
const state = $dataStates[stateId];
|
||
if (!state || !state.name) {
|
||
return;
|
||
}
|
||
|
||
// Torigoya NotifyMessageが利用可能かチェック
|
||
if (typeof Torigoya !== 'undefined' &&
|
||
Torigoya.NotifyMessage &&
|
||
Torigoya.NotifyMessage.Manager) {
|
||
|
||
const message = `\\c[2]${state.name}\\c[0] has worn off...!`;
|
||
Torigoya.NotifyMessage.Manager.notify(
|
||
new Torigoya.NotifyMessage.NotifyItem({ message: message })
|
||
);
|
||
}
|
||
};
|
||
|
||
})();
|