- plugins/AlwaysMaxHp.js, AlwaysMaxMp.js を新規追加 本作のカードバトルは Game_BattlerBase/Game_Actor のHP/MP APIを使わず、 独自の NPlayer[0](= $gameActors._data[1])の _hp/_mp を直接書き換える実装。 戦闘毎フレーム入口 Game_Interpreter.prototype.update をフックし、 主人公 NPlayer[0] の _hp/_mp を毎フレーム mhp/mmp へクランプする。 - TkoolGameItem に PrincessAlwaysMaxHp / PrincessAlwaysMaxMp を追加し、 PluginSettings(AlwaysMaxHp/AlwaysMaxMp)へ直接マッピング。 - GameItemBase に IsPrincessSynergy(virtual)を追加し、 TkoolGameItem でタイトル判定("プリンセスシナジー")を実装。 該当ゲーム選択時のみ右パネルに専用チェックを表示し、他ゲームへは非表示。 - MainWindow.xaml にプリンセスシナジー専用のHP/MP常時MAXチェックUIを追加。 - GameLauncher.csproj を更新。
75 lines
3.1 KiB
JavaScript
75 lines
3.1 KiB
JavaScript
/*:
|
||
* @target MZ
|
||
* @plugindesc プリンセスシナジー専用: 主人公のHPを常時最大に固定する
|
||
* @author GameLauncher
|
||
*
|
||
* @help
|
||
* プリンセスシナジー(RPGツクールMZ/カードバトル)専用プラグインです。
|
||
*
|
||
* 【分析結果】
|
||
* 本作の戦闘は標準の Game_BattlerBase / Game_Actor のHP APIを一切使わず、
|
||
* 独自のプレイヤー配列 NPlayer[] の _hp を直接書き換える実装になっています
|
||
* (JsScript100Set.js で NPlayer[0] = $gameActors._data[1] を参照)。
|
||
* ダメージは JsScript79Set.js:710 で NPlayer[0]._hp -= value と直接減算され、
|
||
* 描画は JsScript87Set.js で NPlayer[i]._hp を読みます。
|
||
* 戦闘の毎フレーム処理は Game_Interpreter.prototype.update
|
||
* (JsScript54Set.js:91)から呼ばれる NUpdate() が担っています。
|
||
*
|
||
* 【方式】
|
||
* 本プラグインは戦闘の毎フレーム入口 Game_Interpreter.prototype.update を
|
||
* フックし、主人公(NPlayer[0])の _hp を毎フレーム mhp へクランプします。
|
||
* どの経路で書き換えられても、描画前に必ず最大値へ戻ります。
|
||
*
|
||
* 【対象範囲】
|
||
* NPlayer[0](主人公ロマーシャ)のみ。敵(NEnemy)・他の味方(NPlayer[1]以降)
|
||
* には一切影響しません。
|
||
*
|
||
* 【適用/解除】
|
||
* ランチャーの改造チェック(PrincessAlwaysMaxHp)でこのプラグインの
|
||
* 適用/解除を切り替えられます(plugins.js への登録/解除)。
|
||
*/
|
||
|
||
(() => {
|
||
'use strict';
|
||
|
||
// 主人公(NPlayer[0])のHPを最大値へクランプする
|
||
function clampHeroHp() {
|
||
if (typeof NPlayer === 'undefined' || !NPlayer || !NPlayer[0]) return;
|
||
const hero = NPlayer[0];
|
||
const mhp = hero.mhp;
|
||
if (typeof mhp === 'number' && mhp > 0 && hero._hp !== mhp) {
|
||
hero._hp = mhp;
|
||
}
|
||
}
|
||
|
||
// 戦闘中、毎フレーム呼ばれる 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);
|
||
clampHeroHp();
|
||
return result;
|
||
};
|
||
}
|
||
|
||
// 毎フレームの戦闘更新(ダメージ等の直接書き換えを毎回打ち消す)
|
||
if (Game_Interpreter.prototype.DmgEffectUpdate) {
|
||
const _DmgEffectUpdate = Game_Interpreter.prototype.DmgEffectUpdate;
|
||
Game_Interpreter.prototype.DmgEffectUpdate = function() {
|
||
const result = _DmgEffectUpdate.apply(this, arguments);
|
||
clampHeroHp();
|
||
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);
|
||
clampHeroHp();
|
||
return result;
|
||
};
|
||
}
|
||
})();
|