pure-full-lily/js/plugins/HidePicturesOnSkill.js
2025-09-16 10:12:44 -05:00

78 lines
3.3 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 特定スキル使用時にピクチャID 3036 を隠し、終了後に戻します(複数スキル対応、アクター使用時のみ)。
* @author
*
* @help HidePicturesOnSkill.js
* 指定した複数のスキルIDを、味方アクターが使用したときだけ
* ピクチャ3036を透明化(0)し、アクション終了後に元の透明度(255)に戻します。
*
* 【使い方】
* 1. プラグインパラメータ HideSkillIds に、隠したいスキルIDを複数指定します。
* 2. プラグインパラメータ NoProcessSkillIds に、処理を何もしないスキルIDを複数指定します。
* 3. 該当するスキルの行動がアクターから開始されると、ピクチャ3037が透明化(0)されます。ただし、NoProcessSkillIds に指定されたスキルは処理されません。
* 4. アクション終了後、ピクチャ3036の透明度は255に戻ります。
*
* @param HideSkillIds
* @text 隠したいスキルIDのリスト
* @desc 透明化の対象となるスキルIDを複数指定可能です。
* @type skill[]
* @default []
*
* @param NoProcessSkillIds
* @text 処理を何もしないスキルIDのリスト
* @desc プラグインの処理を実行しないスキルIDを複数指定可能です。
* @type skill[]
* @default []
*/
(() => {
'use strict';
const pluginName = "HidePicturesOnSkill";
const parameters = PluginManager.parameters(pluginName);
const HideSkillIds = JSON.parse(parameters["HideSkillIds"] || "[]").map(id => Number(id));
const NoProcessSkillIds = JSON.parse(parameters["NoProcessSkillIds"] || "[]").map(id => Number(id));
// 隠し処理が実行されたかどうかを保持するフラグ
let hideSkillUsed = false;
// 指定範囲のピクチャ透明度を一括変更するヘルパー関数
function setPictureOpacityAll(startId, endId, opacity) {
for (let i = startId; i <= endId; i++) {
const picture = $gameScreen.picture(i);
if (picture) {
picture._opacity = opacity;
}
}
}
// 元のメソッドを退避
const _Game_Battler_performActionStart = Game_Battler.prototype.performActionStart;
Game_Battler.prototype.performActionStart = function(action) {
_Game_Battler_performActionStart.apply(this, arguments);
// バトラーがアクターかつスキル使用時のみ処理
if (this.isActor() && action.isSkill()) {
const skillId = action.item().id;
// 「何もしないスキルID」に含まれている場合は処理をスキップ
if (NoProcessSkillIds.includes(skillId)) {
return;
}
// 対象スキルIDの場合のみ処理を行う
if (HideSkillIds.includes(skillId)) {
hideSkillUsed = true;
setPictureOpacityAll(30, 37, 0);
}
}
};
// アクション終了時にピクチャ透明度を元に戻す処理(隠し処理を行った場合のみ)
const _BattleManager_endAction = BattleManager.endAction;
BattleManager.endAction = function() {
_BattleManager_endAction.apply(this, arguments);
if (hideSkillUsed) {
setPictureOpacityAll(30, 37, 255);
hideSkillUsed = false;
}
};
})();