RGSS2 備忘録 その14 臨機応変に行動できる自動戦闘のアクター(修正版)
イヤッホゥ! スリードッグだぜ!(嘘)
今日のは、以前やった臨機応変に行動できる自動戦闘のアクターで、
逃げるのに失敗したときにも、自動戦闘のアクターが行動してしまう
というバグがあるというご指摘がありましたので、
その修正をしました。
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
def start
super
$game_temp.in_battle = true
@spriteset = Spriteset_Battle.new
@message_window = Window_BattleMessage.new
@escaping = false #★
@action_battlers = []
create_info_viewport
end
#--------------------------------------------------------------------------
# ● 逃走の処理
#--------------------------------------------------------------------------
def process_escape
@info_viewport.visible = false
@message_window.visible = true
text = sprintf(Vocab::EscapeStart, $game_party.name)
$game_message.texts.push(text)
if $game_troop.preemptive
success = true
else
success = (rand(100) < @escape_ratio)
end
Sound.play_escape
if success
wait_for_message
battle_end(1)
else
@escaping = true #★
@escape_ratio += 10
$game_message.texts.push('\.' + Vocab::EscapeFailure)
wait_for_message
$game_party.clear_actions
start_main
end
end
#--------------------------------------------------------------------------
# ● 戦闘行動の処理
#--------------------------------------------------------------------------
def process_action
return if judge_win_loss
return if $game_temp.next_scene != nil
set_next_active_battler
if @active_battler == nil
@escaping = false
turn_end
return
end
return if @active_battler.dead?
@message_window.clear
wait(5)
@active_battler.white_flash = true
unless @active_battler.action.forcing
@active_battler.action.prepare
end
if @active_battler.actor? and ! @escaping#★
@active_battler.make_action if @active_battler.auto_battle
end #★
if @active_battler.action.valid?
execute_action
end
unless @active_battler.action.forcing
@message_window.clear
remove_states_auto
display_current_state
end
@active_battler.white_flash = false
@message_window.clear
end
end
もし導入したいという方は、スクリプトをそのままコピーして
ここに追加という部分に追加するか、
赤い部分だけをご自分で挿入してみてください。
ではまたです。( ^ω^)ノシ