# 戦闘表情変化
module BattleManager
DEFAULT_FACE_INDEX = 0 # 通常
DAMAGE_FACE_INDEX = 1 # 被ダメージ
RECOVERY_FACE_INDEX = 2 # 回復
VICTORY_FACE_INDEX = 3 # 勝利
PAINFUL_FACE_INDEX = 4 # 瀕死or重バッドステータス
SLEEP_FACE_INDEX = 5 # 睡眠
SLEEP_STATE_ID = 9 # 睡眠
HEAVY_BAD_STATUS_ID = [ # 重バッドステータス
2, # 徐々に石化
4, # 凍結
5, # 呪い
6, # 毒
7, # 風邪
11, # 麻痺
12, # 盲目
]
def self.neutral_face_index
if is_sleep?
return SLEEP_FACE_INDEX
elsif is_painful?
return PAINFUL_FACE_INDEX
else
return DEFAULT_FACE_INDEX
end
end
def self.is_sleep?
true if $face_index_changed_actor.state?(SLEEP_STATE_ID)
end
def self.is_painful? # 瀕死or重バッドステータス
return true if $face_index_changed_actor.hp <= $face_index_changed_actor.mhp*0.25 || is_heavy_bad_status?
end
def self.is_heavy_bad_status?
HEAVY_BAD_STATUS_ID.each do |i|
return true if $face_index_changed_actor.state?(i)
end
false
end
end
# 戦闘開始
class Scene_Battle < Scene_Base
alias miriel_start start
def start
$game_party.all_members.each do |i|
$face_index_changed_actor = $game_actors[i.id]
#$data_actors[i.id].face_index = BattleManager.neutral_face_index
$game_actors[i.id].set_face_index(BattleManager.neutral_face_index)
$game_actors[i.id].face_updated = true
end
miriel_start
end
end
# 戦闘行動中
class Window_BattleLog < Window_Selectable
alias miriel_display_action_results display_action_results
def display_action_results(target, item)
if target.actor? && !target.result.missed && !target.result.evaded
$face_index_changed_actor = $game_actors[target.id]
#actor = $data_actors[target.id] # 顔グラは $data_actors
actor = $game_actors[target.id] # 顔グラは $data_actors
index = case
when target.result.hp_damage > 0 || target.result.mp_damage > 0 || target.result.tp_damage > 0
BattleManager::DAMAGE_FACE_INDEX
when target.result.hp_damage < 0 || target.result.mp_damage < 0 || target.result.tp_damage < 0
BattleManager::RECOVERY_FACE_INDEX
end
actor.set_face_index(index)
actor.face_updated = true
miriel_display_action_results(target, item)
actor.set_face_index(BattleManager.neutral_face_index)
actor.face_updated = true
else
miriel_display_action_results(target, item)
end
end
end
# 勝利
class << BattleManager
alias miriel_process_victory process_victory
def process_victory
$game_party.all_members.each {|i|
#$data_actors[i.id].face_index = BattleManager::VICTORY_FACE_INDEX }
$game_actors[i.id].set_face_index(BattleManager::VICTORY_FACE_INDEX)
$game_actors[i.id].face_updated = true
}
miriel_process_victory
end
end
# 戦闘終了
class Game_Battler < Game_BattlerBase
alias miriel_on_battle_end on_battle_end
def on_battle_end
miriel_on_battle_end
$game_party.all_members.each {|i|
# $data_actors[i.id].face_index = BattleManager::DEFAULT_FACE_INDEX
$game_actors[i.id].set_face_index(BattleManager::DEFAULT_FACE_INDEX)
$game_actors[i.id].face_updated = true
}
end
end