56 lines
2.1 KiB
JavaScript
56 lines
2.1 KiB
JavaScript
/*:
|
||
* @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); // 上限超過はエンジン側で処理
|
||
}
|
||
};
|
||
})();
|