#============================================================================== # [ZTBS] -Zenith Tactical Battle System- タクティカルバトルシステム #  〜+B15:ZTBS 移動判定修正〜   by 水夜 #  ver0.90  Zenith Creation (http://zenith.ifdef.jp/) #============================================================================== #============================================================================== # ■ Game_Map #============================================================================== class Game_Map #-------------------------------------------------------------------------- # ● ある地点のイベント取得 #-------------------------------------------------------------------------- def point_events(x, y) result = [] for event in self.events if event[1].x == x and event[1].y == y result.push(event) end end return result end #-------------------------------------------------------------------------- # ● 最高プライオリティの取得 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def max_priority(x, y) result = 0 if @map_id != 0 for i in [2, 1, 0] tile_id = data[x, y, i] if tile_id == nil return 0 else result = [@priorities[tile_id], result].max end end return result end return 0 end end #============================================================================== # ■ Game_Character #============================================================================== class Game_Character #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias :ztbsb15_initialize :initialize def initialize ztbsb15_initialize @name = "" end #-------------------------------------------------------------------------- # ● 通行可能判定 # x : X 座標 # y : Y 座標 # d : 方向 (0,2,4,6,8) ※ 0 = 全方向通行不可の場合を判定 (ジャンプ用) #-------------------------------------------------------------------------- def passable?(x, y, d) # 新しい座標を求める new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0) new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0) # 座標がマップ外の場合 unless $game_map.valid?(new_x, new_y) # 通行不可 return false end # すり抜け ON の場合 if @through if $game_system.in_tactics and self != $game_player # 空気イベントは全てを貫く return true if self.name == "" # レイヤーの上から順に調べるループ for i in [2, 1, 0] # タイル ID を取得 tile_id = $game_map.data[new_x, new_y, i] # タイル ID 取得失敗 if tile_id == nil # 通行不可 return false # 全方向の障害物ビットがセットされている場合 elsif $game_map.passages[tile_id] & 0x0f == 0x0f # 通行不可 return false end end # 全イベントのループ for event in $game_map.events.values # イベントの座標が移動先と一致した場合 if event.x == new_x and event.y == new_y # 通行不可 if event.character_name != "" if $game_system.tactics_actors.keys.include?(event.id) if !$game_system.tactics_actors[event.id].dead? and !$game_system.tactics_actors.keys.include?(@id) return false end elsif $game_system.tactics_enemies.keys.include?(event.id) if !$game_system.tactics_enemies[event.id].dead? and !$game_system.tactics_enemies.keys.include?(@id) return false end end end end end end # 通行可 return true end # 移動元のタイルから指定方向に出られない場合 unless $game_map.passable?(x, y, d, self) # 通行不可 return false end # 移動先のタイルに指定方向から入れない場合 unless $game_map.passable?(new_x, new_y, 10 - d) # 通行不可 return false end # 全イベントのループ for event in $game_map.events.values # イベントの座標が移動先と一致した場合 if event.x == new_x and event.y == new_y if $game_system.in_tactics # グラフィックが指定されている場合 if event.character_name != "" or event.tile_id > 0 if $game_system.tactics_actors.keys.include?(event.id) if !$game_system.tactics_actors[event.id].dead? and !$game_system.tactics_actors.keys.include?(@id) return false end elsif $game_system.tactics_enemies.keys.include?(event.id) if !$game_system.tactics_enemies[event.id].dead? and !$game_system.tactics_enemies.keys.include?(@id) return false end end end else # すり抜け OFF なら unless $game_player.through # 自分がイベントの場合 if self != $game_player # 通行不可 return false end # 自分がプレイヤーで、相手のグラフィックがキャラクターの場合 if event.character_name != "" # 通行不可 return false end end end end end # プレイヤーの座標が移動先と一致した場合 if $game_player.x == new_x and $game_player.y == new_y # すり抜け OFF なら unless $game_player.through # 自分のグラフィックがキャラクターの場合 if @character_name != "" # 通行不可 return false end end end # 通行可 return true end #-------------------------------------------------------------------------- # ● 画面 Z 座標の取得 # height : キャラクターの高さ #-------------------------------------------------------------------------- def screen_z(height = 0) # 最前面に表示フラグが ON の場合 if @always_on_top # 無条件に 999 return 999 end # 実座標とマップの表示位置から画面座標を求める z = (@real_y - $game_map.display_y + 3) / 4 + 32 # ネーム補正もかける if @name =~ /((-+)?\d+)/ z += $1.to_i end # タイルの場合 if @tile_id > 0 # タイルのプライオリティ * 32 を足す return z + $game_map.priorities[@tile_id] * 32 # キャラクターの場合 else # 飛行用 Z 補正をかける if @through and $game_system.in_tactics# and self != $game_player z += [$game_map.max_priority(@x, @y) - 1, 3].min * 32 end # 高さが 32 を超えていれば 31 を足す return z + ((height > 32) ? 31 : 0) end end end #============================================================================== # ■ Game_Event #============================================================================== class Game_Event < Game_Character #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias :ztbsb15_e_initialize :initialize def initialize(map_id, event) ztbsb15_e_initialize(map_id, event) @name = event.name end end #============================================================================== # ■ Scene_Map #============================================================================== class Scene_Map #-------------------------------------------------------------------------- # ● 対象に最も近いポジション取得 #-------------------------------------------------------------------------- def nearest_position(target_pos, pos_list) nr = nil for position in pos_list next_if = false # 判定を追加 for event in $game_map.point_events(position[0], position[1]) if event[1].character_name != "" next_if = true break end end next if next_if r = (target_pos[0] - position[0]).abs + (target_pos[1] - position[1]).abs if nr == nil or r < nr nr = r nearest = position elsif r == nr srand if rand(2) == 0 nr = r nearest = position end end end return nearest end #-------------------------------------------------------------------------- # ● 対象から最も遠いポジション取得 #-------------------------------------------------------------------------- def far_away_position(target_pos, pos_list) nr = nil for position in pos_list next_if = false # 判定を追加 for event in $game_map.point_events(position[0], position[1]) if event[1].character_name != "" next_if = true break end end next if next_if r = (target_pos[0] - position[0]).abs + (target_pos[1] - position[1]).abs if nr == nil or r > nr nr = r far_away = position elsif r == nr srand if rand(2) == 0 nr = r far_away = position end end end return far_away 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}/ # 判定を追加 for event in $game_map.point_events($game_player.x, $game_player.y) if event[1].name != "" and !event[1].erased and event[1] != @active_battler # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end end # カーソルが移動エリア内の場合 if in_area?($game_player.x, $game_player.y) @attacker = $game_system.tactics_actors[@active_battler.id] # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # カーソルを固定 $game_player.not_update = true # エリアを解放 dispose_area # ステップ 4 へ移行 $game_system.tactics_step = 4 # 移動可能歩数記録 if Game_Battler.method_defined?("more_step") @attacker.more_step = @attacker.movable end # 座標を記憶 @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) # 判定を追加 for event in $game_map.point_events($game_player.x, $game_player.y) if event[1].name != "" and !event[1].erased and event[1] != @active_battler # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end end # カーソルが移動エリア内の場合 if in_area?($game_player.x, $game_player.y) @attacker = $game_system.tactics_actors[@active_battler.id] # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # カーソルを固定 $game_player.not_update = true # エリアを解放 dispose_area # ステップ 4 へ移行 $game_system.tactics_step = 4 # 移動可能歩数記録 if Game_Battler.method_defined?("more_step") @attacker.more_step = @attacker.movable end # 座標を記憶 @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 end