お世話になります。
無知なりに以前質問させていただいた「MOG_BattleHud」をいじってたところ、
解決した点とできなかった点が出てきたため連投させていただきます。
■戦闘中の立ち絵の表情を変えたい→解決。
コード: 全て選択
Battle_Hud.prototype.update_face_animation = function() {
if (this._battler._bhud_face_data[3] > 0) {this._battler._bhud_face_data[3] -= 1;
if (this._battler._bhud_face_data[3] === 0) {
if (this._battler.isDead()) {this._battler._bhud_face_data[2] = 4}
else if (this._battler.hp <= 30 * this._battler.mhp / 100) {this._battler._bhud_face_data[2] = 3}
else {this._battler._bhud_face_data[2] = 0};
};
};
};
の記述を
コード: 全て選択
Battle_Hud.prototype.update_face_animation = function() {
if (this._battler._bhud_face_data[3] > 0) {this._battler._bhud_face_data[3] -= 1;
if (this._battler._bhud_face_data[3] === 0) {
if (this._battler.isDead()) {this._battler._bhud_face_data[2] = 4}
else if ((this._battler._states[0] == 2) && (this._battler.hp <= 30 * this._battler.mhp / 100)) {this._battler._bhud_face_data[2] = 3}//■瀕死&ステート2の時立ち絵を3番に。成功!
else if (this._battler._states[0] == 2) {this._battler._bhud_face_data[2] = 2}//■ステート2の時立ち絵を2番に。成功!
else if (this._battler.hp <= 30 * this._battler.mhp / 100) {this._battler._bhud_face_data[2] = 1}//■瀕死時の立ち絵を1番に。成功!
else {this._battler._bhud_face_data[2] = 0};
};
};
};
に変更することで、状態異常時に立ち絵が変わるようにできました。こちらに関しては解決しました。
■ダメージ時の立ち絵変更
「MOG_BattleHud」ではフェイスアニメをONにすると、ダメージ時に瀕死時と同じ立ち絵になります。
これも上記の立ち絵と同じような記述にしたところ、うまくいきませんでした。
コード: 全て選択
//=============================================================================
// ** Game Action
//=============================================================================
//==============================
// * Apply
//==============================
var _alias_mog_bhud_apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
var oldhp = target.hp
_alias_mog_bhud_apply.call(this,target);
if (target.isActor()) {
if ((this._battler._states[0] == 2) && (oldhp > target.hp)) {target._bhud_face_data = [30,20,3,30]}//■ステート2でダメージ時は3番の立ち絵にしたいが失敗…
else if (oldhp > target.hp) {target._bhud_face_data = [30,20,1,30]};//■ステート2以外でのダメージでは1番の立ち絵に
// if (oldhp > target.hp) {target._bhud_face_data = [30,20,3,30]} ■本来はダメージで3番の立ち絵に変更
// else if (oldhp < target.hp) {target._bhud_face_data = [0,20,1,30]};■本来は回復で1番の立ち絵になる
};
};
こうするとツクールで起動した時、
TypeError Cannot read property '_states' of undefind
と出てしまいます。
立ち絵表示ではうまくいったステート表記ですが、なぜダメージ表現時にはエラーになるんでしょうか?
プログラム知識がないため頓珍漢なことを書いているのかもしれませんが、どなたかご教授いただけると幸いです。