class Game_Map
#--------------------------------------------------------------------------
# ○ 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :map
attr_reader :ex_data
attr_reader :under_bridge_passages # 橋の下の通行判定
attr_reader :back_tiles_position # 裏回りする座標
attr_reader :keep_back_position # 裏回りを維持する座標
attr_reader :prohibited_get_off # 接岸禁止座標
attr_reader :ex_data # 拡張レイヤー用タイルデータ
#--------------------------------------------------------------------------
# ◎ セットアップ
# map_id : マップ ID
#--------------------------------------------------------------------------
alias tig_ew_setup setup
def setup(map_id)
tig_ew_setup(map_id)
create_ex_passages
pick_up_back_tiles
setup_back_tiles
$game_player.set_on_tile
for event in $game_map.events.values
event.update_turn_back
end
end
#--------------------------------------------------------------------------
# ○ 指定座標のタイルIDの取得
#--------------------------------------------------------------------------
def point_tile_id(x, y)
return [data[x, y, 0], data[x, y, 1], data[x, y, 2]]
end
#--------------------------------------------------------------------------
# ○ オートタイルIDの取得(オートタイル郡の中で順番にIDをつけた独自のIDです)
#--------------------------------------------------------------------------
def auto_(tile_id)
return 0 unless (1904...8192).include?(tile_id)
return (tile_id - 1904) % 48
end
#--------------------------------------------------------------------------
# ○ トップタイルIDの取得(オートタイル郡の最初のID)
#--------------------------------------------------------------------------
def top_(tile_id)
return 0 if tile_id == nil
return (tile_id - auto_(tile_id))
end
#--------------------------------------------------------------------------
# ○ スクリプト機能を使用する屋根・天井・壁タイルか?
#--------------------------------------------------------------------------
def ceiling?(tile_id)
return false unless Data_Tile::FUNCTION_TILE.include?(top_(tile_id))
return true if wall?(tile_id)
return true if (2000...2048).include?(tile_id)
return true if (4352...4736).include?(tile_id)
return true if (5120...5504).include?(tile_id)
return true if (5888...6272).include?(tile_id)
return true if (6656...7040).include?(tile_id)
return (7424...7808).include?(tile_id)
end
#--------------------------------------------------------------------------
# ○ スクリプト機能を使用する壁タイルか?
#--------------------------------------------------------------------------
def wall?(tile_id)
return false unless Data_Tile::FUNCTION_TILE.include?(top_(tile_id))
return true if (1904...2000).include?(tile_id)
return true if (4736...5120).include?(tile_id)
return true if (5504...5888).include?(tile_id)
return true if (6272...6656).include?(tile_id)
return true if (7040...7424).include?(tile_id)
return (7808...8192).include?(tile_id)
end
#--------------------------------------------------------------------------
# ○ スクリプト機能を使用する地形タイルか?
#--------------------------------------------------------------------------
def cliff?(tile_id)
return false unless Data_Tile::FUNCTION_TILE.include?(top_(tile_id))
return [2816, 3200, 3584, 2960, 3344, 3728, 4112].include?(top_(tile_id))
end
#--------------------------------------------------------------------------
# ○ 指定の向きにオートタイルチップの境目があるか?
#--------------------------------------------------------------------------
def verge?(tile_id, direction)
auto_tile_id = auto_(tile_id)
return false if auto_tile_id == 0
return false unless ceiling?(tile_id) or cliff?(tile_id)
if (1904...2000).include?(tile_id) or
(4352...5888).include?(tile_id) or
(6272...6656).include?(tile_id) or
(7040...7424).include?(tile_id) or
(7808...8192).include?(tile_id) # オートタイルの線画タイプ判別
case direction # 壁タイプの場合 方向ごとに振り分け
when 2 ; return true if Data_Auto_Tile::VERGE_DOWN_B.include?(auto_tile_id)
when 4 ; return true if Data_Auto_Tile::VERGE_LEFT_B.include?(auto_tile_id)
when 6 ; return true if Data_Auto_Tile::VERGE_RIGHT_B.include?(auto_tile_id)
when 8 ; return true if Data_Auto_Tile::VERGE_UP_B.include?(auto_tile_id)
end
else
case direction # 床タイプの場合 方向ごとに振り分け
when 2 ; return true if Data_Auto_Tile::VERGE_DOWN_A.include?(auto_tile_id)
when 4 ; return true if Data_Auto_Tile::VERGE_LEFT_A.include?(auto_tile_id)
when 6 ; return true if Data_Auto_Tile::VERGE_RIGHT_A.include?(auto_tile_id)
when 8 ; return true if Data_Auto_Tile::VERGE_UP_A.include?(auto_tile_id)
end
end
end
#--------------------------------------------------------------------------
# ○ 指定の向きに有効な境目があるか?
#--------------------------------------------------------------------------
def rip?(direction, x, y, floating = false)
#- 位置情報の準備
tile_id = point_tile_id(x, y)
front_x = x_with_direction(x, direction)
front_y = y_with_direction(y, direction)
front_tile_id = point_tile_id(front_x, front_y)
#- ステップタイルがあれば無効
return false if Data_Tile::STEP.include?(front_tile_id[0])
return false if Data_Tile::STEP.include?(front_tile_id[2])
return false if Data_Tile::STEP.include?(tile_id[0])
return false if Data_Tile::STEP.include?(tile_id[2])
#- 橋タイルの処理
if floating
if Data_Tile::BRIDRE_LENGTH.include?(tile_id[2]) or
Data_Tile::BRIDGE_BREADTH.include?(tile_id[2])
return false if @under_bridge_passages[[x, y]] == -1
elsif Data_Tile::BRIDRE_LENGTH.include?(front_tile_id[2]) or
Data_Tile::BRIDGE_BREADTH.include?(front_tile_id[2])
return false if @under_bridge_passages[[front_x, front_y]] == -1
end
end
if bridge?(front_tile_id[2], direction)
return false
elsif Data_Tile::BRIDRE_LENGTH.include?(tile_id[2]) and back_tile?(x, y)
return true if direction == 4 or direction == 6
return false if direction == 2 or direction == 8
elsif Data_Tile::BRIDGE_BREADTH.include?(tile_id[2]) and back_tile?(x, y)
return true if direction == 2 or direction == 8
return false if direction == 4 or direction == 6
end
#- 地形タイルの処理
if cliff?(tile_id[0])
if Expansion_Passable::CLIFF_MAP.include?($game_map.map_id)
return false unless ceiling?(front_tile_id[0]) or cliff?(front_tile_id[0])
if cliff?(front_tile_id[0]) and verge?(front_tile_id[0], 10 - direction)
return false
end
else
return false
end
end
#- タイルに境目があるか?
return verge?(tile_id[0], direction)
end
#--------------------------------------------------------------------------
# ○ 指定の向きに準じた橋タイルか?(渡ることの出来る向きか)
#--------------------------------------------------------------------------
def bridge?(tile_id, direction)
if direction == 2 or direction == 8
return true if Data_Tile::BRIDRE_LENGTH.include?(tile_id)
elsif direction == 4 or direction == 6
return true if Data_Tile::BRIDGE_BREADTH.include?(tile_id)
end
return false
end
#--------------------------------------------------------------------------
# ○ 上層に移すタイルか?
#--------------------------------------------------------------------------
def upper_layer?(tile_id)
return false if @back_tiles_a == nil
if Expansion_Passable::CLIFF_MAP.include?(@map_id)
return true if @back_tiles_b.include?(tile_id)
else
unless cliff?(tile_id)
return true if @back_tiles_a.include?(tile_id)
end
end
end
#--------------------------------------------------------------------------
# ○ <船の橋下通過>処理をするエリアか?
#--------------------------------------------------------------------------
def ship_pass_area?(x, y)
result = false
for area in $data_areas.values
next if area == nil
next unless area.ship_pass
next if $game_map.map_id != area.map_id
next if x < area.rect.x
next if y < area.rect.y
next if x >= area.rect.x + area.rect.width
next if y >= area.rect.y + area.rect.height
result = true
end
return result
end
#--------------------------------------------------------------------------
# ○ 処理の無視をするエリアか?
#--------------------------------------------------------------------------
def disregard_processing_area?(x, y, map_id)
result = false
for area in $data_areas.values
next if area == nil
next unless area.disregard_processing
next if map_id != area.map_id
next if x < area.rect.x
next if y < area.rect.y
next if x >= area.rect.x + area.rect.width
next if y >= area.rect.y + area.rect.height
result = true
end
return result
end
#--------------------------------------------------------------------------
# ○ 段差マップか?
#--------------------------------------------------------------------------
def cliff_map?
return Expansion_Passable::CLIFF_MAP.include?(@map_id)
end
#--------------------------------------------------------------------------
# ○ 特殊通行判定の作成
#--------------------------------------------------------------------------
def create_ex_passages
@ex_passages = $data_system.passages
#- 壁・屋根・天井タイルの通行判定を○に変える
for i in 1904...2048
@ex_passages = 0x06 if ceiling?(i)
end
for i in 4352...8192
@ex_passages = 0x06 if ceiling?(i)
end
#- 橋タイルの通行判定を○に
for i in (Data_Tile::BRIDRE_LENGTH + Data_Tile::BRIDGE_BREADTH)
@ex_passages = 0x00
end
@passages = @ex_passages
end
#--------------------------------------------------------------------------
# ○ 接岸禁止タイル登録
# map_id : マップ ID
#--------------------------------------------------------------------------
def prohibited_get_off_set(x, y)
@map.data[x, y, 2] = 0
@prohibited_get_off.push([x, y])
end
#--------------------------------------------------------------------------
# ○ 影消しタイル処理
#--------------------------------------------------------------------------
def shadow_eraser(x, y)
r_x = round_x(x - 1) ; r_y = round_y(y - 1)
tile_id = @map.data[r_x, y, 0]
# 壁(線画・壁タイプ)
if (4736...5120).include?(tile_id) or
(5504...5888).include?(tile_id) or
(6272...6656).include?(tile_id) or
(7040...7424).include?(tile_id) or
(7808...8192).include?(tile_id)
dummy_tile_id = 1904 + auto_(tile_id)
# 屋根(線画・壁タイプ)
elsif (4352...4736).include?(tile_id) or
(5120...5504).include?(tile_id)
dummy_tile_id = 1952 + auto_(tile_id)
# 天井(線画・床タイプ)
elsif (5888...6272).include?(tile_id) or
(6656...7040).include?(tile_id) or
(7424...7808).include?(tile_id)
dummy_tile_id = 2000 + auto_(tile_id)
else
return
end
@map.data[r_x, r_y, 1] = @map.data[r_x, r_y, 0]
@map.data[r_x, r_y, 0] = dummy_tile_id
end
#--------------------------------------------------------------------------
# ○ 裏回り消去タイル処理
#--------------------------------------------------------------------------
def back_tiles_position_delete(x, y)
return if Expansion_Passable::DELETE_BACK_TILE_ID == nil
y = round_y(y+1) if Expansion_Passable::BACK_TILE_DEEP
if @map.data[x, y, 2] == Expansion_Passable::DELETE_BACK_TILE_ID or
@ex_data[x, y, 2] == Expansion_Passable::DELETE_BACK_TILE_ID
@back_tiles_position.delete([x, y])
@map.data[x, y, 2] = 0
@ex_data[x, y, 2] = 0
end
end
#--------------------------------------------------------------------------
# ○ 裏回り用タイル種類ピックアップ
#--------------------------------------------------------------------------
def pick_up_back_tiles
return if @back_tiles_a != nil
@back_tiles_a = []
@back_tiles_b = []
for i in 1904...8192
next unless ceiling?(i) or cliff?(i)
if wall?(i)
next if verge?(i, 2)
if verge?(i, 4) or verge?(i, 6)
@back_tiles_a.push(i) unless cliff?(i)
end
else
@back_tiles_a.push(i) unless cliff?(i)
@back_tiles_b.push(i) if verge?(i, 8)
end
end
end
#--------------------------------------------------------------------------
# ○ 通行判定初期化と裏回り用タイル座標ピックアップ
#--------------------------------------------------------------------------
def setup_back_tiles
if $game_player.game_map_data.include?(@map_id)
@map = $game_player.game_map_data[@map_id].map
@ex_data = $game_player.game_map_data[@map_id].ex_data
@under_bridge_passages = $game_player.game_map_data[@map_id].under_bridge_passages
@back_tiles_position = $game_player.game_map_data[@map_id].back_tiles_position
@keep_back_position = $game_player.game_map_data[@map_id].keep_back_position
@prohibited_get_off = $game_player.game_map_data[@map_id].prohibited_get_off
return
end
return if Expansion_Passable::ESCAPE_MAP.include?(@map_id)
#- 座標毎処理
for x in 0...width
for reverse_y in 1..height
y = height - reverse_y # Y座標を逆順にする為の処理
next if disregard_processing_area?(x, y, @map_id)
tile_id = point_tile_id(x, y)
#- 橋タイル処理
if (Data_Tile::BRIDRE_LENGTH + Data_Tile::BRIDGE_BREADTH).include?(tile_id[2])
if (2048...2815).include?(tile_id[0])
if ship_pass_area?(x, y)
@under_bridge_passages[[x, y]] = 1
@back_tiles_position.push([x, y])
@ex_data[x, y, 2] = @map.data[x, y, 2]
else
@back_tiles_position.push([x, y])
@under_bridge_passages[[x, y]] = -1
end
elsif @passages[tile_id[0]] != 0x06 or $game_map.wall?(tile_id[0])
@under_bridge_passages[[x, y]] = -1
@back_tiles_position.push([x, y])
@ex_data[x, y, 2] = @map.data[x, y, 2]
else
@under_bridge_passages[[x, y]] = 0
@back_tiles_position.push([x, y])
@ex_data[x, y, 2] = @map.data[x, y, 2]
end
if Data_Tile::BRIDGE_BREADTH.include?(tile_id[2])
@keep_back_position.push([x, round_y(y+1)])
end
#- 通行判定☆タイルを上層に移動
elsif tile_id[2] != 0 and @passages[tile_id[2]] & 0x10 == 0x10
if @back_tiles_position.include?([x, round_y(y+1)])
@keep_back_position.push([x, y])
else
@ex_data[x, y, 2] = @map.data[x, y, 2]
end
end
#- 影消しタイルの処理
if @map.data[x, y, 2] == Expansion_Passable::SHADOW_ERASER_TILE_ID
shadow_eraser(x, y)
@map.data[x, y, 2] = 0
#- 接岸禁止タイルの処理
elsif @map.data[x, y, 2] == Expansion_Passable::PROHIBITED_GET_OFF_TILE_ID
prohibited_get_off_set(x, y)
end
#- 壁・天井タイル処理
if ceiling?(tile_id[0]) or (cliff?(tile_id[0]) and cliff_map?)
#- 基本となる裏回りタイルの場合、裏回り位置に登録
if not wall?(tile_id[0]) and verge?(tile_id[0], 8)
@back_tiles_position.push([x, y])
end
#- 裏回り位置にするタイルの場合、上層に移動
back_tiles = cliff_map? ? @back_tiles_b : @back_tiles_a
if back_tiles.include?(tile_id[0])
@ex_data[x, y, 0] = @map.data[x, y, 0]
@ex_data[x, y, 1] = @map.data[x, y, 1]
#- 裏回り位置追加タイルの誤用時には、タイルを消去する
if tile_id[2] != Expansion_Passable::ADDITION_BACK_TILE_ID
@ex_data[x, y, 2] = @map.data[x, y, 2]
end
@map.data[x, y, 1] = 0
@map.data[x, y, 2] = 0
end
#- 深く裏回りする設定の際の処理(裏回り位置の下をさらに上層に)
if Expansion_Passable::BACK_TILE_DEEP
unless @back_tiles_position.include?([x, round_y(y+1)])
if not wall?(tile_id[0]) and verge?(tile_id[0], 8)
unless wall?(data[x, round_y(y+1), 0]) and verge?(data[x, round_y(y+1), 0], 2)
@back_tiles_position.push([x, round_y(y+1)])
@ex_data[x, round_y(y+1), 0] = @map.data[x, round_y(y+1), 0]
@ex_data[x, round_y(y+1), 1] = @map.data[x, round_y(y+1), 1]
@ex_data[x, round_y(y+1), 2] = @map.data[x, round_y(y+1), 2]
@map.data[x, round_y(y+1), 1] = 0
@map.data[x, round_y(y+1), 2] = 0
end
end
end
end
#- 裏回り追加タイルの処理
if Expansion_Passable::ADDITION_BACK_TILE_ID != nil and
tile_id[2] == Expansion_Passable::ADDITION_BACK_TILE_ID
@back_tiles_position.push([x, y])
@ex_data[x, y, 0] = @map.data[x, y, 0]
@ex_data[x, y, 1] = @map.data[x, y, 1]
@map.data[x, y, 2] = 0
if (2816...8192).include?(@map.data[x, round_y(y-1), 0])
@ex_data[x, round_y(y-1), 0] = @map.data[x, round_y(y-1), 0]
@ex_data[x, round_y(y-1), 1] = @map.data[x, round_y(y-1), 1]
end
end
end
#- 裏回り部分除去タイルの処理
back_tiles_position_delete(x, y)
end
end
end
#--------------------------------------------------------------------------
# ○ 裏回り用タイルの存在する座標か?
#--------------------------------------------------------------------------
def back_tile?(x, y)
return false if @back_tiles_position == nil
return @back_tiles_position.include?([x, y])
end
end
#- 階段タイルなら通行可
unless back_tile?(start_pos) and turn_back
return true if Data_Tile::STEP.include?(arriv_tile[0])
return true if Data_Tile::STEP.include?(arriv_tile[2])
unless $game_map.wall?(arriv_tile[0])
return true if Data_Tile::STEP.include?(start_tile[0])
return true if Data_Tile::STEP.include?(start_tile[2])
end
end
#- 境目&橋の下の通行判定
if back_tile?(start_pos) and turn_back # 始点が裏かつ裏回り中
return false unless under_bridge_passages(arriv_pos) # 橋の下の通行判定
unless back_tile?(arriv_pos) # 終点が裏でない
if start_side_rip # 始点側に境目がある
if arriv_side_rip # 終点側に境目がある
return false
else
return false if $game_map.wall?(arriv_tile[0])
end
else # 始点側に境目がない
return false
end
end
else # 始点は裏でない
unless $game_map.bridge?(arriv_tile[2], direction) or # 橋がなければ
$game_map.bridge?(start_tile[2], direction)
if start_side_rip # 始点側に境目がある
return false
else # 始点側に境目がない
if arriv_side_rip # 終点側に境目がある
if back_tile?(arriv_pos) # 終点が裏
unless $game_map.bridge?(start_tile[2], direction) # この場が橋でなければ
return false unless under_bridge_passages(arriv_pos) # 橋の下の通行判定
turn_back = true
end
else # 終点が裏でない
unless $game_map.bridge?(start_tile[2], direction) # この場が橋でなければ
return false
end
end
else # 終点側に境目がない
return false if $game_map.wall?(arriv_tile[0])
end
end
end
end
#- 上層の通行判定
if $game_map.upper_layer?(arriv_tile[0]) and not turn_back
for i in [2, 1, 0] # レイヤーの上から順に調べる
tile_id = $game_map.ex_data[arriv_pos[0], arriv_pos[1], i] # タイル ID を取得
unless tile_id == nil
pass = $game_map.passages[tile_id] # 通行属性を取得
next if pass & 0x10 == 0x10 # [☆] : 通行に影響しない
next if pass & 0x01 == 0x00 # [○] : 通行可
if pass & 0x01 == 0x01 # [×] : 通行不可
return false
end
end
end
end
return true
end
#--------------------------------------------------------------------------
# ◎ 下に移動
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
alias tig_ew_move_down move_down
def move_down(turn_ok = true)
unless ex_passable(2)
turn_down if turn_ok
@move_failed = true
check_event_trigger_touch(@x, @y+1) # 接触イベントの起動判定
return
end
tig_ew_move_down(turn_ok)
end
#--------------------------------------------------------------------------
# ◎ 左に移動
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
alias tig_ew_move_left move_left
def move_left(turn_ok = true)
unless ex_passable(4)
turn_left if turn_ok
@move_failed = true
check_event_trigger_touch(@x-1, @y) # 接触イベントの起動判定
return
end
tig_ew_move_left(turn_ok)
end
#--------------------------------------------------------------------------
# ◎ 右に移動
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
alias tig_ew_move_right move_right
def move_right(turn_ok = true)
unless ex_passable(6)
turn_right if turn_ok
check_event_trigger_touch(@x+1, @y) # 接触イベントの起動判定
@move_failed = true
return
end
tig_ew_move_right(turn_ok)
end
#--------------------------------------------------------------------------
# ◎ 上に移動
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
alias tig_ew_move_up move_up
def move_up(turn_ok = true)
unless ex_passable(8)
turn_up if turn_ok
check_event_trigger_touch(@x, @y-1) # 接触イベントの起動判定
@move_failed = true
return
end
tig_ew_move_up(turn_ok)
end
#--------------------------------------------------------------------------
# ◎ 左下に移動
#--------------------------------------------------------------------------
alias tig_ew_move_lower_left move_lower_left
def move_lower_left
turn_back1 = $game_map.rip?(8, @x, @y+1) ? true : @turn_back
turn_back2 = $game_map.rip?(6, @x-1, @y) ? true : @turn_back
unless passable?(@x, @y+1) and passable?(@x-1, @y) and passable?(@x-1, @y+1) and
ex_passable(2) and ex_passable(4, @x-1, @y+1, turn_back1) and
ex_passable(4) and ex_passable(2, @x-1, @y+1, turn_back2)
if @direction == 2
if passable?(@x-1, @y) and ex_passable(4)
move_left
else
move_down
end
elsif @direction == 4
if passable?(@x, @y+1) and ex_passable(2)
move_down
else
move_left
end
end
return
end
tig_ew_move_lower_left
end
#--------------------------------------------------------------------------
# ◎ 右下に移動
#--------------------------------------------------------------------------
alias tig_ew_move_lower_right move_lower_right
def move_lower_right
turn_back1 = $game_map.rip?(8, @x, @y+1) ? true : @turn_back
turn_back2 = $game_map.rip?(4, @x+1, @y) ? true : @turn_back
unless passable?(@x, @y+1) and passable?(@x+1, @y) and passable?(@x+1, @y+1) and
ex_passable(2) and ex_passable(6, @x+1, @y+1, turn_back1) and
ex_passable(6) and ex_passable(2, @x+1, @y+1, turn_back2)
if @direction == 2
if passable?(@x-1, @y) and ex_passable(6)
move_right
else
move_down
end
elsif @direction == 6
if passable?(@x, @y+1) and ex_passable(2)
move_down
else
move_right
end
end
return
end
tig_ew_move_lower_right
end
#--------------------------------------------------------------------------
# ◎ 左上に移動
#--------------------------------------------------------------------------
alias tig_ew_move_upper_left move_upper_left
def move_upper_left
turn_back1 = $game_map.rip?(2, @x, @y-1) ? true : @turn_back
turn_back2 = $game_map.rip?(6, @x-1, @y) ? true : @turn_back
unless passable?(@x, @y-1) and passable?(@x-1, @y) and passable?(@x-1, @y-1) and
ex_passable(8) and ex_passable(4, @x-1, @y-1, turn_back1) and
ex_passable(4) and ex_passable(8, @x-1, @y-1, turn_back2)
if @direction == 8
if passable?(@x-1, @y) and ex_passable(4)
move_left
else
move_up
end
elsif @direction == 4
if passable?(@x, @y+1) and ex_passable(8)
move_up
else
move_left
end
end
return
end
tig_ew_move_upper_left
end
#--------------------------------------------------------------------------
# ◎ 右上に移動
#--------------------------------------------------------------------------
alias tig_ew_move_upper_right move_upper_right
def move_upper_right
turn_back1 = $game_map.rip?(2, @x, @y-1) ? true : @turn_back
turn_back2 = $game_map.rip?(4, @x+1, @y) ? true : @turn_back
unless passable?(@x, @y-1) and passable?(@x+1, @y) and passable?(@x+1, @y-1) and
ex_passable(8) and ex_passable(6, @x+1, @y-1, turn_back1) and
ex_passable(6) and ex_passable(8, @x+1, @y-1, turn_back2)
if @direction == 8
if passable?(@x+1, @y) and ex_passable(6)
move_right
else
move_up
end
elsif @direction == 6
if passable?(@x, @y-1) and ex_passable(8)
move_up
else
move_right
end
end
return
end
tig_ew_move_upper_right
end
#--------------------------------------------------------------------------
# ● キャラクター衝突判定
# x : X 座標
# y : Y 座標
# プレイヤーと乗り物を含め、通常キャラの衝突を検出する。
#--------------------------------------------------------------------------
def collide_with_characters?(x, y)
for event in $game_map.events_xy(x, y) # イベントの座標と一致
next unless parallel?(event) ##### 追加部分 (この行) #####
unless event.through # すり抜け OFF?
return true if self.is_a?(Game_Event) # 自分がイベント
return true if event.priority_type == 1 # 相手が通常キャラ
end
end
if @priority_type == 1 # 自分が通常キャラ
if parallel?($game_player) ##### 追加部分 (この行) #####
return true if $game_player.pos_nt?(x, y) # プレイヤーの座標と一致
end ##### 追加部分 (この行) #####
return true if $game_map.boat.pos_nt?(x, y) # 小型船の座標と一致
return true if $game_map.ship.pos_nt?(x, y) # 大型船の座標と一致
end
return false
end
#--------------------------------------------------------------------------
# ○ キャラクターの同軸存在判定
#--------------------------------------------------------------------------
def parallel?(character)
direction = search_direction(@x, @y, character.x, character.y)
turn_back = @turn_back
character_turn_back = character.turn_back
if direction != 5
if direction % 2 == 0
if $game_map.rip?(10 - direction, character.x, character.y)
turn_back = true
end
else
if diagonal_move_turn_back(direction, character.x, character.y)
turn_back = true
end
end
if direction % 2 == 0
if $game_map.rip?(direction, @x, @y)
character_turn_back = true
end
else
if diagonal_move_turn_back(10 - direction, @x, @y)
character_turn_back = true
end
end
tile_id = $game_map.data[character.x, character.y, 0]
if $game_map.wall?(tile_id)
return true unless ex_passable(direction)
end
end
class Game_Vehicle < Game_Character
#--------------------------------------------------------------------------
# ○ タイル表示(on_tile)状態取得
#--------------------------------------------------------------------------
def on_tile
if @driving or @altitude > 0
return $game_player.on_tile
else
return false
end
end
#--------------------------------------------------------------------------
# ◎ プレイヤーとの同期
#--------------------------------------------------------------------------
alias tig_ew_sync_with_player sync_with_player
def sync_with_player
tig_ew_sync_with_player
update_turn_back
end
end
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# ○ 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :game_map_data
attr_accessor :reserve_load_map_id
#--------------------------------------------------------------------------
# ◎ オブジェクト初期化
# map_id : マップ ID
# event : イベント (RPG::Event)
#--------------------------------------------------------------------------
alias tig_ew_pl_initialize initialize
def initialize
tig_ew_pl_initialize
@reserve_load_map_id = []
@game_map_data = {}
end
#--------------------------------------------------------------------------
# ○ マップデータの先読み
#--------------------------------------------------------------------------
def beforehand_load(map_id = @reserve_load_map_id)
for i in map_id
next if @game_map_data.key?(i)
map_data = Game_Map.new
map_data.setup(i)
@game_map_data = map_data
end
for i in @game_map_data.keys.clone
unless map_id.include?(i)
@game_map_data.delete(i)
end
end
end
#--------------------------------------------------------------------------
# ◎ 場所移動の実行
#--------------------------------------------------------------------------
alias tig_ew_perform_transfer perform_transfer
def perform_transfer
return unless @transferring
unless $game_player.reserve_load_map_id.empty?
$game_player.beforehand_load
end
tig_ew_perform_transfer
end
#--------------------------------------------------------------------------
# ○ 浮かんでいるか?(乗り物拡張用・魔法の絨毯搭乗時)
#--------------------------------------------------------------------------
def floating?
return @vehicle_type == 5
end
#--------------------------------------------------------------------------
# ● 同位置のイベント起動判定
# triggers : トリガーの配列
#--------------------------------------------------------------------------
def check_event_trigger_here(triggers)
return false if $game_map.interpreter.running?
result = false
for event in $game_map.events_xy(@x, @y)
next unless parallel?(event) ##### 追加部分 (この行) #####
if triggers.include?(event.trigger) and event.priority_type != 1
event.start
result = true if event.starting
end
end
return result
end
#--------------------------------------------------------------------------
# ● 正面のイベント起動判定
# triggers : トリガーの配列
#--------------------------------------------------------------------------
def check_event_trigger_there(triggers)
return false if $game_map.interpreter.running?
result = false
front_x = $game_map.x_with_direction(@x, @direction)
front_y = $game_map.y_with_direction(@y, @direction)
for event in $game_map.events_xy(front_x, front_y)
next unless parallel?(event) ##### 追加部分 (この行) #####
if triggers.include?(event.trigger) and event.priority_type == 1
event.start
result = true
end
end
if result == false and $game_map.counter?(front_x, front_y)
front_x = $game_map.x_with_direction(front_x, @direction)
front_y = $game_map.y_with_direction(front_y, @direction)
for event in $game_map.events_xy(front_x, front_y)
next unless parallel?(event) ##### 追加部分 (この行) #####
if triggers.include?(event.trigger) and event.priority_type == 1
event.start
result = true
end
end
end
return result
end
#--------------------------------------------------------------------------
# ● 接触イベントの起動判定
# x : X 座標
# y : Y 座標
#--------------------------------------------------------------------------
def check_event_trigger_touch(x, y)
return false if $game_map.interpreter.running?
result = false
for event in $game_map.events_xy(x, y)
if event.character_name != "" #### 追加部分 (ここから) ####
next unless parallel?(event)
end #### 追加部分 (ここまで) ####
if [1,2].include?(event.trigger) and event.priority_type == 1
event.start
result = true
end
end
return result
end
#--------------------------------------------------------------------------
# ◎ 乗り物から降りる
# 現在乗り物に乗っていることが前提。
#--------------------------------------------------------------------------
alias tig_ew_get_off_vehicle get_off_vehicle
def get_off_vehicle
return if $game_map.back_tile?(@x, @y)
if @vehicle_type == 0 or @vehicle_type == 1
front_x = $game_map.x_with_direction(@x, @direction)
front_y = $game_map.y_with_direction(@y, @direction)
return if $game_map.wall?($game_map.point_tile_id(front_x, front_y)[0])
return if $game_map.under_bridge_passages[[front_x, front_y]] == 1
return if $game_map.prohibited_get_off.include?([front_x, front_y])
@no_turn_back = true
end
tig_ew_get_off_vehicle
end
end