//============================================================================= // RPG Maker MZ - Block clear state // // Copyright 2024 Panzer-IV. All rights reserved. // This source code or any portion thereof must not be // reproduced or used without licensed in any manner whatsoever. //============================================================================= /*: * @target MZ * @plugindesc 永続ステートプラグイン * @author 四号戦車 * @base PluginCommonBase * @orderAfter PluginCommonBase * * @param targetStates * @text 対象ステート * @desc クリアされないステートの指定 * @type state[] * @default [] * * @help BlockClearState.js * * Version: 0.0.1 * * 永続ステートプラグイン * * ステートを永続的に付与できるように全回復・死亡・逃走時等に解除されないようにします。 * 指定のステート以外は解除されます。 * * @command clearAllState * @text ステート全解除 * @desc 永続ステートも含め全解除します。 * * @arg actor * @text 対象アクター * @desc ステートを解除するアクター * @type actor * @default 0 */ (() => { "use strict"; //======================================================================== // プラグイン定義 //======================================================================== const pluginName = "BlockClearState"; const script = document.currentScript; const param = PluginUtils.reparseParameter(script); //======================================================================== // 定数定義 //======================================================================== //======================================================================== // コアスクリプト変更部 (Game_BattlerBase) //======================================================================== const _Game_BattlerBase_clearStates = Game_BattlerBase.prototype.clearStates; Game_BattlerBase.prototype.clearStates = function() { if (!!this._states) { this._states = this._states.filter(stateId => { return this.isStickyState(stateId); }); } else { this._states = []; } if (!!this._stateTurns) { const entries = Object.keys(this._stateTurns).filter(stateId => { return this.isStickyState(stateId); }).map(stateId => { return [stateId, this._stateTurns[stateId]]; }); this._stateTurns = Object.fromEntries(entries); } else { this._stateTurns = {}; } // for MPP_StateLevel if (!!this._stateLevels) { Object.keys(this._stateLevels).forEach(stateId => { if (!this.isStickyState(stateId)) { delete this._stateLevels[stateId]; } }); } else { this._stateLevels = {}; } if (!!this._stateMaxTurns) { Object.keys(this._stateMaxTurns).forEach(stateId => { if (!this.isStickyState(stateId)) { delete this._stateMaxTurns[stateId]; } }); } else { this._stateMaxTurns = {}; } }; Game_BattlerBase.prototype.clearStateForce = function() { this._states = []; this._stateTurns = {}; // for MPP_StateLevel this._stateLevels = {}; this._stateMaxTurns = {}; }; Game_BattlerBase.prototype.isStickyState = function(stateId) { return param.targetStates.includes(Number(stateId)); }; //======================================================================== // プラグインコマンド //======================================================================== PluginManagerEx.registerCommand(script, 'clearAllState', args => { const target = $gameActors.actor(args.actor); if (!!target) { target.clearStateForce(); } }); })();