赞 13
VIP 320
好人卡 64
积分 3
经验 112963
最后登录 2022-8-25
在线时间 2355 小时
Lv2.观梦者 (暗夜天使 )
梦石 0
星屑 266
在线时间 2355 小时
注册时间 2009-3-13
帖子 2309
本帖最后由 Sion 于 2013-10-28 18:58 编辑
ayano2k 发表于 2013-3-20 16:34
感谢楼主的脚本,很好用~~
但是这个功能想知道该怎么设置??
[[ 1.3a: 代码小修改;
=begin ========================================================================
八方移动补丁 置于Sion_Mouse_System脚本下
2013.10.28 v1.2 鼠标2.0+更新修正
2013.5.3 v1.1 修正斜向触发事件
=end #=========================================================================
class Game_Player
# ───────────────────────────────────────
# † 八方移动
# ───────────────────────────────────────
def move_by_input
return if !movable? || $game_map .interpreter .running ?
case Input.dir8
when 2 ,4 ,6 ,8 ; move_straight( Input.dir8 )
when 1
if diagonal_passable?( x, y, 4 , 2 ) ; move_diagonal( 4 , 2 )
elsif passable?( x, y, 4 ) ; move_straight( 4 )
else ; move_straight( 2 )
end
when 3
if diagonal_passable?( x, y, 6 , 2 ) ; move_diagonal( 6 , 2 )
elsif passable?( x, y, 6 ) ; move_straight( 6 )
else ; move_straight( 2 )
end
when 7
if diagonal_passable?( x, y, 4 , 8 ) ; move_diagonal( 4 , 8 )
elsif passable?( x, y, 4 ) ; move_straight( 4 )
else ; move_straight( 8 )
end
when 9
if diagonal_passable?( x, y, 6 , 8 ) ; move_diagonal( 6 , 8 )
elsif passable?( x, y, 6 ) ; move_straight( 6 )
else ; move_straight( 6 )
end
else ; move_by_mouse
end
end
# ───────────────────────────────────────
# † 鼠标八方移动
# ───────────────────────────────────────
def move_by_mouse
unless @mouse_move_path .empty ? # 移动路线数组不为空则执行移动
dir = @mouse_move_path .shift
if passable?( x, y, dir) && !@mouse_move_path.empty ?
if @mouse_move_path [ 0 ] == dir
move_straight( dir)
else
if @mouse_move_path .size == 1 &&
touch_event?( x, y, dir, @mouse_move_path [ 0 ] )
move_straight( dir)
elsif dir == 4 || dir == 6
move_diagonal( dir, @mouse_move_path .shift )
else
move_diagonal( @mouse_move_path.shift , dir)
end
end
elsif @mouse_move_path .empty ? # 判断是否是最后一步
x2 = $game_map .round_x_with_direction ( x, dir)
y2 = $game_map .round_y_with_direction ( y, dir)
move_straight( dir) unless dir.zero ?
unless x == x2 && y == y2 # 如果移动失败,检查是否启动前方事件、上下载具
check_event_trigger_there( [ 0 ,1 ,2 ] )
get_on_off_vehicle unless $game_map .setup_starting_event
end
$mouse_move_sign .transparent = true if $mouse_move_sign .direction == 2
@mouse_dash = false
elsif @mouse_move_path [ 0 ] .zero ? # 目标点无法抵达,调整朝向→目标点
@mouse_move_path .shift
@direction = dir
@mouse_dash = false
else
draw_move_path
end
end
end
def touch_event?( x, y, dir, dir_)
x = $game_map .round_x_with_direction (
$game_map .round_x_with_direction ( x, dir) , dir_)
y = $game_map .round_y_with_direction (
$game_map .round_y_with_direction ( y, dir) , dir_)
if collide_with_events?( x, y)
return x, y
else
return nil , nil
end
end
# ───────────────────────────────────────
# † 步行路径
# ───────────────────────────────────────
def draw_walk_path
# 准备绘制路径表格
sheet = Table.new ( $game_map.width , $game_map .height )
chase_path = [ ]
new_end_points = [ @moveto_x, @moveto_y ]
sheet[ @moveto_x, @moveto_y ] = 1
reach_point = false
step = 2
loop do #loop1 开始填充表格
draw_path = false
check_points = new_end_points
new_end_points = [ ]
break if step > KsOfSion::Break_Steps &&
!Input.press ?( KsOfSion::Find_Path_Key )
loop do #loop3 从终点开始反向填充
point_x = check_points.shift
break if point_x == nil
point_y = check_points.shift
# 判断路径是否连通
if point_x == x && point_y == y
reach_point = true ; break ; end
# 以需要抵达该点的步数填充路径表格 #
left_x = $game_map .round_x ( point_x - 1 )
right_x = $game_map .round_x ( point_x + 1 )
up_y = $game_map .round_y ( point_y - 1 )
down_y = $game_map .round_y ( point_y + 1 )
if sheet[ left_x, point_y] == 0 &&
$game_map .passable ?( left_x, point_y, 6 ) &&
!collide_with_events?( left_x, point_y) &&
$game_map .passable ?( point_x, point_y, 4 ) &&
!collide_with_vehicles?( left_x, point_y) #judge_end
sheet[ left_x, point_y] = step
draw_path = true
new_end_points.push ( left_x, point_y)
end
if sheet[ right_x, point_y] == 0 &&
$game_map .passable ?( right_x, point_y, 4 ) &&
!collide_with_events?( right_x, point_y) &&
$game_map .passable ?( point_x, point_y, 6 ) &&
!collide_with_vehicles?( right_x, point_y) #judge_end
sheet[ right_x, point_y] = step
draw_path = true
new_end_points.push ( right_x, point_y)
end
if sheet[ point_x, up_y] == 0 &&
$game_map .passable ?( point_x, up_y, 2 ) &&
!collide_with_events?( point_x, up_y) &&
$game_map .passable ?( point_x, point_y, 8 ) &&
!collide_with_vehicles?( point_x, up_y) #judge_end
sheet[ point_x, up_y] = step
draw_path = true
new_end_points.push ( point_x, up_y)
end
if sheet[ point_x, down_y] == 0 &&
$game_map .passable ?( point_x, down_y, 8 ) &&
!collide_with_events?( point_x, down_y) &&
$game_map .passable ?( point_x, point_y, 2 ) &&
!collide_with_vehicles?( point_x, down_y) #judge_end
sheet[ point_x, down_y] = step
draw_path = true
new_end_points.push ( point_x, down_y)
end
end #endOfLoop3
break if !draw_path || reach_point
step += 1
end #endOfLoop1 路径表格填充完毕
$mouse_move_sign .transparent = false
# 判断指定地点能否抵达
if reach_point
$mouse_move_sign .direction = 2
else
return not_reach_point
end
# 根据路径表格绘制最短移动路径(正向)
step -= 1 # 因为需要再填充一次才能判定是否抵达
point_x, point_y = x, y
for i in 2 ..step
step -= 1
if ( @moveto_x - point_x) .abs < ( @moveto_y - point_y) .abs
if sheet[ point_x, $game_map .round_y ( point_y + 1 ) ] == step &&
$game_map .passable ?( point_x, $game_map .round_y ( point_y + 1 ) , 8 ) &&
$game_map .passable ?( point_x, point_y, 2 ) #judge_end
chase_path.push ( 2 )
point_y = $game_map .round_y ( point_y + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y - 1 ) ] == step &&
$game_map .passable ?( point_x, $game_map .round_y ( point_y - 1 ) , 2 ) &&
$game_map .passable ?( point_x, point_y, 8 ) #judge_end
chase_path.push ( 8 )
point_y = $game_map .round_y ( point_y - 1 )
elsif sheet[ $game_map.round_x ( point_x - 1 ) , point_y] == step &&
$game_map .passable ?( $game_map.round_x ( point_x - 1 ) , point_y, 6 ) &&
$game_map .passable ?( point_x, point_y, 4 ) #judge_end
chase_path.push ( 4 )
point_x = $game_map .round_x ( point_x - 1 )
elsif sheet[ $game_map.round_x ( point_x + 1 ) , point_y] == step &&
$game_map .passable ?( $game_map.round_x ( point_x + 1 ) , point_y, 4 ) &&
$game_map .passable ?( point_x, point_y, 6 ) #judge_end
chase_path.push ( 6 )
point_x = $game_map .round_x ( point_x + 1 )
end
else
if sheet[ $game_map.round_x ( point_x - 1 ) , point_y] == step &&
$game_map .passable ?( $game_map.round_x ( point_x - 1 ) , point_y, 6 ) &&
$game_map .passable ?( point_x, point_y, 4 ) #judge_end
chase_path.push ( 4 )
point_x = $game_map .round_x ( point_x - 1 )
elsif sheet[ $game_map.round_x ( point_x + 1 ) , point_y] == step &&
$game_map .passable ?( $game_map.round_x ( point_x + 1 ) , point_y, 4 ) &&
$game_map .passable ?( point_x, point_y, 6 ) #judge_end
chase_path.push ( 6 )
point_x = $game_map .round_x ( point_x + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y + 1 ) ] == step &&
$game_map .passable ?( point_x, $game_map .round_y ( point_y + 1 ) , 8 ) &&
$game_map .passable ?( point_x, point_y, 2 ) #judge_end
chase_path.push ( 2 )
point_y = $game_map .round_y ( point_y + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y - 1 ) ] == step &&
$game_map .passable ?( point_x, $game_map .round_y ( point_y - 1 ) , 2 ) &&
$game_map .passable ?( point_x, point_y, 8 ) #judge_end
chase_path.push ( 8 )
point_y = $game_map .round_y ( point_y - 1 )
end
end
end #endOfForLoop
return chase_path
end #walk
# ───────────────────────────────────────
# † boat路径
# ───────────────────────────────────────
def draw_boat_path
# 准备绘制路径表格
sheet = Table.new ( $game_map.width , $game_map .height )
chase_path = [ ]
new_end_points = [ @moveto_x, @moveto_y ]
sheet[ @moveto_x, @moveto_y ] = 1
reach_point = false
step = 2
loop do #loop1 开始填充表格
draw_path = false
check_points = new_end_points
new_end_points = [ ]
break if step > KsOfSion::Break_Steps &&
!Input.press ?( KsOfSion::Find_Path_Key )
loop do #loop3 从终点开始反向填充
point_x = check_points.shift
break if point_x == nil
point_y = check_points.shift
left_x = $game_map .round_x ( point_x - 1 )
right_x = $game_map .round_x ( point_x + 1 )
up_y = $game_map .round_y ( point_y - 1 )
down_y = $game_map .round_y ( point_y + 1 )
# 判断路径是否连通
if left_x == x && point_y == y
reach_point = true ; break
elsif right_x == x && point_y == y
reach_point = true ; break
elsif point_x == x && up_y == y
reach_point = true ; break
elsif point_x == x && down_y == y
reach_point = true ; break
end
# 以需要抵达该点的步数填充路径表格 #
if sheet[ left_x, point_y] == 0 &&
$game_map .boat_passable ?( left_x, point_y) &&
!collide_with_events?( left_x, point_y) &&
!collide_with_vehicles?( left_x, point_y) #judge_end
sheet[ left_x, point_y] = step
draw_path = true
new_end_points.push ( left_x, point_y)
end
if sheet[ right_x, point_y] == 0 &&
$game_map .boat_passable ?( right_x, point_y) &&
!collide_with_events?( right_x, point_y) &&
!collide_with_vehicles?( right_x, point_y) #judge_end
sheet[ right_x, point_y] = step
draw_path = true
new_end_points.push ( right_x, point_y)
end
if sheet[ point_x, up_y] == 0 &&
$game_map .boat_passable ?( point_x, up_y) &&
!collide_with_events?( point_x, up_y) &&
!collide_with_vehicles?( point_x, up_y) #judge_end
sheet[ point_x, up_y] = step
draw_path = true
new_end_points.push ( point_x, up_y)
end
if sheet[ point_x, down_y] == 0 &&
$game_map .boat_passable ?( point_x, down_y) &&
!collide_with_events?( point_x, down_y) &&
!collide_with_vehicles?( point_x, down_y) #judge_end
sheet[ point_x, down_y] = step
draw_path = true
new_end_points.push ( point_x, down_y)
end
end #endOfLoop3
break if !draw_path || reach_point
step += 1
end #endOfLoop1 路径表格填充完毕
$mouse_move_sign .transparent = false
# 判断指定地点能否抵达
if reach_point
$mouse_move_sign .direction = 2
else
return not_reach_point
end
# 根据路径表格绘制最短移动路径(正向)
point_x, point_y = x, y
for i in 2 ..step # forLoop
step -= 1
if ( @moveto_x - point_x) .abs < ( @moveto_y - point_y) .abs
if sheet[ point_x, $game_map .round_y ( point_y + 1 ) ] == step
chase_path.push ( 2 )
point_y = $game_map .round_y ( point_y + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y - 1 ) ] == step
chase_path.push ( 8 )
point_y = $game_map .round_y ( point_y - 1 )
elsif sheet[ $game_map.round_x ( point_x - 1 ) , point_y] == step
chase_path.push ( 4 )
point_x = $game_map .round_x ( point_x - 1 )
elsif sheet[ $game_map.round_x ( point_x + 1 ) , point_y] == step
chase_path.push ( 6 )
point_x = $game_map .round_x ( point_x + 1 )
end
else
if sheet[ $game_map.round_x ( point_x - 1 ) , point_y] == step
chase_path.push ( 4 )
point_x = $game_map .round_x ( point_x - 1 )
elsif sheet[ $game_map.round_x ( point_x + 1 ) , point_y] == step
chase_path.push ( 6 )
point_x = $game_map .round_x ( point_x + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y + 1 ) ] == step
chase_path.push ( 2 )
point_y = $game_map .round_y ( point_y + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y - 1 ) ] == step
chase_path.push ( 8 )
point_y = $game_map .round_y ( point_y - 1 )
end
end
end #endOfForLoop
# 如果指定点无法抵达或者登陆
return not_reach_point unless landable?( @moveto_x, @moveto_y , chase_path)
return chase_path
end #boat
# ───────────────────────────────────────
# † ship路径
# ───────────────────────────────────────
def draw_ship_path
# 准备绘制路径表格
sheet = Table.new ( $game_map.width , $game_map .height )
chase_path = [ ]
new_end_points = [ @moveto_x, @moveto_y ]
sheet[ @moveto_x, @moveto_y ] = 1
reach_point = false
step = 2
loop do #loop1 开始填充表格
draw_path = false
check_points = new_end_points
new_end_points = [ ]
break if step > KsOfSion::Break_Steps &&
!Input.press ?( KsOfSion::Find_Path_Key )
loop do #loop3 从终点开始反向填充
point_x = check_points.shift
break if point_x == nil
point_y = check_points.shift
left_x = $game_map .round_x ( point_x - 1 )
right_x = $game_map .round_x ( point_x + 1 )
up_y = $game_map .round_y ( point_y - 1 )
down_y = $game_map .round_y ( point_y + 1 )
# 判断路径是否连通
if left_x == x && point_y == y
reach_point = true ; break
elsif right_x == x && point_y == y
reach_point = true ; break
elsif point_x == x && up_y == y
reach_point = true ; break
elsif point_x == x && down_y == y
reach_point = true ; break
end
# 以需要抵达该点的步数填充路径表格 #
if sheet[ left_x, point_y] == 0 &&
$game_map .ship_passable ?( left_x, point_y) &&
!collide_with_events?( left_x, point_y) &&
!collide_with_vehicles?( left_x, point_y) #judge_end
sheet[ left_x, point_y] = step
draw_path = true
new_end_points.push ( left_x, point_y)
end
if sheet[ right_x, point_y] == 0 &&
$game_map .ship_passable ?( right_x, point_y) &&
!collide_with_events?( right_x, point_y) &&
!collide_with_vehicles?( right_x, point_y) #judge_end
sheet[ right_x, point_y] = step
draw_path = true
new_end_points.push ( right_x, point_y)
end
if sheet[ point_x, up_y] == 0 &&
$game_map .ship_passable ?( point_x, up_y) &&
!collide_with_events?( point_x, up_y) &&
!collide_with_vehicles?( point_x, up_y) #judge_end
sheet[ point_x, up_y] = step
draw_path = true
new_end_points.push ( point_x, up_y)
end
if sheet[ point_x, down_y] == 0 &&
$game_map .ship_passable ?( point_x, down_y) &&
!collide_with_events?( point_x, down_y) &&
!collide_with_vehicles?( point_x, down_y) #judge_end
sheet[ point_x, down_y] = step
draw_path = true
new_end_points.push ( point_x, down_y)
end
end #endOfLoop3
break if !draw_path || reach_point
step += 1
end #endOfLoop1 路径表格填充完毕
$mouse_move_sign .transparent = false
# 判断指定地点能否抵达
if reach_point
$mouse_move_sign .direction = 2
else
not_reach_point
return
end
# 根据路径表格绘制最短移动路径(正向)
point_x, point_y = x, y
for i in 2 ..step
step -= 1
if ( @moveto_x - point_x) .abs < ( @moveto_y - point_y) .abs
if sheet[ point_x, $game_map .round_y ( point_y + 1 ) ] == step
chase_path.push ( 2 )
point_y = $game_map .round_y ( point_y + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y - 1 ) ] == step
chase_path.push ( 8 )
point_y = $game_map .round_y ( point_y - 1 )
elsif sheet[ $game_map.round_x ( point_x - 1 ) , point_y] == step
chase_path.push ( 4 )
point_x = $game_map .round_x ( point_x - 1 )
elsif sheet[ $game_map.round_x ( point_x + 1 ) , point_y] == step
chase_path.push ( 6 )
point_x = $game_map .round_x ( point_x + 1 )
end
else
if sheet[ $game_map.round_x ( point_x - 1 ) , point_y] == step
chase_path.push ( 4 )
point_x = $game_map .round_x ( point_x - 1 )
elsif sheet[ $game_map.round_x ( point_x + 1 ) , point_y] == step
chase_path.push ( 6 )
point_x = $game_map .round_x ( point_x + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y + 1 ) ] == step
chase_path.push ( 2 )
point_y = $game_map .round_y ( point_y + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y - 1 ) ] == step
chase_path.push ( 8 )
point_y = $game_map .round_y ( point_y - 1 )
end
end
end #endOfForLoop
# 如果指定点无法抵达或者登陆
return not_reach_point unless landable?( @moveto_x, @moveto_y , chase_path)
return chase_path
end #ship
end
=begin ========================================================================
八方移动补丁 置于Sion_Mouse_System脚本下
2013.10.28 v1.2 鼠标2.0+更新修正
2013.5.3 v1.1 修正斜向触发事件
=end #=========================================================================
class Game_Player
# ───────────────────────────────────────
# † 八方移动
# ───────────────────────────────────────
def move_by_input
return if !movable? || $game_map .interpreter .running ?
case Input.dir8
when 2 ,4 ,6 ,8 ; move_straight( Input.dir8 )
when 1
if diagonal_passable?( x, y, 4 , 2 ) ; move_diagonal( 4 , 2 )
elsif passable?( x, y, 4 ) ; move_straight( 4 )
else ; move_straight( 2 )
end
when 3
if diagonal_passable?( x, y, 6 , 2 ) ; move_diagonal( 6 , 2 )
elsif passable?( x, y, 6 ) ; move_straight( 6 )
else ; move_straight( 2 )
end
when 7
if diagonal_passable?( x, y, 4 , 8 ) ; move_diagonal( 4 , 8 )
elsif passable?( x, y, 4 ) ; move_straight( 4 )
else ; move_straight( 8 )
end
when 9
if diagonal_passable?( x, y, 6 , 8 ) ; move_diagonal( 6 , 8 )
elsif passable?( x, y, 6 ) ; move_straight( 6 )
else ; move_straight( 6 )
end
else ; move_by_mouse
end
end
# ───────────────────────────────────────
# † 鼠标八方移动
# ───────────────────────────────────────
def move_by_mouse
unless @mouse_move_path .empty ? # 移动路线数组不为空则执行移动
dir = @mouse_move_path .shift
if passable?( x, y, dir) && !@mouse_move_path.empty ?
if @mouse_move_path [ 0 ] == dir
move_straight( dir)
else
if @mouse_move_path .size == 1 &&
touch_event?( x, y, dir, @mouse_move_path [ 0 ] )
move_straight( dir)
elsif dir == 4 || dir == 6
move_diagonal( dir, @mouse_move_path .shift )
else
move_diagonal( @mouse_move_path.shift , dir)
end
end
elsif @mouse_move_path .empty ? # 判断是否是最后一步
x2 = $game_map .round_x_with_direction ( x, dir)
y2 = $game_map .round_y_with_direction ( y, dir)
move_straight( dir) unless dir.zero ?
unless x == x2 && y == y2 # 如果移动失败,检查是否启动前方事件、上下载具
check_event_trigger_there( [ 0 ,1 ,2 ] )
get_on_off_vehicle unless $game_map .setup_starting_event
end
$mouse_move_sign .transparent = true if $mouse_move_sign .direction == 2
@mouse_dash = false
elsif @mouse_move_path [ 0 ] .zero ? # 目标点无法抵达,调整朝向→目标点
@mouse_move_path .shift
@direction = dir
@mouse_dash = false
else
draw_move_path
end
end
end
def touch_event?( x, y, dir, dir_)
x = $game_map .round_x_with_direction (
$game_map .round_x_with_direction ( x, dir) , dir_)
y = $game_map .round_y_with_direction (
$game_map .round_y_with_direction ( y, dir) , dir_)
if collide_with_events?( x, y)
return x, y
else
return nil , nil
end
end
# ───────────────────────────────────────
# † 步行路径
# ───────────────────────────────────────
def draw_walk_path
# 准备绘制路径表格
sheet = Table.new ( $game_map.width , $game_map .height )
chase_path = [ ]
new_end_points = [ @moveto_x, @moveto_y ]
sheet[ @moveto_x, @moveto_y ] = 1
reach_point = false
step = 2
loop do #loop1 开始填充表格
draw_path = false
check_points = new_end_points
new_end_points = [ ]
break if step > KsOfSion::Break_Steps &&
!Input.press ?( KsOfSion::Find_Path_Key )
loop do #loop3 从终点开始反向填充
point_x = check_points.shift
break if point_x == nil
point_y = check_points.shift
# 判断路径是否连通
if point_x == x && point_y == y
reach_point = true ; break ; end
# 以需要抵达该点的步数填充路径表格 #
left_x = $game_map .round_x ( point_x - 1 )
right_x = $game_map .round_x ( point_x + 1 )
up_y = $game_map .round_y ( point_y - 1 )
down_y = $game_map .round_y ( point_y + 1 )
if sheet[ left_x, point_y] == 0 &&
$game_map .passable ?( left_x, point_y, 6 ) &&
!collide_with_events?( left_x, point_y) &&
$game_map .passable ?( point_x, point_y, 4 ) &&
!collide_with_vehicles?( left_x, point_y) #judge_end
sheet[ left_x, point_y] = step
draw_path = true
new_end_points.push ( left_x, point_y)
end
if sheet[ right_x, point_y] == 0 &&
$game_map .passable ?( right_x, point_y, 4 ) &&
!collide_with_events?( right_x, point_y) &&
$game_map .passable ?( point_x, point_y, 6 ) &&
!collide_with_vehicles?( right_x, point_y) #judge_end
sheet[ right_x, point_y] = step
draw_path = true
new_end_points.push ( right_x, point_y)
end
if sheet[ point_x, up_y] == 0 &&
$game_map .passable ?( point_x, up_y, 2 ) &&
!collide_with_events?( point_x, up_y) &&
$game_map .passable ?( point_x, point_y, 8 ) &&
!collide_with_vehicles?( point_x, up_y) #judge_end
sheet[ point_x, up_y] = step
draw_path = true
new_end_points.push ( point_x, up_y)
end
if sheet[ point_x, down_y] == 0 &&
$game_map .passable ?( point_x, down_y, 8 ) &&
!collide_with_events?( point_x, down_y) &&
$game_map .passable ?( point_x, point_y, 2 ) &&
!collide_with_vehicles?( point_x, down_y) #judge_end
sheet[ point_x, down_y] = step
draw_path = true
new_end_points.push ( point_x, down_y)
end
end #endOfLoop3
break if !draw_path || reach_point
step += 1
end #endOfLoop1 路径表格填充完毕
$mouse_move_sign .transparent = false
# 判断指定地点能否抵达
if reach_point
$mouse_move_sign .direction = 2
else
return not_reach_point
end
# 根据路径表格绘制最短移动路径(正向)
step -= 1 # 因为需要再填充一次才能判定是否抵达
point_x, point_y = x, y
for i in 2 ..step
step -= 1
if ( @moveto_x - point_x) .abs < ( @moveto_y - point_y) .abs
if sheet[ point_x, $game_map .round_y ( point_y + 1 ) ] == step &&
$game_map .passable ?( point_x, $game_map .round_y ( point_y + 1 ) , 8 ) &&
$game_map .passable ?( point_x, point_y, 2 ) #judge_end
chase_path.push ( 2 )
point_y = $game_map .round_y ( point_y + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y - 1 ) ] == step &&
$game_map .passable ?( point_x, $game_map .round_y ( point_y - 1 ) , 2 ) &&
$game_map .passable ?( point_x, point_y, 8 ) #judge_end
chase_path.push ( 8 )
point_y = $game_map .round_y ( point_y - 1 )
elsif sheet[ $game_map.round_x ( point_x - 1 ) , point_y] == step &&
$game_map .passable ?( $game_map.round_x ( point_x - 1 ) , point_y, 6 ) &&
$game_map .passable ?( point_x, point_y, 4 ) #judge_end
chase_path.push ( 4 )
point_x = $game_map .round_x ( point_x - 1 )
elsif sheet[ $game_map.round_x ( point_x + 1 ) , point_y] == step &&
$game_map .passable ?( $game_map.round_x ( point_x + 1 ) , point_y, 4 ) &&
$game_map .passable ?( point_x, point_y, 6 ) #judge_end
chase_path.push ( 6 )
point_x = $game_map .round_x ( point_x + 1 )
end
else
if sheet[ $game_map.round_x ( point_x - 1 ) , point_y] == step &&
$game_map .passable ?( $game_map.round_x ( point_x - 1 ) , point_y, 6 ) &&
$game_map .passable ?( point_x, point_y, 4 ) #judge_end
chase_path.push ( 4 )
point_x = $game_map .round_x ( point_x - 1 )
elsif sheet[ $game_map.round_x ( point_x + 1 ) , point_y] == step &&
$game_map .passable ?( $game_map.round_x ( point_x + 1 ) , point_y, 4 ) &&
$game_map .passable ?( point_x, point_y, 6 ) #judge_end
chase_path.push ( 6 )
point_x = $game_map .round_x ( point_x + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y + 1 ) ] == step &&
$game_map .passable ?( point_x, $game_map .round_y ( point_y + 1 ) , 8 ) &&
$game_map .passable ?( point_x, point_y, 2 ) #judge_end
chase_path.push ( 2 )
point_y = $game_map .round_y ( point_y + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y - 1 ) ] == step &&
$game_map .passable ?( point_x, $game_map .round_y ( point_y - 1 ) , 2 ) &&
$game_map .passable ?( point_x, point_y, 8 ) #judge_end
chase_path.push ( 8 )
point_y = $game_map .round_y ( point_y - 1 )
end
end
end #endOfForLoop
return chase_path
end #walk
# ───────────────────────────────────────
# † boat路径
# ───────────────────────────────────────
def draw_boat_path
# 准备绘制路径表格
sheet = Table.new ( $game_map.width , $game_map .height )
chase_path = [ ]
new_end_points = [ @moveto_x, @moveto_y ]
sheet[ @moveto_x, @moveto_y ] = 1
reach_point = false
step = 2
loop do #loop1 开始填充表格
draw_path = false
check_points = new_end_points
new_end_points = [ ]
break if step > KsOfSion::Break_Steps &&
!Input.press ?( KsOfSion::Find_Path_Key )
loop do #loop3 从终点开始反向填充
point_x = check_points.shift
break if point_x == nil
point_y = check_points.shift
left_x = $game_map .round_x ( point_x - 1 )
right_x = $game_map .round_x ( point_x + 1 )
up_y = $game_map .round_y ( point_y - 1 )
down_y = $game_map .round_y ( point_y + 1 )
# 判断路径是否连通
if left_x == x && point_y == y
reach_point = true ; break
elsif right_x == x && point_y == y
reach_point = true ; break
elsif point_x == x && up_y == y
reach_point = true ; break
elsif point_x == x && down_y == y
reach_point = true ; break
end
# 以需要抵达该点的步数填充路径表格 #
if sheet[ left_x, point_y] == 0 &&
$game_map .boat_passable ?( left_x, point_y) &&
!collide_with_events?( left_x, point_y) &&
!collide_with_vehicles?( left_x, point_y) #judge_end
sheet[ left_x, point_y] = step
draw_path = true
new_end_points.push ( left_x, point_y)
end
if sheet[ right_x, point_y] == 0 &&
$game_map .boat_passable ?( right_x, point_y) &&
!collide_with_events?( right_x, point_y) &&
!collide_with_vehicles?( right_x, point_y) #judge_end
sheet[ right_x, point_y] = step
draw_path = true
new_end_points.push ( right_x, point_y)
end
if sheet[ point_x, up_y] == 0 &&
$game_map .boat_passable ?( point_x, up_y) &&
!collide_with_events?( point_x, up_y) &&
!collide_with_vehicles?( point_x, up_y) #judge_end
sheet[ point_x, up_y] = step
draw_path = true
new_end_points.push ( point_x, up_y)
end
if sheet[ point_x, down_y] == 0 &&
$game_map .boat_passable ?( point_x, down_y) &&
!collide_with_events?( point_x, down_y) &&
!collide_with_vehicles?( point_x, down_y) #judge_end
sheet[ point_x, down_y] = step
draw_path = true
new_end_points.push ( point_x, down_y)
end
end #endOfLoop3
break if !draw_path || reach_point
step += 1
end #endOfLoop1 路径表格填充完毕
$mouse_move_sign .transparent = false
# 判断指定地点能否抵达
if reach_point
$mouse_move_sign .direction = 2
else
return not_reach_point
end
# 根据路径表格绘制最短移动路径(正向)
point_x, point_y = x, y
for i in 2 ..step # forLoop
step -= 1
if ( @moveto_x - point_x) .abs < ( @moveto_y - point_y) .abs
if sheet[ point_x, $game_map .round_y ( point_y + 1 ) ] == step
chase_path.push ( 2 )
point_y = $game_map .round_y ( point_y + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y - 1 ) ] == step
chase_path.push ( 8 )
point_y = $game_map .round_y ( point_y - 1 )
elsif sheet[ $game_map.round_x ( point_x - 1 ) , point_y] == step
chase_path.push ( 4 )
point_x = $game_map .round_x ( point_x - 1 )
elsif sheet[ $game_map.round_x ( point_x + 1 ) , point_y] == step
chase_path.push ( 6 )
point_x = $game_map .round_x ( point_x + 1 )
end
else
if sheet[ $game_map.round_x ( point_x - 1 ) , point_y] == step
chase_path.push ( 4 )
point_x = $game_map .round_x ( point_x - 1 )
elsif sheet[ $game_map.round_x ( point_x + 1 ) , point_y] == step
chase_path.push ( 6 )
point_x = $game_map .round_x ( point_x + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y + 1 ) ] == step
chase_path.push ( 2 )
point_y = $game_map .round_y ( point_y + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y - 1 ) ] == step
chase_path.push ( 8 )
point_y = $game_map .round_y ( point_y - 1 )
end
end
end #endOfForLoop
# 如果指定点无法抵达或者登陆
return not_reach_point unless landable?( @moveto_x, @moveto_y , chase_path)
return chase_path
end #boat
# ───────────────────────────────────────
# † ship路径
# ───────────────────────────────────────
def draw_ship_path
# 准备绘制路径表格
sheet = Table.new ( $game_map.width , $game_map .height )
chase_path = [ ]
new_end_points = [ @moveto_x, @moveto_y ]
sheet[ @moveto_x, @moveto_y ] = 1
reach_point = false
step = 2
loop do #loop1 开始填充表格
draw_path = false
check_points = new_end_points
new_end_points = [ ]
break if step > KsOfSion::Break_Steps &&
!Input.press ?( KsOfSion::Find_Path_Key )
loop do #loop3 从终点开始反向填充
point_x = check_points.shift
break if point_x == nil
point_y = check_points.shift
left_x = $game_map .round_x ( point_x - 1 )
right_x = $game_map .round_x ( point_x + 1 )
up_y = $game_map .round_y ( point_y - 1 )
down_y = $game_map .round_y ( point_y + 1 )
# 判断路径是否连通
if left_x == x && point_y == y
reach_point = true ; break
elsif right_x == x && point_y == y
reach_point = true ; break
elsif point_x == x && up_y == y
reach_point = true ; break
elsif point_x == x && down_y == y
reach_point = true ; break
end
# 以需要抵达该点的步数填充路径表格 #
if sheet[ left_x, point_y] == 0 &&
$game_map .ship_passable ?( left_x, point_y) &&
!collide_with_events?( left_x, point_y) &&
!collide_with_vehicles?( left_x, point_y) #judge_end
sheet[ left_x, point_y] = step
draw_path = true
new_end_points.push ( left_x, point_y)
end
if sheet[ right_x, point_y] == 0 &&
$game_map .ship_passable ?( right_x, point_y) &&
!collide_with_events?( right_x, point_y) &&
!collide_with_vehicles?( right_x, point_y) #judge_end
sheet[ right_x, point_y] = step
draw_path = true
new_end_points.push ( right_x, point_y)
end
if sheet[ point_x, up_y] == 0 &&
$game_map .ship_passable ?( point_x, up_y) &&
!collide_with_events?( point_x, up_y) &&
!collide_with_vehicles?( point_x, up_y) #judge_end
sheet[ point_x, up_y] = step
draw_path = true
new_end_points.push ( point_x, up_y)
end
if sheet[ point_x, down_y] == 0 &&
$game_map .ship_passable ?( point_x, down_y) &&
!collide_with_events?( point_x, down_y) &&
!collide_with_vehicles?( point_x, down_y) #judge_end
sheet[ point_x, down_y] = step
draw_path = true
new_end_points.push ( point_x, down_y)
end
end #endOfLoop3
break if !draw_path || reach_point
step += 1
end #endOfLoop1 路径表格填充完毕
$mouse_move_sign .transparent = false
# 判断指定地点能否抵达
if reach_point
$mouse_move_sign .direction = 2
else
not_reach_point
return
end
# 根据路径表格绘制最短移动路径(正向)
point_x, point_y = x, y
for i in 2 ..step
step -= 1
if ( @moveto_x - point_x) .abs < ( @moveto_y - point_y) .abs
if sheet[ point_x, $game_map .round_y ( point_y + 1 ) ] == step
chase_path.push ( 2 )
point_y = $game_map .round_y ( point_y + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y - 1 ) ] == step
chase_path.push ( 8 )
point_y = $game_map .round_y ( point_y - 1 )
elsif sheet[ $game_map.round_x ( point_x - 1 ) , point_y] == step
chase_path.push ( 4 )
point_x = $game_map .round_x ( point_x - 1 )
elsif sheet[ $game_map.round_x ( point_x + 1 ) , point_y] == step
chase_path.push ( 6 )
point_x = $game_map .round_x ( point_x + 1 )
end
else
if sheet[ $game_map.round_x ( point_x - 1 ) , point_y] == step
chase_path.push ( 4 )
point_x = $game_map .round_x ( point_x - 1 )
elsif sheet[ $game_map.round_x ( point_x + 1 ) , point_y] == step
chase_path.push ( 6 )
point_x = $game_map .round_x ( point_x + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y + 1 ) ] == step
chase_path.push ( 2 )
point_y = $game_map .round_y ( point_y + 1 )
elsif sheet[ point_x, $game_map .round_y ( point_y - 1 ) ] == step
chase_path.push ( 8 )
point_y = $game_map .round_y ( point_y - 1 )
end
end
end #endOfForLoop
# 如果指定点无法抵达或者登陆
return not_reach_point unless landable?( @moveto_x, @moveto_y , chase_path)
return chase_path
end #ship
end
评分
查看全部评分