はじめに
今回は一定のTP,MP,HPでスキルを発動させる方法を紹介します。
この記事では、主人公が一定のTPになった際に相手に技を発動する方法を紹介します。
同じ方法を使えば、敵側でもTP、MP、HPの条件に合わせて技発動などさせることができます。

RPGツクールMZがある程度触れ、敵を出現させれることを前提に進めます。
最低限の操作や敵の出現させかたはこちらをご覧ください。
一定のTPで技発動
下記の仕組みを作ります。
・コモンイベントで主人公のTPによる条件分岐 → 強制スキル使用
・ある敵の攻撃でこのコモンイベントを呼び出し
・スキルにTPやMP増減を入れてゲーム性の調整
コモンイベントの作成
データベースを開きます。

コモンイベントで「TP30以上」などの名前を付けたイベントを作成。

実行内容に変数の操作を追加。
任意の変数(ここでは0005)=主人公のTPに設定。

設定の位置は下図の通り。

次に条件分岐を作ります。
変数0005 ≧ 30を設定。
すると、TPが30以上になった際に中の内容が実行されます。

この条件分岐の中に「戦闘行動の強制」を入れます。
ここで使わせたいスキルとターゲットを設定。

スキルは今回0004を割り当て。

対象は敵にしかできないようです。
味方回復は敵側にスキルを持たせるなどで調整してください。

最後に「イベント処理の中断」を入れます。
入れないとTP90の時にスキルを3回連続使う挙動になります。

これでコモンイベントの作成が完了です。
スキルの設定
まず、敵キャラが使うスキルを確認します。
データベース → 敵キャラ → 行動パターンを確認。
この敵が使うスキルは「攻撃、ファイアⅠ、2回攻撃」の3つです。

スキルを開きます。
ここのスキルに先ほどの顧問イベントを呼び出す設定を入れます。

使用効果の所に、先ほど設定したコモンイベントを追加。

あとは、コモンイベントで強制的に使う設定をしたスキルを確認。
消費TPなどを設定します。

これでOKで確定。
Ctrl+Rでゲーム実行。
これでTP30を超えて、敵の攻撃でコモンイベントを呼び出された際に強制スキルが発動します。

以上が一定のTPでスキルを強制使用させる方法です。
TPの増減量調整
TPはレベル差などがあるとうまく増えない事があります。
この場合、TP増加などを設定が役立ちます。

これで、TPの増減量を調整することができます。

以上がTPの増減量調整です。
戦闘ログの一部非表示化
…がTP増加=回復なので、TPが5増えた!という表示が増えてしまします。
この3行目の表示はえっちなゲームだと絵と被り気になってしまいます。

こちらの対処法は、ツクテマのこちらで解説されてました。
まず、データベース → 用語メッセージを確認。

ここで消したい項目の文字を消します。

すると… 空白の文字が現れます。
そこで先ほどのツクテマにあったプラグインを使います。

ただ、そのまま入れると説明文が無かったり、対応してないという表示が出て不親切です。

そこで、下記のようにテキストを編集。
/*:
* @target MZ
* @plugindesc 用語 → 不要なメッセージの空欄を消す処理。
* @author ツクテマの質問より
* @url https://tm.lucky-duet.com/viewtopic.php?t=6926
*
* @help
* 用語 → 不要なメッセージの空欄を消す処理。
*/
(function(){
var __Window_BattleLog_addText = Window_BattleLog.prototype.addText;
Window_BattleLog.prototype.addText = function(text) {
if (text.length === 0) return;
__Window_BattleLog_addText.call(this, text);
};
}());
これを”好きな名前.js”のテキストファイルで保存。
ゲーム → フォルダを開くを選択。

js → pluginsのファイルの中に入れます。

F10キーでプラグイン管理を起動。

ここで、先ほどのプラグインを追加。
これで、説明などが増えました。

あとはCtrl+Rで動作確認。
TPやMPが増えてますが、テキストの表示は消えてます。
成功です。

利用規約などは特に書かれてませんが…。
使ってもらう事を前提に、質問の返答をしていたので大丈夫だと思います。
もちろん、私が説明を加えた方もご自由にお使いください。
おまけ:一定のMPでスキル発動
同じ仕組みで一定のHPやMPでスキル発動を行うことができます。
ここではMP30以上で、消費MP30の様子を見るを発動させる設定にしました。

MPの場合、TPのように自動で増えません。
そこで、敵の攻撃スキルにMPを増やす処理を入れます。

あとは、戦闘時などでMPを0にするイベント(-9999)を入れます。

これで、MPゲージを使ってTPのようなことができます。

この方法を使う際は、宿屋の人の回復を全回復からHPの増減+9999にするなどの工夫をしてください。
また、MP10以下でスキル発動などは「MPカウント ≦ 10」に設定すればできます。

あとは、皆さんのアイデア次第です。
まとめ
今回は一定のTP,MP,HPで強制的に技を発動させる方法を紹介しました。
・変数の操作 → ゲームデータより主人公のTP,MP,HPを取得
・コモンイベントでTP,MP,HPの条件分岐を作成
・条件分岐内で「戦闘行動の強制」を使いスキルを使用
・あとは、敵の攻撃スキルなどでコモンイベントを呼び出す
また、他にもRPGツクール関係の情報を発信してます。
ぜひこちらもご覧ください。
コメント