urami-demo/www/js/plugins/FixApproachMove.js
2026-04-24 20:01:10 -05:00

43 lines
No EOL
1.8 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.

/*:
* @plugindesc スイッチとセルフスイッチAがONのとき、特定イベントの「近づく」自律移動を「固定」にするプラグイン
* @author 魚雷城
*
* @param Switch ID
* @desc 条件となる通常スイッチのIDこのスイッチがONのときに動作します
* @default 1
*
* @help
* イベントのメモ欄に <FixApproach> と記載することで、
* 「近づく」自律移動のイベントに対して、指定スイッチとセルフスイッチAがONなら
* 自律移動タイプが「固定」となり動かなくなります。
*
* ◆ 使用手順
* 1. プラグイン管理で有効化
* 2. 対象イベントのメモ欄に <FixApproach> を記述
* 3. 通常スイッチがONかつ、そのイベントのセルフスイッチAがONのとき「固定」になります
*/
(function () {
const parameters = PluginManager.parameters('FixApproachMoveWithSelfSwitch');
const switchId = Number(parameters['Switch ID'] || 1);
const _Game_Event_updateSelfMovement = Game_Event.prototype.updateSelfMovement;
Game_Event.prototype.updateSelfMovement = function () {
if (this.page()) {
const note = this.event().note;
const isFixApproach = note && note.includes("<FixApproach>");
const moveType = this.page().moveType;
const keyA = [this._mapId, this._eventId, 'A'];
const isSelfSwitchAOn = $gameSelfSwitches.value(keyA);
if (isFixApproach && moveType === 2) { // 2 = 近づく
if ($gameSwitches.value(switchId) && isSelfSwitchAOn) {
return; // スイッチとセルフスイッチAがONなら自律移動停止
}
}
}
_Game_Event_updateSelfMovement.call(this);
};
})();