Files
GameLauncher/plugins/AlwaysMaxMp.js
T

85 lines
3.5 KiB
JavaScript
Raw 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 プリンセスシナジー専用: 主人公のMPを常時最大に固定する
* @author GameLauncher
*
* @help
* プリンセスシナジー(RPGツクールMZ/カードバトル)専用プラグインです。
*
* 【分析結果】
* 本作の戦闘は標準の Game_BattlerBase / Game_Actor のMP APIを一切使わず、
* 独自のプレイヤー配列 NPlayer[] の _mp を直接書き換える実装になっています
* (JsScript100Set.js で NPlayer[0] = $gameActors._data[1] を参照)。
* カードコストは JsScript72Set.js:119 で NPlayer[0]._mp -= Cost と直接減算
* され、毎ターン減少や回復(上限9クランプ)も直接書き換えです。
* 戦闘の毎フレーム処理は Game_Interpreter.prototype.update
* (JsScript54Set.js:91)から呼ばれる NUpdate() が担っています。
*
* 【方式】
* 本プラグインは戦闘の毎フレーム入口 Game_Interpreter.prototype.update を
* フックし、主人公(NPlayer[0])の _mp を毎フレーム mmp へクランプします。
* どの経路で書き換えられても、描画前に必ず最大値へ戻ります。
*
* 【対象範囲】
* NPlayer[0](主人公ロマーシャ)のみ。敵(NEnemy)・他の味方(NPlayer[1]以降)
* には一切影響しません。
*
* 【適用/解除】
* ランチャーの改造チェック(PrincessAlwaysMaxMp)でこのプラグインの
* 適用/解除を切り替えられます(plugins.js への登録/解除)。
*/
(() => {
'use strict';
// 主人公(NPlayer[0])のMPを最大値へクランプする
function clampHeroMp() {
if (typeof NPlayer === 'undefined' || !NPlayer || !NPlayer[0]) return;
const hero = NPlayer[0];
const mmp = hero.mmp;
if (typeof mmp === 'number' && mmp > 0 && hero._mp !== mmp) {
hero._mp = mmp;
}
}
// 戦闘中、毎フレーム呼ばれる Game_Interpreter.update をフック
if (Game_Interpreter.prototype.update) {
const _Game_Interpreter_update = Game_Interpreter.prototype.update;
Game_Interpreter.prototype.update = function() {
const result = _Game_Interpreter_update.apply(this, arguments);
clampHeroMp();
return result;
};
}
// 毎フレームの戦闘更新(カードコスト等の直接書き換えを毎回打ち消す)
if (Game_Interpreter.prototype.DmgEffectUpdate) {
const _DmgEffectUpdate = Game_Interpreter.prototype.DmgEffectUpdate;
Game_Interpreter.prototype.DmgEffectUpdate = function() {
const result = _DmgEffectUpdate.apply(this, arguments);
clampHeroMp();
return result;
};
}
// プレイヤーターン開始時の保険
if (Game_Interpreter.prototype.BtlPLTurnSetup_Update) {
const _BtlPLTurnSetup_Update = Game_Interpreter.prototype.BtlPLTurnSetup_Update;
Game_Interpreter.prototype.BtlPLTurnSetup_Update = function() {
const result = _BtlPLTurnSetup_Update.apply(this, arguments);
clampHeroMp();
return result;
};
}
// 本作のMP回復は上限9でクランプされるため、回復後にも最大値へ戻す
if (Game_Interpreter.prototype.MPKaihuku) {
const _MPKaihuku = Game_Interpreter.prototype.MPKaihuku;
Game_Interpreter.prototype.MPKaihuku = function() {
const result = _MPKaihuku.apply(this, arguments);
clampHeroMp();
return result;
};
}
})();