ページ 1 / 1
【解決済】プラグイン素材(Actor Hud)の表示アクターの体力が減った時に表情を変えたいのですが…
Posted: 2017年2月16日(木) 19:30
by 柘榴つくも
まず最初に、私はプログラミング知識はありません。
導入したプラグインの仕様変更についてご質問させてください。
Atelier Rgss様(https://atelierrgss.wordpress.com/)の
Actor Hudをお借りしているのですが、表示しているアクター画像を
HPが減ると表情も変わる仕様にいじる事は可能でしょうか?
(残50%で苦しそうな顔、残30%で厳しそうな顔といった感じです)
一応スクリプトの中身を確認したのですが、
Battle HudにあったアクターフェイスアニメーションがこのActor Hudにも組み込まれているようなのです。
これが入っているという事は動かすことができるのではないかな?と思いまして、
プラグインのパラメータにもアニメーションの可否を表示できるようなので、画像もBattle Hudのアニメーションに使うような5種類を横につなげた画像を入れて試してみました。
表示はうまくいくのですが(5種類のうちの左側の1コマ)
HPをトラップイベントで削っても表情が変わりません…。
スクリプトのどの部分をいじればアニメーションに変化が起こるのでしょうか。

- 体力が満タンの時
- 001.png (121.31 KiB) 閲覧された回数 4196 回

- 体力が50%以下くらいの時
- 002.png (120.04 KiB) 閲覧された回数 4196 回
(※2枚目はアクターの部分だけ画像合成です。)
Re: プラグイン素材(Actor Hud)の表示アクターの体力が減った時に表情を変えたいのですが…
Posted: 2017年2月23日(木) 00:17
by トリアコンタン
こんばんは!
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;
};
Re: プラグイン素材(Actor Hud)の表示アクターの体力が減った時に表情を変えたいのですが…
Posted: 2017年2月26日(日) 12:47
by 柘榴つくも
トリアコンタンさん、ありがとうございます!
早速試しましたら変化しました!
あと、もう一つお聞きしたいのですが、
MAX>50%>30%というようなもう一段階変化することも可能でしょうか?
Re: プラグイン素材(Actor Hud)の表示アクターの体力が減った時に表情を変えたいのですが…
Posted: 2017年2月26日(日) 13:39
by トリアコンタン
お疲れさまです。戦闘不能時のフェイスを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));
}
// 追加終了
};
【解決済】プラグイン素材(Actor Hud)の表示アクターの体力が減った時に表情を変えたいのですが…
Posted: 2017年2月26日(日) 21:19
by 柘榴つくも
お早いご返信と対処法をご伝授くださりありがとうございます!
無事切り替えることが出来ました!