magical-girls-runa-and-nanami/js/plugins/CGPT_skill_hp.js
2026-02-28 12:33:13 -06:00

56 lines
2.1 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 [MZ] 戦闘中のターン終了時に習得スキルに応じてHPを回復重複可2-4-6%版)
* @author you
* @help
* 概要:
* 戦闘中の各ターン終了時、アクターが習得している下記スキルに応じて
* 最大HPの一定を加算回復します効果は重複します
*
* - スキルID 417: +2%
* - スキルID 418: +4%
* - スキルID 419: +6%
*
* 仕様:
* - 戦闘中のみ動作
* - アクターのみ対象(敵は対象外)
* - 回復量は合算後に Math.floor で小数点切り捨て
* - Game_Battler.prototype.regenerateAll をフックして実装
*
* 使い方:
* プロジェクトの js/plugins/ に本ファイルを保存し、プラグイン管理で有効化してください
*
* 変更したい場合:
* 下の「const SKILL_*」「const RATE_*」の値を書き換えてください
*/
(() => {
// ===== 設定値(必要なら書き換え) =====
const SKILL_2P_ID = 417; // 習得で+2%
const SKILL_4P_ID = 418; // 習得で+4%
const SKILL_6P_ID = 419; // 習得で+6%
const RATE_2P = 2; // %
const RATE_4P = 4; // %
const RATE_6P = 6; // %
// ===== 実装本体 =====
const _regenerateAll = Game_Battler.prototype.regenerateAll;
Game_Battler.prototype.regenerateAll = function() {
_regenerateAll.call(this);
// 戦闘中のみ・生存中のみ・アクターのみ
if (!$gameParty.inBattle() || !this.isAlive() || !this.isActor()) return;
// 習得状況に応じて%を加算
let totalRate = 0; // 合計%
if (this.isLearnedSkill && this.isLearnedSkill(SKILL_2P_ID)) totalRate += RATE_2P;
if (this.isLearnedSkill && this.isLearnedSkill(SKILL_4P_ID)) totalRate += RATE_4P;
if (this.isLearnedSkill && this.isLearnedSkill(SKILL_6P_ID)) totalRate += RATE_6P;
if (totalRate > 0) {
const gain = Math.floor(this.mhp * (totalRate / 100));
if (gain !== 0) this.gainHp(gain); // 上限超過はエンジン側で処理
}
};
})();