#============================================================================== # [ZTBS] -Zenith Tactical Battle System- タクティカルバトルシステム #  〜CP5:ZTBS エネミーフェーズ&アフターバトルフェーズ〜   by 水夜 #  ver1.10  Zenith Creation (http://zenith.ifdef.jp/) #------------------------------------------------------------------------------ # マップ上での戦略的なバトルを実現。 #  ※「CP制御ターンシステム」・・・スクリプトシェルフ(桜雅在土氏) #                   http://scriptshelf.jpn.org/x/ #============================================================================== #============================================================================== # ■ Scene_Map #============================================================================== class Scene_Map #-------------------------------------------------------------------------- # ● エネミーフェーズ開始 #-------------------------------------------------------------------------- def start_phase2 # カーソル固定 $game_player.not_update = true # フェーズ 2 に移行 $game_system.tactics_phase = 2 # ターンカウント $game_system.tactics_turn += 1 # ステップを 1 に設定 $game_system.tactics_step = 1 # ターンイベントセット if defined? turn_event set_turn_event end end #-------------------------------------------------------------------------- # ● フレーム更新 (エネミーフェーズ) #-------------------------------------------------------------------------- def update_phase2 # ウィンドウ位置調整 move_window # 戦闘不能復活判定 battler_revival # 勝敗判定 if judge return end # エフェクト中の場合 if effect? return end # イベント実行中の場合 if $game_system.map_interpreter.running? return end # リザルトウィンドウ表示中の場合 if defined? result_window and result_window return end # ステップに応じて更新 case $game_system.tactics_step when 0 update_phase2_step0 when 1 update_phase2_step1 when 2 update_phase2_step2 when 3 update_phase2_step3 when 4 update_phase2_step4 when 5 update_phase2_step5 when 6 update_phase2_step6 when 7 update_step7 when 8 update_step8 when 9 update_step9 when 10 update_step10 end if $game_system.tactics_step != 1 return end end #-------------------------------------------------------------------------- # ● フレーム更新 (エネミーフェーズ ステップ 0 : 次のエネミーへ) #-------------------------------------------------------------------------- def update_phase2_step0 # ヘルプウィンドウにアクター or エネミーをセット set_battler_info if !@spriteset.effect? next_enemy # ステップを 1 に設定 $game_system.tactics_step = 1 end end #-------------------------------------------------------------------------- # ● フレーム更新 (エネミーフェーズ ステップ 1 : アクション作成) #-------------------------------------------------------------------------- def update_phase2_step1 @wait_count = ZTBS::ENEMY_THINKING if $game_player.x != @active_battler.x or $game_player.y != @active_battler.y $game_player.moveto(@active_battler.x, @active_battler.y) @battler = @active_battler set_battler_info end # ヘルプウィンドウにアクター or エネミーをセット set_battler_info # アクション作成 @attacker.make_tactical_action # ステップを 2 に設定 $game_system.tactics_step = 2 end #-------------------------------------------------------------------------- # ● フレーム更新 (エネミーフェーズ ステップ 2 : アクション判定) #-------------------------------------------------------------------------- def update_phase2_step2 @wait_count = ZTBS::ENEMY_THINKING # 行動できない場合 if @attacker.restriction == 4 # ステップを 10 に設定 $game_system.tactics_step = 10 return end # 防御 or 何もしない の場合 if @attacker.current_action.kind == 0 and (@attacker.current_action.basic == 1 or @attacker.current_action.basic == 3) # ステップを 10 に設定 $game_system.tactics_step = 10 return end # 攻撃エリア検索 position = search_attack_area # 攻撃 の場合 if @attacker.current_action.kind == 0 and @attacker.current_action.basic == 0 and @active_battler.move_frequency != 6 # 攻撃範囲が定義されている場合 if defined? ENEMY_RANGE # 攻撃ターゲット判定 targets = check_attack_target(position) if targets[1].size > 0 @targets = {} @target_position = targets[0] for i in targets[1] @targets[i] = $game_system.tactics_actors[i] end # 攻撃エリアをセット set_attack_area(1) # ステップを 6 に設定 $game_system.tactics_step = 6 return else # 最も近いバトラー取得 id = nearest_battler($game_system.tactics_actors.keys) @target_position = [$game_map.events[id].x, $game_map.events[id].y] end else targets = battlers_in_area(position) if targets.size > 0 @targets = {} id = decide_target(targets) @target_position = [$game_map.events[id].x, $game_map.events[id].y] if $game_system.tactics_actors.keys.include?(id) @targets[id] = $game_system.tactics_actors[id] else @targets[id] = $game_system.tactics_enemies[id] end # 攻撃エリアをセット set_attack_area(1) # ステップを 6 に設定 $game_system.tactics_step = 6 return else # 最も近いバトラー取得 id = nearest_battler($game_system.tactics_actors.keys) @target_position = [$game_map.events[id].x, $game_map.events[id].y] end end # スキル の場合 elsif @attacker.current_action.kind == 1 and @active_battler.move_frequency != 6 # スキル取得 skill = $data_skills[@attacker.current_action.skill_id] # スキルターゲット判定 targets = check_skill_target(skill, position) if targets[1].size > 0 @targets = {} @target_position = targets[0] for i in targets[1] if $game_system.tactics_actors.keys.include?(i) @targets[i] = $game_system.tactics_actors[i] else @targets[i] = $game_system.tactics_enemies[i] end end # 攻撃エリアをセット set_attack_area(1) # ステップを 6 に設定 $game_system.tactics_step = 6 return else # 最も近いバトラー取得 case skill.scope when 0, 1, 2, 5, 6 id = nearest_battler($game_system.tactics_actors.keys) @target_position = [$game_map.events[id].x, $game_map.events[id].y] when 3, 4, 7 id = nearest_battler($game_system.tactics_enemies.keys) @target_position = [$game_map.events[id].x, $game_map.events[id].y] end end else # 最も近いアクター取得 id = nearest_battler($game_system.tactics_actors.keys) @target_position = [$game_map.events[id].x, $game_map.events[id].y] end # 移動頻度が 1 の場合 if @active_battler.move_frequency == 1 # ステップを 10 に設定 $game_system.tactics_step = 10 return end # 移動エリア検索 search_route # 逃げる の場合 if @attacker.current_action.kind == 0 and @attacker.current_action.basic == 2 # 移動先決定 @target_position = far_away_position(@target_position, @position) else # 移動先決定 @target_position = nearest_position(@target_position, @position) end # 移動エリアをセット set_movable_area(1) # ステップを 3 に設定 $game_system.tactics_step = 3 end #-------------------------------------------------------------------------- # ● フレーム更新 (エネミーフェーズ ステップ 3 : 移動先選択) #-------------------------------------------------------------------------- def update_phase2_step3 # カーソル位置のバトラー(イベント)取得 get_cursor_battler # カーソル位置にバトラーがいる場合 if @battler != nil # ヘルプウィンドウにアクター or エネミーをセット set_battler_info # カーソル位置にバトラーがいない場合、ヘルプウィンドウを隠す else @help_window.visible = false end # 現在カーソル位置記憶 @now_x = $game_player.x @now_y = $game_player.y # カーソル固定を解除 $game_player.not_update = false # 移動中の場合 if !move_cursor_auto(@target_position) return end # 移動ルート取得 @route_list = @route[@position.index([@target_position[0], @target_position[1]])] # エリア解放 dispose_area # ステップを 4 に設定 $game_system.tactics_step = 4 end #-------------------------------------------------------------------------- # ● フレーム更新 (エネミーフェーズ ステップ 4 : 移動中) #-------------------------------------------------------------------------- def update_phase2_step4 # ステップカウント初期化 if @step_count == nil @step_count = 0 end if !@active_battler.moving? if @active_battler.x == $game_player.x and @active_battler.y == $game_player.y and # 移動完了でステップ 5 に移行 $game_system.tactics_step = 5 # 選択中アクター更新 @battler = @active_battler back_cursor # カーソルを固定 $game_player.not_update = true @step_count = nil return end # カーソル位置まで移動 action = @route_list[@step_count] @step_count += 1 case action when 2 @active_battler.move_down when 4 @active_battler.move_left when 6 @active_battler.move_right when 8 @active_battler.move_up end end end #-------------------------------------------------------------------------- # ● フレーム更新 (エネミーフェーズ ステップ 5 : アクション再判定) #-------------------------------------------------------------------------- def update_phase2_step5 @wait_count = ZTBS::ENEMY_THINKING # 防御 or 何もしない の場合 if @attacker.current_action.kind == 0 and (@attacker.current_action.basic == 1 or @attacker.current_action.basic == 3) # ステップを 10 に設定 $game_system.tactics_step = 10 return end # 攻撃エリア検索 position = search_attack_area # 攻撃 の場合 if @attacker.current_action.kind == 0 and @attacker.current_action.basic == 0 # 攻撃範囲が定義されている場合 if defined? ENEMY_RANGE # 攻撃ターゲット判定 targets = check_attack_target(position) if targets[1].size > 0 @targets = {} @target_position = targets[0] for i in targets[1] @targets[i] = $game_system.tactics_actors[i] end # 攻撃エリアをセット set_attack_area(1) # ステップを 6 に設定 $game_system.tactics_step = 6 return end else targets = battlers_in_area(position) if targets.size > 0 @targets = {} id = decide_target(targets) @target_position = [$game_map.events[id].x, $game_map.events[id].y] if $game_system.tactics_actors.keys.include?(id) @targets[id] = $game_system.tactics_actors[id] else @targets[id] = $game_system.tactics_enemies[id] end # 攻撃エリアをセット set_attack_area(1) # ステップを 6 に設定 $game_system.tactics_step = 6 return end end # スキル の場合 elsif @attacker.current_action.kind == 1 # スキル取得 skill = $data_skills[@attacker.current_action.skill_id] # スキルターゲット判定 targets = check_skill_target(skill, position) if targets[1].size > 0 @targets = {} @target_position = targets[0] for i in targets[1] if $game_system.tactics_actors.keys.include?(i) @targets[i] = $game_system.tactics_actors[i] else @targets[i] = $game_system.tactics_enemies[i] end end # 攻撃エリアをセット set_attack_area(1) # ステップを 6 に設定 $game_system.tactics_step = 6 return end end # ステップを 10 に設定 $game_system.tactics_step = 10 end #-------------------------------------------------------------------------- # ● フレーム更新 (エネミーフェーズ ステップ 6 : 対象選択) #-------------------------------------------------------------------------- def update_phase2_step6 # カーソル位置のバトラー(イベント)取得 get_cursor_battler # カーソル位置にバトラーがいる場合 if @battler != nil # ヘルプウィンドウにアクター or エネミーをセット set_battler_info # カーソル位置にバトラーがいない場合、ヘルプウィンドウを隠す else @help_window.visible = false end # 現在カーソル位置記憶 @now_x = $game_player.x @now_y = $game_player.y # カーソル固定を解除 $game_player.not_update = false # 移動中の場合 if !move_cursor_auto(@target_position) return end # アクション結果作成 case @attacker.current_action.kind when 0 make_basic_action_result when 1 make_skill_action_result end # 互いに向き合う for i in @targets.keys $game_map.events[i].turn_toward_event(@active_battler.id) end @active_battler.turn_toward_position($game_player.x, $game_player.y) # エリア解放 dispose_area # ステップを 7 に設定 $game_system.tactics_step = 7 end #-------------------------------------------------------------------------- # ● アフターバトルフェーズ開始 #-------------------------------------------------------------------------- def start_phase3(result) @help_window.visible = false # 結果に応じた移動先取得 @end_map = $game_map.tactics_end_map[result] # 移動前コモンイベントをセット if @end_map[4] != nil common_event = $data_common_events[@end_map[4]] $game_system.map_interpreter.setup(common_event.list, 0) end # フェーズ 3 に移行 $game_system.tactics_phase = 3 end #-------------------------------------------------------------------------- # ● フレーム更新 (アフターバトルフェーズ) #-------------------------------------------------------------------------- def update_phase3 # エフェクト中の場合 if effect? return end # イベント実行中の場合 if $game_system.map_interpreter.running? return end # リザルトウィンドウ表示中の場合 if defined? result_window and result_window return end # 場所移動 tactics_end_transfer(@end_map) end end