#============================================================================== # [ZTBS] -Zenith Tactical Battle System- タクティカルバトルシステム #  〜+B14:ZTBS 再移動〜   by 水夜 #  ver0.90  Zenith Creation (http://zenith.ifdef.jp/) #------------------------------------------------------------------------------ # マップ上での戦略的なバトルを実現。 #============================================================================== #============================================================================== # □ カスタマイズポイント #============================================================================== module ZTBSB14 # 再移動を許可する属性 MORESTEP_TEXT = "再移動" end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler attr_accessor :more_step #-------------------------------------------------------------------------- # ○ 再移動可能フラグ #-------------------------------------------------------------------------- def more_step? return XRXS.element_include?(self.multy_element_set, ZTBSB14::MORESTEP_TEXT) end end #============================================================================== # ■ Scene_Map #============================================================================== class Scene_Map #-------------------------------------------------------------------------- # ● 待機ウィンドウ作成 #-------------------------------------------------------------------------- def make_end_window @command_window = Window_Command.new(120, ["待機"]) @command_window.x = 0 @command_window.y = 64 if @command_window != nil @command_window.back_opacity = 200 @command_window.index = 0 if $game_player.y < 4 @command_window.y = 416 - @command_window.height end if $game_player.x < 10 @command_window.x = 640 - @command_window.width end end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターフェーズ) #-------------------------------------------------------------------------- def update_phase1 # ウィンドウ位置調整 move_window # 戦闘不能復活判定 battler_revival # 勝敗判定 if judge return end # エフェクト中の場合 if effect? return end # イベント実行中の場合 if $game_system.map_interpreter.running? return end # セレクト中の場合 if @select != nil and @select != 10 update_select return end # リザルトウィンドウ表示中の場合 if defined? result_window and result_window return end # ステップに応じて更新 case $game_system.tactics_step when 0 update_phase1_step0 when 1 update_phase1_step1 when 2 update_phase1_step2 when 3 update_phase1_step3 when 4 update_phase1_step4 when 5 update_phase1_step5 when 6 update_phase1_step6 when 7 update_step7 when 8 update_step8 when 9 update_step9 when 10 update_step10 when 11 update_phase1_step11 when 12 update_phase1_step12 when 13 update_phase1_step13 end if $game_system.tactics_step != 1 return end # 全員行動済み判定 case all_acted? when 1 start_phase2 return when 2 # 未行動アクター処理 not_acted_actor_refresh return end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターフェーズ ステップ 2 : 移動前コマンド) #-------------------------------------------------------------------------- def update_phase1_step2 # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # コマンドウィンドウを解放 dispose_command_window # カーソル固定を解除 $game_player.not_update = false # ステップ 1 へ移行 $game_system.tactics_step = 1 end # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # コマンドによって分岐 case @command_window.index # 移動 when 0 # コマンドウィンドウ解放 dispose_command_window # 移動エリアをセット set_movable_area(0) # カーソル固定を解除 $game_player.not_update = false # ステップ 3 へ移行 $game_system.tactics_step = 3 # 行動バトラー設定 @active_battler = @battler # 攻撃 when 1 # コマンドウィンドウ解放 dispose_command_window # 行動バトラー設定 @active_battler = @battler # 攻撃バトラー取得 @attacker = $game_system.tactics_actors[@active_battler.id] # アクションを設定 @attacker.current_action.kind = 0 @attacker.current_action.basic = 0 # 攻撃エリアをセット set_attack_area(0) # カーソル固定を解除 $game_player.not_update = false # ステップ 6 へ移行 $game_system.tactics_step = 6 # ステップ 2 帰還フラグ @back_step2 = true # 防御 when 2 # コマンドウィンドウ解放 dispose_command_window # 行動バトラー設定 @active_battler = @battler # 攻撃バトラー取得 @attacker = $game_system.tactics_actors[@active_battler.id] # 防御状態に設定 @attacker.current_action.kind = 0 @attacker.current_action.basic = 1 # カーソル固定を解除 $game_player.not_update = false # 再移動可能距離を0にする @attacker.more_step = 0 # ステップ 10 へ移行 $game_system.tactics_step = 10 # ステップ 2 帰還フラグ @back_step2 = true # スキル when 3 # コマンドウィンドウ解放 dispose_command_window # セレクト へ移行 @select = 2 # 行動バトラー設定 @active_battler = @battler # 攻撃バトラー取得 @attacker = $game_system.tactics_actors[@active_battler.id] # セレクトウィンドウを作成 make_select_window(1, @attacker) # アクションを設定 @attacker.current_action.kind = 1 # ステップ 2 帰還フラグ @back_step2 = true # アイテム when 4 # コマンドウィンドウ解放 dispose_command_window # セレクト へ移行 @select = 3 # 行動バトラー設定 @active_battler = @battler # 攻撃バトラー取得 @attacker = $game_system.tactics_actors[@active_battler.id] # セレクトウィンドウを作成 make_select_window(2) # アクションを設定 @attacker.current_action.kind = 2 # ステップ 2 帰還フラグ @back_step2 = true # その他 else if defined?("talk_event") # 「待機」のための分岐 if defined?(XRXS_CP_SYSTEM) and @command_window.index == 5 # 行動バトラー設定 @active_battler = @battler # 攻撃バトラー取得 @attacker = $game_system.tactics_actors[@active_battler.id] # コマンドウィンドウ解放 dispose_command_window # 再移動可能距離を0にする @attacker.more_step = 0 # ステップ 10 へ移行 $game_system.tactics_step = 10 else @comindex = @command_window.index @comvalue = @command_window.commands[@comindex] # コマンドウィンドウ解放 dispose_command_window # 行動バトラー設定 @active_battler = @battler # 攻撃バトラー取得 @attacker = $game_system.tactics_actors[@active_battler.id] # アクションを設定 @attacker.current_action.kind = 0 @attacker.current_action.basic = @comindex # 攻撃エリアをセット set_attack_area(0) # カーソル固定を解除 $game_player.not_update = false # ステップ 6 へ移行 $game_system.tactics_step = 6 # ステップ 2 帰還フラグ @back_step2 = true end # 待機 else # コマンドウィンドウ解放 dispose_command_window # 再移動可能距離を0にする @attacker.more_step = 0 # ステップ 10 へ移行 $game_system.tactics_step = 10 end end end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターフェーズ ステップ 3 : 移動先選択) #-------------------------------------------------------------------------- if defined?(XRXS_CP_SYSTEM) def update_phase1_step3 # カーソル位置のバトラー(イベント)取得 get_cursor_battler # ヘルプウィンドウにアクター or エネミーをセット set_battler_info # C ボタンが押された場合 if Input.trigger?(Input::C) and !$game_player.moving? # 行動出来る場合 if @active_battler.name =~ /actor#{@attacker.id}/ # カーソルが移動エリア内の場合 if in_area?($game_player.x, $game_player.y) @attacker = $game_system.tactics_actors[@battler.id] # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # カーソルを固定 $game_player.not_update = true # エリアを解放 dispose_area # ステップ 4 へ移行 $game_system.tactics_step = 4 # 移動可能歩数記録 @attacker.more_step = @attacker.movable # 座標を記憶 @pre_x = @active_battler.x @pre_y = @active_battler.y # 移動ルート取得 @route_list = @route[@position.index([$game_player.x, $game_player.y])] else # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) end # エネミーの場合 else # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # エリアを解放 dispose_area # アクティブバトラーを解除 @active_battler = nil # カーソル位置を戻す back_cursor # ステップ 1 へ移行 $game_system.tactics_step = 1 end end # B ボタンが押された場合 if Input.trigger?(Input::B) and !$game_player.moving? # 行動出来る場合 if @active_battler.name =~ /actor#{@attacker.id}/ # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # エリアを解放 dispose_area # カーソル位置を戻す back_cursor # カーソルを固定 $game_player.not_update = true # ステップ 2 へ移行 $game_system.tactics_step = 2 # コマンドウィンドウを作成 make_command_window # エネミーの場合 else # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # エリアを解放 dispose_area # アクティブバトラーを解除 @active_battler = nil # カーソル位置を戻す back_cursor # ステップ 1 へ移行 $game_system.tactics_step = 1 end end end else def update_phase1_step3 # カーソル位置のバトラー(イベント)取得 get_cursor_battler # ヘルプウィンドウにアクター or エネミーをセット set_battler_info # C ボタンが押された場合 if Input.trigger?(Input::C) and !$game_player.moving? # アクターの場合 if $game_system.tactics_actors.keys.include?(@active_battler.id) # カーソルが移動エリア内の場合 if in_area?($game_player.x, $game_player.y) @attacker = $game_system.tactics_actors[@battler.id] # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # カーソルを固定 $game_player.not_update = true # エリアを解放 dispose_area # ステップ 4 へ移行 $game_system.tactics_step = 4 # 移動可能歩数記録 @attacker.more_step = @attacker.movable # 座標を記憶 @pre_x = @active_battler.x @pre_y = @active_battler.y # 移動ルート取得 @route_list = @route[@position.index([$game_player.x, $game_player.y])] else # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) end # エネミーの場合 else # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # エリアを解放 dispose_area # アクティブバトラーを解除 @active_battler = nil # カーソル位置を戻す back_cursor # ステップ 1 へ移行 $game_system.tactics_step = 1 end end # B ボタンが押された場合 if Input.trigger?(Input::B) and !$game_player.moving? # アクターの場合 if $game_system.tactics_actors.keys.include?(@active_battler.id) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # エリアを解放 dispose_area # カーソル位置を戻す back_cursor # カーソルを固定 $game_player.not_update = true # ステップ 2 へ移行 $game_system.tactics_step = 2 # コマンドウィンドウを作成 make_command_window # エネミーの場合 else # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # エリアを解放 dispose_area # アクティブバトラーを解除 @active_battler = nil # カーソル位置を戻す back_cursor # ステップ 1 へ移行 $game_system.tactics_step = 1 end end end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターフェーズ ステップ 4 : 移動中) #-------------------------------------------------------------------------- def update_phase1_step4 # ステップカウント初期化 @step_count = 0 if @step_count == nil 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 # コマンドウィンドウを作成 make_command_window # カーソルを固定 $game_player.not_update = true @step_count = nil return end # カーソル位置まで移動 action = @route_list[@step_count] @step_count += 1 @attacker.more_step -= 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 # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # 元の位置に戻す @active_battler.moveto(@pre_x, @pre_y) # カーソル位置を戻す back_cursor # 移動エリアをセット set_movable_area(0) # カーソル固定を解除 $game_player.not_update = false # ステップ 3 へ移行 $game_system.tactics_step = 3 @step_count = nil end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターフェーズ ステップ 5 : 移動後コマンド) #-------------------------------------------------------------------------- def update_phase1_step5 # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # コマンドウィンドウ解放 dispose_command_window # 元の位置に戻す @active_battler.moveto(@pre_x, @pre_y) # カーソル位置を戻す back_cursor # 移動エリアをセット set_movable_area(0) # カーソル固定を解除 $game_player.not_update = false # ステップ 3 へ移行 $game_system.tactics_step = 3 end # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # コマンドによって分岐 case @command_window.index # 攻撃 when 0 # コマンドウィンドウ解放 dispose_command_window # 攻撃バトラー取得 @attacker = $game_system.tactics_actors[@active_battler.id] # アクションを設定 @attacker.current_action.kind = 0 @attacker.current_action.basic = 0 # 攻撃エリアをセット set_attack_area(0) # カーソル固定を解除 $game_player.not_update = false # ステップ 6 へ移行 $game_system.tactics_step = 6 # 防御 when 1 # 行動バトラー設定 @active_battler = @battler # 攻撃バトラー取得 @attacker = $game_system.tactics_actors[@active_battler.id] # 防御状態に設定 @attacker.current_action.kind = 0 @attacker.current_action.basic = 1 # コマンドウィンドウ解放 dispose_command_window # 再移動可能距離を0にする @attacker.more_step = 0 # ステップ 10 へ移行 $game_system.tactics_step = 10 # スキル when 2 # コマンドウィンドウ解放 dispose_command_window # セレクト へ移行 @select = 1 # 行動バトラー設定 @active_battler = @battler # 攻撃バトラー取得 @attacker = $game_system.tactics_actors[@active_battler.id] # セレクトウィンドウを作成 make_select_window(1, @attacker) # アクションを設定 @attacker.current_action.kind = 1 # アイテム when 3 # コマンドウィンドウ解放 dispose_command_window # セレクト へ移行 @select = 2 # 行動バトラー設定 @active_battler = @battler # 攻撃バトラー取得 @attacker = $game_system.tactics_actors[@active_battler.id] # セレクトウィンドウを作成 make_select_window(2) # アクションを設定 @attacker.current_action.kind = 2 # 待機 when 4 # 行動バトラー設定 @active_battler = @battler # 攻撃バトラー取得 @attacker = $game_system.tactics_actors[@active_battler.id] # コマンドウィンドウ解放 dispose_command_window # 再移動可能距離を0にする @attacker.more_step = 0 # ステップ 10 へ移行 $game_system.tactics_step = 10 # その他 else @comindex = @command_window.index @comvalue = @command_window.commands[@comindex] # コマンドウィンドウ解放 dispose_command_window # 行動バトラー設定 @active_battler = @battler # 攻撃バトラー取得 @attacker = $game_system.tactics_actors[@active_battler.id] # アクションを設定 @attacker.current_action.kind = 0 @attacker.current_action.basic = @comindex # 攻撃エリアをセット set_attack_area(0) # カーソル固定を解除 $game_player.not_update = false # ステップ 6 へ移行 $game_system.tactics_step = 6 end end end #-------------------------------------------------------------------------- # ● フレーム更新 (ステップ 10 共有 : 行動終了) #-------------------------------------------------------------------------- def update_step10 # スリップダメージ if @attacker.hp > 0 and @attacker.slip_damage? @attacker.slip_damage_effect @active_battler.damage = @attacker.damage @active_battler.damage_pop = true end # ステート自然解除 @attacker.remove_states_auto # エネミーが戦闘不能になった場合 if @attacker.is_a?(Game_Enemy) and @attacker.dead? # 経験値など獲得 get_exp_etc(@attacker) end # 消去対象をチェック set_erase_battler # カーソル位置を戻す back_cursor refresh_battler_info # エネミーフェーズの場合、ステップ 0 へ if $game_system.tactics_phase == 2 @wait_count = ZTBS::ENEMY_THINKING if @attacker.dead? @enemy_index -= 1 end if @active_battler.move_frequency > 1 if @attacker.more_step == nil @attacker.more_step = @attacker.movable / 2 # 移動エリア検索 search_route(@attacker.more_step - 1) # 移動先決定 @target_position = far_away_position(@target_position, @position) # 再移動エリアをセット set_movable_area(1, @attacker.more_step - 1) # ステップ 11 に移行 $game_system.tactics_step += 1 elsif @attacker.more_step? and @attacker.more_step > 1 max_step = @attacker.movable / 2 if @attacker.more_step > max_step @attacker.more_step = max_step end # 移動エリア検索 search_route(@attacker.more_step - 1) # 移動先決定 @target_position = far_away_position(@target_position, @position) # 再移動エリアをセット set_movable_area(1, @attacker.more_step - 1) # ステップ 11 に移行 $game_system.tactics_step += 1 else # 行動者を解放 @active_battler.acted = true @active_battler = nil @attacker = nil # ステップ 0 に移行 $game_system.tactics_step = 0 end else # 行動者を解放 @active_battler.acted = true @active_battler = nil @attacker = nil # ステップ 0 に移行 $game_system.tactics_step = 0 end if @targets != nil @targets.clear end return end # カーソル固定を解除 $game_player.not_update = false if @attacker.more_step == nil @attacker.more_step = @attacker.movable # 再移動エリアをセット set_movable_area(0) # ステップ 11 に移行 $game_system.tactics_step += 1 elsif @attacker.more_step? and @attacker.more_step > 1 # 再移動エリアをセット set_movable_area(0, @attacker.more_step - 1) # ステップ 11 に移行 $game_system.tactics_step += 1 else # 行動者を解放 @active_battler.acted = true @active_battler = nil @attacker = nil # ステップ 1 に移行 $game_system.tactics_step = 1 end # 対象を解放 if @targets != nil @targets.clear end 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 # 移動開始距離よりも遠い場合 if defined?(ZTBS::MOVEABLE_SA) sa = (@active_battler.x - @target_position[0]).abs + (@active_battler.y - @target_position[1]).abs move = $game_system.tactics_enemies[@active_battler.id].movable if @active_battler.move_frequency != 6 if sa > (move * ZTBS::MOVEABLE_SA[@active_battler.move_frequency - 1]).ceil # 再移動可能距離を0にする @attacker.more_step = 0 # ステップを 10 に設定 $game_system.tactics_step = 10 return end end # 移動頻度が 1 の場合 elsif @active_battler.move_frequency == 1 # 再移動可能距離を0にする @attacker.more_step = 0 # ステップを 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 @attacker.more_step = @attacker.movable # 現在カーソル位置記憶 @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 @attacker.more_step -= 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) # 再移動可能距離を0にする @attacker.more_step = 0 # ステップを 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 #-------------------------------------------------------------------------- # ● フレーム更新 (アクターフェーズ ステップ 11 : 再移動先選択) #-------------------------------------------------------------------------- def update_phase1_step11 # カーソル位置のバトラー(イベント)取得 get_cursor_battler # ヘルプウィンドウにアクター or エネミーをセット set_battler_info # C ボタンが押された場合 if Input.trigger?(Input::C) and !$game_player.moving? # カーソルが移動エリア内の場合 if in_area?($game_player.x, $game_player.y) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # カーソルを固定 $game_player.not_update = true # エリアを解放 dispose_area # ステップ 12 へ移行 $game_system.tactics_step += 1 # 座標を記憶 @pre_x = @active_battler.x @pre_y = @active_battler.y # 移動ルート取得 @route_list = @route[@position.index([$game_player.x, $game_player.y])] else # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) end end # B ボタンが押された場合 if Input.trigger?(Input::B) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターフェーズ ステップ 12 : 再移動中) #-------------------------------------------------------------------------- def update_phase1_step12 # ステップカウント初期化 @step_count = 0 if @step_count == nil if !@active_battler.moving? if @active_battler.x == $game_player.x and @active_battler.y == $game_player.y and # 移動完了でステップ 13 に移行 $game_system.tactics_step += 1 # 選択中アクター更新 @battler = @active_battler back_cursor # 待機のみのウィンドウを作成 make_end_window # カーソルを固定 $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 # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # 元の位置に戻す @active_battler.moveto(@pre_x, @pre_y) # カーソル位置を戻す back_cursor # 移動エリアをセット set_movable_area(0, @attacker.more_step - 1) # カーソル固定を解除 $game_player.not_update = false # ステップ 11 へ移行 $game_system.tactics_step -= 1 @step_count = nil end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターフェーズ ステップ 13 : 待機コマンド) #-------------------------------------------------------------------------- def update_phase1_step13 # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # コマンドウィンドウ解放 dispose_command_window # 元の位置に戻す @active_battler.moveto(@pre_x, @pre_y) # カーソル位置を戻す back_cursor # 移動エリアをセット set_movable_area(0, @attacker.more_step - 1) # カーソル固定を解除 $game_player.not_update = false # ステップ 11 へ移行 $game_system.tactics_step -= 2 end # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # コマンドウィンドウ解放 dispose_command_window # カーソル固定を解除 $game_player.not_update = false # 行動者を解放 @active_battler.acted = true @active_battler = nil @attacker = nil # ステップ 1 へ移行 $game_system.tactics_step = 1 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 when 11 update_phase2_step11 when 12 update_phase2_step12 end if $game_system.tactics_step != 1 return end # 全員行動済み判定 case all_acted? when 1 start_phase1 return when 2 # 未行動エネミー処理 not_acted_enemy_refresh return end end #-------------------------------------------------------------------------- # ● フレーム更新 (エネミーフェーズ ステップ 11 : 移動先選択) #-------------------------------------------------------------------------- def update_phase2_step11 # カーソル位置のバトラー(イベント)取得 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 # ステップを 12 に設定 $game_system.tactics_step += 1 end #-------------------------------------------------------------------------- # ● フレーム更新 (エネミーフェーズ ステップ 12 : 移動中) #-------------------------------------------------------------------------- def update_phase2_step12 # ステップカウント初期化 @step_count = 0 if @step_count == nil if !@active_battler.moving? if @active_battler.x == $game_player.x and @active_battler.y == $game_player.y and # 移動完了でステップ 0 に移行 $game_system.tactics_step = 0 back_cursor # カーソルを固定 $game_player.not_update = false # 行動者を解放 @active_battler.acted = true @active_battler = nil @attacker = nil @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 #-------------------------------------------------------------------------- # ● 移動エリア & ルート検索 #-------------------------------------------------------------------------- def search_route(max_step = 0) if $game_system.tactics_actors.keys.include?(@battler.id) battler = $game_system.tactics_actors[@battler.id] else battler = $game_system.tactics_enemies[@battler.id] end max_step = battler.movable if max_step == 0 @position = [[@battler.x, @battler.y]] @route = [[]] cost = [0] more_step = [0] for i in more_step x = @position[i][0] y = @position[i][1] # 下 if !@position.include?([x, y + 1]) and @battler.passable?(x, y, 2) if Game_Map.method_defined?("move_cost") mikomi = cost[i] + $game_map.move_cost(battler, x, y + 1) if mikomi < battler.movable @position.push([x, y + 1]) @route.push(@route[i] + [2]) cost.push(mikomi) if cost.last < max_step more_step.push(@route.index(@route[i] + [2])) end end else @position.push([x, y + 1]) @route.push(@route[i] + [2]) if @route[i].size + 1 < max_step more_step.push(@route.index(@route[i] + [2])) end end end # 左 if !@position.include?([x - 1, y]) and @battler.passable?(x, y, 4) if Game_Map.method_defined?("move_cost") mikomi = cost[i] + $game_map.move_cost(battler, x - 1, y) if mikomi < battler.movable @position.push([x - 1, y]) @route.push(@route[i] + [4]) cost.push(mikomi) if cost.last < max_step more_step.push(@route.index(@route[i] + [4])) end end else @position.push([x - 1, y]) @route.push(@route[i] + [4]) if @route[i].size + 1 < max_step more_step.push(@route.index(@route[i] + [4])) end end end # 右 if !@position.include?([x + 1, y]) and @battler.passable?(x, y, 6) if Game_Map.method_defined?("move_cost") mikomi = cost[i] + $game_map.move_cost(battler, x + 1, y) if mikomi < battler.movable @position.push([x + 1, y]) @route.push(@route[i] + [6]) cost.push(mikomi) if cost.last < max_step more_step.push(@route.index(@route[i] + [6])) end end else @position.push([x + 1, y]) @route.push(@route[i] + [6]) if @route[i].size + 1 < max_step more_step.push(@route.index(@route[i] + [6])) end end end # 下 if !@position.include?([x, y - 1]) and @battler.passable?(x, y, 8) if Game_Map.method_defined?("move_cost") mikomi = cost[i] + $game_map.move_cost(battler, x, y - 1) if mikomi < battler.movable @position.push([x, y - 1]) @route.push(@route[i] + [8]) cost.push(mikomi) if cost.last < max_step more_step.push(@route.index(@route[i] + [8])) end end else @position.push([x, y - 1]) @route.push(@route[i] + [8]) if @route[i].size + 1 < max_step more_step.push(@route.index(@route[i] + [8])) end end end end end #-------------------------------------------------------------------------- # ● 移動エリアセット #-------------------------------------------------------------------------- def set_movable_area(type, more_step = 0) search_route(more_step) for i in 0...@position.size x = @position[i][0] y = @position[i][1] sprite = Sprite_Area.new(@spriteset.viewport1, type, x, y) @spriteset.area_sprites.push(sprite) end end end