#============================================================================== # [ZTBS] -Zenith Tactical Battle System- タクティカルバトルシステム #  〜+B5:エリア内カーソル〜 by 水夜 #  ver0.90 Zenith Creation (http://zenith.ifdef.jp/) #------------------------------------------------------------------------------ # マップ上での戦略的なバトルを実現。 #============================================================================== #============================================================================== # ■ Game_Character #============================================================================== class Game_Character #-------------------------------------------------------------------------- # ● 指定方向を向く #-------------------------------------------------------------------------- def turn(direct) unless @direction_fix @direction = direct @stop_count = 0 end end #-------------------------------------------------------------------------- # ● 下に移動 #-------------------------------------------------------------------------- alias :ztbs_move_down :move_down def move_down(turn_enabled = true) if self.is_a?(Game_Player) if !$game_system.in_tactics ztbs_move_down(turn_enabled) elsif $game_system.tactics_phase == 2 ztbs_move_down(turn_enabled) elsif $scene.in_area?(@x, @y + 1) ztbs_move_down(turn_enabled) elsif ($scene.active_battler.x - @x).abs <= 1 and ($scene.active_battler.y - @y - 1).abs <= 1 ztbs_move_down(turn_enabled) elsif @x == $scene.active_battler.x and @y == $scene.active_battler.y $scene.active_battler.turn_down(turn_enabled) end else ztbs_move_down(turn_enabled) end end #-------------------------------------------------------------------------- # ● 左に移動 #-------------------------------------------------------------------------- alias :ztbs_move_left :move_left def move_left(turn_enabled = true) if self.is_a?(Game_Player) if !$game_system.in_tactics ztbs_move_left(turn_enabled) elsif $game_system.tactics_phase == 2 ztbs_move_left(turn_enabled) elsif $scene.in_area?(@x - 1, @y) ztbs_move_left(turn_enabled) elsif ($scene.active_battler.x - @x + 1).abs <= 1 and ($scene.active_battler.y - @y).abs <= 1 ztbs_move_left(turn_enabled) elsif @x == $scene.active_battler.x and @y == $scene.active_battler.y $scene.active_battler.turn_left(turn_enabled) end else ztbs_move_left(turn_enabled) end end #-------------------------------------------------------------------------- # ● 右に移動 #-------------------------------------------------------------------------- alias :ztbs_move_right :move_right def move_right(turn_enabled = true) if self.is_a?(Game_Player) if !$game_system.in_tactics ztbs_move_right(turn_enabled) elsif $game_system.tactics_phase == 2 ztbs_move_right(turn_enabled) elsif $scene.in_area?(@x + 1, @y) ztbs_move_right(turn_enabled) elsif ($scene.active_battler.x - @x - 1).abs <= 1 and ($scene.active_battler.y - @y).abs <= 1 ztbs_move_right(turn_enabled) elsif @x == $scene.active_battler.x and @y == $scene.active_battler.y $scene.active_battler.turn_right(turn_enabled) end else ztbs_move_right(turn_enabled) end end #-------------------------------------------------------------------------- # ● 上に移動 #-------------------------------------------------------------------------- alias :ztbs_move_up :move_up def move_up(turn_enabled = true) if self.is_a?(Game_Player) if !$game_system.in_tactics ztbs_move_up(turn_enabled) elsif $game_system.tactics_phase == 2 ztbs_move_up(turn_enabled) elsif $scene.in_area?(@x, @y - 1) ztbs_move_up(turn_enabled) elsif ($scene.active_battler.x - @x).abs <= 1 and ($scene.active_battler.y - @y + 1).abs <= 1 ztbs_move_up(turn_enabled) elsif @x == $scene.active_battler.x and @y == $scene.active_battler.y $scene.active_battler.turn_up(turn_enabled) end else ztbs_move_up(turn_enabled) end end #-------------------------------------------------------------------------- # ● 左下に移動 #-------------------------------------------------------------------------- alias :ztbs_move_lower_left :move_lower_left def move_lower_left if self.is_a?(Game_Player) if !$game_system.in_tactics ztbs_move_lower_left elsif $game_system.tactics_phase == 2 ztbs_move_lower_left elsif $scene.in_area?(@x - 1, @y + 1) ztbs_move_lower_left elsif ($scene.active_battler.x - @x + 1).abs <= 1 and ($scene.active_battler.y - @y - 1).abs <= 1 ztbs_move_lower_left elsif @x == $scene.active_battler.x and @y == $scene.active_battler.y $scene.active_battler.turn_left end else ztbs_move_lower_left end end #-------------------------------------------------------------------------- # ● 右下に移動 #-------------------------------------------------------------------------- alias :ztbs_move_lower_right :move_lower_right def move_lower_right if self.is_a?(Game_Player) if !$game_system.in_tactics ztbs_move_lower_right elsif $game_system.tactics_phase == 2 ztbs_move_lower_right elsif $scene.in_area?(@x + 1, @y + 1) ztbs_move_lower_right elsif ($scene.active_battler.x - @x - 1).abs <= 1 and ($scene.active_battler.y - @y - 1).abs <= 1 ztbs_move_lower_right elsif @x == $scene.active_battler.x and @y == $scene.active_battler.y $scene.active_battler.turn_right end else ztbs_move_lower_right end end #-------------------------------------------------------------------------- # ● 左上に移動 #-------------------------------------------------------------------------- alias :ztbs_move_upper_left :move_upper_left def move_upper_left if self.is_a?(Game_Player) if !$game_system.in_tactics ztbs_move_upper_left elsif $game_system.tactics_phase == 2 ztbs_move_upper_left elsif $scene.in_area?(@x - 1, @y - 1) ztbs_move_upper_left elsif ($scene.active_battler.x - @x + 1).abs <= 1 and ($scene.active_battler.y - @y + 1).abs <= 1 ztbs_move_upper_left elsif @x == $scene.active_battler.x and @y == $scene.active_battler.y $scene.active_battler.turn_left end else ztbs_move_upper_left end end #-------------------------------------------------------------------------- # ● 右上に移動 #-------------------------------------------------------------------------- alias :ztbs_move_upper_right :move_upper_right def move_upper_right if self.is_a?(Game_Player) if !$game_system.in_tactics ztbs_move_upper_right elsif $game_system.tactics_phase == 2 ztbs_move_upper_right elsif $scene.in_area?(@x + 1, @y - 1) ztbs_move_upper_right elsif ($scene.active_battler.x - @x - 1).abs <= 1 and ($scene.active_battler.y - @y + 1).abs <= 1 ztbs_move_upper_right elsif @x == $scene.active_battler.x and @y == $scene.active_battler.y $scene.active_battler.turn_right end else ztbs_move_upper_right end end end #============================================================================== # ■ Scene_Map #============================================================================== class Scene_Map #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :active_battler # アクティブなバトラー #-------------------------------------------------------------------------- # ● 攻撃エリア検索 #-------------------------------------------------------------------------- def search_attack_area position = [[@battler.x, @battler.y]] 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 case battler.current_action.kind when 0 if (defined? ACTOR_RANGE and @attacker.is_a?(Game_Actor)) or (defined? ENEMY_RANGE and @attacker.is_a?(Game_Enemy)) form = battler.attack_range[0][0] max = battler.attack_range[0][1] through = battler.attack_range[0][2] cannot_near = battler.attack_range[0][3] if cannot_near == nil cannot_near = false end else form = 0 max = 1 through = false cannot_near = false end if battler.is_a?(Game_Actor) type = 1 else type = 0 end when 1 skill = $data_skills[battler.current_action.skill_id] form = skill.range[0][0] max = skill.range[0][1] through = skill.range[0][2] cannot_near = skill.range[0][3] if cannot_near == nil cannot_near = false end return position if max == 0 case skill.scope when 0, 5, 6 type = 4 when 1, 2 if battler.is_a?(Game_Actor) type = 1 else type = 0 end when 3, 4 if battler.is_a?(Game_Actor) type = 0 else type = 1 end when 7 return position end when 2 item = $data_items[battler.current_action.item_id] form = item.range[0][0] max = item.range[0][1] through = item.range[0][2] cannot_near = item.range[0][3] if cannot_near == nil cannot_near = false end case item.scope when 0, 5, 6 type = 4 when 1, 2 if battler.is_a?(Game_Actor) type = 1 else type = 0 end when 3, 4 if battler.is_a?(Game_Actor) type = 0 else type = 1 end when 7 return position end end more_step = [0] route = [[]] case form # ひし形or四角形の場合 when 0, 2, 3 if form == 2 or form == 3 max *= 2 end for i in more_step x = position[i][0] y = position[i][1] # 障害物無視の場合 if through # 下 if !position.include?([x, y + 1]) position.push([x, y + 1]) route.push(route[i] + [2]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [2])) end end # 左 if !position.include?([x - 1, y]) position.push([x - 1, y]) route.push(route[i] + [4]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [4])) end end # 右 if !position.include?([x + 1, y]) position.push([x + 1, y]) route.push(route[i] + [6]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [6])) end end # 上 if !position.include?([x, y - 1]) position.push([x, y - 1]) route.push(route[i] + [8]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [8])) end end # 障害物無視でない場合 else # 下 if !position.include?([x, y + 1]) and !on_area?(x, y, type) and (@battler.passable?(x, y, 2) or (on_area?(x, y + 1, type) and type != 4)) position.push([x, y + 1]) route.push(route[i] + [2]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [2])) end end # 左 if !position.include?([x - 1, y]) and !on_area?(x, y, type) and (@battler.passable?(x, y, 4) or (on_area?(x - 1, y, type) and type != 4)) position.push([x - 1, y]) route.push(route[i] + [4]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [4])) end end # 右 if !position.include?([x + 1, y]) and !on_area?(x, y, type) and (@battler.passable?(x, y, 6) or (on_area?(x + 1, y, type) and type != 4)) position.push([x + 1, y]) route.push(route[i] + [6]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [6])) end end # 上 if !position.include?([x, y - 1]) and !on_area?(x, y, type) and (@battler.passable?(x, y, 8) or (on_area?(x, y - 1, type) and type != 4)) position.push([x, y - 1]) route.push(route[i] + [8]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [8])) end end end end # 四角形の場合 case form when 2 delete = [] for pos in position if (pos[0] - @battler.x).abs > max/2 or (pos[1] - @battler.y).abs > max/2 delete.push(pos) end end for i in delete position.delete(i) end when 3 delete = [] for pos in position if (pos[0] - @battler.x).abs != max/2 and (pos[1] - @battler.y).abs != max/2 delete.push(pos) end end for i in delete position.delete(i) end return position end # 十字形の場合 when 1 for i in 1..max x = position[0][0] y = position[0][1] # 障害物無視の場合 if through position.push([x, y + i]) position.push([x - i, y]) position.push([x + i, y]) position.push([x, y - i]) # 障害物無視でない場合 else if position.include?([x, y + i - 1]) and !on_area?(x, y + i - 1, type) and (@battler.passable?(x, y + i - 1, 2) or on_area?(x, y + i, type)) position.push([x, y + i]) end if position.include?([x - i + 1, y]) and !on_area?(x - i + 1, y, type) and (@battler.passable?(x - i + 1, y, 4) or on_area?(x - i, y, type)) position.push([x - i, y]) end if position.include?([x + i - 1, y]) and !on_area?(x + i - 1, y, type) and (@battler.passable?(x + i - 1, y, 6) or on_area?(x + i, y, type)) position.push([x + i, y]) end if position.include?([x, y - i + 1]) and !on_area?(x, y - i + 1, type) and (@battler.passable?(x, y - i + 1, 8) or on_area?(x, y - i, type)) position.push([x, y - i]) end end end end # 近接不可の場合 if cannot_near position.delete([@battler.x, @battler.y + 1]) position.delete([@battler.x - 1, @battler.y]) position.delete([@battler.x + 1, @battler.y]) position.delete([@battler.x, @battler.y - 1]) end return position end #-------------------------------------------------------------------------- # ● エリア内判定 #-------------------------------------------------------------------------- def in_area?(x, y) return true if @spriteset.area_sprites.empty? for sprite in @spriteset.area_sprites if sprite.map_x == x and sprite.map_y == y return true end end return false end end