【解決済】プラグイン素材(Actor Hud)の表示アクターの体力が減った時に表情を変えたいのですが…

アバター
柘榴つくも
記事: 12
登録日時: 2017年2月09日(木) 12:08
連絡を取る:

【解決済】プラグイン素材(Actor Hud)の表示アクターの体力が減った時に表情を変えたいのですが…

投稿記事by 柘榴つくも » 2017年2月16日(木) 19:30

まず最初に、私はプログラミング知識はありません。

導入したプラグインの仕様変更についてご質問させてください。
Atelier Rgss様(https://atelierrgss.wordpress.com/)の
Actor Hudをお借りしているのですが、表示しているアクター画像を
HPが減ると表情も変わる仕様にいじる事は可能でしょうか?
(残50%で苦しそうな顔、残30%で厳しそうな顔といった感じです)
一応スクリプトの中身を確認したのですが、
Battle HudにあったアクターフェイスアニメーションがこのActor Hudにも組み込まれているようなのです。
これが入っているという事は動かすことができるのではないかな?と思いまして、
プラグインのパラメータにもアニメーションの可否を表示できるようなので、画像もBattle Hudのアニメーションに使うような5種類を横につなげた画像を入れて試してみました。
表示はうまくいくのですが(5種類のうちの左側の1コマ)
HPをトラップイベントで削っても表情が変わりません…。

スクリプトのどの部分をいじればアニメーションに変化が起こるのでしょうか。

001.png
体力が満タンの時
001.png (121.31 KiB) 閲覧数: 3787 回

002.png
体力が50%以下くらいの時
002.png (120.04 KiB) 閲覧数: 3787 回

(※2枚目はアクターの部分だけ画像合成です。)
最後に編集したユーザー 柘榴つくも on 2017年2月28日(火) 01:04 [ 編集 1 回目 ]

アバター
トリアコンタン
記事: 2311
登録日時: 2015年11月10日(火) 21:13
お住まい: きのこ王国
連絡を取る:

Re: プラグイン素材(Actor Hud)の表示アクターの体力が減った時に表情を変えたいのですが…

投稿記事by トリアコンタン » 2017年2月23日(木) 00:17

こんばんは!
MOG_ActorHud.jsのv1.5を基準に説明します。

1. 335行目付近を以下の通り書き換える(アニメーションは隠しパラメータのようです)

コード: 全て選択

Moghunter.ahud_face_animated = String(Moghunter.parameters['Face Frame Animation'] || true);


2. 866行目付近の数値[30]を任意の数値に書き換える。(50にすると、50%以下で表情変化)

コード: 全て選択

else if (this._battler.hp <= 30 * this._battler.mhp / 100) {this._battler._ahud_face_data[2] = 3}


3. 以下のコードをプラグイン内の任意の箇所に追加する。

コード: 全て選択

//==============================
// * Gain HP
//==============================
var _alias_mog_ahud_gainHp =Game_Actor.prototype.gainHp;
Game_Actor.prototype.gainHp = function(value) {
    _alias_mog_ahud_gainHp.call(this,value);
    this._ahud_face_data[3] += 1;
};

//==============================
// * Recover All
//==============================
var _alias_mog_ahud_recoverAll = Game_Actor.prototype.recoverAll;
Game_Actor.prototype.recoverAll = function() {
    _alias_mog_ahud_recoverAll.call(this);
    this._ahud_face_data[3] += 1;
};
プラグイン関連のトラブルが発生した際の切り分けと報告の方法です。
http://qiita.com/triacontane/items/2e227e5b5ce9503a2c30

[Blog] : http://triacontane.blogspot.jp/
[Twitter]: https://twitter.com/triacontane/
[GitHub] : https://github.com/triacontane/
アバター
柘榴つくも
記事: 12
登録日時: 2017年2月09日(木) 12:08
連絡を取る:

Re: プラグイン素材(Actor Hud)の表示アクターの体力が減った時に表情を変えたいのですが…

投稿記事by 柘榴つくも » 2017年2月26日(日) 12:47

トリアコンタンさん、ありがとうございます!
早速試しましたら変化しました!
あと、もう一つお聞きしたいのですが、
MAX>50%>30%というようなもう一段階変化することも可能でしょうか?
アバター
トリアコンタン
記事: 2311
登録日時: 2015年11月10日(火) 21:13
お住まい: きのこ王国
連絡を取る:

Re: プラグイン素材(Actor Hud)の表示アクターの体力が減った時に表情を変えたいのですが…

投稿記事by トリアコンタン » 2017年2月26日(日) 13:39

お疲れさまです。戦闘不能時のフェイスを30%以下に差し替えれば比較的簡単に実装可能です。
(プレイヤーが一人の場合は、戦闘不能時は不要かと思うので)
Actor_Hud.prototype.update_face_animationの変更例です。

コード: 全て選択

Actor_Hud.prototype.update_face_animation = function() {
   if (this._battler._ahud_face_data[3] > 0) {this._battler._ahud_face_data[3] -= 1;
      if (this._battler._ahud_face_data[3] === 0) {
         // 変更開始
//            if (this._battler.isDead()) {this._battler._ahud_face_data[2] = 4}
         if (this._battler.hp <= 30 * this._battler.mhp / 100) {this._battler._ahud_face_data[2] = 4}
         else if (this._battler.hp <= 50 * this._battler.mhp / 100) {this._battler._ahud_face_data[2] = 3}
         // 変更終了
         else {this._battler._ahud_face_data[2] = 0};
         };
   };
};



また、追加調査により、メニュー画面の開閉等を行うとフェイスが初期化されてしまう問題が見付かりました。
Actor_Hud.prototype.create_faceを以下のように変更すれば回避できます。

コード: 全て選択

Actor_Hud.prototype.create_face = function() {
   if (String(Moghunter.ahud_face_visible) != "true") {return};
   this.removeChild(this._face);
   if (!this._battler) {return};   
   this._face = new Sprite(ImageManager.loadAHud("Face_" + this._battler._actorId));
   this._face.anchor.x = 0.5;
   this._face.anchor.y = 0.5;
   this._face_data = [0,0,false,false,false,-1];
   if (String(Moghunter.ahud_face_shake) === "true") {this._face_data[2] = true}
   if (String(Moghunter.ahud_face_animated) === "true") {this._face_data[4] = true}
   this._battler._ahud_face_data = [0,0,0,0]
   this.addChild(this._face);
   // 追加開始
   if (this._face_data[4]) {
      this._face.bitmap.addLoadListener(function() {
         this._battler._ahud_face_data[3] += 1;
         this.update_face_animation();
         this.refresh_face();
      }.bind(this));
   }
   // 追加終了
};
プラグイン関連のトラブルが発生した際の切り分けと報告の方法です。
http://qiita.com/triacontane/items/2e227e5b5ce9503a2c30

[Blog] : http://triacontane.blogspot.jp/
[Twitter]: https://twitter.com/triacontane/
[GitHub] : https://github.com/triacontane/
アバター
柘榴つくも
記事: 12
登録日時: 2017年2月09日(木) 12:08
連絡を取る:

【解決済】プラグイン素材(Actor Hud)の表示アクターの体力が減った時に表情を変えたいのですが…

投稿記事by 柘榴つくも » 2017年2月26日(日) 21:19

お早いご返信と対処法をご伝授くださりありがとうございます!
無事切り替えることが出来ました!

“MV:質問” へ戻る