查看: 850|回复: 0

存放腳本

[复制链接]

梦石
0
星屑
407
在线时间
1291 小时
注册时间
2013-1-12
回帖
3349

贵宾

发表于 2013-8-29 09:01:09 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
純屬給LBQ腳本:
  1. =begin #=======================================================================
    % @% k- L9 H  Z; G4 C5 B5 P) A3 W

  2. , |/ b3 s7 M1 W
  3.   Sion Mouse System v1.3e  s: [& J  e# E7 T7 @- I
  4.   
    ) W+ _' D; W1 P4 E3 W4 |
  5.   Changlog
    8 s  I4 b3 ?- Y1 z3 X# P$ u5 d# v
  6.   
    & D+ I5 l4 N- A8 \
  7.   2013.4.21 v1.3f3 X& \1 a/ P9 v& t" s" Q
  8.    
    0 ?. ?1 N& Q+ i/ Q' ~
  9.     1.3f 卷动地图 bug 修正
    / d0 n& t0 d9 w+ L1 ~+ w
  10.    
    " i. q  o# H* Y* `
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口( m) }! E+ |0 F! g! G
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    + g( a& V5 V- [/ X6 r# \- U
  13.                               Mouse.unlock_mouse_in_screen 解除锁定% w1 r  `6 q9 O5 [

  14. 2 z* B# T9 I8 e3 t0 T& w( f' V; W* I
  15.     1.3f bug修正) b% r, r0 T* j: y( [+ {0 U' Z
  16.   
    ! ?7 \5 {; b, _
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    9 V8 B5 r' A+ o: g
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    ' `& _; _3 z* @4 E8 Y
  19. 0 X0 b/ p7 v. d1 p
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处  U8 s' D# j9 k+ J- |( W6 J

  21.   k/ p9 l; e2 C; }8 p
  22.     1.3b 修正一些罕见的bug;. o" t% A2 ~6 m1 l: x
  23. 4 ?! j5 H( v- n6 v9 B: C9 D
  24.     1.3a 代码小修改;7 q  ]/ \/ T) U; O# R7 A
  25.           加入了鼠标点击启动事件的功能,& ?) V3 v8 T; `% v( r: t
  26.           在事件中加入“注释”: 鼠标启动  ,/ v2 X" ]2 ^/ G4 }
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    4 i- m3 N. k" x8 g% J' t
  28.   ) h. C) w; x* O/ U8 [7 P2 X
  29.   2013.2.12 v1.2. f+ t1 R1 ~# I; g# V
  30. 0 d3 [; p# @  _6 C9 G6 X. R' }
  31.     寻路逻辑优化;
    : N0 q; C6 S  u: @
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;: l/ r) O3 W9 P3 Q& J4 n, \5 G/ {& A
  33.     现在支持用鼠标来操作载具了。
    9 O% e: ]4 @/ Q% ^9 a! N1 X9 @/ A

  34.   ?3 g' K) V3 X
  35.   2013.2.8 v1.1; d: r) s  z* {0 U+ N0 s; o1 D
  36. 3 S! f6 @! t% D; w
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    , @0 W& U& C: V  C  a
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;' U, j: ~; c5 D& u  x8 h
  39.     移动时,路径指示点的绘制更加稳定;* d% w) X0 G( }% J6 C" r
  40.     现在支持默认存档画面的鼠标操作了。: C) H: {3 L( i  }5 J4 v' b* J9 R

  41.   c, z) s9 u5 U3 w4 n' t
  42. . c/ [+ }5 `' u
  43.   OrigenVersion
    ! ~! A5 Q" B% [
  44.   
    3 }5 V2 F# H  B" z2 U
  45.     2013.2.7 v1.0 7 ~& H7 ]* S) R! ?- a
  46. - r3 p( i9 ]$ ~9 v( k7 W' l
  47.   主要功能
    , d9 f# s: _, m

  48. " @9 g9 Q5 W  ]$ `$ g2 I
  49.       使用鼠标进行各种操作...
    3 v& {$ y$ B) h6 J. Q- I
  50.       将鼠标锁定在游戏窗口内1 s6 ?3 K% g  c/ l% h
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    , D/ R  o4 F$ D+ L
  52.       双击鼠标进行冲刺
    1 R/ V. f* V8 E0 c7 l7 `7 D
  53.       更改地图卷动方式以适应鼠标移动' O, v/ A& k: a8 j+ B
  54.       变量输入框改良
    1 r, x  q; ?8 Q( d( U

  55. ) b8 O) O8 Q- i* }4 `8 L  v
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    ; M# C# v/ V( U

  57. 6 g4 a/ l( g9 Q9 D- f8 e
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹& I/ `: Q) W' C
  59. * Z# ~1 C6 N' M; F
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    8 |) F. M8 Y2 @

  61. * A% v& d# g1 X2 d3 ]0 T) i$ {. z) s5 U

  62. 7 M% ~% j+ x; I$ p
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    , S; x2 `" g, F2 `, x2 m' K# c4 s
  64. 8 [9 X  c: y9 B  d1 B! p( K
  65. . R* h/ V! Q' W3 w% o; x8 y. G$ U& s. f
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示- b! g0 }7 k( F/ k- q$ p" |' I

  67. 7 d* Q5 R# v* A7 V: c! C
  68. #==============================================================================( e) C# ?  p6 g+ k- ~
  69. # ■ 常数设置
    3 }# Q" h9 _+ z) e1 o; B+ F
  70. #==============================================================================
    # G) T2 U% `& i0 D4 C2 i0 j5 H
  71. module KsOfSion. B" x9 [! r, Z7 u
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false* [/ n0 i3 y; {* N2 C7 w3 z
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑1 n  D2 ^3 [1 x8 u& }8 K
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false0 O) `& x7 c1 I. c: ^7 c8 p/ x! G
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    9 L/ N  [# H9 w' [2 p
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    / j0 r" h; k$ L9 y  s8 y/ M& H. c
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧" X: ~  ^/ o8 u
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13); E! u0 c/ ~2 T; e( o
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    " m) [/ @, F, R% f! p
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)2 g& M! C/ S5 B4 v& U. c) o
  81. end
    0 [) ^: A7 [6 D/ k6 `. j

  82. % R0 e5 L- H# f# `: C& _' r2 s
  83. #==============================================================================
    ( g" v& `: a& z  y2 \- Y
  84. # ■ 用来显示路径点的类
    , _$ |; e' h6 O, a$ k5 c
  85. #==============================================================================( h* B2 n3 X# [
  86. class Move_Sign  Game_Character& t0 Y: X% y7 h/ D' m
  87.   #--------------------------------------------------------------------------
    ; R& {# G% K: |5 S6 s* m
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    7 d. n6 G2 M: g- m. W
  89.   #--------------------------------------------------------------------------
    * |3 N4 w. h# W1 r, |: ?, f$ I8 P
  90.   def init_public_members
    " k3 N' F2 M0 t! v& J3 o! x3 P
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹! u* N7 R1 x" M/ z5 H
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    . k& u$ [2 r. x( G- I0 q
  93.     @move_speed      = 5        # ★ 踏步速度# f8 \$ Z. c# d: m( q8 ^
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    " T1 {9 E# O7 [8 s! b. B) d
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    : J1 k7 p& _8 F4 f* J* {
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)3 G7 v! g2 \8 q4 |2 x# o% m) E
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    ' Y: ^! r! T7 U
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    - h! {& ?3 j9 V; U. W8 P2 _
  99. ) K6 D& B0 i( _3 ^7 h2 Z* @9 a$ w

  100. + f  n5 s! C: c1 j4 r1 e
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    ; Q: X, E0 v& c8 r/ N3 \4 h

  102. 1 O" s* d+ {9 Z

  103. 5 m* u, u4 d3 b& Q' P- u) A) H2 H
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图; e/ y' j" P6 y
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    ; P( _. t; N" Q
  106. : _( i0 z8 ^8 ]% E
  107.       if $no_arrowpic_warn: U# i0 G8 A4 q4 K2 c# K3 K
  108.         MouseShow_Cursor.call(1)
    3 ^+ U( b: m4 B3 B
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png, q* s3 }7 ~4 B

  110. * q$ Z+ p$ h& g* F- C# N9 X
  111. “路径指示点”将使用游戏自带图片$ P& f) h. G$ {; l5 ^7 @

  112. 0 h, D7 K3 _5 D: U3 @
  113. 该提示可以在脚本内关闭')7 i  J7 Y6 t; J! H
  114.         MouseShow_Cursor.call(0)
    - p% ]# W1 M& V' n- B
  115.         $no_arrowpic_warn = false
    ' u6 n, z7 U7 l
  116.       end
    % F" q+ [; w5 v  U6 ~4 w
  117.       @character_name  = '!Flame'! X* K3 h2 d) u, y
  118.       @character_index = 66 ?& u& X9 K8 X' X
  119. : b, V( L! ^6 y
  120.     end
    # b2 Y) U. M3 W3 F1 O$ U# s$ v
  121.     @direction_fix = false  # 固定朝向6 B% v- y& P/ C$ ]) P& O
  122.     @move_frequency = 6     # 移动频率
    " Z$ o% m  a6 ]& Y1 K
  123.     @walk_anime = true      # 步行动画
    0 s. }5 ]8 @$ E
  124.     @pattern = 1            # 图案1 L. _/ k7 X. J2 F  K/ R6 ~& H
  125.     @through = true         # 穿透" I# C/ C& \8 v; X, n; `
  126.     @bush_depth = 0         # 草木深度
    4 ?1 Q3 [( T8 R+ V9 w! _5 j
  127.     @animation_id = 0       # 动画 ID
    , ^3 l" l% g7 |+ P+ d* v1 ?
  128.     @balloon_id = 0         # 心情 ID; ~6 d8 E  l3 s8 `
  129.     @transparent = true     # 透明
    " `! Z- M1 @6 C" I
  130.     @id = 0
    8 z5 a4 V) o4 N! r8 p- S
  131.     @x = 0; l2 y; k, i0 q
  132.     @y = 0
    # H/ ~  `' ~, d  m
  133.     @real_x = 0& w, z9 N6 n. A4 S
  134.     @real_y = 0
    ! F! j. D6 x4 ^: e4 q9 e5 [5 h
  135.     @tile_id = 0
    3 {6 _2 R1 W8 @) z( Z2 _; h9 f! ?
  136.   end
    . `/ e3 w! c; R
  137.   #--------------------------------------------------------------------------# z) z6 i: Y$ ~1 Y, a' h6 b6 L
  138.   # ● 定义实例变量- D0 R8 S( R% f& R8 C
  139.   #--------------------------------------------------------------------------
    ' w. p5 o! F" K6 o& h
  140.   attr_accessor direction1 R/ E& X/ f% i* w: |4 K
  141. end
    & l5 t9 o  O" p; d- X

  142. 1 i% F7 ~$ g; o
  143. #==============================================================================
    7 G! F$ N& g- ^5 |1 Q3 Z
  144. # ■ Module Mouse. H4 h+ o' ^! o" j/ g% S1 j
  145. #==============================================================================
    9 [4 J# n9 A+ P1 W: ]
  146. module Mouse
    3 f' i0 k& B4 N, m$ O: S( K' ~
  147.   #--------------------------------------------------------------------------
    % v9 ?- d1 k: b" w6 |, H; r
  148.   # ● API
    : I, g- E5 E7 v2 s4 {1 u3 T) J- }
  149.   #--------------------------------------------------------------------------
    5 X+ k  q1 C- [
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    2 b' |9 V. S% }- I! R/ u
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')& t& [& J# H( ~) s/ a) E
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')4 \- _% p2 v) I6 e5 N5 A8 s( H7 v+ {
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
    0 D% C3 Q; z9 u7 j7 X
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    6 t5 i6 V+ V, ]  n* J* r* y; s. y
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')8 l, P( \! U7 c" ~5 Y
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    : Y+ u+ ~4 w% n* D2 ^
  157.   Window_Hwnd       = Get_Active_Window.call* h9 n5 X6 W- o2 f5 x# ?0 A: S

  158. 2 q. `4 X2 g5 {
  159. class  self
    , {: }! H1 s3 g4 `7 Q* a9 O
  160.   #--------------------------------------------------------------------------5 S& l6 @& c! z% x
  161.   # ● 初始化
    ) g  Q9 E& N3 E" m; h1 M
  162.   #--------------------------------------------------------------------------
    ; X% v6 k% T' ?9 ?) D  D8 R
  163.   def init& }7 X. v1 \3 o! E- U8 W
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor  i, ^1 y' g& U- m+ M' [2 ]
  165.     @left_state = 0- X; P" [. e, i& _8 g, T/ D
  166.     @right_state = 0
    ( l( {1 a! }, L9 f# z' h5 D
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    ' d. s% L5 _3 v! S9 C' [: l
  168.     @dk_count = 0 # 用于双击的判定
    7 h) c( h0 r6 W& z! P& I& B
  169.     @clicked = false8 \. e4 i, @+ E! l0 r. d
  170.     creat_mouse_sprite
    0 G7 t; e' ^9 \. z3 k( l! k
  171.     update7 s6 G/ T! e7 L, I" t
  172.   end5 B3 ^7 x( l8 @
  173.   #--------------------------------------------------------------------------) e" g% y$ h. V4 w& z+ O1 w$ x
  174.   # ● 鼠标指针精灵- q: _; _- J& T9 v; A: V; ]- I
  175.   #--------------------------------------------------------------------------+ n. a( O( d: w% H$ h8 h! J9 I
  176. #~   def creat_mouse_sprite& X& m+ N, f. _2 ]8 X" b
  177. #~     
    3 q3 y; ^. I( [, S$ j! x
  178. #~       @mouse_sprite = Sprite.new
      e% ]: o, X4 H1 I5 Z4 ~
  179. #~       panda = 2#rand(2)+1, j  N, F: h% `$ a7 N) }

  180. / L* q4 O6 I9 u5 L2 F9 H) i/ [
  181. #~      if panda = 1
    4 @# B( O( Z9 X. i4 B" I+ n' C9 Q
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    " p# H5 k8 f0 J. X
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')) g  R! F5 I9 u8 Z1 C5 r
  184. #~        end#with if File.exist
    ; _7 \2 A7 V1 h$ v! }- [$ _' _& S4 c; D
  185. #~   
    8 m- }' p; E& p- t4 z
  186. #~     else if panda = 2 #with if panda=14 z8 L9 a* s* w; O
  187. #~      
    * E& Y# s; F9 I
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    9 D( g* a9 _" f5 u0 f( j: r
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    7 }2 W) W- q. K* }! i
  190. #~      end#with if File.exist2 o# @+ z- V/ A' m! Z3 M: X
  191. #~       , \& k! C+ I# Z& U! N; i2 W, E
  192. #~     else #with if panda=1; N9 l- Y  z# `! A$ W9 t* N7 y
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)& M, z1 j( o- O4 c9 S
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),/ k$ C- C: p/ [! Y( r0 X) N
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    % J0 g8 M- A/ r. ]7 [
  196. #~     end#with if panda=18 Y, c6 X- v% @$ V) X$ M/ w
  197. #~     
    7 Z0 ~6 a5 a+ e* K% t% ?0 @, o* R/ ^1 B
  198. #~     #with def
    6 c' u4 b- R( |& }5 A& }
  199. #~   end! G( m& ~+ K, @. Q2 Z
  200. def creat_mouse_sprite8 L* M2 r; _$ E9 {
  201.     @mouse_sprite = Sprite.new
    + `9 \7 y7 G: E& L
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})8 m0 i* Z& y& P: {. R$ r
  203.     @mouse_sprite.z = 9999
    2 \5 {3 Z) l( L- `' |# ?, b, w
  204.     Show_Cursor.call(0)5 F+ W) Z& `) X# m/ x& d6 C  o9 f
  205. end# y8 i# W8 o, n
  206. + B4 O* M$ z6 A  S
  207.   #--------------------------------------------------------------------------
    " I; ^+ H6 \8 B' ^3 Z: {
  208.   # ● 更新
    8 O4 W$ ?+ u- H) }5 _! G
  209.   #--------------------------------------------------------------------------+ C% n5 D( ?+ Z8 T# o: j4 i
  210.   def update
    % c, w" M' N( \  e  [6 R$ L9 m
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
      A1 d6 P; H% U/ [* I1 G) i! z
  212.     left_state  = Get_Key_State.call(0x01)% u. j( D$ ~1 P
  213.     left_state[7] == 1  @left_state +=1  @left_state = 04 k% B. f6 |6 c" Y
  214.     right_state = Get_Key_State.call(0x02)2 W7 x" j+ e3 Y, U- _5 f1 J$ J
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0# g5 @5 [6 \; c3 L! M
  216.     update_double_click* v1 Z7 w9 |- C5 X" B) C
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    , J0 Y, X5 H  N/ O
  218.   end1 ?7 Y. ~% q: i
  219.   #--------------------------------------------------------------------------2 N9 [: x7 l+ r2 T8 a) w) S
  220.   # ● 获取鼠标坐标
    . K. k- ^, U' N* W
  221.   #--------------------------------------------------------------------------
    8 ]% e6 b/ [9 C1 s7 ^1 ?5 p
  222.   def get_mouse_pos$ j; o; e9 Q+ v: ~3 E5 ~; D
  223.     arg = [0, 0].pack('ll')
    ) A, _7 h# v9 X' @+ d
  224.     Get_Cursor_Pos.call(arg); o% ~9 E2 v( C
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    - t# @4 Y* v7 C6 q5 _! n0 }( U
  226.     x, y = arg.unpack('ll')
    $ K. V8 `+ S3 p' s: x; d; p
  227.     return x, y
    # D0 I5 K: b: {8 a. O" a3 g
  228.   end
    + P/ ~) T8 E; [
  229.   #--------------------------------------------------------------------------5 O! S/ ?: y7 W5 e
  230.   # ● 将鼠标固定在屏幕内
    1 d5 \* L+ [/ v4 {& t4 `
  231.   #--------------------------------------------------------------------------
    ; W# B7 d3 @4 h$ P/ h
  232.   def lock_mouse_in_screen1 ?: G8 R# z: U5 X. ?7 }; i; N$ ?- r
  233.     arg = [0, 0].pack('ll')
    0 ]& {% a6 S2 A  Y
  234.     Screen_To_Client.call(Window_Hwnd, arg)& a$ d5 ?* t+ J5 f* C
  235.     x, y  = arg.unpack('ll'), B. o" }+ O; ]# D% \: Y' K. P
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))$ i1 X3 e* J/ |8 B! j
  237.   end' m( B2 z3 r8 |% b' f- c7 k8 ^8 ~
  238.   #--------------------------------------------------------------------------4 ~4 G% u/ y  n) F% }2 D
  239.   # ● 解除鼠标固定
    9 q: x3 z4 F8 K7 q
  240.   #--------------------------------------------------------------------------& g2 t8 i. J9 Q$ w/ ~  E6 u* W" s
  241.   def unlock_mouse_in_screen
    8 ?, [4 D+ I, Z4 `3 H% }: a0 ~- r5 K
  242.     Clip_Cursor.call(0)
    * J6 r7 ?& K! [* t* a
  243.   end/ k% d* X/ z; R( p
  244.   #--------------------------------------------------------------------------
    ( e; O' E1 A7 F4 `2 w' c
  245.   # ● 鼠标双击判定
    ) {4 C4 F4 ~9 }3 ?6 u! C) G5 N2 g
  246.   #--------------------------------------------------------------------------
    6 v2 o9 w1 Q0 H7 z5 k. b% c. [
  247.   def update_double_click0 Q* z: o* j$ u7 a4 D" H# g# {
  248.     @clicked = true if @left_state == 1# H4 r1 x# p5 h/ g( [
  249.     if @dk_count  0 && @left_state == 18 [, _& z- N4 O, H' T$ p. I1 B
  250.       @dk_count = 0; @clicked = false, q$ a4 z, c5 p; y  p" f
  251.       return @double_click = true& T" E9 W, v$ J9 R) q
  252.     elsif @clicked
    1 B' ~* r; `9 x4 M" t$ V
  253.       if @dk_count  KsOfSionDbclick_Frame' f7 w* y5 Y  }! o
  254.         @dk_count += 1
    $ W$ o8 u8 c; k5 }( N  w0 b' u; y
  255.       else" B6 A5 j+ b, |
  256.         @dk_count = 0; @clicked = false
    4 {. C* g& Y5 K4 Y2 J
  257.       end
    ) f0 P4 `. e! |) N
  258.     end
    + r2 F2 w. O7 f. F
  259.     @double_click = false
    1 {9 B/ r1 z' T' z( p+ p$ B
  260.   end
    3 D$ A+ A6 G) B
  261.   #--------------------------------------------------------------------------
    / V/ u8 u  v; C1 ]! q0 G/ E* e  D
  262.   # ● 按键被按下就返回true
    8 v' Q4 G. C: D' K, v# a0 @
  263.   #--------------------------------------------------------------------------
    : s; X4 f- J' T& B
  264.   def press(button)" j* L: C# J# W9 T6 d6 \
  265.     case button& U7 ^& \0 s+ M- `
  266.       when 0x01; return !@left_state.zero1 ?9 Q4 u( n9 Z$ F% k6 t9 }, z
  267.       when 0x02; return !@right_state.zero( p9 S, r+ P9 v6 b1 r' M
  268.     end
    $ z: s% T( d) o
  269.     return false
    2 @9 X. S' U0 x; ^
  270.   end" E0 S, i9 W' o' Y4 J
  271.   #--------------------------------------------------------------------------' A. Z4 R% G7 f1 C1 a- q. e* S
  272.   # ● 按键刚被按下则返回true7 _2 }& Y. i# i0 h& U
  273.   #--------------------------------------------------------------------------
    7 m5 J, C; R4 M4 H/ x- W+ Y
  274.   def trigger(button)4 `  a4 [% W4 N
  275.     case button
    / ~6 M' u4 p/ k
  276.       when 0x01; return @left_state == 1) m# h0 a6 {8 n$ H, b6 i
  277.       when 0x02; return @right_state == 15 {/ f$ C, P8 N, f# ?9 K
  278.     end
    7 _8 k0 ~! w1 d" ?6 r# q
  279.     return false$ f; f' \: i6 X' d8 ?, d
  280.   end
    # s. O# m) w) M& `$ ]: O
  281.   #--------------------------------------------------------------------------
    8 Y& r7 u" E% @/ {7 r+ w# x
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true5 P+ X6 L$ T% \3 ~! g0 i; u+ n
  283.   #--------------------------------------------------------------------------
    ( ]( {8 m  ?0 e
  284.   def repeat(button)
    : v* h% t4 h: J
  285.     case button- u2 j  s+ ?0 N. U) i
  286.       when 0x01; return @left_state == 1
    6 H' S5 Q6 ]2 E3 t) x
  287.         (@left_state  22 && (@left_state % 6).zero)
    8 e1 U( J$ X% y8 I
  288.       when 0x02; return @right_state == 1
    / {4 M( P. ~' G0 R: G* v
  289.         (@right_state  22 && (@right_state % 6).zero)
    8 k, @" {' r: r# L
  290.     end* o0 q* X$ D& Z& f$ R3 z
  291.     return false- L' _* R  J. X4 ]8 k" H6 S. K
  292.   end
    ! u# z" b$ ]4 S* P6 E% Z. u; \6 `- s
  293.   #--------------------------------------------------------------------------
    + s" J+ T- E- J5 h) r& h
  294.   # ● 判断是否双击鼠标% y( \# q1 u: S# A" ?9 n
  295.   #--------------------------------------------------------------------------. F0 ]& {+ A9 L# v  ^+ h) d1 H
  296.   def double_click
    1 z* s7 F+ W! j" i3 B
  297.     @double_click
    ! q7 Y- v9 |3 P. \6 r" U/ B$ R( W7 l
  298.   end' [7 m! I" M( g! X0 l2 o* c
  299.   #--------------------------------------------------------------------------
    2 |# [$ a! i& n0 e/ H
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)3 Z0 J0 w* W4 t! c" a5 Q
  301.   #--------------------------------------------------------------------------
    ' G% A" C8 j) h+ Q1 l; W
  302.   def click_count
    $ i% G6 w2 H1 C3 |: M
  303.     @ck_count! p: L# V1 x. Q3 t# J: v
  304.   end+ P8 p9 p7 M! [5 D
  305.   #--------------------------------------------------------------------------
    - P/ C) b3 e& n2 L! \8 q
  306.   # ● 获取@left_state(按住左键每一帧+=1)3 C9 W* [  h, p  S: [( _8 a
  307.   #--------------------------------------------------------------------------$ C: W7 Y3 e0 j$ w
  308.   def left_state. g& u9 L( u1 Q* l' h7 A& j
  309.     @left_state* l' g2 o+ e. @# W( u
  310.   end
    4 A8 @: w0 a3 \, }' a
  311.   #--------------------------------------------------------------------------! T7 @% [7 x6 w  }2 v3 C) I! E8 f7 F
  312.   # ● 获取鼠标的x坐标% f6 J6 J  `9 c) n  M/ F0 ^
  313.   #--------------------------------------------------------------------------
    8 Z% z9 W* C3 A( \2 B0 [' ^
  314.   def mouse_x
    2 T: ?. ]1 B/ G" ?3 V6 f
  315.     @mouse_sprite.x# l3 |6 h% m" p$ D
  316.   end7 [* t7 a" p1 n4 F' u  i
  317.   #--------------------------------------------------------------------------, }) l$ a0 N6 H9 B! `* a
  318.   # ● 获取鼠标的y坐标
    8 _- m9 x/ ]" Z$ J
  319.   #--------------------------------------------------------------------------
    + K: G: I1 F+ x+ X
  320.   def mouse_y
    9 W/ z3 _5 x8 Q/ K# Z! V/ O
  321.     @mouse_sprite.y
    & ^" T1 p7 V. F
  322.   end
    8 Y0 N8 V8 B9 o6 _# ]! I
  323.   #--------------------------------------------------------------------------; m+ R5 j3 V8 O5 l: I
  324.   # ● 设置鼠标坐标
    + N! B8 q6 b- O
  325.   #--------------------------------------------------------------------------: S% S. K9 W; @- l: p
  326.   def set_mouse_pos(new_x, new_y)4 U' E) I$ M# j4 W- j
  327.     arg = [0, 0].pack('ll'): m" A+ [7 L" U9 w8 I5 T7 `" K3 r" X
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    8 D& l" B5 |! L9 k2 j2 R" Q. w
  329.     x, y  = arg.unpack('ll')1 }$ Z* k9 O% ~$ Y: s
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    # L) Z7 c' z0 ]$ i1 v. _
  331.   end8 Q4 p! u, i1 |( [
  332. end #end of class  self
    , r. o' w/ u3 n8 ?0 {( R
  333. + d/ K/ B- v0 J5 N: I3 J
  334. end- V" p8 y' ?* S* }8 ?9 L
  335. + {* z5 m" V* J2 q! w' ]% V- n  p4 ~
  336. #==============================================================================
    5 N3 F; H& x' Q3 k' }' @
  337. # ■ SceneManager
    ; y9 O# y$ [9 z+ O/ k" d
  338. #==============================================================================
    ( e6 K1 a! N+ @, w7 Q9 B
  339. class  SceneManager
    ! C4 p+ Z; P0 c$ {7 }* z
  340.   #--------------------------------------------------------------------------
    6 o0 I0 n2 T( p. g& S( E
  341.   # ● alias
    $ `- a$ y+ A9 d# f
  342.   #--------------------------------------------------------------------------4 B( J5 k; G6 g: T- |& n8 I9 n8 n+ }
  343.   unless self.method_defined(sion_mouse_run)
    9 o& l) t$ @, x9 b8 n9 d- e7 s
  344.     alias_method sion_mouse_run, run
    % x3 k: o5 G! _
  345.     alias_method sion_mouse_call, call! E/ \7 T! V$ b: F2 X0 g: Y; E7 G, d
  346.     alias_method sion_mouse_return, return, y! h, L0 u5 t) }
  347.   end9 w+ Z3 |3 c8 n
  348.   #--------------------------------------------------------------------------
    + t( }8 d! M. C" l% x  P) t
  349.   # ● 运行  B" N4 E1 F9 e! I# @/ @8 [9 \7 Y" ?6 o
  350.   #--------------------------------------------------------------------------
    % `5 a, J' C' t/ @, q9 Z: \5 h
  351.   def run5 c0 V4 Q7 s6 q% W/ Y- {) A+ O& ?
  352.     Mouse.init
    ! G' Q  `! }% U
  353.     sion_mouse_run
    ' J% W9 T/ r, I( \9 ~- Z
  354.   end
    8 {& C7 k  F% ~) u8 A
  355.   #--------------------------------------------------------------------------
    1 {0 J& |) r# U/ A0 E5 T/ e+ ~
  356.   # ● 切换* @+ I4 [$ e( O2 h- F; }' E
  357.   #--------------------------------------------------------------------------% y( h. N- o' \* H5 |
  358.   def call(scene_class): [% R* E/ q0 t/ P0 e
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map). l2 g3 H! n, t' x
  360.     sion_mouse_call(scene_class)9 E. C1 x* {) i" _
  361.   end
    2 L: I, S0 V3 l  M
  362.   #--------------------------------------------------------------------------
    4 y0 l; r' z9 ~( h' w" ~# {* D8 G
  363.   # ● 返回到上一个场景
    4 ]( d5 I! r' ^# S$ w
  364.   #--------------------------------------------------------------------------
    * v* g7 M: q7 z' s* H% b
  365.   def return+ G. N/ {5 s$ v5 \/ F- V, o
  366.     sion_mouse_return
    * v& C9 t/ a  J4 j+ L
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    * Q! s6 ^4 V/ u( q
  368.       @scene.instance_of(Scene_Map), \. Q- I; `! {- {% `2 t
  369.   end: x$ v' h5 [$ Y! D8 n
  370. end9 a; J# r/ T+ _" q+ p- Y

  371. 4 {5 \6 v% S. [& m, f% I
  372. #==============================================================================, D8 M" f$ b; w" b) |5 K
  373. # ■ Module Input
    $ Q9 U+ K! `: F. ]
  374. #==============================================================================
    2 y2 G# [2 n( p( ~+ P, v5 o: P
  375. class  Input2 [% h* J- @9 Z+ \# u# w
  376.   #--------------------------------------------------------------------------2 t. s3 e9 u/ N
  377.   # ● alias
    ( G1 j. W6 o/ L# h
  378.   #--------------------------------------------------------------------------
    . P0 U: H, v7 j7 v) ~& t! S
  379.   unless self.method_defined(sion_mouse_update)
    $ L8 P  m3 i% H/ g$ @
  380.     alias_method sion_mouse_update,   update
    4 M( j4 W! n0 \; a& K1 Y
  381.     alias_method sion_mouse_press,   press
    0 G( i9 t" M" h) V* n
  382.     alias_method sion_mouse_trigger, trigger
    : b( k1 r( p1 H4 @4 ?: K9 P
  383.     alias_method sion_mouse_repeat,  repeat
    ( O- K2 y" `  a/ X' J7 C3 ^/ N
  384.   end
    - J  T$ `) X% S7 e
  385.   #--------------------------------------------------------------------------
    - w7 m, W, Y) M
  386.   # ● 更新鼠标
    2 i: Z5 }  N: E& ~. P
  387.   #--------------------------------------------------------------------------! F0 v. S1 F: s; H! m
  388.   def update
    3 S# ?6 m# U; Q
  389.     Mouse.update" E7 O  G" }1 G4 f) _6 c( J9 O
  390.     sion_mouse_update
    2 R" s/ Q" J8 v8 N8 _( a/ d
  391.   end, D7 |+ }' h; L0 U
  392.   #--------------------------------------------------------------------------
    8 \# l1 Z3 q. l" |
  393.   # ● 按键被按下就返回true7 V+ @/ }8 [' N# [6 E
  394.   #--------------------------------------------------------------------------) S  z: U1 k$ \" |' I
  395.   def press(key)
    1 \+ h& J8 z* ^9 T* ?
  396.     return true if sion_mouse_press(key)
    ) p+ [  F1 O# n
  397.     return Mouse.press(0x01) if key == C
    * \4 d, ~2 S" V) B' A" S
  398.     return Mouse.press(0x02) if key == B4 o' I( U/ `# _: e* C' ]. s- s
  399.     return false
    / m3 `* W2 v( D$ y0 k8 ~7 M
  400.   end2 }9 ^$ ?0 P! i9 i' i% b/ o+ @
  401.   #--------------------------------------------------------------------------) V9 P4 H" \/ o
  402.   # ● 按键刚被按下则返回true
    6 z& F' Q6 Y3 q1 G
  403.   #--------------------------------------------------------------------------
    6 d/ Z1 w1 d# s9 e% J1 L- \
  404.   def trigger(key)
    / P1 ~; ^1 s1 p9 M2 t: w# l
  405.     return true if sion_mouse_trigger(key)) d9 a( t5 b$ I9 x
  406.     return Mouse.trigger(0x01) if key == C8 t) K: A% U+ Y# ]6 K* b1 [
  407.     return Mouse.trigger(0x02) if key == B
    5 p1 i* U) ], ?/ A
  408.     return false0 f4 A9 ~. e% P0 Z8 U) A' q
  409.   end4 q7 B- ?6 H* ~" V" m& \
  410.   #--------------------------------------------------------------------------- C8 G- |  k! B+ Z% Z+ T& v
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true" q+ T, x* c# ?/ @7 P- b& `, V
  412.   #--------------------------------------------------------------------------
      J, C' D" s' f8 u1 l- C# R
  413.   def repeat(key)
    / B' ?  j! k: k: P7 Q0 h
  414.     return true if sion_mouse_repeat(key)6 X/ A2 i1 Y/ K# M$ g! F
  415.     return Mouse.repeat(0x01) if key == C+ B+ Q' G( H: c2 e
  416.     return Mouse.repeat(0x02) if key == B0 `- _+ `! m" C. v' }
  417.     return false% Z: x: |7 x4 k' m+ _5 C$ Y/ x
  418.   end% R! p2 ]* C9 e- E
  419. end
    % K: Z7 ^  `6 c2 n% F
  420. 0 a# t# Z: J( \+ J" S

  421. " P6 U/ M& k6 Z$ w( T
  422. #==============================================================================
      E. N" l6 c* B; v
  423. # ■ Window_Selectable8 {) T0 I( `' ~: A/ E- \
  424. #------------------------------------------------------------------------------. ?  z" P' u- |* }, \& U
  425. #  拥有光标移动、滚动功能的窗口, w, I% \, Y' Z2 W8 X1 ]
  426. #==============================================================================
    , m' C* e( W, J* L
  427. class Window_Selectable0 ^' W" F  U: u$ V% r1 K) ?, F
  428.   #--------------------------------------------------------------------------4 @$ e1 X9 l1 G6 L) y/ `
  429.   # ● 初始化" q+ k. h6 c( B9 f
  430.   #--------------------------------------------------------------------------
    ' J8 M  u8 p' S+ R7 w: X$ G
  431.   alias sion_mouse_initialize initialize
    ; \( D0 }  u! I
  432.   def initialize(x, y, width, height)
    , W( _! @* v! |3 x, _7 O
  433.     sion_mouse_initialize(x, y, width, height). t5 M6 H' z0 O( \2 x
  434.     @move_state = 0
      W( A9 e8 V2 L6 `6 {$ Y
  435.   end8 u$ T0 n6 [/ q# n1 P) f6 r
  436.   #--------------------------------------------------------------------------3 b( I& U+ m2 M/ z: J+ q
  437.   # ● 更新
    5 x* _, H- u; p' w2 A
  438.   #--------------------------------------------------------------------------  u8 d6 Y1 h/ `7 c- N2 ?. g0 K
  439.   alias sion_mouse_update update' o  r. g4 d8 ^3 N6 m& v& f7 V
  440.   def update
    / _* R& Y# z& ~$ b& u
  441.     sion_mouse_update0 R& I; p; |0 j
  442.     update_mouse_cursor. K. `% i. H4 r! l5 m  M
  443.   end
    9 P7 X) {4 s6 s
  444.   #--------------------------------------------------------------------------! ?5 d! R( _0 }  B6 x
  445.   # ● 启动后设置鼠标到index位置
    ' l6 m; e7 }" C& K2 i' [
  446.   #--------------------------------------------------------------------------
    $ x9 V4 _" V2 {2 W; a0 a! j$ Q! [. K, r
  447.   def activate- R; Y0 x0 ~6 D0 d4 ]: _
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    2 l. F9 ]$ w, p! K' V
  449.     super
    ; O0 h7 m. x: D* s. ?7 L4 J
  450.   end
    2 _/ b8 ]( Y! r1 G& o6 h8 _
  451.   #--------------------------------------------------------------------------
    % R; {) P1 B  [. g1 e7 b) Q
  452.   # ● 更新鼠标和光标的位置
    + K; }' z; H; y! V0 X' |: P) d5 v: t' [  o
  453.   #--------------------------------------------------------------------------
    9 @" H3 Z% ]3 b5 V: Z. |
  454.   def update_mouse_cursor
    8 f- D2 W+ {- D/ K( `2 B
  455.     if active
    . }: ~4 j9 h, ^6 _# t
  456.       if @need_set_pos- M$ ?* }$ O% U
  457.         @need_set_pos = nil
    5 n% [: i- T+ r! d1 Q7 x: P; H
  458.         set_mouse_pos
    # v* U* y& x+ l9 A, q+ z8 e% ]- s
  459.       elsif cursor_movable. L, L9 `: A! T7 x
  460.         Input.dir4.zero  set_cursor  set_mouse_pos1 c" k8 j/ D0 |2 S
  461.       end
    * w1 e' D4 o& |. A+ Z: h
  462.     end
    1 X- c6 b1 c: s6 D/ v2 V# K
  463.   end0 Q% v5 b4 f# j8 u8 K  J& `
  464.   #--------------------------------------------------------------------------/ s- r" k/ ^4 z) I+ _. y
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    ( R" E. o# M+ _9 y. C+ s4 a: R
  466.   #--------------------------------------------------------------------------
      g$ c: Q! k) f; Y7 _2 v. Y
  467.   def set_cursor
    3 M% W, G1 G; g' ^8 n) g  C4 |
  468.     mouse_row, mouse_col = mouse_window_area
    / M6 C$ `4 Z$ Z# k# m) {
  469.     if    mouse_row == -1# l! G; _) X  `9 K8 t3 k$ ^
  470.       @move_state += 1 if need_scroll% {% a: ^2 k/ u  y  s
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand* _. I4 T+ v; S, B$ A
  472.     elsif mouse_row == -2
    ; {( [8 g3 s4 D4 z
  473.       @move_state += 1 if need_scroll
    7 w& t& A& X5 U
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand3 z3 W5 Z& v7 H
  475.     elsif mouse_col == -1
    $ q+ Y0 E# R, f
  476.       @move_state += 1 if need_scroll. K" ?: ?/ O0 s8 f9 r
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand& m" f9 p, |1 g
  478.     elsif mouse_col == -2
    / H* Y8 k7 v9 B5 g" O) a
  479.       @move_state += 1 if need_scroll
    4 B; [/ i" E! |- B2 ?
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand: I3 h: }, |3 \) x
  481.     else- y. `8 u3 g6 j6 k: o5 c
  482.       @move_state = 0
    / v% W, n7 g9 `. e: n# N
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    6 ]. w5 o2 w6 a
  484.       select(new_index) if new_index  item_max && new_index != @index
    6 G9 _* V  j4 Z. }1 r6 w! k
  485.     end, K* i0 x( L+ k( ~+ Y
  486.   end
    3 }- B8 S7 \) d8 ]* h5 @: M
  487.   #--------------------------------------------------------------------------) e6 H* @# m8 {
  488.   # ● 判断鼠标位于菜单的第几行、第几列5 T8 F- i) t9 O% T: \
  489.   #--------------------------------------------------------------------------
    5 J# I3 [7 U% U- r- q6 F
  490.   def mouse_window_area% u: _$ B8 d- S1 |
  491.     if viewport.nil # necessary!
    2 E8 |2 o5 G& e. a9 }5 ~( J
  492.       vp_x, vp_y = 0, 0: j5 h6 h1 r4 U9 C
  493.     else- q+ u6 l- _( x) s$ J2 z; F
  494.       vp_x = viewport.rect.x - viewport.ox$ `+ X; q2 b' D$ l
  495.       vp_y = viewport.rect.y - viewport.oy) O" M8 _# E% I4 M# v% {$ Z
  496.     end+ K: E9 P6 o* A: p5 I8 s% o+ E( p
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y7 c( N" G7 y7 d3 h  r/ I9 w
  498.     item_x1 = vp_x + x + standard_padding 3 S' _1 }' u- [; e- }
  499.     item_y1 = vp_y + y + standard_padding% v% i& _% v( {7 e" m0 H3 R' F
  500.     item_x2 = vp_x + x - standard_padding + width
    6 `; a& H  z  c% _* `) m8 I& c8 B
  501.     item_y2 = vp_y + y - standard_padding + height; I& ?, P4 R. n1 Z, T
  502.     if mouse_x  item_x1
    6 q: g% q  ]$ o0 U  ~5 ?
  503.       mouse_col = -1# `* ^  t  _+ R' {
  504.     elsif mouse_x  item_x21 U1 l- w7 Z3 i; r7 ]( r
  505.       mouse_col = -2
    1 ^( M( R1 d' K* o' D
  506.     else
    " W5 i: n# T, R/ l
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)# O) s' E9 V, R9 q4 V1 m, f7 i
  508.     end
    1 c1 [  N, |# ]; b
  509.     if mouse_y  item_y16 l9 U- H' f, @) G6 N' t4 i
  510.       mouse_row = -13 G* b+ k6 Q; |. H$ D% P% f. V  Z; x
  511.     elsif mouse_y  item_y22 ^# A: e+ t3 X" Y7 m+ H
  512.       mouse_row = -25 V6 f9 Y& V7 Y. W! h' ]6 e4 p* `
  513.     else
    + j- r8 E- q1 o
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)3 u+ T* P9 a  {* D5 k
  515.     end: N; \/ \* y& f+ T1 |2 a
  516.     return mouse_row, mouse_col4 r' f' \1 T2 w( H
  517.   end, ~/ a0 c6 q2 E) }' L/ r8 Z6 |- p
  518.   #--------------------------------------------------------------------------$ F" u6 v- G" p% e" ?- G; a6 H! {4 h: G7 X
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置$ X# J0 W4 O- K2 c/ @' s* T
  520.   #--------------------------------------------------------------------------2 J. r0 ?9 o9 T  h7 D, a+ G# q" W
  521.   def set_mouse_pos
    5 _+ S- w- s* g9 I% i8 Y: w+ U9 O, p) ~
  522.     if viewport.nil # necessary!1 d( W; ~* W, d% ~
  523.       vp_x, vp_y = 0, 0
    & s! f: D1 L' z  F, N7 H
  524.     else
    , [2 i( S( \* y
  525.       vp_x = viewport.rect.x - viewport.ox9 A& p6 i% T: x) @
  526.       vp_y = viewport.rect.y - viewport.oy5 x$ d+ I6 |1 n" F$ U
  527.     end( h, c, ?  n: A. y
  528.     item_x1 = vp_x + x + standard_padding ) w7 i% I0 `+ {
  529.     item_y1 = vp_y + y + standard_padding
    ) G' j0 V! R( D2 K
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index & P6 [3 p  n, Q- T0 S  e2 z2 ^- @) e/ u
  531.     row = get_index  col_max - top_row
    7 Q0 L# o2 T) J! r8 {
  532.     col = get_index % col_max
    5 U, F6 k1 y& [
  533.     new_x = item_x1 + item_width  (col + 0.5)9 e+ R" Q" a. Q: @& q: A
  534.     new_y = item_y1 + item_height  (row + 0.5)" e+ ^+ s3 B5 O. C) C. z% `
  535.     Mouse.set_mouse_pos(new_x, new_y)
    , S; D# Z4 ?' \
  536.   end9 F& V1 x) F3 h6 r! E7 W1 E6 f8 P
  537.   #--------------------------------------------------------------------------( ?( E: ]5 m% g
  538.   # ● 判断菜单是否需要卷动4 U3 U% |5 [8 X& r+ @
  539.   #--------------------------------------------------------------------------. A% {9 ^+ q/ q/ o
  540.   def need_scroll
    % }+ e# E' `% D0 o$ }/ O' T
  541.     item_max  col_max  page_row_max8 p+ [" t2 F4 i- ^
  542.   end1 C- ?7 b1 z* u
  543.   #--------------------------------------------------------------------------
    9 R* w0 v8 m8 G' H. w3 y0 r0 x. r3 d
  544.   # ● 判断是否为水平卷动菜单
    ( ?; I5 G/ `6 }2 ]4 Y2 Y. O7 R
  545.   #--------------------------------------------------------------------------
    ; ~( [! i6 n* K% R
  546.   def is_horzcommand; E" Y( z+ \+ Q
  547.     return false
    * E7 g3 N/ H: ]2 [/ j# |  c) W
  548.   end
    6 h$ K2 F" H6 Z! m9 W9 g2 M
  549. end# d8 [7 h" v$ x% c: X% ?* ~

  550. : w$ y8 E* s4 l. R. c
  551. class Window_HorzCommand! D$ [$ H* \! Q: O) T" ]: C& j
  552.   #--------------------------------------------------------------------------$ V4 E) W) `) M+ b* a
  553.   # ● 判断是否为水平卷动菜单6 N- p8 _* h5 ?6 Q0 w2 P' N; y, z
  554.   #--------------------------------------------------------------------------
    / K" u+ _  u8 w4 d$ p1 c: P3 V* R
  555.   def is_horzcommand/ [% Q2 Y2 n1 D) k2 Q
  556.     return true( i0 M; D, {8 q2 j: f" H9 R
  557.   end6 |$ z( G- S4 v2 a5 J1 R
  558. end1 R, r% L) M6 {2 v
  559. + j% e$ {" A8 Y8 W- k' b0 c
  560. #==============================================================================! b+ c% ]' ^# U0 V# Z
  561. # ■ Window_NameInput
    2 i. N; |4 m2 o, h; x
  562. #------------------------------------------------------------------------------
    % H8 _1 J, ^% y* P! j, G+ G: K
  563. #  名字输入画面中,选择文字的窗口。
    ) f0 l; g( _6 @2 p3 }7 `! T
  564. #==============================================================================3 n1 S0 a4 y6 f  k  e
  565. class Window_NameInput* G( _4 u6 Q4 A8 E, Q: Z
  566.   #--------------------------------------------------------------------------: s5 R! v8 N& @3 Z, g) s1 y4 s& C
  567.   # ● 设置列数7 L9 x' z4 c8 c  K3 H# l# D
  568.   #--------------------------------------------------------------------------
    " m" \: U# S5 S. m2 x8 q$ \3 f
  569.   def col_max: s  C, T! W0 L
  570.     return 10
    0 M( D- Y/ Y' q5 [9 ~
  571.   end
    ( J) G: P% ]- [; ?5 M
  572.   #--------------------------------------------------------------------------8 s  u. r: c5 g" f& n5 \, s6 C
  573.   # ● 设置填充的Item个数! P3 q1 H# p/ M# G
  574.   #--------------------------------------------------------------------------
    . X  G: K* f) W# F
  575.   def item_max
    + E0 J% z' `, a7 z0 D0 _  g
  576.     return 903 Z  ^2 K7 o- k
  577.   end
    6 {: w# X. G: V$ d4 C3 a7 t
  578.   #--------------------------------------------------------------------------
    + Q" _" Q  \4 L6 f* \9 Q0 P
  579.   # ● 设置填充的Item个数) ?1 R; q/ s0 F
  580.   #--------------------------------------------------------------------------
    0 G6 |$ f9 Z# c
  581.   def item_width, }, w  u9 }/ ^4 h% j: \' M* b" C( |
  582.     return 32
    * l! o3 ?% @3 j" m  p% }
  583.   end9 n: I8 N. Z! J1 q
  584.   #--------------------------------------------------------------------------  X  X' i6 t& o5 m* g
  585.   # ● 判断鼠标位于菜单的第几行、第几列$ x' F7 I) S+ Q6 [8 F
  586.   #--------------------------------------------------------------------------3 o, K+ Z0 M2 l8 T% M9 X
  587.   def mouse_window_area
    % w0 C$ l" D9 y
  588.     if viewport.nil) ^/ Z" Z* R+ ?! X
  589.       vp_x, vp_y = 0, 0! F! L1 E& ^% S6 b8 o- d
  590.     else4 e7 S6 `. H( O2 o6 |
  591.       vp_x = viewport.rect.x - viewport.ox
    5 v0 X2 z# X1 k( L) C9 q: F
  592.       vp_y = viewport.rect.y - viewport.oy
    " O5 f( o( n' U9 T" H
  593.     end
    6 \' Z' x( g  O0 [# B
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y' d1 @( Y$ [: S# |9 L# S6 _7 t
  595.     item_x1 = vp_x + x + standard_padding - ]- i2 n. S' K, U7 n) `
  596.     item_y1 = vp_y + y + standard_padding  |8 m, S: [8 z
  597.     item_x2 = vp_x + x - standard_padding + width
    $ s, g' I+ y: ]9 O/ k; ]
  598.     item_y2 = vp_y + y - standard_padding + height. U0 H4 |& T: M
  599.     if mouse_x  item_x1, m3 ?) M3 K* Y8 \/ R
  600.       mouse_col = -1
    ! s' Y8 Y# e0 a7 ~4 Y
  601.     elsif mouse_x  item_x2
      Z7 W9 k: D9 L
  602.       mouse_col = -2' K' M) v' J- F" |
  603.     elsif mouse_x  item_x1 + 160
    ! |* Z# Q: s0 _( D. U
  604.       mouse_col = (mouse_x - item_x1)32
    # c+ C1 \9 C/ P  e; U; b1 M7 j; O( J
  605.     elsif mouse_x  item_x2 - 160; ]$ d8 L( @3 Q) J, L( s8 N
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    1 G/ B9 i: R5 k, y- W
  607.     else5 H% A/ @3 z) Y5 u/ u/ T
  608.       mouse_col = mouse_x  x + width2  5  4
    $ F' q5 x% i  V8 R
  609.     end' e$ m, @: I0 }2 O, Q* ]& |
  610.     if mouse_y  item_y1
    ! @9 j9 }8 C; P9 `9 w7 a6 C
  611.       mouse_row = -1
    4 h, z8 E$ }6 X# E2 H
  612.     elsif mouse_y  item_y2
    . t0 f2 ?/ l$ T( ~! G2 O! z
  613.       mouse_row = -2
    ( A" I0 a+ Q4 w6 g& |
  614.     else
    : S: a) J1 I5 Y/ ], S$ Y
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    ' l% s) s$ A( ~( v4 Z
  616.     end0 m2 z/ c, w6 D+ W# X- i
  617.     return mouse_row, mouse_col
    4 A: u2 E  ?1 _6 \: k: w: W/ ~3 V/ [' E
  618.   end
    . Q3 P) p, q* U  x% @
  619.   #--------------------------------------------------------------------------2 h" r  k( h$ X& p8 ~, r
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    " I) L) u+ o$ T3 |. }+ ]8 O( i
  621.   #--------------------------------------------------------------------------2 `" i6 f' K, Z( E) {
  622.   def set_mouse_pos
    . w' G; G# |! k; h  T
  623.     if viewport.nil # necessary!
    4 L1 ?( E' R! j0 N/ L' Z! D: |
  624.       vp_x, vp_y = 0, 07 e1 @/ g7 _# g
  625.     else5 f' [& d9 a. i7 s, B
  626.       vp_x = viewport.rect.x - viewport.ox+ C0 u" c0 N. I/ N" `  |
  627.       vp_y = viewport.rect.y - viewport.oy* \! T  H- V: I& O2 o
  628.     end* a( y9 C' n8 ~0 Z& H( a$ O; ?
  629.     item_x1 = vp_x + x + standard_padding
    / b6 i4 Y- h4 T7 K1 B  B
  630.     item_y1 = vp_y + y + standard_padding5 V& F" ?1 ]+ }- C& o! [9 l" n
  631.     get_index = @index  0  0  @index
    0 f5 L9 {, O; o- M! B/ t. X1 q& i. Y  I
  632.     row = get_index  col_max - top_row' y- ?) v! u9 J: k
  633.     col = get_index % col_max
    : @6 @+ W: U. j7 y8 h
  634.     new_x = item_x1 + item_width  (col + 0.5)
    $ c) U$ ~- Z" d
  635.     new_y = item_y1 + item_height  (row + 0.5)3 l( d5 v( D6 u; b% H; ~: f
  636.     new_x += 14 if col  4
    * C$ h% _: b2 k& W
  637.     Mouse.set_mouse_pos(new_x, new_y)8 g4 A9 Q& K. c5 k- l
  638.   end9 }$ g0 }3 p* C
  639. end
    / G% _; C  L4 m
  640. 9 M1 l5 {' B7 x0 Y
  641. #==============================================================================# ~! N3 j0 q, I1 V
  642. # ■ Window_NumberInput
    & O- c& ]0 W+ |7 P/ ^- P9 Y' S1 F
  643. #------------------------------------------------------------------------------
    1 b5 R  u/ w- ^! E
  644. #  重写了数值输入的方法以适应鼠标8 {( W& q% Q& N1 R& X( r& E/ I
  645. #==============================================================================4 M' a" ]' p! w* ?" {1 e
  646. class Window_NumberInput  Window_Base% u) [* y1 m4 @# G- Z
  647.   #--------------------------------------------------------------------------
    + m9 s! M* j9 a. a' K
  648.   # ● 定义实例变量1 b7 u& f0 a0 h" c$ E+ A" n8 D
  649.   #--------------------------------------------------------------------------
    . R, X% G0 p3 x
  650.   attr_reader extra_window% x/ A- c' f/ P4 m
  651.   #--------------------------------------------------------------------------2 M; l" \4 D- Q- ]+ S: [: a
  652.   # ● 初始化  U; @7 h2 U+ D/ h; ~8 i. [6 I  A
  653.   #--------------------------------------------------------------------------
    & V; ]- _/ _6 l3 x; w1 f
  654.   alias sion_mouse_initialize initialize
    4 E) n5 k7 p3 E6 X! _6 D
  655.   def initialize(arg)3 T* O. a. k! o2 _
  656.     sion_mouse_initialize(arg)
    : R" |& ?5 j5 Q# ~
  657.     create_extra_window- n' Q$ J& T( O' F& {
  658.   end/ p6 f- J* w3 C+ R! M, I9 V8 O
  659.   #--------------------------------------------------------------------------
    * ]" \6 i: M) U! s% I
  660.   # ● 启动
    ' `/ y  S8 @6 U% s, Y
  661.   #--------------------------------------------------------------------------1 r! k7 Y- R6 c8 S
  662.   alias sion_mouse_start start
    % e5 R! r9 J3 Q  [* P
  663.   def start8 T! V$ c* ]  Q/ e
  664.     sion_mouse_start
    3 i1 l  m. k6 B8 m
  665.     deactivate3 j6 W2 ^$ Y0 {) g6 m8 x" G" o
  666.     extra_start
    ! {0 j5 o: Y& R
  667.   end  m2 H, ^/ _. i: u
  668.   #--------------------------------------------------------------------------
    . J' f. N3 U; e0 }; B/ p# R
  669.   # ● 创建新的数值输入窗口
    0 V: a! ?  i/ e- D! }
  670.   #--------------------------------------------------------------------------
    " a! {9 Z% H% Y
  671.   def create_extra_window, V( u+ [9 W, c3 ^8 A
  672.     @extra_window = Window_NumberInput_Ex.new" M5 ~6 l2 ?. d& b
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    2 A/ A8 O5 |' m
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }0 a# w; v- X0 Z
  675.     @extra_window.index_proc   = Proc.new {n @index = n }3 z0 ^9 D: q9 ^, \
  676.     @extra_window.close_proc   = Proc.new { close }
    7 i! U8 q, Y) d4 \) B
  677.     @extra_window.refresh_proc = Proc.new { refresh }5 W8 Q: y0 Q0 n' m
  678.   end
    8 ]# O- K9 b5 n8 |4 _
  679.   #--------------------------------------------------------------------------2 S* N& \# @, u& n* C- l; J# m3 J5 g
  680.   # ● 激活新窗口1 ?  r( [, b; _/ P
  681.   #--------------------------------------------------------------------------
    ; Q( O  u) q, [! m% c* m7 `. x# l
  682.   def extra_start- w$ l4 x5 W- f7 p0 E$ r; {
  683.     case $game_message.position4 P" _/ Z8 ]8 N6 l( S2 P* }
  684.       when 0; @extra_window.y = y + height + 4
    & j- N. @+ n  k7 \& f9 _
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    $ b+ P9 P) y3 F, D8 o. o) a
  686.       when 2; @extra_window.y = y - @extra_window.height - 45 Q6 u* U+ T, g  r- F* a- M
  687.       else  ; @extra_window.y = 8
    5 u" w8 ]( N4 G3 p
  688.     end
    : `9 g/ x( l+ K2 X5 T- G
  689.     @extra_window.variable_id = $game_message.num_input_variable_id6 H' {8 L- d4 A
  690.     @extra_window.digits_max  = @digits_max
    0 X+ }  U# o, c5 S) n3 w( O
  691.     @extra_window.number      = @number) `* S0 W! ~. D0 |
  692.     @extra_window.open
    # k/ Y* I- H4 J6 C
  693.     @extra_window.activate, R, e9 t- V- P+ _
  694.   end
    # z8 G7 X# G% D$ U+ R
  695.   #--------------------------------------------------------------------------2 _  q4 c# Q' D/ y1 M
  696.   # ● 更新
    " E3 }1 K( \' d$ E' l/ S
  697.   #--------------------------------------------------------------------------
    9 F+ Q) ]  o7 n$ g: c
  698.   def update
    " ^8 @+ J# w6 z3 H1 ~& t9 h
  699.     super
    / t  O7 [0 F( y& c  O: K
  700.     @extra_window.update- z! Y' y' `; l4 U/ ^
  701.     update_cursor7 j8 k( H/ P$ @1 @
  702.   end/ ^# y/ @' g4 [! h' n2 }( F1 z8 x8 \# n
  703.   #--------------------------------------------------------------------------
    , r$ Z2 c  I7 E
  704.   # ● 关闭窗口$ `+ ~& D3 p5 G* v7 F* f# i
  705.   #--------------------------------------------------------------------------
      Y, h; O; F2 j& E. k% ~7 n2 @
  706.   def close9 @0 r3 Z+ I4 x2 M, }2 C/ ~& B
  707.     super3 y7 d! S/ k* O+ r9 s- R
  708.     @extra_window.close
    " x7 e: Q; z% h4 b- s
  709.     @extra_window.deactivate' H- Q* u+ Y% D2 K( j! b1 U
  710.   end  {& J8 ~  }1 Q& \2 M) K; o
  711. end
    , Z' K8 G$ J( O) f

  712. / O1 c$ p$ ]* E8 _! B; g2 P4 U
  713. #==============================================================================
    7 V" q, g/ m! g- \
  714. # ■ Window_NumberInput_Ex
    ; k$ c9 n" i7 C+ n
  715. #------------------------------------------------------------------------------
    / U- K$ R5 s! V7 W) Q( m( ]& S3 Z( l
  716. #  新的数值输入窗口(NewClass)
    / h5 o4 a8 R* t
  717. #==============================================================================+ u# J- ?# T$ x( \: J
  718. class Window_NumberInput_Ex  Window_Selectable5 Z- w! L0 J, X2 w
  719.   #--------------------------------------------------------------------------
    6 e- d+ v7 Q7 k* n- x% h0 V
  720.   # ● 定义实例变量! F& h7 V% D, G6 n& z
  721.   #--------------------------------------------------------------------------3 [' n( m& j1 Q8 D9 G! {% z
  722.   attr_accessor number_proc- ^; C; ]( ]$ Y$ O* _2 i
  723.   attr_accessor index_proc6 W7 m! a. u" H: A7 C6 t; W
  724.   attr_accessor close_proc6 S' N7 T! n/ D6 \% l
  725.   attr_accessor refresh_proc" f4 e3 Q7 Z: w8 D
  726.   attr_accessor number0 f$ O( \. r, v/ l2 q3 w
  727.   attr_accessor digits_max5 W& W# b) G% N5 q
  728.   attr_accessor variable_id+ _! I& C; M6 |5 w4 e3 R
  729.   #--------------------------------------------------------------------------
    / U$ G+ O( I7 j6 a% P
  730.   # ● 数字表
    * A/ m/ r: I: V
  731.   #--------------------------------------------------------------------------
    8 c) y9 g9 X$ _/ [) K
  732.   TABLE = [  7,  8,  9,
    3 N8 a& p  A' ~5 q6 m# o
  733.              4,  5,  6,( U8 F! n  L# _) N3 c
  734.              1,  2,  3," c4 z- ~8 Q4 R- i8 [" A
  735.             '←',0,'确定',]
    ' \1 A5 t, {+ \: ?
  736.   #--------------------------------------------------------------------------. Z% N! a& [- u" F% w
  737.   # ● 初始化对象9 x- Y: o; G6 v/ u  u! i, @
  738.   #--------------------------------------------------------------------------
    4 b4 U8 [* Z" Y7 A; I, J- ~
  739.   def initialize! ^" ]. K+ q' b. y, q  C3 z
  740.     super(0, 0, 120, fitting_height(4))
    ; W8 k8 t& ^( v
  741.     self.openness = 0/ {- }& L4 l. ]  g! `! b( g
  742.     @index = 0, y" l* O7 ~' m& }6 R8 r6 U
  743.     @number = 0
    / d1 }8 O2 D1 j3 l
  744.     @old_window_index = 0$ G5 N$ S; |( B! E4 z
  745.     @digits_max = 0
    + m4 ?( j8 H, D+ h
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    - K/ d& `7 `4 H4 \/ J! k" H3 U
  747.   end# F; d8 p3 N* C! u9 N, F
  748.   #--------------------------------------------------------------------------* Y7 n$ d% t# c5 a/ c
  749.   # ● 获取项目的绘制矩形- o! o' f- ^6 o  y2 q8 V
  750.   #--------------------------------------------------------------------------7 I! L! A& G# W4 M$ Q: q- j) o
  751.   def item_rect(index)
    / j: w9 `( V! w8 u" K- T
  752.     rect = Rect.new
    ! k7 y  t1 v7 w: D8 r" P
  753.     rect.x = index % 3  32
    2 ~0 h' `& C2 [, w5 x
  754.     rect.y = index  3  line_height3 z, W% |5 l( m3 W
  755.     rect.width = 32
    3 _. e# I$ S( a* g
  756.     rect.height = line_height0 z3 G& x2 i' Q/ F9 Y! R
  757.     return rect+ G. @- j( ~1 X& L3 Z* Z
  758.   end; {( y* ]: o1 s
  759.   #--------------------------------------------------------------------------
    ! j& m5 a7 p/ g: s. k. J& U
  760.   # ● 将光标设置到鼠标所在的位置: T6 P; O2 Q  b- b" n
  761.   #--------------------------------------------------------------------------$ n% h! Q" Y# G3 E6 \8 i, @( r
  762.   def set_cursor
    3 v/ D# [$ ^& {1 O% y  N
  763.     mouse_row, mouse_col = mouse_window_area
    7 L+ B4 Q$ g$ T
  764.     if mouse_row = 0 && mouse_col = 0) _* v! l: T6 q7 Y1 k
  765.       new_index = mouse_row  3 + mouse_col& Q, U; a8 k- @; f3 ^9 r
  766.       select(new_index) if new_index = 118 v# g: F$ g! G' x8 B, e
  767.     end+ m/ U. D# n$ b3 @% w# c
  768.   end
    5 b9 Z3 f6 ?% r4 l! r
  769.   #--------------------------------------------------------------------------1 e/ m' t  ^/ e/ f$ N! u9 q2 w
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    0 P8 H6 w1 }$ T( D
  771.   #--------------------------------------------------------------------------, x  q1 ]2 k' W- d
  772.   def mouse_window_area
    : v2 M8 W- N1 X9 b! ^; H
  773.     if viewport.nil
    3 A* ?' s6 E+ ^, C- A8 q
  774.       vp_x, vp_y = 0, 0
    ) B; ?+ Y: w+ C: M- u# K
  775.     else& ?7 |, i$ `; n$ k$ Z' a' c
  776.       vp_x = viewport.rect.x - viewport.ox$ G* z% l& w# J: L8 F
  777.       vp_y = viewport.rect.y - viewport.oy
    ) N) P. I) s- g, B
  778.     end
    1 u* `5 S; E. Y& f/ N8 B; Y/ c
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y3 y  m. s# d( u" w2 H
  780.     item_x1 = vp_x + x + standard_padding 2 P# k6 b0 M1 A* ?* v
  781.     item_y1 = vp_y + y + standard_padding9 `1 K2 _/ R6 I. q6 y7 o/ N- A6 u
  782.     item_x2 = vp_x + x - standard_padding + width
    , n  f+ f" C3 q. S  i
  783.     item_y2 = vp_y + y - standard_padding + height+ E) E* [' s* J7 i( X
  784.     if mouse_x  item_x1
    7 U" m! [/ t; o, \0 l3 y
  785.       mouse_col = -1$ {1 x, k; P1 E: S: A0 w- U
  786.     elsif mouse_x  item_x2% ?) Z: O5 i: Y: |/ ]) c4 V, r3 y
  787.       mouse_col = -29 y, C3 C8 W/ x4 y9 S2 M
  788.     else% L1 D& O# S+ b
  789.       mouse_col = (mouse_x - item_x1)  32
    ) x5 q2 Y2 v. E  T! V. O
  790.     end
    1 @' c8 W4 u  d* l/ h, W% I
  791.     if mouse_y  item_y1% c  a2 _$ m+ @. l' ]! ]7 ?
  792.       mouse_row = -1- @* U( j" @' y$ F0 h
  793.     elsif mouse_y  item_y2
      T9 y. m9 P% ]0 c* U
  794.       mouse_row = -2/ g/ F) r- n* W6 r& E
  795.     else: _- w( q( Y6 z; c( c4 O# x2 \0 L
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    / d0 E; H, j* s: ^6 G# _
  797.     end
    6 J' m4 m' q6 _# s
  798.     return mouse_row, mouse_col
    # n4 e0 y: X- |' n
  799.   end
    % b1 |# A  ?2 U- l7 [6 O
  800.   #--------------------------------------------------------------------------
    5 m3 g: V) O3 l' K
  801.   # ● 获取文字
    9 y" t2 p# T6 b0 e% D8 p
  802.   #--------------------------------------------------------------------------
      F- t. a- m/ z3 l; [' S" i
  803.   def get_number# w- c# t7 d  W6 s8 m3 e) q+ V
  804.     return false if @index == 9  @index == 11
    - D% f8 }5 |* J( q) l" |  H" i
  805.     return TABLE[@index]
    : [- t8 x: b2 W
  806.   end
    * a0 `7 u. R% H, |: u
  807.   #--------------------------------------------------------------------------/ E4 i1 G. X1 a) D; q1 \
  808.   # ● 判定光标位置是否在“退格”上
    % y% d3 j  R  W- C% }
  809.   #--------------------------------------------------------------------------
    ) L& F2 a' x  ~! [* S: Z
  810.   def is_delete6 K6 d# p* H4 ]8 h2 V' a
  811.     @index == 9
    & ~* m& R0 ~! A1 m  M  f5 w% Y
  812.   end5 y2 u# q' F+ i* S4 S
  813.   #--------------------------------------------------------------------------/ W4 i/ t+ O$ E, z9 \
  814.   # ● 判定光标位置是否在“确定”上; H' R7 y" w+ b
  815.   #--------------------------------------------------------------------------: Q, n- M- r7 Q2 N
  816.   def is_ok
    1 J! X5 Q* y3 y& y6 ~
  817.     @index == 11  w2 n: E9 S7 C% N0 E1 h* q
  818.   end/ }" _* H- D- f
  819.   #--------------------------------------------------------------------------) f$ o8 A+ G9 E2 r, I+ m& s  Y/ C
  820.   # ● 更新光标
    6 u; W) T4 M$ ~7 X
  821.   #--------------------------------------------------------------------------
    ! r9 O3 j; P' K) G( {# M1 H
  822.   def update_cursor1 r6 `9 D+ x$ |5 ~  d
  823.     cursor_rect.set(item_rect(@index))
    * v! H& a, q5 ^: q0 I! B
  824.   end! I' c# h: ?, u$ C
  825.   #--------------------------------------------------------------------------
    * T+ `- b9 ~5 f9 G
  826.   # ● 判定光标是否可以移动/ ~  B- Z4 z8 f7 z" K! ~* i4 x  z
  827.   #--------------------------------------------------------------------------: X0 Q$ X$ ]; V! m3 V: f  A
  828.   def cursor_movable
    0 P) b$ Y' A/ `9 K
  829.     active4 z: R- x# R# p6 k
  830.   end+ F5 F, m* o, K! ^8 }. h
  831.   #--------------------------------------------------------------------------
    0 s4 x; W% r, H9 e
  832.   # ● 光标向下移动
    0 X" x" ^' d0 M- m' A
  833.   #     wrap  允许循环( t, b8 m9 p4 j( D: j) r% x6 S
  834.   #--------------------------------------------------------------------------$ |4 g  H2 V: z
  835.   def cursor_down(wrap)
    ' |7 x4 _) [/ W1 B: z" I- ?) f
  836.     if @index  9 or wrap
    6 i6 ~3 [2 o" }9 f7 P4 j
  837.       @index = (index + 3) % 12
    5 n# h+ j; c) i% \- o5 c: g, |
  838.     end7 w3 x5 K7 {0 P+ T4 s! Q
  839.   end  E+ U7 y: A6 c) u, d8 P0 b
  840.   #--------------------------------------------------------------------------
    ) q- F% P  E. x* T! R6 U, V$ Y
  841.   # ● 光标向上移动
    % ]3 d9 o& ~* {$ e! m
  842.   #     wrap  允许循环- d  e& p( k0 J, E
  843.   #--------------------------------------------------------------------------8 d) X( v0 X* [; H% \: @
  844.   def cursor_up(wrap)
    ) x1 d: w% Y! z7 l! k! r& {
  845.     if @index = 3 or wrap
    6 ]" R2 t' y4 m; A
  846.       @index = (index + 9) % 12
    3 Q$ Y$ l: }; @/ g7 E; f
  847.     end5 o5 {# H- T, t1 q$ ~4 j  R; n
  848.   end1 c- B) ^3 `6 O) l% u8 \/ K! x- Y& }
  849.   #--------------------------------------------------------------------------4 `' x9 D- A/ y" i" U4 v
  850.   # ● 光标向右移动3 W% B+ P1 S  j  E
  851.   #     wrap  允许循环* d, k* b8 R. B4 U2 t# X
  852.   #--------------------------------------------------------------------------
    1 }# A, c2 F6 o# U- c6 h0 l9 f
  853.   def cursor_right(wrap)/ e* b7 j- |2 I6 S0 @
  854.     if @index % 3  29 A5 A* S9 Y& M2 U
  855.       @index += 1( ?0 B2 V0 G/ K$ L( ]
  856.     elsif wrap
    9 S: v( v- ~/ K! v' _0 e6 ?
  857.       @index -= 2
    " q; `. Q# I) u/ x8 [3 w
  858.     end2 `4 u8 l5 L! ~
  859.   end
    , i; {  o. Q( a$ S/ j
  860.   #--------------------------------------------------------------------------
    2 S4 m% [, y0 j3 h
  861.   # ● 光标向左移动5 l/ k; e5 I' ~. M$ H6 ]/ z$ d$ A
  862.   #     wrap  允许循环: K( \: s5 v2 [! j$ v! Z
  863.   #--------------------------------------------------------------------------
    # [8 a% R' S1 t; X- A" U, z
  864.   def cursor_left(wrap)) A! {( Z+ m; p$ S; ^, N
  865.     if @index % 3  0
    ; g8 a1 L6 h; e
  866.       @index -= 1. P& W+ @( l9 a0 \; N
  867.     elsif wrap
    8 y/ E* @8 s; ?2 b8 K9 M6 S
  868.       @index += 2) j$ ?7 T5 e6 x; {1 r
  869.     end
    ) ^  v/ ]+ W  K- K( ]+ a7 G; O& `
  870.   end4 d. h8 M) V; {: t* W; ?6 Z
  871.   #--------------------------------------------------------------------------
    4 X8 h4 c. d  R  R% H( ]
  872.   # ● 处理光标的移动# Y  G! n3 ^2 M; t
  873.   #--------------------------------------------------------------------------% ~( t) Q+ s/ p3 `, Q- Q" L3 s
  874.   def process_cursor_move
    + |) O0 s) J" P
  875.     super1 _) U! ^( l8 N$ l( n) O
  876.     update_cursor$ w0 @& B) D( `$ X8 n
  877.   end/ l- g5 g! l1 T
  878.   #--------------------------------------------------------------------------
    0 H- R, e0 _* v2 Y* W9 E
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    , B6 I; M$ X( I
  880.   #--------------------------------------------------------------------------
    1 ?5 [/ [2 A  m& G5 ~$ N" P
  881.   def process_handling
    6 v( E+ b% Q# c% g: b
  882.     return unless open && active
    ' ]' }! U5 j! W
  883.     process_jump if Input.trigger(A)
    , T" z4 \, v# j* E2 G
  884.     process_back if Input.repeat(B). K7 Y; d' h$ I& `
  885.     process_ok   if Input.trigger(C)
    , L1 {/ `3 t' ]
  886.   end
      _4 i# V4 a9 X9 g8 \
  887.   #--------------------------------------------------------------------------
    $ Z, q5 p" N3 r
  888.   # ● 跳转“确定”
    " ]( B% t8 y, b- |
  889.   #--------------------------------------------------------------------------
    2 ~  o3 V. N0 q, M! L# }
  890.   def process_jump
    7 p) g: N4 u) |& o
  891.     if @index != 11
    : v, C4 V9 Q8 o/ O$ d* i) ~9 L3 E
  892.       @index = 11
    . }9 a8 F6 F! ?
  893.       Sound.play_cursor
      ^4 j6 n+ p. U/ E0 s: l2 F! I
  894.     end
    / i0 I' b1 u0 z/ J: _* t5 l: j
  895.   end
    ! k( k  V5 z/ @7 |
  896.   #--------------------------------------------------------------------------
    2 Q, }. g" {2 D. b) M$ z% j
  897.   # ● 后退一个字符
    ! Q/ l3 ?' Z- ]; D" m1 K
  898.   #--------------------------------------------------------------------------
    ' G- O& |3 f. J" V3 I) A( j; H! @+ o) Q
  899.   def process_back
    2 V+ K/ [2 ?8 a6 q
  900.     Sound.play_cancel
    & |0 g* _. e+ N$ S
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    2 N- J& I8 D( ~/ P  O
  902.     n = (@number  place) % 105 I; v4 G& b/ m* G1 F; G3 y6 ^
  903.     @number -= n  place
    ! a" T8 K. w. z( I
  904.     @number_proc.call(@number)1 F( O$ I9 V, Z% s2 c. C
  905.     @old_window_index -= 1 if @old_window_index  0! q# V' V5 [! O8 h  F- h8 S  [
  906.     @index_proc.call(@old_window_index)
    , z5 m4 i) R) K* e$ ?2 G7 Q2 N
  907.     @refresh_proc.call
      O" }' @. g  l% \: X7 b
  908.   end
    + X8 z8 Z9 Y9 N
  909.   #--------------------------------------------------------------------------
    " ~% L( Y8 K/ d9 w3 n' ~) I
  910.   # ● 按下确定键时的处理+ P0 \2 O$ y& \. ]5 V1 h& \" e8 y# s
  911.   #--------------------------------------------------------------------------
    + y  l3 L  L, k+ {6 j
  912.   def process_ok
    5 k" ]$ A/ O+ C2 A
  913.     if get_number
    : m8 F3 ]: u1 Z
  914.       Sound.play_cursor
    $ J0 n4 i1 L$ x. I: Z+ G; T2 e  k
  915.       place = 10  (@digits_max - 1 - @old_window_index)6 s  _6 L- ~( o/ M
  916.       n = get_number - (@number  place) % 10
    3 v) A3 q. M$ g+ n1 C& f% E4 ^
  917.       @number += n  place
    1 |0 ?5 Z. l, Y, d: f' v
  918.       @number_proc.call(@number)- q) |: t" w( i2 {& ^% H
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1. ]+ k# e  W' b/ d1 X
  920.       @index_proc.call(@old_window_index)
    * r& ]/ l) a5 \
  921.       @refresh_proc.call  X3 }" b" w' e- x; W* |
  922.     elsif is_delete" O  S; y9 g7 X$ e# T/ a$ f% Y4 h8 ]
  923.       process_back
    ( t. h) ~2 ~2 Q( p" s
  924.     elsif is_ok. }" P) k' Z: Q; w# }
  925.       on_input_ok3 ]: Y0 B% e2 P( G8 H4 ^! u
  926.     end
    " F' V' G) z9 b0 u
  927.   end
    * k) N+ R( D8 j0 B1 W' }  N4 h
  928.   #--------------------------------------------------------------------------
    . T1 g3 C5 E& G' n$ g
  929.   # ● 确定6 z+ v; ~+ O, [( V# b# c2 v5 h
  930.   #--------------------------------------------------------------------------1 l. L6 i  g" K8 \
  931.   def on_input_ok1 Y' F( K: g- i0 O0 ?- A0 g
  932.     @index = 0
    , L: d4 D* u3 u& ~  S* N
  933.     @old_window_index = 0
    6 g7 N+ I0 ^, E7 u, ]. u8 J
  934.     $game_variables[@variable_id] = @number
    # g* B5 q4 r2 g' [
  935.     Sound.play_ok* _$ K9 ?+ Z  ?! L
  936.     @close_proc.call
    3 x& R" X- y$ u" ?; V$ M  N
  937.   end
    4 E4 U) N+ @0 |5 ]. }
  938.   #--------------------------------------------------------------------------
    ( ^% E" J( V7 J9 ^* i; p
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置( f/ R! U1 r0 ]6 e( P) o0 k; v
  940.   #--------------------------------------------------------------------------
    : S  ]$ ]$ J$ V4 t* c
  941.   def set_mouse_pos/ V9 P" I/ s1 h0 V. ?$ `' p8 J
  942.     if viewport.nil # necessary!
    , L' M2 e( S/ ]; v
  943.       vp_x, vp_y = 0, 09 b, G' ~) G3 n$ d* {
  944.     else: W5 T0 X/ ~0 I4 q! j( Y) o
  945.       vp_x = viewport.rect.x - viewport.ox
    ! y+ j: F8 |' F8 d* u3 n
  946.       vp_y = viewport.rect.y - viewport.oy
    ( ~: ~# z/ a# G. n; Q
  947.     end
    - }! |# N* C8 F/ ]  \( _, Z0 U
  948.     item_x1 = vp_x + x + standard_padding + U/ m  q9 v/ S$ N/ }4 `- e
  949.     item_y1 = vp_y + y + standard_padding6 w& ?( ?% c0 ~1 F6 R% }. x2 c
  950.     get_index = @index  0  0  @index : `2 W3 N- A9 U+ |& q
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)& Q, U3 B* y+ t2 h" _! y- y
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    3 y, ?! Y) R! s' d7 ^: G
  953.     Mouse.set_mouse_pos(new_x, new_y)
    8 R7 W& a4 X. P8 _+ N
  954.   end
    0 G: D! K+ S: m5 f$ N
  955. end
    5 h7 d3 N4 ^5 ~2 V8 Q& ^. N1 Y
  956. / k) d+ y9 q5 ^+ O/ n' ]
  957. #==============================================================================
    & a2 S  U" A+ Z; p% N
  958. # ■ Window_Message& {" p! _( N) S2 ?; f0 H
  959. #------------------------------------------------------------------------------
    6 C0 U. g+ e: s: B1 M+ {
  960. #  显示文字信息的窗口。
    ( J) u" {; f( ?0 ]  d4 b
  961. #==============================================================================
    ) x$ k+ F3 |( G) R
  962. class Window_Message  Window_Base# e0 `) J! z6 @5 ^" Z( M* b
  963.   #--------------------------------------------------------------------------0 q8 n( {" I; {# n1 i
  964.   # ● 处理数值的输入(覆盖原方法)4 D0 @9 F, K& m) g# o
  965.   #--------------------------------------------------------------------------
    1 f/ S. O* t% m# o
  966.   def input_number
    ) I; m8 j2 l5 H0 d1 N  x) G
  967.     @number_window.start
    ( B+ A/ n+ r; o8 R" U
  968.     Fiber.yield while @number_window.extra_window.active1 K# \& z3 }. K
  969.   end
    & f) U: l# c+ L
  970. end; |# K) e* _: ?# D4 c* r

  971. 2 ^" N8 y# o4 h, u2 `7 C' @
  972. #==============================================================================# c# Z6 w9 V+ m# v8 n; p( i- ~
  973. # ■ Window_PartyCommand5 O2 R& }* X/ Y6 a% B% j6 d
  974. #------------------------------------------------------------------------------
    8 ^) C4 K) M5 n' B$ p
  975. #  战斗画面中,选择“战斗/撤退”的窗口。/ O2 T. g) v5 l% I- ^
  976. #==============================================================================
    % R2 [! c) b& n) ~
  977. class Window_PartyCommand  Window_Command
    2 C+ g, S5 i1 G" W
  978.   #--------------------------------------------------------------------------' f; T! p9 j' G  j
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置6 u: y6 A. B/ o; T3 R
  980.   #--------------------------------------------------------------------------
    / a4 V- H7 d. f
  981.   def set_mouse_pos
    % K& c" f0 Y3 a) k; _6 ^
  982.     if viewport.nil9 v, k1 l# e, d* x/ i/ K
  983.       vp_x, vp_y = 0, 0
    " H4 m# E3 M& W2 u1 i7 g% b  J" U
  984.     else: X+ q# i3 {( n! P& Q/ j* E5 P
  985.       #vp_x = viewport.rect.x - viewport.ox% ^: y9 a2 P' D) K2 B) ~0 c& h) {
  986.       vp_y = viewport.rect.y - viewport.oy4 D5 e3 P; n( |! O) d% A5 X
  987.     end- I3 V* r) q7 g8 w5 x5 ?
  988.     item_x1 = x + standard_padding
    & o$ W9 u, D3 k6 f9 E% d
  989.     item_y1 = vp_y + y + standard_padding
    ; L% |$ [) O% b+ a
  990.     get_index = @index  0  0  @index $ h! r9 W4 {- e: p9 q
  991.     row = get_index  col_max - top_row$ i4 B- J  g7 |: Y: z( _# O
  992.     col = get_index % col_max
    4 k3 _% `  E" i. e
  993.     new_x = item_x1 + item_width  (col + 0.5)
    . w% f# b+ u3 ?% T
  994.     new_y = item_y1 + item_height  (row + 0.5)
    9 z/ b/ D) b$ v
  995.     Mouse.set_mouse_pos(new_x, new_y)
    3 n% |7 z# i0 h! z3 E* m
  996.   end
    ) N: U2 L/ I+ a. \1 [+ C
  997. end
    % U! @' E& h. G, P6 w$ Y
  998. ) X: h! f- T% x. H
  999. #==============================================================================
    & M7 m* f9 O! T& Y* ~, b! D5 B
  1000. # ■ Window_ActorCommand/ b+ m) v& R/ l7 S* u* i
  1001. #------------------------------------------------------------------------------( o* v/ B' h/ s7 u1 s
  1002. #  战斗画面中,选择角色行动的窗口。9 G' r' N' I% p
  1003. #==============================================================================
    . Y8 w- ~4 j7 \" n/ m- q# T
  1004. class Window_ActorCommand  Window_Command! e4 U: k/ o5 b! t; X# M
  1005.   #--------------------------------------------------------------------------2 `6 Y4 W9 w) U
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    / q  L# w: Q; p9 Y5 L
  1007.   #--------------------------------------------------------------------------7 ^5 A8 v) ~( c1 ]6 X3 I
  1008.   def set_mouse_pos* q% h+ h7 @) E5 ?' c: p
  1009.     if viewport.nil
    - J. n. M9 I& s( ?  L1 e& m
  1010.       vp_x, vp_y = 0, 0
    5 ~# D2 g  B. l5 W* S
  1011.     else
    + b  X  V5 M2 W4 d* x
  1012.       #vp_x = viewport.rect.x - viewport.ox
    ) j7 N6 C, }/ O$ o
  1013.       vp_y = viewport.rect.y - viewport.oy: t* U& H. q2 g+ x7 t9 m1 |
  1014.     end
    + n9 C8 v, A9 }* i, m
  1015.     item_x1 = Graphics.width - width + standard_padding' `6 c. c4 J+ k% d: w! a
  1016.     item_y1 = vp_y + y + standard_padding( [  P% C2 T6 d& L
  1017.     get_index = @index  0  0  @index
    ! U1 W$ c% }( K' q
  1018.     row = get_index  col_max - top_row
    ; O- F8 p9 e# a1 E( I
  1019.     col = get_index % col_max
    / b1 N' w1 j: a" K% e
  1020.     new_x = item_x1 + item_width  (col + 0.5)
    & R6 A& h# [% Y' D3 Q5 y; H: c! R
  1021.     new_y = item_y1 + item_height  (row + 0.5)# Z) Y2 s6 {! k0 S, n; C: _
  1022.     Mouse.set_mouse_pos(new_x, new_y)! A9 ~8 n0 Y# f- x
  1023.   end  J4 B% K$ A) S* n) ?' a3 ^- _5 I
  1024. end
    / H& ]/ P. V+ n0 v

  1025. 1 ~* y, F7 D, u/ y5 z* Z$ b
  1026. #==============================================================================
    # H. h' F; i, O; }& [% w+ M
  1027. # ■ Game_Player
    4 g& O3 k% U* Z. q  ?" M
  1028. #------------------------------------------------------------------------------4 w5 ?) R9 o$ k/ m; E+ H
  1029. #  处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。3 Z* }/ o+ r+ Q! I6 X& Q
  1030. #   本类的实例请参考 $game_player 。1 p. C& K$ Z# [8 B
  1031. #==============================================================================
    5 R, N% \; q" C
  1032. class Game_Player  Game_Character
    / C3 M& d1 A1 M) a
  1033.   #--------------------------------------------------------------------------
    ( T& Y4 d1 C8 V- A9 G
  1034.   # ● 由方向移动(覆盖原方法)
    ) R" ?( w$ k# E5 E( C- O; _5 P
  1035.   #--------------------------------------------------------------------------$ D1 D( Y+ ~: n* M5 `+ ^7 t
  1036.   def move_by_input' j" C/ f$ R4 I$ c
  1037.     return if !movable  $game_map.interpreter.running; E5 F' J2 S2 G  ?2 p" x
  1038.     if Input.dir4  00 P0 y( M4 T6 i
  1039.       move_straight(Input.dir4)
    ( W' Q  {% C& o9 C& D+ p
  1040.       reset_move_path
    ( y! {( S% a+ x# |
  1041.     else$ a! U8 J) M' j2 o# J
  1042.       move_by_mouse
    1 m8 X5 O2 V6 E. i
  1043.     end7 p1 u2 `! R' z$ y. i0 {3 y
  1044.   end* c3 X4 H& ?1 T
  1045.   #--------------------------------------------------------------------------( g2 r/ o0 ]( e7 @
  1046.   # ● 非移动中的处理(覆盖原方法)
    : u5 u& o4 ?. A+ |2 F
  1047.   #     last_moving  此前是否正在移动; U# q2 j% Y, h7 t7 L8 G# S
  1048.   #--------------------------------------------------------------------------( J9 C9 ~0 p  d- m4 W
  1049.   def update_nonmoving(last_moving)' l3 n; y; @' T- G. L# K, Z
  1050.     return if $game_map.interpreter.running- K3 [; a" @" D
  1051.     if last_moving" @+ v. Z* m. w' H% I2 Z) P3 N0 y
  1052.       $game_party.on_player_walk: N( J, ~6 g; ~" @1 L
  1053.       return if check_touch_event( N2 u3 M, @1 m8 _5 B
  1054.     end# W& \$ c$ w4 H7 Y# ?
  1055.     if movable && Input.trigger(C)
    - ?$ w. x& p5 g; E& Y5 |% u
  1056.       return if Mouse.press(0x01) # 防止按下鼠标左键绘制路径时触发事件或载具切换, B& b4 |* U! h
  1057.       return if get_on_off_vehicle
    & ?1 B! f: y( S- B( A9 G. @/ S/ t
  1058.       return if check_action_event
    0 M, B" ?+ h! s: \2 r1 a7 `
  1059.     end& p; ?. h9 z2 Q7 X
  1060.     update_encounter if last_moving: S5 _) w' A9 S( T6 J" C& ]
  1061.   end
    5 V, n: s+ P5 s, w# I% g8 i
  1062.   #--------------------------------------------------------------------------. p& O) m  g4 w  x1 p; n
  1063.   # ● 判定是否跑步状态(覆盖原方法)- E1 h# u$ `# T- P
  1064.   #--------------------------------------------------------------------------
    : x, z% ?  m: M3 v( N
  1065.   def dash$ H7 Z' O0 |/ R& \
  1066.     return false if @move_route_forcing
    + G* y0 R6 \. r# {7 ?
  1067.     return false if $game_map.disable_dash
    / A! x' I) c6 K* x6 r+ ?9 Z4 H
  1068.     return false if vehicle% r2 W3 [: L$ A/ s2 ~
  1069.     return Input.press(A)  @mouse_dash, o- j% ?! m# z& y1 Q/ `
  1070.   end1 \9 _0 v9 p, U- P# K" N
  1071.   #--------------------------------------------------------------------------9 w" V8 }: ?7 C8 L$ ~
  1072.   # ● 初始化4 h1 f9 j' T- @
  1073.   #--------------------------------------------------------------------------
    : S. y" J* V6 [9 p4 K
  1074.   alias sion_mouse_initialize initialize
    0 ]9 O  N) B/ [
  1075.   def initialize
    2 L5 v: }0 f5 W
  1076.     sion_mouse_initialize
    5 l- S1 i% K, H& o
  1077.     reset_move_path/ Q9 d; ?9 a; `! }5 I$ s( l
  1078.     @moveto_x = 0
    . t$ l. r+ i# N6 x
  1079.     @moveto_y = 0% J' f& q2 J7 m  H1 @% x: s7 r( H
  1080.   end/ K, J- u1 V. k& t8 h
  1081.   #--------------------------------------------------------------------------  J+ n' X; F3 B
  1082.   # ● 更新
      ~: C7 k2 C8 _
  1083.   #--------------------------------------------------------------------------1 Q  g* {6 \+ ^
  1084.   alias sion_mouse_update update2 i! j3 ~" c7 E' g
  1085.   def update, m% K% T& ?5 ]8 X, L9 y% ]% w
  1086.     sion_mouse_update
    ) ~+ L; ?- b) U  s' g) o: `
  1087.     clear_unreachable_sign/ d$ z3 `1 \- |) B, @
  1088.   end
    9 @% q& _. v$ C' q1 n' F# V
  1089.   #--------------------------------------------------------------------------
    & c, Y7 L7 H/ q+ g7 P+ n7 \" ^. `
  1090.   # ● 处理卷动
    5 I: {. H, x& j* p# Z. F, s
  1091.   #--------------------------------------------------------------------------( M, P9 b$ U9 O) k% A
  1092.   alias sion_mouse_update_scroll update_scroll1 Z9 A0 b8 A0 z$ {7 }, O
  1093.   def update_scroll(last_real_x, last_real_y)
    ! U1 d7 |% Y# g
  1094.     return if $game_map.scrolling
    4 x/ m! Q: O, u6 ?0 g8 B0 L  u) E6 c
  1095.     KsOfSionNew_Scroll  new_update_scroll 6 P# u+ p% J3 H  @+ M
  1096.       sion_mouse_update_scroll(last_real_x, last_real_y)
    ) _# o1 A! Y  q; a! S* m5 _
  1097.   end
    4 M" M% p* [' n3 Q' T* m. T. e  [
  1098.   #--------------------------------------------------------------------------; a4 l3 m( q9 G; o
  1099.   # ● 重置移动路径相关信息
    0 T9 r8 F1 n. H% _) K" ~/ I4 E
  1100.   #--------------------------------------------------------------------------
    # C0 a; q( T: f* w5 ?% S. l
  1101.   def reset_move_path( I- \- B1 _" R
  1102.     @mouse_dash = false
    & ?( a6 ?, m5 x) \! c, R; g
  1103.     @mouse_move_path = []1 u4 e2 s3 i: q/ p! n
  1104.     $mouse_move_sign.transparent = true! S3 y3 j' G' G; M
  1105.   end
    - g9 @: D# g2 E- d8 p) g
  1106.   #--------------------------------------------------------------------------) s- U* E# }0 ?
  1107.   # ● 新的卷动地图方法, R3 |% A+ q( O1 f$ P+ A" N
  1108.   #--------------------------------------------------------------------------. H! f" b5 Z3 s( @4 [
  1109.   def new_update_scroll
    # o( M3 s* L5 [+ b. Z
  1110.     horz_speed = 2  @move_speed  KsOfSionMap_Scroll_Spd  Graphics.width
      X6 b2 t  K0 a- N
  1111.     vert_speed = 2  @move_speed  KsOfSionMap_Scroll_Spd  Graphics.height; O( e3 y0 E( y1 [. R$ R: N" l
  1112.     ax = $game_map.adjust_x(@real_x)0 x+ ^7 V: E8 H  ~  P
  1113.     ay = $game_map.adjust_y(@real_y): S! ?$ F0 ~" t
  1114.     $game_map.scroll_down (vert_speed  (ay - center_y)) if ay  center_y
    / E/ `6 @/ F) K7 G+ F
  1115.     $game_map.scroll_left (horz_speed  (center_x - ax)) if ax  center_x
    7 C$ ~- ~* f" g" d: W. |, X0 C
  1116.     $game_map.scroll_right(horz_speed  (ax - center_x)) if ax  center_x5 ?4 r$ F" o3 ]. P) \
  1117.     $game_map.scroll_up   (vert_speed  (center_y - ay)) if ay  center_y
    8 h& h6 o# O$ C: o4 L1 L- d
  1118.   end! w* m3 Z$ U. A
  1119.   #--------------------------------------------------------------------------2 c  F9 k$ z6 B) n" Q& G
  1120.   # ● 消除不能抵达图标& E$ c3 K( X2 A( p+ h  k( N
  1121.   #--------------------------------------------------------------------------
    : @0 J" x3 T7 E# s9 S" F
  1122.   def clear_unreachable_sign
    ; k& e1 O" o& j: ^
  1123.     return if Mouse.press(0x01)& S2 ]/ E) s. d8 C$ ?
  1124.     if $mouse_move_sign.direction == 4 && Mouse.click_count % 20 == 0
    7 {3 X$ D, y4 B  U9 p. p: \; H+ R1 X
  1125.       $mouse_move_sign.transparent = true- ^5 C& l; _, H- A1 _8 _
  1126.       $mouse_move_sign.direction = 2
    , W5 S4 m% t1 V7 L6 _4 d; x: @2 G
  1127.     end. y& _6 T: a& E2 J% }4 ^
  1128.   end: D- z4 m, E3 T
  1129.   #--------------------------------------------------------------------------* {. c" w% {, `& K9 w2 X
  1130.   # ● 由鼠标移动
    ; H" i6 S2 W  y4 X& ~2 t& e
  1131.   #--------------------------------------------------------------------------
    8 Q6 \' R' _7 g2 D% G4 G% q* F' j
  1132.   def move_by_mouse/ S6 M( g5 R6 c# r) N: y$ ~: T, G
  1133.     unless @mouse_move_path.empty # 移动路线数组不为空则执行移动
    ) w0 W6 i( t% I  q& p
  1134.       dir = @mouse_move_path.shift
    + t* F: b. j$ t% T4 a. ]# c
  1135.       if passable(x, y, dir) && !@mouse_move_path.empty
    8 I, D2 o1 s9 A9 r+ t) A
  1136.         move_straight(dir)
    " F; P) y: j7 n
  1137.       elsif @mouse_move_path.empty # 判断是否是最后一步
    0 z8 ^' w7 j' C! v$ R  d1 v; C; L
  1138.         x2 = $game_map.round_x_with_direction(x, dir). M' y5 W* W+ A: }) s3 U; W
  1139.         y2 = $game_map.round_y_with_direction(y, dir). o, B$ Q0 A. {3 C
  1140.         move_straight(dir) unless dir.zero4 D6 F% O: t- K9 a' F- C
  1141.         unless x == x2 && y == y2 # 如果移动失败,检查是否启动前方事件、上下载具
    + z0 l7 B6 B3 Z7 w  H6 M
  1142.           check_event_trigger_there([0,1,2])
    ! Y- q+ E" j5 X6 t+ `; j  J
  1143.           get_on_off_vehicle unless $game_map.setup_starting_event
    3 z2 a: _6 H4 W8 S
  1144.         end) ]) L  b5 S8 K; Q$ ~+ J, ^
  1145.         $mouse_move_sign.transparent = true if $mouse_move_sign.direction == 2
    0 P/ a1 o! a% A7 G' C
  1146.         @mouse_dash = false0 o/ p# E" U$ G, l
  1147.       elsif @mouse_move_path[0].zero # 目标点无法抵达,调整朝向→目标点
    0 }) k; R0 W' O8 D
  1148.         @mouse_move_path.shift, M6 s# ~5 v* U
  1149.         @direction = dir
    5 I/ `. L1 }( `' K9 V' X) D
  1150.         @mouse_dash = false
    - T/ v( Z0 V* O) J7 D- g1 f
  1151.       else! R9 s) b& p* {% ~
  1152.         draw_move_path
    - b: W' f5 E, L8 Y
  1153.       end
    % s" e  [, y7 J8 B
  1154.     end5 Y* l$ y$ d  G; `
  1155.   end
    ' q; _, `1 y4 ], o9 v
  1156.   #--------------------------------------------------------------------------) ]9 X8 J( \: B0 |
  1157.   # ● 地图界面按下鼠标左键的处理
    ) H' u. s6 o6 h/ P. w
  1158.   #--------------------------------------------------------------------------
    7 ]9 b' d- B7 y) U6 V! e! L
  1159.   def left_button_action
    % t* h( Y$ [" K6 s0 a  h
  1160.     return if !drawable  $game_map.interpreter.running
    ' w; K! Q9 t1 W) E
  1161.     get_mouse_pos0 H% p1 R/ ?$ [3 O0 c
  1162.     $mouse_move_sign.moveto(@moveto_x, @moveto_y) # 移动路径点指示图' X1 M, h+ R& g/ i$ v+ k" F
  1163.     if @shift_event, ^6 \) T- X, A2 O
  1164.       if Mouse.trigger(0x01)8 @2 r* b* w6 r0 v$ {! H2 G
  1165.         @shift_event.jump(@moveto_x - @shift_event.x,
    3 |% E" i: v" b* S; r1 K
  1166.           @moveto_y - @shift_event.y)
    ' i( X% J- Y0 L5 p
  1167.         @shift_event = nil1 N, L# P* W' u3 R
  1168.       end3 P% l* U8 ^9 q: \
  1169.       return
    2 f4 `& H3 W3 |3 s: P/ Y
  1170.     end6 H3 J& a& k! S
  1171.     if @moveto_x == x && @moveto_y == y # 判断目标点是否与角色重合" B2 f- e6 s; U( G4 L
  1172.       return if moving  (vehicle && !vehicle.movable)
    * S7 a% Y" i1 K9 V+ Z
  1173.       check_event_trigger_here([0]) # 判断是否触发重合点事件' C- Z# ~8 k# T) }
  1174.       get_on_off_vehicle if !$game_map.setup_starting_event &&
    ; a. j/ S& \$ p; @8 d" B+ P
  1175.         $game_map.airship.pos(x, y)  # 判断是否要上、下飞艇4 ~+ d4 d% |4 R0 E* i2 p
  1176.       return
    % h+ F. `8 u$ W  k6 w
  1177.     end6 t' n$ |  m& G
  1178.     # 判断是否用鼠标启动事件
    6 q" l, T* t) T( ~
  1179.     $game_map.events_xy(@moveto_x, @moveto_y).each do event
    / G+ W# Z' r& J) e) K8 V. `: |+ e
  1180.       if event.mouse_start2 l: q! B7 L* R; V( W5 {
  1181.         reset_move_path/ v1 T$ X1 e4 Z+ ]; n  [
  1182.         event.start if Mouse.trigger(0x01)1 `6 }) ~9 a8 n6 v1 Y
  1183.         return
    % r1 }( ^( s  f2 L- D) D8 z& E
  1184.       end+ C- f4 x% H, _9 f* K
  1185.     end! M2 y: g4 o' z1 B- s0 j' m
  1186.     @mouse_dash = true if Mouse.double_click # 双击冲刺
    * |3 }2 Z7 w% X  P) v; L6 L0 j
  1187.     return if Mouse.left_state % 10 != 1 # 按住鼠标左键10帧绘制1次路径3 }4 u2 X+ H' M6 V# g7 w" B9 M
  1188.     for i in 1..4 # 判断目标点是否为角色周围四点0 L" W1 g, s3 {. P5 O6 i
  1189.       if x == $game_map.round_x_with_direction(@moveto_x, i  2) &&
      @$ K4 v$ G& x3 P8 A2 @
  1190.          y == $game_map.round_y_with_direction(@moveto_y, i  2); `* @, J* U" D
  1191.       $mouse_move_sign.transparent = true
    & c2 o/ w# ~5 |- b2 u6 B
  1192.       @mouse_move_path = [10 - i  2] if Mouse.trigger(0x01)
    % a8 A: e3 t; Q1 j& I
  1193.       return; end
    3 F2 U6 h& x4 A5 e7 h7 ~4 c+ p
  1194.     end
    6 b9 Q7 n9 B; o& K: y0 `7 ^
  1195.     draw_move_path5 j6 ?- i8 J0 _$ A
  1196.   end
    , \- n8 M3 [( s0 A
  1197.   #--------------------------------------------------------------------------* b& f/ W. m; v2 w, q2 Y: y2 L7 B, v) T: w
  1198.   # ● 取得鼠标处对应地图坐标点. s5 [8 V: y  Z: S9 ]$ A
  1199.   #--------------------------------------------------------------------------
    - @8 A, X1 O9 x" a1 c" w5 t
  1200.   def get_mouse_pos8 k' G0 u5 s' V8 c
  1201.     $game_map.get_mouse_map_xy
    + b' a: {, I) N1 D- m  t4 D4 t
  1202.     @moveto_x = $game_map.mouse_map_x
    ! R! z; G: `* U7 @$ u
  1203.     @moveto_y = $game_map.mouse_map_y+ a- N0 L$ {* ?- D: {& q, E+ f
  1204.     #mouse_x, mouse_y = Mouse.get_mouse_pos
    + {& u& b) \2 g& Z7 ?- E
  1205.     #@moveto_x = $game_map.round_x(x + (mouse_x - 7 g; g! c0 p4 f5 ?7 g
  1206.     #  ($game_map.adjust_x(x)  32 + 16).to_i + 16)  32)* V6 d$ _8 z; c) Z: K+ w% H" L1 O
  1207.     #@moveto_y = $game_map.round_y(y + 1 + (mouse_y -
    , c- R- m4 b0 {9 z6 t( V
  1208.     #  ($game_map.adjust_y(y)  32 + 16).to_i - 16)  32)* l; a% @5 k* ]" `2 D8 ]9 S
  1209.   end
    ! ?- C6 ]+ I, c) ^' X0 l$ x8 J
  1210.   #--------------------------------------------------------------------------
    . F& V- V" m  O
  1211.   # ● 绘制移动路径 @array[move_directions...]
    , u" _3 b, z( }( q
  1212.   #--------------------------------------------------------------------------: h& W6 Z7 Y$ _( }
  1213.   def draw_move_path
    ( s1 o; {1 K8 I
  1214.     #temp = Time.now- F; D2 _0 |+ Z0 E0 c% I! O- A" E
  1215.     case @vehicle_type
    8 a; ]  V  s/ w, ~' x$ e
  1216.     when walk
    % s$ Z: @, J7 q' F
  1217.       draw_walk_path
    9 s! P+ `& _2 i6 H( M% O
  1218.     when boat
    ' }# S& Q; H7 d$ s1 |- j
  1219.       draw_boat_path
      a/ N# _. g+ T  a3 w7 `3 E- ?
  1220.     when ship
    . a5 X7 P% E: y' z( ?1 z3 u
  1221.       draw_ship_path
    7 i  |7 m, J6 l
  1222.     when airship! J1 j. `  f* V7 \% q
  1223.       draw_air_path- [1 |5 \! L5 ?0 o1 [6 Z9 y
  1224.     end  c% _% M$ ~7 m9 Y
  1225.     #p (Time.now.to_f - temp.to_f) # 测试效率
    * V! I7 `# L) Z+ |, s$ l
  1226.   end
    1 [/ P  l5 Y% _' t' K  w- ?- u
  1227.   #--------------------------------------------------------------------------
      s. J0 _4 Q1 ~3 ?* D
  1228.   # ● 判定是否可以绘制移动路径6 b' M" a7 {# ?# D) D6 i* t
  1229.   #--------------------------------------------------------------------------7 K( c* v# _& @& q4 S8 P
  1230.   def drawable
    1 Z1 M4 ~3 i! h  V: S- \9 y! I
  1231.     return false if @move_route_forcing  @followers.gathering
    ' ?8 l' ?+ n4 I1 x
  1232.     return false if @vehicle_getting_on  @vehicle_getting_off# K, r  D: s  Y# J# Z  ?6 `( U3 u
  1233.     return false if $game_message.busy  $game_message.visible
    0 o- o, B3 _, Q$ C
  1234.     return true7 c2 s2 h; h& K; p7 ^4 Z
  1235.   end
    ; p' d: w5 u( ]  ~4 H9 @
  1236.   #--------------------------------------------------------------------------
    4 P8 L/ [* w- W% M$ s
  1237.   # ● 绘制walk移动路径 @array[move_directions...]( ]- ^2 o$ p/ n' B0 @) K
  1238.   #--------------------------------------------------------------------------3 a$ j2 `' v2 i5 [$ g8 t
  1239.   def draw_walk_path
    # T9 }" i7 W( X7 C4 l% C, j
  1240.     # 准备绘制路径表格
    1 f7 o0 d; s* ]5 Y& ?* I
  1241.     sheet = Table.new($game_map.width, $game_map.height)2 G# N" M+ v3 S
  1242.     reversed_chase_path  = []; chase_path  = []
    ! T) {& M2 c: _( E( M7 q+ A" D5 w
  1243.     reversed_chase_point = []; chase_point = []
      y4 [! [: E! q% r/ w+ [
  1244.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
    ; C# f0 y2 g: t4 Q  [& O$ K2 D
  1245.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 25 r' z: Q' M! Z
  1246.     reach_point = false* w! {; _$ H9 ^5 X( v/ Q
  1247.     step = 39 _! Q. b/ v0 i) u- d- d% E* `, Z
  1248.     loop do #loop1 开始填充表格, U* I! ^  t9 V
  1249.      draw_path = false4 S- z: {4 p$ Z9 i2 v. T
  1250.      check_points = new_start_points
    , k& [* ], ]4 i0 \9 C7 r' P4 \
  1251.      new_start_points = []
      r: ^  V; d# p- M6 H
  1252.       loop do #loop2 从起点开始正向填充
    , X/ y5 p. p) b$ c* S, t/ E' s
  1253.         point_x = check_points.shift
    8 q% L3 Y2 [& ~! }3 `# {  K* \4 y
  1254.         break if point_x == nil
    7 H/ b: O# i1 j3 f: r5 D2 u2 W
  1255.         point_y = check_points.shift% l0 f8 b6 m+ N/ b  V8 x8 _
  1256.         left_x  = $game_map.round_x(point_x - 1)
    % c7 c5 k) l1 W! X; W
  1257.         right_x = $game_map.round_x(point_x + 1)- B: i1 X! b& l+ ~, v! Z+ D& @
  1258.         up_y    = $game_map.round_y(point_y - 1)
    ; ^  X* i. [+ y" |
  1259.         down_y  = $game_map.round_y(point_y + 1)
    5 K) I/ J0 c& R8 |. k" T" @5 n
  1260.                     # 判断路径是否连通
    " O4 d+ _; f& \. K
  1261.         path_step = step - 12 W; L0 Y4 Y) L8 {& Q
  1262.         if sheet[left_x, point_y] == path_step     &&7 Q& h  ]4 x* n. \& _) O8 @9 r
  1263.            $game_map.passable(left_x, point_y, 6) &&9 d' B3 W0 [/ ]& s
  1264.            $game_map.passable(point_x, point_y, 4)
    # W! N6 l5 E4 z6 B; ?& N
  1265.           chase_path.push(4)
    ( P& O" S- K( [# D2 Z+ ]! U9 z
  1266.           chase_point = [left_x, point_y]& B& H! O- M% X6 p2 B' q
  1267.           reversed_chase_point = [point_x, point_y]8 F" Z$ i( W0 ~9 h" K! s
  1268.           reach_point = true; break
    ) p$ g" U: ?* ^) `1 t, c
  1269.         elsif sheet[right_x, point_y] == path_step     &&
    & G7 _( C! m$ H7 x& m5 `
  1270.               $game_map.passable(right_x, point_y, 4) &&- ^" O- R9 x1 u
  1271.               $game_map.passable(point_x, point_y, 6)
    2 g/ E* i9 W* J& P! m( ^* @" U
  1272.             chase_path.push(6)1 r* o5 T; R) t3 s9 z3 }! X' [
  1273.             chase_point = [right_x, point_y]
    5 G; L8 @. o' Z5 E
  1274.             reversed_chase_point = [point_x, point_y]
    5 C/ b3 S1 B! u
  1275.             reach_point = true; break
    , M( {2 Y2 r) F3 @
  1276.         elsif sheet[point_x, up_y] == path_step     &&0 U' C% ]& F! p  s
  1277.               $game_map.passable(point_x, up_y, 2) &&2 L1 E% e) w5 \8 {# U4 H+ W, Z
  1278.               $game_map.passable(point_x, point_y, 8)' }' b  v4 z# Q# N/ Q/ f: K
  1279.             chase_path.push(8)
    9 D9 [6 S4 M: m& d4 R* [% x3 ]! u4 c8 Z2 c
  1280.             chase_point = [point_x, up_y]
    ; K% }" X* V9 N# _' ~: _7 N
  1281.             reversed_chase_point = [point_x, point_y]
    " V5 f0 F; Z5 }
  1282.             reach_point = true; break
    " h" _; U# P( q% F
  1283.         elsif sheet[point_x, down_y] == path_step     &&: z, E3 {& m0 w. g* _! z* l& Q
  1284.               $game_map.passable(point_x, down_y, 8) &&
    6 T* ]: t& J7 d# _
  1285.               $game_map.passable(point_x, point_y, 2)2 s( M0 E# ?5 d5 ]
  1286.             chase_path.push(2)( c! `$ L  |8 {! f! [' m+ M
  1287.             chase_point = [point_x, down_y]
    & U% k* |( m6 v* J1 s
  1288.             reversed_chase_point = [point_x, point_y]
    , Y3 R# f: k4 p4 D+ G" R, J3 H
  1289.             reach_point = true; break3 M8 S8 Z5 B2 i! B4 v
  1290.         end3 F9 ]' S; v$ v: k
  1291.         # 以需要抵达该点的步数填充路径表格 #
    6 x9 b3 k' e0 Q+ D
  1292.         if sheet[left_x, point_y] == 0              &&! J. `/ s  a4 W5 M
  1293.            $game_map.passable(left_x, point_y, 6)  &&5 |% r1 z4 o8 f8 _
  1294.            !collide_with_events(left_x, point_y)   &&+ j! j' r# q* M9 Z
  1295.            $game_map.passable(point_x, point_y, 4) &&6 L- Z" \; q4 g  Z. t* v* o4 L
  1296.            !collide_with_vehicles(left_x, point_y) #judge_end
    ' }* @6 E# j' @) V! O
  1297.           sheet[left_x, point_y] = step: h- Y) [& O" P7 z
  1298.           draw_path = true% {; ]5 M" O+ b( a) Z6 o0 }, ?0 C
  1299.           new_start_points.push(left_x, point_y)
    / m$ o5 {5 m9 P: w( }( p6 [+ i
  1300.         end- M! @- p1 a& y0 G" V  Z0 t
  1301.         if sheet[right_x, point_y] == 0             &&0 q1 A, Z; q+ \
  1302.            $game_map.passable(right_x, point_y, 4) &&
    2 q! ?' b. ~1 Y$ ^0 N
  1303.            !collide_with_events(right_x, point_y)  &&8 O& ?- ]3 b2 [# y( M
  1304.            $game_map.passable(point_x, point_y, 6) &&$ ~8 i) t: l: W0 `5 n
  1305.            !collide_with_vehicles(right_x, point_y)#judge_end, P1 I, j$ x. |8 ~( @1 V
  1306.           sheet[right_x, point_y] = step
    % b4 U. ~% C1 \/ k+ Y. W7 ^/ `# T
  1307.           draw_path = true
    8 r7 ^6 T$ Z5 W; {8 S' C( C. y
  1308.           new_start_points.push(right_x, point_y)8 U( ^! Y8 G' M/ E7 Z6 ]$ r! u6 Q
  1309.         end) u0 C% w8 n' P
  1310.         if sheet[point_x, up_y] == 0                &&
    1 I1 Y  q% B7 e6 G1 @0 L: U! w# W
  1311.            $game_map.passable(point_x, up_y, 2)    &&8 j+ T/ a; w6 [& A' b
  1312.            !collide_with_events(point_x, up_y)     &&) V' _2 {) f) f
  1313.            $game_map.passable(point_x, point_y, 8) &&
    9 J& p9 i3 H6 g! m% o# o! J! U
  1314.            !collide_with_vehicles(point_x, up_y)   #judge_end
    / ?6 e. x4 _4 q+ a2 L1 V8 Q
  1315.           sheet[point_x, up_y] = step  e% b1 ?3 y  r8 j2 z) S' X  }
  1316.           draw_path = true
    * A' z1 A* K3 K  Z. i5 u
  1317.           new_start_points.push(point_x, up_y)" F4 X* G* z: F3 X, D3 |; ?
  1318.         end
    " Y+ r& ~6 Z+ i# `' a
  1319.         if sheet[point_x, down_y] == 0              &&4 h" V/ D" S) S7 D& k0 R5 }
  1320.            $game_map.passable(point_x, down_y, 8)  &&
    3 g% Y7 c6 K7 I! v6 H2 K8 C
  1321.            !collide_with_events(point_x, down_y)   &&+ H7 V$ T! [6 u; ~6 E3 K
  1322.            $game_map.passable(point_x, point_y, 2) &&
    ; G2 z+ L4 R* Q8 c1 E
  1323.            !collide_with_vehicles(point_x, down_y) #judge_end
    7 n1 k5 m- S( z/ L9 k
  1324.           sheet[point_x, down_y] = step6 C$ k" o5 Q0 @2 R2 F9 R8 N
  1325.           draw_path = true
    6 r+ ]6 \$ l" U3 B
  1326.           new_start_points.push(point_x, down_y)% S* J$ O- P# n4 I
  1327.         end
    : y5 h) G# {- g& Z3 ~1 [
  1328.       end#endOfLoop2% \( O/ R9 |$ c$ h& d. A/ o
  1329.       break if !draw_path  reach_point+ G2 K* u" `5 P! K
  1330.       draw_path = false' }- f7 D3 A9 A2 i& M
  1331.       check_points = new_end_points
    : L4 z* x! b  c! ?7 M  z% S8 S
  1332.       new_end_points = []
    4 F, }) N: @3 L$ I: C( s! ]! S3 z; V) N6 j
  1333.       step += 1/ Y8 S" q# l- {* f3 y/ A9 \
  1334.       break if step  KsOfSionBreak_Steps &&6 [" l5 t" F# W6 c) \/ R- i% G1 d
  1335.                !Input.press(KsOfSionFind_Path_Key)6 T7 {+ B* G  e
  1336.       loop do #loop3 从终点开始反向填充1 i# _7 O* o' [8 N& y
  1337.         point_x = check_points.shift" h, ^1 ]# |& J8 v3 D8 O
  1338.         break if point_x == nil
    : R6 W2 @; \  {( E1 b
  1339.         point_y = check_points.shift, \  i  ~8 Y' p% O# v. q- }
  1340.         left_x  = $game_map.round_x(point_x - 1)
    ' _% v9 ]8 E0 K4 Q6 R% i  J
  1341.         right_x = $game_map.round_x(point_x + 1)$ Z. t; U5 x7 v+ @
  1342.         up_y    = $game_map.round_y(point_y - 1)- C$ Q- n) d+ b" H: Q
  1343.         down_y  = $game_map.round_y(point_y + 1)! [1 t; T) L  o+ @3 }0 v& r) l1 c. s
  1344.         # 判断路径是否连通
    5 G5 |' a5 l/ X
  1345.         path_step = step - 1. T0 o9 E. z$ H" r3 ]" T4 x7 b2 L" x
  1346.         if sheet[left_x, point_y] == path_step     &&
    ) r& ?% k' E8 v
  1347.            $game_map.passable(left_x, point_y, 6) &&
    0 w5 F9 v- v/ ~/ y; B/ g  v
  1348.            $game_map.passable(point_x, point_y, 4)
    ; q8 E  q) {( d; A. E" L0 s. t
  1349.           chase_path.push(6)
    $ Q- `6 N& S8 T
  1350.           chase_point = [point_x, point_y]
    % g4 I' T: d8 `' e
  1351.           reversed_chase_point = [left_x, point_y]5 H1 s+ F2 ~3 n& F
  1352.           reach_point = true; break; U- w5 T3 [# t: \: P# X
  1353.         elsif sheet[right_x, point_y] == path_step     &&
    - F+ L+ X0 a; q  f$ [; e
  1354.               $game_map.passable(right_x, point_y, 4) &&% ^8 F& P- S) b  i& ]& |: _& @8 [. O' P4 d
  1355.               $game_map.passable(point_x, point_y, 6)
    . @' f: @4 c# j+ V  O3 f# t
  1356.             chase_path.push(4)
    9 w6 }% i7 z. U7 a; h) y
  1357.             chase_point = [point_x, point_y]) s5 a  C% d2 ^: ]: [* J
  1358.             reversed_chase_point = [right_x, point_y]0 C2 F* d  h6 ^: X7 X
  1359.             reach_point = true; break
    ! n, W% Q) p0 L, W, E  s/ @
  1360.         elsif sheet[point_x, up_y] == path_step     &&
    7 Y! b/ D9 {/ _# n
  1361.               $game_map.passable(point_x, up_y, 2) &&8 O0 _+ Y8 v& g. A* w
  1362.               $game_map.passable(point_x, point_y, 8)( t% }- ^' s# J# j: q
  1363.             chase_path.push(2)
    ) M( E  U" t; R! b, z1 V! J5 A
  1364.             chase_point = [point_x, point_y]
    # k, R+ y, V1 j3 u7 B& {% s
  1365.             reversed_chase_point = [point_x, up_y]) W; H( o9 q" r  f& w
  1366.             reach_point = true; break
    7 z! C3 T5 B/ t: h( |) o" _
  1367.         elsif sheet[point_x, down_y] == path_step     &&
    " t2 u, \8 e: t9 h* k2 U( Q9 D
  1368.               $game_map.passable(point_x, down_y, 8) &&
    - H$ Z+ c8 [; u. M& |; a
  1369.               $game_map.passable(point_x, point_y, 2)! i  R) w9 O1 ]0 x
  1370.             chase_path.push(8)* Q* f& ~" {% s  k' ~* f- y+ F
  1371.             chase_point = [point_x, point_y]% O- a2 z; @' A; J
  1372.             reversed_chase_point = [point_x, down_y]0 w1 u" N  d* w
  1373.             reach_point = true; break
    0 {7 _  ^( a5 U+ Q" x6 R
  1374.         end$ ^4 y/ K6 l# a, d
  1375.         # 以需要抵达该点的步数填充路径表格 #
    / c! y/ m6 X8 k( r, B8 B9 g) E
  1376.         if sheet[left_x, point_y] == 0              &&
    + n, g7 z# u4 \
  1377.            $game_map.passable(left_x, point_y, 6)  &&& S1 a0 V( D) y' i0 X! }
  1378.            !collide_with_events(left_x, point_y)   &&
    : W, l$ |$ k2 \; }
  1379.            $game_map.passable(point_x, point_y, 4) &&
      |1 A5 Z& y4 h3 O' W
  1380.            !collide_with_vehicles(left_x, point_y) #judge_end3 i! A+ q' {5 `5 K% g
  1381.           sheet[left_x, point_y] = step
    # g/ l* \  w9 s! b& y; O
  1382.           draw_path = true8 N& a3 v: M& Q; I, q
  1383.           new_end_points.push(left_x, point_y), O, D/ G8 E/ l. E" d8 H& x
  1384.         end' @$ z5 [0 s& P2 g  y8 g/ r' t- L
  1385.         if sheet[right_x, point_y] == 0             &&
    : B+ j. _/ ~# w( C
  1386.            $game_map.passable(right_x, point_y, 4) &&7 `( m7 p7 ~5 T, j9 W" w
  1387.            !collide_with_events(right_x, point_y)  &&
    . m; s- q6 K% p9 b; O9 K  \: m5 b
  1388.            $game_map.passable(point_x, point_y, 6) &&0 p# N# O: t* J; i7 }; v1 J' ~) R# q
  1389.            !collide_with_vehicles(right_x, point_y)#judge_end
    $ B8 c- l" Q, A( `3 W7 B6 b- e  g  ^
  1390.           sheet[right_x, point_y] = step0 N0 [9 \! W& E# T
  1391.           draw_path = true# h+ x* e" N0 n# a% U
  1392.           new_end_points.push(right_x, point_y)
    " F& Y8 Q2 y0 p+ Z; L% _6 y& ^
  1393.         end& ]- _0 q  Y; B3 u1 q
  1394.         if sheet[point_x, up_y] == 0                &&
    8 ?: A% t$ P% B  [! N0 B' q5 K* R
  1395.            $game_map.passable(point_x, up_y, 2)    &&
    : q% s. l/ X; ~  ~0 K# b" F
  1396.            !collide_with_events(point_x, up_y)     &&
    7 ?8 B: `  ^! p  R" J4 H: G
  1397.            $game_map.passable(point_x, point_y, 8) &&
    . C& g: A$ a) Z: w1 }
  1398.            !collide_with_vehicles(point_x, up_y)   #judge_end
    $ D. ?  [  I. [
  1399.           sheet[point_x, up_y] = step- n7 h1 ^: g) d2 B' L% y: A- `
  1400.           draw_path = true
    0 z1 \8 Y/ @7 ~3 w8 Q2 Z0 K& W  ?
  1401.           new_end_points.push(point_x, up_y)% M- P" f; h. H" |" w- [; a
  1402.         end
    $ k6 i  ]. K! ]5 U5 f3 K- ~3 p% T
  1403.         if sheet[point_x, down_y] == 0              &&
    ; Q& i; k- r* X2 p: f2 r
  1404.            $game_map.passable(point_x, down_y, 8)  &&
    . R" K7 E7 k5 g" y- u/ j' [
  1405.            !collide_with_events(point_x, down_y)   &&; I4 \( }) c5 _; h: q
  1406.            $game_map.passable(point_x, point_y, 2) &&" u/ I* Y7 Z, v6 Q/ C: G+ Q
  1407.            !collide_with_vehicles(point_x, down_y) #judge_end: l; i5 \0 [5 k/ y+ m# N5 u
  1408.           sheet[point_x, down_y] = step
      V: c$ R/ ]0 N2 ?: T  [- G) W) k
  1409.           draw_path = true' \3 }! |& |- S) A6 R. o6 e& `
  1410.           new_end_points.push(point_x, down_y)+ b9 g$ k% L' s1 ?, P
  1411.         end
    5 \7 Q1 p: V; |* r
  1412.       end#endOfLoop3: b  S0 S6 ~4 ?8 |5 x7 ?$ A
  1413.       break if !draw_path  reach_point
    $ M) F5 {) |- U; f
  1414.       step += 1- x! M7 i3 j! _) \" B- C+ K' E8 e  f' b
  1415.     end #endOfLoop1 路径表格填充完毕
      N0 o; G: b3 c9 b
  1416.     $mouse_move_sign.transparent = false
    ; d! Z8 e# d6 F3 \. A
  1417.     # 判断指定地点能否抵达% u$ ^; V! ?' S8 D0 l) {1 L
  1418.     if reach_point/ e# Y5 }5 r2 S! V5 U# @/ _
  1419.       $mouse_move_sign.direction = 2
    " b" V0 K$ O& d- d/ Q, w3 b% Q# ]
  1420.     else5 W+ v  d* e7 H' Z+ V0 u
  1421.       not_reach_point
    # F2 e' e3 M5 Z+ I0 T8 |
  1422.       return
    ( ?! v2 D* G$ B3 O5 j4 Z% }
  1423.     end
    + x4 p+ p; p% }
  1424.     # 根据路径表格绘制最短移动路径(反向)
    + e6 t; h  ?$ l9 P/ w8 n2 C: i
  1425.     steps = step  2  2 + 1
    8 x& z" A- Y6 q4 c" f& A7 H
  1426.     loop_times = step  2+ F2 ]0 n. i6 q
  1427.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
    - J* \$ A( O! c  H3 k
  1428.     for i in 1..loop_times # forLoop
    / p( [: J0 @" ~
  1429.     steps -= 2) A( n% O, R# A# h% ]( z4 F4 f
  1430.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs #反过来?蛋疼了……/ O9 ]+ ~3 s9 l1 }
  1431.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
    3 t3 V0 c& u0 O# ^
  1432.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&
    1 E$ g' t; G7 [  ?9 A, p) z' S
  1433.             $game_map.passable(point_x, point_y, 4)                #judge_end
    2 ~" k& n- o* o7 i
  1434.         reversed_chase_path.push(6); o: \% f* _4 R; m6 M1 ]
  1435.         point_x = $game_map.round_x(point_x - 1)
    ' i3 ^% s7 f( F
  1436.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    - R; Q+ M( Z7 `2 c9 P
  1437.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
    " r9 G, l0 g( Q4 }. s% M' q( P
  1438.             $game_map.passable(point_x, point_y, 6)                #judge_end5 G( \+ f4 o8 u4 t9 c/ \: N% C
  1439.         reversed_chase_path.push(4)
    ) r9 }: s' t& y+ }
  1440.         point_x = $game_map.round_x(point_x + 1)
    / E! j3 u! ]% g7 O; x. L
  1441.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&! T# @; k1 O* E: G
  1442.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&3 p/ g, s0 A0 j7 Q0 t8 w+ e
  1443.             $game_map.passable(point_x, point_y, 2)                #judge_end: j$ V* D! @& O6 M$ J/ u
  1444.         reversed_chase_path.push(8)
    ; q9 r( ?  B& r
  1445.         point_y = $game_map.round_y(point_y + 1)6 J8 ]3 ^% Y  q$ \. Q! `* t0 u
  1446.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&0 K* z% r0 B$ q
  1447.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&- a( Z# D2 v5 `  h) B$ A
  1448.             $game_map.passable(point_x, point_y, 8)                #judge_end
    * n" {" G5 z3 F4 X5 Z6 L- _
  1449.         reversed_chase_path.push(2)
    ; E/ _5 ^* u9 Y. o
  1450.         point_y = $game_map.round_y(point_y - 1)! k2 H5 g( u% A5 b; K0 ~
  1451.       end
    ( l: i7 N3 y" z0 O; U
  1452.     else
    ( t" Z) y# g; o0 ~9 c9 b# c' M+ b
  1453.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&  d1 ~8 b: U; P1 w
  1454.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
    : ~9 W' I; g/ u- }7 `+ E
  1455.             $game_map.passable(point_x, point_y, 2)                #judge_end5 s' U! I: L( B, G' S2 J: a
  1456.         reversed_chase_path.push(8). z2 O1 y7 R7 T. K! Y# C
  1457.         point_y = $game_map.round_y(point_y + 1)
    * j3 T" c6 l- s$ n- n, F
  1458.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&- s2 O/ u' o  G  _6 t8 U
  1459.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
    " f/ \0 j6 u. [5 P/ _: j) {
  1460.             $game_map.passable(point_x, point_y, 8)                #judge_end
    " y2 j* t- z( z
  1461.         reversed_chase_path.push(2)- r4 u! C7 H- y# j+ Q, G9 B
  1462.         point_y = $game_map.round_y(point_y - 1)
    $ a/ E) S' Q) g8 T5 X; W& K
  1463.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&- u( K: Y7 c* x% w7 v" N. i
  1464.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&/ w" u1 x5 R" b/ P& R% C& h
  1465.             $game_map.passable(point_x, point_y, 4)                #judge_end0 T  S1 `3 s" j' d5 z2 E/ g: c
  1466.         reversed_chase_path.push(6)
    1 Y, V6 [0 g. P+ {0 I% W* l+ c7 ~$ z
  1467.         point_x = $game_map.round_x(point_x - 1)
    - e* K( {, A: [: Z
  1468.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&  n; g" Y4 i9 G1 C( ^
  1469.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
    1 V/ ~! K2 J+ x% {( c
  1470.             $game_map.passable(point_x, point_y, 6)                #judge_end
    2 a$ M9 U' P8 h4 Z4 y% d: _$ n  v6 H
  1471.         reversed_chase_path.push(4)
    & B! j. x2 ?) O0 ?$ g* G
  1472.         point_x = $game_map.round_x(point_x + 1)
    8 Q  K7 W) o( x9 S
  1473.       end  J. o4 G  s1 n' {8 U
  1474.     end
    ! ~+ Y4 Z' p% C* f' U0 H
  1475.     end #endOfForLoop
    , q, K) Z1 z% Y* z" w  Q1 D
  1476.     # 根据路径表格绘制最短移动路径(正向)2 {  A" H- v- M3 U# z2 @
  1477.     steps = step  2  2
    # @5 R+ ~- `( P& {! C8 p5 F
  1478.     loop_times = step  2
    / C4 t2 w; W" i, g" q
  1479.     point_x, point_y = chase_point[0], chase_point[1]
    ' C1 Z+ J2 t- O# q
  1480.     for i in 2..loop_times # forLoop: M5 |) G# m" v$ S' S/ c+ P
  1481.     steps -= 2' g+ z4 s2 v' l: P, |% A
  1482.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    1 F8 d% h5 k8 I# p0 m4 i
  1483.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&7 L: g- _5 H  J) y0 d$ A3 o; k+ n) j
  1484.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&7 E+ L% `+ }3 w
  1485.             $game_map.passable(point_x, point_y, 2)                #judge_end
    & g4 v/ l+ m3 v1 F7 W5 a
  1486.         chase_path.push(2). V# Y  h, f" i6 s4 C* h6 b0 G* Q
  1487.         point_y = $game_map.round_y(point_y + 1)
    ! y$ a; T% y, K& |
  1488.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
    ! R& j) U& X2 S0 Y4 R: I9 B
  1489.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
    # x8 P/ {$ _- V3 T2 }1 g0 j
  1490.             $game_map.passable(point_x, point_y, 8)                #judge_end! Z# X' {/ e6 l& Z
  1491.         chase_path.push(8)- t, D3 e3 V9 z
  1492.         point_y = $game_map.round_y(point_y - 1)$ T3 I4 V7 D3 h1 d4 q1 I; C: J! G
  1493.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
    5 y; Z1 H: u$ }5 \/ m/ j5 U
  1494.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&$ T6 K/ n+ o+ q* h
  1495.             $game_map.passable(point_x, point_y, 4)                #judge_end) n# o3 r$ C. o% o' a( {
  1496.         chase_path.push(4)- k( X& a' K9 m6 a* W7 w
  1497.         point_x = $game_map.round_x(point_x - 1)7 C6 m! \9 T& {) m  M: l# ^
  1498.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    * O* V* c! C8 X3 G
  1499.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&8 M5 H8 c0 N9 g" a/ B
  1500.             $game_map.passable(point_x, point_y, 6)                #judge_end8 Q# {2 Z/ p& |
  1501.         chase_path.push(6)) u4 f7 l+ j# k0 B
  1502.         point_x = $game_map.round_x(point_x + 1)$ U8 P" u+ f- V6 f
  1503.       end) k$ O- I# \9 \) n# }
  1504.     else8 Z% {1 s% D% F8 U
  1505.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
    % O" h! u* K" ?/ a6 m: l
  1506.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&
    & @" g* S/ o# ]% q
  1507.             $game_map.passable(point_x, point_y, 4)                #judge_end
    ( M! n% ?; E2 t$ l
  1508.         chase_path.push(4)9 I$ T- l: U1 h! S+ B
  1509.         point_x = $game_map.round_x(point_x - 1)
    1 P! I' @/ l& r
  1510.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    8 E( W' F( f& N" S7 E' q
  1511.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&* \1 ^% |: Y' X$ P5 T
  1512.             $game_map.passable(point_x, point_y, 6)                #judge_end! {( F3 }2 R% n5 W' S
  1513.         chase_path.push(6)
    6 k4 b- i, u$ n! P
  1514.         point_x = $game_map.round_x(point_x + 1)5 Y" V( s0 @; F: ?+ Y5 B
  1515.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
    5 L8 n2 y& X: ~8 s* w! H
  1516.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&1 o0 k" ]. M6 f8 J
  1517.             $game_map.passable(point_x, point_y, 2)                #judge_end( b: b$ C; ~$ ^; s8 D; X! j) v7 e& l5 H
  1518.         chase_path.push(2)9 C3 q" g, I+ t! p. x) f0 O
  1519.         point_y = $game_map.round_y(point_y + 1)) q9 W: z3 ]3 ^% Q; U
  1520.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
    9 j0 M% x- c2 j0 L* Z/ x
  1521.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
    ; r' J7 J" f6 K6 k+ j/ [
  1522.             $game_map.passable(point_x, point_y, 8)                #judge_end) Y# t* M, k0 s1 ?& L% N
  1523.         chase_path.push(8)& |7 U, c! S7 q& I/ ^3 x+ C3 {
  1524.         point_y = $game_map.round_y(point_y - 1)
    % P3 P1 }" v9 y$ A) T7 S. Z
  1525.       end% q4 T. e  x7 P- ~! U& I3 n
  1526.     end
    3 T2 @* {1 M1 ^  U7 [
  1527.     end #endOfForLoop1 D) o# H9 Y" i8 y$ b' K
  1528.     @mouse_move_path = reversed_chase_path.reverse + chase_path! N- F* Z! j% E: S5 a, q2 w2 s: q
  1529.   end#walk  O9 m1 [$ O: ?, j
  1530.   #--------------------------------------------------------------------------. ^- G$ G( P8 j+ f: N  \
  1531.   # ● 绘制boat的移动路径 @array[move_directions...]
    6 @% B# s+ y1 q" Y
  1532.   #--------------------------------------------------------------------------0 B7 B1 B! w+ @8 g- a  K! f
  1533.   def draw_boat_path
    * H" P/ i! \4 I, {$ q( h- s" U
  1534.     # 准备绘制路径表格7 ^) I! r) i. V# g0 o
  1535.     sheet = Table.new($game_map.width, $game_map.height)
    : r  o5 e; W: j& B1 V
  1536.     reversed_chase_path  = []; chase_path  = []
    & E, M# p# s7 V  O8 ]! P
  1537.     reversed_chase_point = []; chase_point = []9 e2 g5 L) X! q; o% S+ Q1 Y% d6 h
  1538.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
    ' P  P7 x7 G, S5 x* {) G
  1539.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
    - D$ j5 ^5 W: t& J  U5 O. d
  1540.     reach_point = false
    2 s: V5 Z3 o2 V4 h  j7 Z
  1541.     step = 3+ E- |$ d- h/ l3 c
  1542.     loop do #loop1 开始填充表格
    : ?$ O! t2 v9 U1 s' B; ^
  1543.      draw_path = false& y2 ?5 P! D8 e/ e& `) o7 r, K
  1544.      check_points = new_start_points
    " l2 u* C% o: r2 _. H& a
  1545.      new_start_points = []
    + b; s/ [1 l% G3 \
  1546.       loop do #loop2 从起点开始正向填充
    7 q# @; r& F) ]5 z$ D/ o' W
  1547.         point_x = check_points.shift
    - _1 P* p: r+ U1 }
  1548.         break if point_x == nil7 b* \% z* V4 |  f( q6 m
  1549.         point_y = check_points.shift( R; G5 S) J0 o7 H8 Q" c# G3 W7 N3 ?: l
  1550.         left_x  = $game_map.round_x(point_x - 1)
    + b! ^7 h7 W' U- g
  1551.         right_x = $game_map.round_x(point_x + 1)
    7 F0 m' V3 @1 A5 ^% a
  1552.         up_y    = $game_map.round_y(point_y - 1)
    0 |  _. W4 ~! t/ A! R# }: U9 n
  1553.         down_y  = $game_map.round_y(point_y + 1)
    9 K, o/ T* J7 |7 d
  1554.                     # 判断路径是否连通
    * ?+ @5 E2 Y1 ~  J2 `3 u; O
  1555.         path_step = step - 1* n& B: j5 N' p
  1556.         if sheet[left_x, point_y] == path_step
    4 h- r1 N# h, |: y& N4 _2 m8 F- w4 [- L9 T
  1557.           chase_path.push(4)
    8 Q  J, @, V) m  x9 J1 J8 ?
  1558.           chase_point = [left_x, point_y]
    " D$ w' g  D" d  {1 x
  1559.           reversed_chase_point = [point_x, point_y]; d" h5 U1 Q% _3 J+ W% b5 c
  1560.           reach_point = true; break
    0 P+ w% U6 z6 ~2 x% o
  1561.         elsif sheet[right_x, point_y] == path_step
    % Y4 O, O% Q3 C: K7 O* G; s
  1562.             chase_path.push(6)! s. z1 d# ?4 g
  1563.             chase_point = [right_x, point_y]8 Q3 p" m0 u/ g- _6 A9 Q: O
  1564.             reversed_chase_point = [point_x, point_y]
    . W% X8 h2 D" f8 t; ^+ \
  1565.             reach_point = true; break
    * F& v, }0 }/ ?/ T) u: L
  1566.         elsif sheet[point_x, up_y] == path_step: Z5 q1 _" l$ V' |( {8 I% U; t* K$ B
  1567.             chase_path.push(8)
    7 j, u; i  d" @; l8 p
  1568.             chase_point = [point_x, up_y]
    3 d5 _' b# R" E6 O, m$ K
  1569.             reversed_chase_point = [point_x, point_y]
    % ~* {9 P. B" A+ s3 \5 }
  1570.             reach_point = true; break1 v5 z* V) V& F. _5 N* p: a
  1571.         elsif sheet[point_x, down_y] == path_step
    . F& i% m6 w% `9 d7 E- E* I
  1572.             chase_path.push(2)7 F* Q) Y  G! m1 X
  1573.             chase_point = [point_x, down_y]  F( A7 T& P2 w
  1574.             reversed_chase_point = [point_x, point_y]+ i  l, D, @9 h& m
  1575.             reach_point = true; break5 q& g  Y) w$ b# m
  1576.         end1 o* g0 R, ^- v# ^5 I
  1577.         # 以需要抵达该点的步数填充路径表格 #
    0 u' I( n2 j! V9 f% N' W
  1578.         if sheet[left_x, point_y] == 0                &&1 I+ Z) Y. d) \
  1579.            $game_map.boat_passable(left_x, point_y)  &&$ K- c. n. e) r$ l2 `& K2 ~0 b
  1580.            !collide_with_events(left_x, point_y)     &&
    4 e  [* q# v4 M) a1 A/ r1 r
  1581.            !collide_with_vehicles(left_x, point_y)   #judge_end
    9 K/ s6 B9 M/ f$ L0 E( j" E
  1582.           sheet[left_x, point_y] = step
    & ?1 v' y3 G* e. z( f; O! d
  1583.           draw_path = true' m7 A& p, U5 J9 W! [
  1584.           new_start_points.push(left_x, point_y)
    , z0 D* V! V3 L1 O4 x" ]. q
  1585.         end$ |' N; x  [0 w2 p. n8 ~
  1586.         if sheet[right_x, point_y] == 0               &&
    - s3 b- w" D1 I7 a% l
  1587.            $game_map.boat_passable(right_x, point_y) &&4 \8 ~; {5 O  B" k- ^7 b# s; h$ i
  1588.            !collide_with_events(right_x, point_y)    &&# ~+ h9 v4 t- f
  1589.            !collide_with_vehicles(right_x, point_y)  #judge_end
    ! k) Y, j; C- a6 z- c2 v+ X9 u+ l
  1590.           sheet[right_x, point_y] = step
    3 i7 O, K& |; x$ w& W( d- C3 G
  1591.           draw_path = true
    + `( _$ F% D2 r1 `3 N/ u
  1592.           new_start_points.push(right_x, point_y)
    % T+ T0 K- l* a; b6 J7 `. I
  1593.         end+ h( y6 E7 R3 o
  1594.         if sheet[point_x, up_y] == 0                  &&
    ' E. \" z  d3 j& j' G
  1595.            $game_map.boat_passable(point_x, up_y)    &&1 ~0 a" t5 q$ s3 d. O
  1596.            !collide_with_events(point_x, up_y)       &&# ~9 `+ J+ ^! Z3 Z( n
  1597.            !collide_with_vehicles(point_x, up_y)     #judge_end
    8 B$ ]/ E. H1 ^! [7 f4 C
  1598.           sheet[point_x, up_y] = step$ _  q! H4 U+ P: {) G& r4 {
  1599.           draw_path = true
    + W. p0 p) k# e, V
  1600.           new_start_points.push(point_x, up_y)0 s6 W% B4 Y2 G
  1601.         end
    * Y$ r/ x- `$ Y% w7 F
  1602.         if sheet[point_x, down_y] == 0                &&
    8 l) X4 ^: B2 i6 q7 t! g
  1603.            $game_map.boat_passable(point_x, down_y)  &&) ^# a8 W' d7 n) @8 H
  1604.            !collide_with_events(point_x, down_y)     &&, P" V5 v+ B- f) l. i
  1605.            !collide_with_vehicles(point_x, down_y)   #judge_end
      Y  v' B/ Y+ G: t5 N' B% N, A
  1606.           sheet[point_x, down_y] = step
    ; H) }5 p  z% Q: o! B, N" A
  1607.           draw_path = true# a1 y! i4 v% p
  1608.           new_start_points.push(point_x, down_y); ~( e2 o2 J+ G5 ~6 G- L$ u* n- H
  1609.         end0 _1 t( }. x6 x6 ^1 V
  1610.       end#endOfLoop2
    3 ?5 j, ~) n" F- M1 A! [( C2 Z
  1611.       break if !draw_path  reach_point
    2 ?2 c0 d( w& o# z4 P+ {' p7 ^
  1612.       draw_path = false
    3 }0 l+ U3 r6 r8 O( H2 u% j1 L* s
  1613.       check_points = new_end_points2 d. w. [( J, _
  1614.       new_end_points = []
    & ?  W" h5 Q) ?& g; v& x
  1615.       step += 1: f5 K6 \1 N6 a2 f6 Y& g
  1616.       break if step  KsOfSionBreak_Steps &&& ]% ^# E. k1 }
  1617.                !Input.press(KsOfSionFind_Path_Key)
    $ G( h* Z  R( |4 H/ b& p; B1 M; ]( {
  1618.       loop do #loop3 从终点开始反向填充' I4 `& p% s8 S& ^8 {
  1619.         point_x = check_points.shift1 n) F# B' T) y  D5 ?+ y
  1620.         break if point_x == nil
    " H' K0 r  L7 ^3 Y4 @1 I
  1621.         point_y = check_points.shift
    ) Q, O6 z' P" ~
  1622.         left_x  = $game_map.round_x(point_x - 1). M# j" u( O# p7 b% b; Q3 S$ p
  1623.         right_x = $game_map.round_x(point_x + 1)
    9 z6 p* W) N: t  I
  1624.         up_y    = $game_map.round_y(point_y - 1), O% Q3 }* T6 B+ d
  1625.         down_y  = $game_map.round_y(point_y + 1)
    % j* k# ?  t6 |, O! Z2 |: ~+ I- Y0 m
  1626.         # 判断路径是否连通; c& d7 N( o+ F$ P# X/ F9 p! a
  1627.         path_step = step - 1; A8 L8 o+ o: |+ o9 a
  1628.         if sheet[left_x, point_y] == path_step8 Q2 G, N/ p: [4 `$ c" _7 F6 H3 }
  1629.           chase_path.push(6)
      Y: n0 j1 _2 Z' q& t0 W; P% e" g
  1630.           chase_point = [point_x, point_y]9 V9 {2 }$ N* ]$ _* ~9 H
  1631.           reversed_chase_point = [left_x, point_y]
    . d' M! u5 d$ Y
  1632.           reach_point = true; break2 c2 y/ f; g) ~7 B  `
  1633.         elsif sheet[right_x, point_y] == path_step
    8 Q5 c3 b3 k% D/ x$ V* L! S
  1634.             chase_path.push(4)0 L' [6 Q$ Q4 U1 v# c( [
  1635.             chase_point = [point_x, point_y]+ R; B" G* z" Y1 G& R0 ?
  1636.             reversed_chase_point = [right_x, point_y]
    2 h' V3 z# k- U: t$ c% a9 Z. L# r
  1637.             reach_point = true; break
    / V2 k) V( v( Q+ l
  1638.         elsif sheet[point_x, up_y] == path_step
    . ~1 a5 x: t$ h0 t" d" b5 d
  1639.             chase_path.push(2)1 Z/ O: k! B6 s% N6 w( z
  1640.             chase_point = [point_x, point_y]& D9 \2 {! Q, k7 m/ _7 T" l7 k
  1641.             reversed_chase_point = [point_x, up_y]
    $ \8 t; U: B! ^7 x
  1642.             reach_point = true; break) ^4 V9 ^, T* \# {9 j
  1643.         elsif sheet[point_x, down_y] == path_step* Q8 D3 [* c& ~. \* q2 O! U
  1644.             chase_path.push(8)
    ! N0 C2 `$ |! ~. o% H+ {5 V) \
  1645.             chase_point = [point_x, point_y]
    % Z$ h7 u- `- r( v  k9 A, e) y
  1646.             reversed_chase_point = [point_x, down_y]
    ( x1 N4 s  t- q" @+ E, g$ ~$ }
  1647.             reach_point = true; break
    1 |( l( e, v' s/ J! V0 s
  1648.         end
    + I+ \/ b: [+ ?3 W
  1649.         # 以需要抵达该点的步数填充路径表格 #
    $ ]) F3 E0 Z+ J4 T( a
  1650.         if sheet[left_x, point_y] == 0                &&) n+ [9 P+ L  \1 X5 H
  1651.            $game_map.boat_passable(left_x, point_y)  &&( w$ w0 N2 V/ \- `
  1652.            !collide_with_events(left_x, point_y)     &&
    , T, G( d0 Z4 m+ U/ A/ b, c
  1653.            !collide_with_vehicles(left_x, point_y)   #judge_end
    7 G- X0 B4 g, O! q6 M
  1654.           sheet[left_x, point_y] = step
    " a' {. u- \, a7 e; J. K( m) l
  1655.           draw_path = true
    + ^! C2 y+ W" |2 `, q% _
  1656.           new_end_points.push(left_x, point_y)
    1 l) t1 l- E, H/ ^8 q
  1657.         end
    ( k! K& `8 m! o
  1658.         if sheet[right_x, point_y] == 0               &&
    & y" S+ b  d* N8 h  U
  1659.            $game_map.boat_passable(right_x, point_y) &&
    1 k8 Y' W  R( Q. t/ p. Y
  1660.            !collide_with_events(right_x, point_y)    &&) x0 R& t! b) \$ O  Z7 s
  1661.            !collide_with_vehicles(right_x, point_y)  #judge_end0 _( }6 o  W: D- m$ G
  1662.           sheet[right_x, point_y] = step8 d: [* R& D  p  p
  1663.           draw_path = true
    * v/ _3 ]3 c; y# a
  1664.           new_end_points.push(right_x, point_y)
    . `! U9 `5 |* t  k% \1 r
  1665.         end6 p+ H1 O4 R5 G& Q+ I
  1666.         if sheet[point_x, up_y] == 0                  &&7 @/ M% t, f& }
  1667.            $game_map.boat_passable(point_x, up_y)    &&
    4 C: L5 J. h4 P0 F# I
  1668.            !collide_with_events(point_x, up_y)       &&8 S, m) n4 h$ K0 D
  1669.            !collide_with_vehicles(point_x, up_y)     #judge_end# I4 y7 N9 k3 F, K# u& a+ g
  1670.           sheet[point_x, up_y] = step. a' C" G8 z$ e) l, g
  1671.           draw_path = true2 M* ~# w7 _2 w: ^
  1672.           new_end_points.push(point_x, up_y)$ J' J# I  K' ?  s
  1673.         end
    9 k% m$ c0 n6 n1 U, ]3 M; U
  1674.         if sheet[point_x, down_y] == 0                &&( l# x$ B% g8 G* U6 S1 f) w9 L4 ?
  1675.            $game_map.boat_passable(point_x, down_y)  &&; W! W4 q" u4 }0 P7 D. S" W
  1676.            !collide_with_events(point_x, down_y)     &&6 B9 F: |9 f$ A: r, c' t
  1677.            !collide_with_vehicles(point_x, down_y)   #judge_end4 X5 F# S9 n  U4 U) f: m0 r
  1678.           sheet[point_x, down_y] = step  Q. V# l- X# i2 w3 U! {
  1679.           draw_path = true
    4 w7 r) ]6 K% R6 s3 `8 E
  1680.           new_end_points.push(point_x, down_y)
    ) I. G3 T2 G1 T0 N
  1681.         end
    & S- y3 T! z% O  U! `$ o( g
  1682.       end#endOfLoop3, W0 l# c5 k9 J5 s
  1683.       break if !draw_path  reach_point
    $ _3 }5 K+ y# u- @  h
  1684.       step += 13 u" T' m, |6 h# T
  1685.     end #endOfLoop1 路径表格填充完毕
    3 t& w- {- i" ?
  1686.     $mouse_move_sign.transparent = false
    3 u+ x9 X+ T, d) v; B  r9 c
  1687.     # 判断指定地点能否抵达
    2 c( k& U2 Z- A/ E6 C
  1688.     if reach_point
    7 A" A$ G1 }7 Q% B
  1689.       $mouse_move_sign.direction = 2
    ' ?6 l4 K% s# U8 t9 K! J" G( S* F
  1690.     else
    / F& z6 F5 }5 k% U8 M, d2 M- ~; Y
  1691.       not_reach_point$ J8 s. |1 `2 k4 V9 }
  1692.       return. V1 S4 @4 F! Z( G1 N, j7 w
  1693.     end
    # v0 Q- t4 j1 v2 g, p
  1694.     # 根据路径表格绘制最短移动路径(正向)" g% z$ L, U% I& |0 S3 S% R4 c
  1695.     steps = step  2  2$ ?/ K- G+ F. u& g. O
  1696.     loop_times = step  2+ Z! j" }. L" z6 H- {
  1697.     point_x, point_y = chase_point[0], chase_point[1]
    1 e$ g' C! U) z7 h% c9 }
  1698.     for i in 2..loop_times # forLoop
    0 R9 O7 u8 z8 W. d+ [- V7 s0 n$ K3 H, _
  1699.     steps -= 2$ E# Y. m+ m% U) U3 R
  1700.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    ; ]5 v( ^! p) j6 m, s8 Q: I
  1701.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    5 H( k3 {& V6 ^! k" s7 n* N/ R
  1702.         chase_path.push(2)9 S# k  @4 }4 D0 a# N9 k
  1703.         point_y = $game_map.round_y(point_y + 1)
    . R( v# Q0 t$ J- H* O, k0 f
  1704.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    3 M" Y# \+ f, [% R. e
  1705.         chase_path.push(8)( A- h  R( o8 a, L2 j! h' Y
  1706.         point_y = $game_map.round_y(point_y - 1)  A$ k% @+ z0 |; t
  1707.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
    . n" v7 y: z) _& M8 O! g
  1708.         chase_path.push(4)
    ; {% F7 y" Y$ f/ q& X
  1709.         point_x = $game_map.round_x(point_x - 1)
    5 X8 [" e  v" Z1 a8 i8 N
  1710.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps3 n3 ~# g0 q2 M2 J5 O( e, v7 ]
  1711.         chase_path.push(6)6 J' M- N4 b/ e. U, r% z
  1712.         point_x = $game_map.round_x(point_x + 1)3 S! R+ K& q2 q3 ]2 h1 ]8 ^) c, ]0 g
  1713.       end
    ( ^: |0 o0 v5 ~, A
  1714.     else
    ) @' D9 a4 n8 S- Q+ C
  1715.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps; V' B7 Q( p. @, g8 o
  1716.         chase_path.push(4)6 h- `( U$ @! M
  1717.         point_x = $game_map.round_x(point_x - 1)/ ]+ j4 D* V# u6 g$ o2 s
  1718.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps- u  a7 d+ M8 U0 c" M
  1719.         chase_path.push(6)
    # E7 B" A5 }7 @, H/ q
  1720.         point_x = $game_map.round_x(point_x + 1)! P. V$ Q5 }: K- ^. t. L
  1721.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    $ R3 n% V" T( }0 Y9 m
  1722.         chase_path.push(2)
    2 |; o) ?1 T1 L
  1723.         point_y = $game_map.round_y(point_y + 1)) y0 n& A  j$ A" u7 @! H
  1724.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    ' X6 L) d9 x- Z: A/ b
  1725.         chase_path.push(8)
    / S" F: n1 q6 p. F! l" H# m
  1726.         point_y = $game_map.round_y(point_y - 1)
    ( \4 }' y" f, e# Z" L: Y% Z. j
  1727.       end
    8 T0 t. k/ f5 v% @/ L( ~
  1728.     end
    1 m9 L( {8 ^. Y4 V3 S2 s
  1729.     end #endOfForLoop. s4 C, I, T2 g( n2 i
  1730.     # 如果指定点无法抵达或者登陆
    9 ?/ n- }/ n  P! b( n
  1731.     return not_reach_point unless landable(@moveto_x, @moveto_y, chase_path)
    ; D6 w+ W, s3 L* W0 {* |: Q
  1732.     # 根据路径表格绘制最短移动路径(反向)' ~3 I' \+ Y9 t' J; @
  1733.     steps = step  2  2 + 12 Z& O, ]; E' ?3 r0 |
  1734.     loop_times = step  2% U: v8 {* U$ y: R; F5 G; W8 G( F5 h: @
  1735.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
    0 A* A. E3 _+ j* {. E. D. v$ O/ u5 G
  1736.     for i in 1..loop_times # forLoop
    ; I( y2 n# q1 V
  1737.     steps -= 2
    5 r% c, D4 S! E5 |
  1738.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    * J  K: C) ~3 ?4 ^
  1739.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
    1 P% P$ b7 o% A' q
  1740.         reversed_chase_path.push(6)
    1 C8 y% j2 r  p& U. c+ G: a+ L4 d
  1741.         point_x = $game_map.round_x(point_x - 1)
    1 D. E5 ^  m) q1 u
  1742.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps$ u" F. O1 W) i% N( U/ C! s$ h1 M
  1743.         reversed_chase_path.push(4)' k/ q$ c6 D/ ~- T1 M
  1744.         point_x = $game_map.round_x(point_x + 1)
    ' F* w6 G' L5 ^' c. p  l: q* k) k
  1745.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps# b9 v0 H$ t* r/ u  W5 b
  1746.         reversed_chase_path.push(8); J2 L# K& W/ U# M0 b% c6 K
  1747.         point_y = $game_map.round_y(point_y + 1)
    $ S1 e5 B: I( L8 }- h9 P4 X4 L
  1748.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    % b+ [6 E+ p5 ]( J7 I0 {
  1749.         reversed_chase_path.push(2)' h2 i8 ~  D  q: G  X, g
  1750.         point_y = $game_map.round_y(point_y - 1)! Q# ~6 M# x: u
  1751.       end4 J* j4 b9 n3 C$ F
  1752.     else( x) P9 Q5 u" t
  1753.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps) d7 P  J+ Y* S# [+ W# a% c
  1754.         reversed_chase_path.push(8)
    / F% R- Y% G6 M; O4 l( z9 j
  1755.         point_y = $game_map.round_y(point_y + 1)4 F- z7 c- o; E
  1756.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    % a3 Z' j, y% ?$ j. q
  1757.         reversed_chase_path.push(2)
    ) f. Q9 I8 T0 G5 X/ f9 G
  1758.         point_y = $game_map.round_y(point_y - 1)
    % J6 p) Z0 M2 d1 ^
  1759.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps: r3 k  U; F" f2 @% F6 w
  1760.         reversed_chase_path.push(6)
    / Y! S. x/ d5 b% `9 C
  1761.         point_x = $game_map.round_x(point_x - 1)
    - k4 W! c* y% k4 p
  1762.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps4 P7 v/ s* K( s( h: E5 w" x
  1763.         reversed_chase_path.push(4)
    * z9 V7 T3 H5 g8 _* r
  1764.         point_x = $game_map.round_x(point_x + 1)
    " y0 ~3 i1 V+ @0 K' S( I
  1765.       end% L0 n1 C1 r2 J3 ?
  1766.     end1 \* h( t5 t* d3 g
  1767.     end #endOfForLoop3 k4 L, m* r; R' S0 r* i: m
  1768.     @mouse_move_path = reversed_chase_path.reverse + chase_path
    + ~! \9 }3 n# u6 X/ y! r
  1769.   end#boat! C( p) y* |2 ~4 W: {: b  A1 ?5 U
  1770.   #--------------------------------------------------------------------------
    8 N1 M4 o7 e2 e' i0 L/ b' q+ p
  1771.   # ● 绘制ship的移动路径 @array[move_directions...]5 R; d; G9 p* V$ ^4 A1 X
  1772.   #--------------------------------------------------------------------------6 e. b: `( F6 K
  1773.   def draw_ship_path8 a$ {5 Y7 ]; c. {5 ^
  1774.     # 准备绘制路径表格+ L  l% X  o; l/ W7 F: a" z" b
  1775.     sheet = Table.new($game_map.width, $game_map.height)
    8 K. W/ @4 @5 T* h2 R. @
  1776.     reversed_chase_path  = []; chase_path  = []* A! Z9 O* {' G0 y* Q- _
  1777.     reversed_chase_point = []; chase_point = []( \9 G& I: T9 P+ c0 c
  1778.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]% I6 L$ \6 y/ X! f9 ?( a8 q4 r$ ~. w
  1779.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2/ q6 k. k  R- |: f0 Z% q2 n2 ~8 y
  1780.     reach_point = false; ?/ U) Y! R7 H6 w8 d
  1781.     step = 3
    , R5 u0 Y" W# b& q6 x+ B) K
  1782.     loop do #loop1 开始填充表格
    % f. f) E( P; o. e
  1783.      draw_path = false
    + S+ F5 r. V* }. X. n1 s' u
  1784.      check_points = new_start_points% ^! B  H; I$ l1 t( s2 k0 X
  1785.      new_start_points = []$ |0 C0 p' `0 d7 E( c8 F# U3 @
  1786.       loop do #loop2 从起点开始正向填充! }2 E0 {( t: g0 }& G1 K
  1787.         point_x = check_points.shift% e; R4 Y: w- D' |9 o2 J; r
  1788.         break if point_x == nil
    ( U+ ^( B7 I1 C- v/ f) J# H- X
  1789.         point_y = check_points.shift
    / S3 r7 U: K0 G* F8 {6 }1 S
  1790.         left_x  = $game_map.round_x(point_x - 1)% y8 u# V/ C0 K0 ?
  1791.         right_x = $game_map.round_x(point_x + 1)
    / M" |4 h- e( g6 d& e" N
  1792.         up_y    = $game_map.round_y(point_y - 1)  h; V4 C$ G/ l% b7 Z
  1793.         down_y  = $game_map.round_y(point_y + 1)' `9 x  w2 t$ Q' S; t8 [
  1794.                     # 判断路径是否连通- j: p) J" ~2 h0 a% n
  1795.         path_step = step - 1
    . x8 D9 R4 _# Y6 |
  1796.         if sheet[left_x, point_y] == path_step
    2 z: I  A$ }. X+ t% R
  1797.           chase_path.push(4)
    # T# s* z# ]* I" x/ \; }
  1798.           chase_point = [left_x, point_y]. {. K6 C, ^1 P; f9 ?1 V6 s4 S
  1799.           reversed_chase_point = [point_x, point_y]) ]9 K# J! s/ i  B& x! b9 a! w8 P
  1800.           reach_point = true; break
    * _+ N1 z8 ^. x/ v8 H" a1 S; G
  1801.         elsif sheet[right_x, point_y] == path_step. W+ S9 U! a1 j6 u9 [/ p' g  z
  1802.             chase_path.push(6)
    & z  d8 T. u' s) H6 O; M& l
  1803.             chase_point = [right_x, point_y]) K9 k% m1 b9 p
  1804.             reversed_chase_point = [point_x, point_y]3 W% G) w; Q6 s7 E8 D# d
  1805.             reach_point = true; break
    6 B7 G! o4 I/ d# r' o+ {7 o( A3 r
  1806.         elsif sheet[point_x, up_y] == path_step
    " e+ b5 {. p& t) q4 E( h& e& X- }
  1807.             chase_path.push(8)
    - `# Y0 r5 A- u# M
  1808.             chase_point = [point_x, up_y]
    . }, c4 b. }: C) L; y! `3 Q( c
  1809.             reversed_chase_point = [point_x, point_y]
    ; X4 w) T: f% ?
  1810.             reach_point = true; break
    8 U, }2 B5 T3 E/ y+ m
  1811.         elsif sheet[point_x, down_y] == path_step! H* `+ {+ C7 W2 _9 b
  1812.             chase_path.push(2)
    ( l7 }) x5 ^  ?4 T1 a: }' @0 c
  1813.             chase_point = [point_x, down_y]
    ' J( O3 q2 l9 T3 o" J0 Q
  1814.             reversed_chase_point = [point_x, point_y]
    " }# E$ b5 y2 o* Q. p( n3 L7 L+ w
  1815.             reach_point = true; break
    ( Z  ?# T& D# m) z$ l% B
  1816.         end) z, U3 }" V, Q0 {4 M. D: R4 Q
  1817.         # 以需要抵达该点的步数填充路径表格 #
    , D% _) r0 q4 a! O" N8 A
  1818.         if sheet[left_x, point_y] == 0                &&
    ) B8 @$ t9 r/ d, j6 H; U
  1819.            $game_map.ship_passable(left_x, point_y)  &&
    ) z& ~3 V, V5 p2 {0 @- N
  1820.            !collide_with_events(left_x, point_y)     &&9 d0 Q+ x8 ^# h/ `1 [# j4 L
  1821.            !collide_with_vehicles(left_x, point_y)   #judge_end
    ( P$ c  Q% \6 K% r# q: v; }
  1822.           sheet[left_x, point_y] = step
    3 z; |* c% g; m5 I+ T" A* b2 e5 a
  1823.           draw_path = true; n4 E0 Q, E3 X
  1824.           new_start_points.push(left_x, point_y)
    ( l" ]5 T2 R6 N* i
  1825.         end
    " Q5 }% O  L7 I
  1826.         if sheet[right_x, point_y] == 0               &&
    + A2 f# k* Z& O
  1827.            $game_map.ship_passable(right_x, point_y) &&
    ' h) Y% Z  U' x( U/ W
  1828.            !collide_with_events(right_x, point_y)    &&8 h' a" C* I! {# g! i
  1829.            !collide_with_vehicles(right_x, point_y)  #judge_end9 z, H0 g7 G" z' W4 N
  1830.           sheet[right_x, point_y] = step2 j3 R1 F7 \  Q
  1831.           draw_path = true
      I4 S: t/ O: Z6 j
  1832.           new_start_points.push(right_x, point_y)
    * I; u/ A+ U4 e: M3 O: f
  1833.         end
    & L2 G; s) y5 z& z+ x/ u
  1834.         if sheet[point_x, up_y] == 0                  &&# U2 Z7 K2 {) C
  1835.            $game_map.ship_passable(point_x, up_y)    &&7 @, h7 l: R$ [8 k  ~) M
  1836.            !collide_with_events(point_x, up_y)       &&7 Q% U) S1 Z7 r6 ~( P1 u
  1837.            !collide_with_vehicles(point_x, up_y)     #judge_end, ?: ?) q7 v) B4 ?! _, Z
  1838.           sheet[point_x, up_y] = step
    & s+ d; D. D0 n% v
  1839.           draw_path = true% h, Y/ J! A# s/ k" V
  1840.           new_start_points.push(point_x, up_y)
      v! z# p9 S1 Q) H* }
  1841.         end
    & J0 f7 K' d4 e, _( F; }& p( l
  1842.         if sheet[point_x, down_y] == 0                &&/ [/ W) p7 {' b1 z0 n; s! J0 {+ `
  1843.            $game_map.ship_passable(point_x, down_y)  &&% A0 s' J; \' K! ]$ ?0 x
  1844.            !collide_with_events(point_x, down_y)     &&* G$ Y  \9 {) C+ b" @* q
  1845.            !collide_with_vehicles(point_x, down_y)   #judge_end
    ! x; ]6 x7 ?& M' F" V
  1846.           sheet[point_x, down_y] = step* ]) L9 L  a4 N' E
  1847.           draw_path = true5 g  ^+ O+ q; b
  1848.           new_start_points.push(point_x, down_y)9 ~$ I3 W' A9 Z( H6 }' b
  1849.         end
    2 b1 j( W, z2 Y: S1 ^
  1850.       end#endOfLoop2
    8 y' X1 i( D/ p% ^+ @5 c
  1851.       break if !draw_path  reach_point
    7 ?4 c$ ]# T* T0 ]; _2 F
  1852.       draw_path = false
    # ~- b2 y5 f  c- K- Z) |7 ^
  1853.       check_points = new_end_points" O2 X! v: W3 K
  1854.       new_end_points = []
    + {  C% R% W) @( S0 c; }7 r
  1855.       step += 1, [- ^1 C3 U9 N5 c8 g, x
  1856.       break if step  KsOfSionBreak_Steps &&
    / ]# N8 [" v4 X* i% N
  1857.                !Input.press(KsOfSionFind_Path_Key)
    3 w- J9 i( d8 T) p9 s
  1858.       loop do #loop3 从终点开始反向填充
    7 N; W1 O  U5 B1 G. }3 {/ y& ~
  1859.         point_x = check_points.shift
    6 W+ r9 e7 q0 l* L! E; E/ L
  1860.         break if point_x == nil0 S/ Z3 v4 @2 {7 U
  1861.         point_y = check_points.shift2 y/ i, t9 o- ]0 ]4 U/ o+ v
  1862.         left_x  = $game_map.round_x(point_x - 1)7 E$ U9 |$ `8 a' l
  1863.         right_x = $game_map.round_x(point_x + 1)
    $ m6 Z7 X0 C: b1 T( @, v
  1864.         up_y    = $game_map.round_y(point_y - 1)
    ( L* i) p% c1 s' v" A) W
  1865.         down_y  = $game_map.round_y(point_y + 1)
    % O0 ]- L; L; O& [# L8 d' P  w7 Y
  1866.         # 判断路径是否连通
    4 j  n0 R2 y+ N% P- E
  1867.         path_step = step - 1) O7 ~& N4 N" G5 Q5 N2 z& E
  1868.         if sheet[left_x, point_y] == path_step% X" w5 N9 L' _' h1 Y6 z! [
  1869.           chase_path.push(6)7 E7 Y9 W  {. z" J4 W8 H! l
  1870.           chase_point = [point_x, point_y]
    " L1 }# d- t: L
  1871.           reversed_chase_point = [left_x, point_y]. ]1 g% r5 Y, _* o& w0 ?! _5 R! T, L
  1872.           reach_point = true; break: e) n9 m2 A$ q0 W' J
  1873.         elsif sheet[right_x, point_y] == path_step9 C% v- U( a  h1 l4 g* }! K
  1874.             chase_path.push(4)' n9 V* B* [) T: R
  1875.             chase_point = [point_x, point_y]) H3 C+ }9 B+ a4 e; e
  1876.             reversed_chase_point = [right_x, point_y]7 F8 m. H* }3 @2 n) M) X+ E% T
  1877.             reach_point = true; break, q9 s3 T( k1 s+ M
  1878.         elsif sheet[point_x, up_y] == path_step; ?8 S, S8 F8 d" t
  1879.             chase_path.push(2)
    / }- h$ v  _; N/ e- \1 u
  1880.             chase_point = [point_x, point_y]  [4 A3 K: {: N; f
  1881.             reversed_chase_point = [point_x, up_y]
    4 F$ a. H6 u; h! e
  1882.             reach_point = true; break3 n$ |8 F& }3 r0 `: V' n5 Q
  1883.         elsif sheet[point_x, down_y] == path_step5 a: e+ J9 O+ O6 s' q% l
  1884.             chase_path.push(8)
    6 K" Q4 V5 Q' F- g- x
  1885.             chase_point = [point_x, point_y]
    " n6 M; E% a, H  u) n6 r; Q, t
  1886.             reversed_chase_point = [point_x, down_y]
    & @# E$ B# N$ d) H- I6 O
  1887.             reach_point = true; break
    ; J; p/ D4 x: S" l2 v) X: n
  1888.         end
    3 v9 q/ V# K* ?, I. g, z4 @% d6 z
  1889.         # 以需要抵达该点的步数填充路径表格 #4 j2 [, j9 e# V' P7 y
  1890.         if sheet[left_x, point_y] == 0                &&
    ( b% W% ?3 ]! D: i
  1891.            $game_map.ship_passable(left_x, point_y)  &&6 A" z, {. Y9 N: |4 {8 T
  1892.            !collide_with_events(left_x, point_y)     &&4 p' [3 l( R( z# {
  1893.            !collide_with_vehicles(left_x, point_y)   #judge_end' S- Z1 H2 d. I. Q+ d% T
  1894.           sheet[left_x, point_y] = step
    " r( n3 _0 P6 a; \8 E, ?
  1895.           draw_path = true
    " e) |& A% ]# c. w+ L
  1896.           new_end_points.push(left_x, point_y)
    8 \4 R0 ~) O% O
  1897.         end
    0 o4 Q( \7 l8 o5 s8 U
  1898.         if sheet[right_x, point_y] == 0               &&
    % n2 x4 X3 k/ t6 w4 p
  1899.            $game_map.ship_passable(right_x, point_y) &&2 d! |: u) _  _1 m
  1900.            !collide_with_events(right_x, point_y)    &&" A2 e" |* X$ \. ]
  1901.            !collide_with_vehicles(right_x, point_y)  #judge_end
    7 b, R, t+ w# x7 l. y! S0 C
  1902.           sheet[right_x, point_y] = step% Y. h; C4 Q/ b5 D8 F
  1903.           draw_path = true& H$ y2 Q. m% i1 Z  N; E& B
  1904.           new_end_points.push(right_x, point_y)/ j" _7 r3 w$ ?/ ~
  1905.         end# [( ^( _; r+ Z1 l% g
  1906.         if sheet[point_x, up_y] == 0                  &&
    : e, y& o- U. [1 D+ _0 ]
  1907.            $game_map.ship_passable(point_x, up_y)    &&
    8 \0 ^% L' J" ?2 m0 N
  1908.            !collide_with_events(point_x, up_y)       &&3 F+ B! _8 y6 f) ~( X0 K4 J/ ^
  1909.            !collide_with_vehicles(point_x, up_y)     #judge_end* M- D% I# H/ R% _$ h
  1910.           sheet[point_x, up_y] = step7 K2 n1 w7 M, r  a( C& y
  1911.           draw_path = true; i0 @7 O& u* t
  1912.           new_end_points.push(point_x, up_y)# p, q1 m9 b2 Z
  1913.         end% }6 q: ?& m8 A5 e; B7 O! ?
  1914.         if sheet[point_x, down_y] == 0                &&
    0 Z; ^$ v4 R/ J7 Q0 S
  1915.            $game_map.ship_passable(point_x, down_y)  &&
    % [1 R* ^+ f' ]7 Z
  1916.            !collide_with_events(point_x, down_y)     &&8 `  }1 u9 o) Q' h
  1917.            !collide_with_vehicles(point_x, down_y)   #judge_end6 h7 w; P& S2 t) N3 t1 a, R
  1918.           sheet[point_x, down_y] = step# S* e3 p2 r- C4 A, k- f' O. h- V
  1919.           draw_path = true/ m$ ]6 x, d+ N% b/ T5 p; u9 M! r: n
  1920.           new_end_points.push(point_x, down_y)- U, e9 V1 l* h
  1921.         end
    % }- S6 x4 B; t, j6 {; Q/ B
  1922.       end#endOfLoop3
    % n/ Y% _7 i+ C/ E
  1923.       break if !draw_path  reach_point
    9 `& v' p5 c5 }" @5 p- d
  1924.       step += 11 e1 }( h, }4 I. J3 }
  1925.     end #endOfLoop1 路径表格填充完毕+ n4 {' o6 z7 P; i7 w2 C% T5 l
  1926.     $mouse_move_sign.transparent = false$ n$ `/ E9 H7 C( g! A- h0 }
  1927.     # 判断指定地点能否抵达
    # `  Z' p  j+ ~; Z+ `
  1928.     if reach_point
    2 g* m0 `; K4 a3 W5 `; [
  1929.       $mouse_move_sign.direction = 2  S+ L+ o: i& j5 }
  1930.     else
    6 Z2 M2 k3 ^/ M# f, m4 l
  1931.       not_reach_point
    3 Q! {; m0 g4 b$ J/ D
  1932.       return) G$ |' B! W6 Q
  1933.     end2 n4 `2 G0 t# _% m
  1934.     # 根据路径表格绘制最短移动路径(正向)
    3 w7 E- C; T. R
  1935.     steps = step  2  2& O6 A- J0 O, J! j4 S
  1936.     loop_times = step  2% l5 c0 _1 ^9 N; a4 A
  1937.     point_x, point_y = chase_point[0], chase_point[1]  v8 l1 k4 X, G& c' X, {
  1938.     for i in 2..loop_times # forLoop
    $ o' a$ {9 b+ h  ?. \
  1939.     steps -= 2
    ! Q" y! f: s( l) f: G
  1940.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    5 R+ e9 F7 v+ ^8 s0 K* P
  1941.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps$ o$ k; N# E% O. _
  1942.         chase_path.push(2)
    % y, t) `1 J2 B% T" E
  1943.         point_y = $game_map.round_y(point_y + 1), f: e0 `4 g- d) d
  1944.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    & y* A# H6 Q! {. n/ T. }
  1945.         chase_path.push(8)
    2 b$ f0 L7 g5 o5 x/ A
  1946.         point_y = $game_map.round_y(point_y - 1)
    0 h- z0 P" I5 I0 W- ?: |
  1947.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps& e- \1 |" O% P( B
  1948.         chase_path.push(4)
    $ I* [  j0 V) S1 w( x
  1949.         point_x = $game_map.round_x(point_x - 1)( c1 ~2 m6 Y0 `$ r, T- g& I
  1950.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    - [& T' p% p. Y2 _& R  ?
  1951.         chase_path.push(6)  b! l9 k. n1 W  K1 p0 l
  1952.         point_x = $game_map.round_x(point_x + 1): R/ V% a# Y% C0 @. r1 g8 D
  1953.       end, L- o) `3 R3 a
  1954.     else  O7 O- @) }, H- G9 ^1 w8 J
  1955.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
    6 @& M$ D, {2 S- Z. g
  1956.         chase_path.push(4)% a$ u' n; D" @. n
  1957.         point_x = $game_map.round_x(point_x - 1)
    & k8 W- s& B6 n% R( p7 t: v
  1958.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps) `5 A$ g" V% n
  1959.         chase_path.push(6)
    9 F5 l8 U9 u5 p, k
  1960.         point_x = $game_map.round_x(point_x + 1)
    $ e$ n2 E8 z4 o
  1961.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    / r& W. ^, Z' i+ [7 E) q
  1962.         chase_path.push(2)
    ( q% p; r% y0 B/ u
  1963.         point_y = $game_map.round_y(point_y + 1)
    - W# p* ]' ~7 ~0 i
  1964.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps9 q9 u4 e- ~6 k: `# k
  1965.         chase_path.push(8)- z0 t& |5 _% M' {
  1966.         point_y = $game_map.round_y(point_y - 1)
    9 O2 G; t1 p- K! }) n; k3 B
  1967.       end
    + e3 L$ S+ P# Z) i  w
  1968.     end/ m2 W2 f5 t  r% \" B
  1969.     end #endOfForLoop
    6 ]: v& h1 s  H
  1970.     # 如果指定点无法抵达或者登陆
    9 \* w8 d/ D7 R8 O
  1971.     return not_reach_point unless landable(@moveto_x, @moveto_y, chase_path)
      k7 ~* `# W; I" T( }7 |- c
  1972.     # 根据路径表格绘制最短移动路径(反向)3 C7 S8 n! |# F3 d
  1973.     steps = step  2  2 + 1
    . v. w  a8 k5 U) ]1 l8 C0 r; Q
  1974.     loop_times = step  2# f' Y3 k9 ?' L8 s0 Y/ {; s2 E
  1975.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]3 V, }+ b/ U9 W5 d/ K
  1976.     for i in 1..loop_times # forLoop( {  \( B3 N, C3 _' u
  1977.     steps -= 2
    ' D  }# @' z; Z0 f5 c" }
  1978.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs6 u7 c* C/ a& W# |- Q' M- A
  1979.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps! y! a7 J2 {5 _8 e6 J" m' O- `. i
  1980.         reversed_chase_path.push(6)
    3 D9 c7 e" x' @
  1981.         point_x = $game_map.round_x(point_x - 1)
    7 l) S0 `4 o$ M2 P2 L2 y/ Q
  1982.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps5 q9 b4 t9 q' S& ~% Q
  1983.         reversed_chase_path.push(4)
    4 r( s$ I2 L1 p# v5 e' e
  1984.         point_x = $game_map.round_x(point_x + 1)
    ' b& K! X, ?  i9 D, Z3 ~
  1985.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    ( @( v0 ]' b4 m0 o# Q/ s
  1986.         reversed_chase_path.push(8)
    : ^( K1 s+ D! G$ G/ F, d
  1987.         point_y = $game_map.round_y(point_y + 1)+ |; L# l0 \) |( c9 ~4 F8 l# ?, z* h
  1988.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    1 Z: e9 k% @) m1 g
  1989.         reversed_chase_path.push(2)& Y/ i5 j; {* Q6 n' P
  1990.         point_y = $game_map.round_y(point_y - 1)8 ^" _3 _; |+ h( a! D4 O$ `" ^
  1991.       end* h" n! E" C' S4 l7 B! l
  1992.     else& H  t4 r% S" I; k  N" o4 t
  1993.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps; y  Y1 Z. ?6 j8 ~& V
  1994.         reversed_chase_path.push(8)5 w4 i. l, r6 _+ V) e
  1995.         point_y = $game_map.round_y(point_y + 1)
    3 P# V4 N$ _# ~! L# k, ]
  1996.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps, O0 D# M& k4 S9 W/ k
  1997.         reversed_chase_path.push(2)
    % _- S% n+ c8 X5 E4 U# Y( s
  1998.         point_y = $game_map.round_y(point_y - 1)
    4 j! }. W- v" R) q. o: i
  1999.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
    # a# S2 k# h7 }, `: e, t+ r
  2000.         reversed_chase_path.push(6)" y9 }9 e( Y+ O* R- b. m
  2001.         point_x = $game_map.round_x(point_x - 1)
    % S; L  g5 _2 n
  2002.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps! A1 M4 m4 V3 x" e1 t* N+ k
  2003.         reversed_chase_path.push(4)8 a8 y# v; i2 M3 D; t" ]$ Q0 v
  2004.         point_x = $game_map.round_x(point_x + 1)2 W7 i- S' }" o: e! v, P, p
  2005.       end' |6 B% h: }6 Q3 O$ S1 q9 A9 r
  2006.     end# M7 |+ @- z; n8 b  c
  2007.     end #endOfForLoop6 m/ O& y: T4 B
  2008.     @mouse_move_path = reversed_chase_path.reverse + chase_path* S. [0 ?. |* x
  2009.   end#ship( l' I7 m  m: n" b' v
  2010.   #--------------------------------------------------------------------------
    ! j5 z( k! ~$ `- M( _' S: G9 S6 t7 C
  2011.   # ● 绘制airship的移动路径 @array[move_directions...]
    , y+ @/ o% Q% g& g5 B- j1 _+ _* C
  2012.   #--------------------------------------------------------------------------" q  U* x- \6 f" \8 B4 `* G5 \9 g
  2013.   def draw_air_path
    ) E8 Z  Z/ Q4 N4 m- W
  2014.     $mouse_move_sign.transparent = false
    4 I- b! M( H  N8 |' Z- K" d5 u1 _
  2015.     # 准备绘制路径表格
    $ k& O9 O1 C! ?- _; T2 P2 a# h
  2016.     sheet = Table.new($game_map.width, $game_map.height)
    : c/ ?0 e6 A7 b! U% V3 S
  2017.     new_check_point = [x, y]; sheet[x, y] = 1* Z- s2 j. V7 U  Z
  2018.     reach_point = false;      step = 2
      u; S2 N7 F6 C9 u
  2019.     loop do #loop1& o/ b  E2 Y) d5 V
  2020.      check_point = new_check_point3 J/ W- E* [& `& X5 d7 ~
  2021.      new_check_point = []% Z& f2 E/ t* @% J4 W7 F$ b. v
  2022.       loop do #loop22 C- h6 \. {  M1 H
  2023.         point_x = check_point.shift8 x( j  T0 w! k" P8 K
  2024.         break if point_x == nil, S( }# v6 v. C: N
  2025.         point_y = check_point.shift
    * S; L+ P9 n9 @) G
  2026.         if point_x == @moveto_x && point_y == @moveto_y. g9 v2 |! ]# M6 w/ L( h- G
  2027.           reach_point = true; break9 _* U% V" J8 v+ c  J) G% _
  2028.         end- N8 J- d0 Z, m$ I5 T3 ^
  2029.         left_x  = $game_map.round_x(point_x - 1)
    ; T/ ?0 i  C% g2 B
  2030.         right_x = $game_map.round_x(point_x + 1)7 Z) N- q1 K( Y. `8 }
  2031.         up_y    = $game_map.round_y(point_y - 1)
    4 f0 P+ `( x/ _% P! d6 U$ J
  2032.         down_y  = $game_map.round_y(point_y + 1)
    - P, g3 N. x: f  A: B3 M. M
  2033.         # 以需要抵达该点的步数填充路径表格 #
    5 W$ }' {4 [4 t8 p0 s: k7 d! n5 }  R
  2034.         if sheet[left_x, point_y] == 0
      d$ N  c/ n/ `
  2035.           sheet[left_x, point_y] = step& w1 N+ |9 u1 o! E0 |
  2036.           new_check_point.push(left_x, point_y)/ B) d3 a+ V3 `
  2037.         end  m( w( f4 N3 `
  2038.         if sheet[right_x, point_y] == 0' b  l- |9 \# d/ g
  2039.           sheet[right_x, point_y] = step
    , e  J. U2 I! I
  2040.           new_check_point.push(right_x, point_y); x5 i% B* T9 n% Q2 e
  2041.         end0 r! v3 y# @( A* q: k- m2 |
  2042.         if sheet[point_x, up_y] == 0) E* ?# t4 U7 H% ^
  2043.           sheet[point_x, up_y] = step
    5 ~8 I9 A& s5 U9 W- o5 T
  2044.           new_check_point.push(point_x, up_y). G2 n. H/ i! P9 S7 n9 v- f
  2045.         end
    . G- F7 i3 z" D! P+ S
  2046.         if sheet[point_x, down_y] == 0
    # N) S7 s9 B+ N8 s! _% K$ z$ A8 O
  2047.           sheet[point_x, down_y] = step1 m0 R7 B1 }; Z3 C* `$ C8 v+ t
  2048.           new_check_point.push(point_x, down_y); W) V7 [6 }* M/ P% D# j
  2049.         end
    * w: w& j" [7 X
  2050.       end#endOfLoop2
    9 s1 M  Y. |3 ~3 J$ T0 F7 |; Z9 [
  2051.       break if reach_point+ g0 n6 X0 |. b
  2052.       step += 1* e, @8 ?# D+ O4 K/ N1 Q  a
  2053.     end #endOfLoop12 q  s5 ]3 {  i9 k) P. x
  2054.     # 根据路径表格绘制最短移动路径 #
    " H$ ^" o& X/ p" {! `
  2055.     reversed_chase_path = []; step -= 1
    ) A$ B4 @! H9 ]. v& B& M' u; u/ q
  2056.     point_x, point_y = @moveto_x, @moveto_y& S: q' Y5 Q# X5 V" k
  2057.     for i in 2..step
    - O% I; x5 y# m# u+ E/ {0 w
  2058.     step -= 1) w# F+ p6 @. V8 D
  2059.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    1 D1 p4 b' r, T
  2060.       if    sheet[$game_map.round_x(point_x - 1), point_y] == step
    ) P/ g% P9 [- Q" j( [8 E- V
  2061.         reversed_chase_path.push(6)& r3 D+ F7 s# b% J
  2062.         point_x = $game_map.round_x(point_x - 1)
    ! r9 G7 R6 Y: C1 ?/ }4 e
  2063.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
    : f( ~/ U5 w& Q" S% t" _
  2064.         reversed_chase_path.push(4)
    % p; K* @5 d, ~) ~4 m5 O
  2065.         point_x = $game_map.round_x(point_x + 1)9 }  H" \- i$ G; ]; W+ [# W" g6 G
  2066.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == step
      N& n! f! ^8 m# l# f
  2067.         reversed_chase_path.push(8)" w$ @2 C& Y% K
  2068.         point_y = $game_map.round_y(point_y + 1)
    3 `2 T( ]4 Z, p
  2069.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step6 m2 N1 |3 ?: ~
  2070.         reversed_chase_path.push(2)6 x  E* Q3 ~6 N2 ?% m4 A& V
  2071.         point_y = $game_map.round_y(point_y - 1)
    - i: V" q( N' {! A/ A  g9 [) F
  2072.       end( h1 y2 J8 D: o6 p' v* E
  2073.     else
    % {+ l4 ]2 f' V) E8 N
  2074.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == step/ r" m6 r3 L8 V) x& y
  2075.         reversed_chase_path.push(8): \" ^- A8 P3 I+ n. Z, N9 n
  2076.         point_y = $game_map.round_y(point_y + 1)6 s0 a/ R: x, }* }. o( @9 m  V
  2077.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
    6 A. ~: n! y5 }6 W3 ?2 D: a
  2078.         reversed_chase_path.push(2), u3 a" ]- P+ h
  2079.         point_y = $game_map.round_y(point_y - 1)( e! R" x% v* h/ X5 J
  2080.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == step
    : @1 n; v; \2 w+ m8 S
  2081.         reversed_chase_path.push(6)
    ! d1 [/ ?: n: i* P  B
  2082.         point_x = $game_map.round_x(point_x - 1)
    7 M4 u1 \' U- G# X* p/ l* q+ R
  2083.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step+ {7 ~8 o9 S/ d- j2 o6 i; M4 N
  2084.         reversed_chase_path.push(4)5 w5 v; t" C, q& K  o( N
  2085.         point_x = $game_map.round_x(point_x + 1)
    8 w# N4 {7 s% Q' @; v
  2086.       end
    4 v& y/ {7 i+ N. ?; [
  2087.     end* e. t: ?- s' v$ y7 }
  2088.     end #endOfForLoop
    2 Z4 V* W- b  m( Q4 |. g  W2 F
  2089.     @mouse_move_path = reversed_chase_path.reverse" ~1 o( ?1 g, n, J
  2090.   end#airship. H) B) E7 c9 n! |
  2091.   #--------------------------------------------------------------------------
    . N  Q' M: ]& U& D( R2 b) F
  2092.   # ● 目标点无法抵达时的处理,用于各路径绘制方法内部+ Z, M& K6 t7 W* k. j- V2 B
  2093.   #--------------------------------------------------------------------------
    * P6 O! U$ g" L4 j. Q, [+ D
  2094.   def not_reach_point5 _( z* z2 f) L. J9 \. N
  2095.     $mouse_move_sign.direction = 4- f+ O& W' W$ E
  2096.     dx = 0; dy = 0; dir = 0
    / a, i3 b4 N' K$ n. a) n
  2097.     if @moveto_x - x  0
      h( t! M& M. r7 {7 O: r
  2098.       if @moveto_x - x  $game_map.width - @moveto_x + x &&5 s! Q) ~1 \* K, J" \
  2099.           $game_map.loop_vertical" o$ G/ ^2 ?* G# A/ o
  2100.         dx = $game_map.width - @moveto_x + x; dir = 4  {3 S7 n4 K' C6 M) K( t
  2101.       else4 W9 ]( X5 M: e. C* Y. m4 m
  2102.         dx = @moveto_x - x; dir = 65 ^8 O' d; |2 z2 g
  2103.       end/ q! @  j. s0 y( y/ X8 f" G
  2104.     else
    ' j  R4 Q$ @8 p. c: A8 {* f
  2105.       if x - @moveto_x  $game_map.width - x + @moveto_x &&9 L- ]# }# c" P5 m2 g1 ~1 ]' \7 ~  M
  2106.           $game_map.loop_vertical
    * I4 ^6 F4 B, S& ~& t
  2107.         dx = $game_map.width - x + @moveto_x; dir = 6( U1 }9 G' ~' n. S3 H6 |8 k
  2108.       else
    0 Z* u: k5 u1 |( V7 ~
  2109.         dx = x - @moveto_x; dir = 4
    3 u" [% y$ z. H, I  y& L
  2110.       end
    * M9 j; i* i5 C) F6 y
  2111.     end
    . r$ T' [- Q6 ?3 x
  2112.     if @moveto_y - y  0$ x+ k# f+ y, N& j3 Q8 k: y
  2113.       if @moveto_y - y  $game_map.height - @moveto_y + y &&
    " h' z8 S( B% I0 q5 @, w3 I! A# w
  2114.           $game_map.loop_horizontal
    6 V+ q  l8 p+ m4 a- o; g2 d
  2115.         dy = $game_map.height - @moveto_y + y
    6 y1 p+ J5 g! Q+ F9 m
  2116.         dir = 8 if dy  dx
    % W3 l* H) a( a: ?
  2117.       else) D  d# E9 f! o! g
  2118.         dy = @moveto_y - y
    ! u! @* T3 G2 {4 b+ n; X
  2119.         dir = 2 if dy  dx* s; r8 R* V6 ~0 w$ o. Z$ ?+ h
  2120.       end
    4 H7 B  l  t  F. W1 `' A  h: V3 V
  2121.     else
    9 f( Y% e1 Z1 O) O/ D! E- P1 v- B& d
  2122.       if y - @moveto_y  $game_map.height - y + @moveto_y &&! S- A8 T! U$ X& _/ t8 k
  2123.           $game_map.loop_horizontal
    . ]. Q" h3 ]1 E
  2124.         dy = $game_map.height - y + @moveto_y
    4 b5 E! y: O* H$ S& l: X# U
  2125.         dir = 2 if dy  dx
    + Z5 l% Y0 H* d; a+ }1 r) a6 p
  2126.       else
    6 v# s8 \# a  Q# w3 |( q2 `
  2127.         dy = y - @moveto_y* c1 ]& \8 w3 }
  2128.         dir = 8 if dy  dx
    , E) O2 {  g, _% Z  z6 K
  2129.       end
    ) B( N+ @2 ?# q3 z% j
  2130.     end
    5 h8 Y3 P% }3 e# J: L6 O
  2131.     @mouse_move_path = [dir, 0] # 0方向用于防止移动过程中触发事件
    2 U& k  v# N5 d
  2132.   end
    : B4 D9 o5 q4 r% {0 z9 _( R8 h
  2133.   #--------------------------------------------------------------------------9 C! O, {4 y9 r# w* p
  2134.   # ● 判断目标点是否能抵达、登陆,用于船只路径绘制; f( h  e; {3 O. p: c
  2135.   #--------------------------------------------------------------------------
    . _% Y" m( X% Z! R& _: ^4 z
  2136.   def landable(x, y, path)
    5 Z" G) G4 G+ Q- @
  2137.     case @vehicle_type
    2 K2 [* s0 t' [. w! ~1 E# m
  2138.       when ship; return $game_map.ship_passable(x, y) ( o* r) {0 b: |( t% J5 w
  2139.         $game_map.passable(x, y, 10 - path[-1])
    ! b) f. w# r4 Q/ D8 v
  2140.       when boat; return $game_map.boat_passable(x, y)
    . M: G2 x& {  B1 c$ e: l3 ^3 K3 b
  2141.         $game_map.passable(x, y, 10 - path[-1])
    ; M( S2 h) ]7 r  {
  2142.     end3 o( l4 G" @) @+ ^' @% f  y! f
  2143.   end) R, s) [2 v8 D" S; e5 j. W
  2144. end
    ; m# Q3 X6 [- D  f6 X- o6 j; H" t
  2145. ! I9 g  d0 ]3 E& I4 m, _% O1 C$ A. ~
  2146. #==============================================================================( ?2 p: `  f3 F% f- \
  2147. # ■ Game_Map' y( r% ^6 K# X+ R
  2148. #------------------------------------------------------------------------------
    * l+ h% y; ~% r
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。8 |$ O0 U  E  ?; H4 V
  2150. #   本类的实例请参考 $game_map 。9 `) U: a. f; [7 {5 t; ~5 x
  2151. #==============================================================================
    5 r. ^: L5 E" x: v7 [' |+ `0 A; q
  2152. class Game_Map
    ! A, t! a, B3 o/ d. P
  2153.   #--------------------------------------------------------------------------
    3 F1 X  Y6 Y' P- y  C- c! l) |
  2154.   # ● 定义实例变量
    3 z8 J: j6 F5 Y9 i- m! c$ e
  2155.   #--------------------------------------------------------------------------- G# W1 [6 I1 c1 f4 c  e
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据% E* `2 }. `: `5 P' o; ~6 D
  2157.   attr_reader mouse_map_y # 同上
    ) n1 {  Y6 `/ H8 d( r9 b
  2158.   #--------------------------------------------------------------------------
    0 _$ r7 G/ }- x8 x
  2159.   # ● 初始化对象
    8 ~9 X, M! M' c: [% D/ ~& _9 L8 u
  2160.   #--------------------------------------------------------------------------
    1 Y" N0 o. l0 ]4 A' }
  2161.   alias sion_mouse_initialize initialize
    - m" M# D4 E8 T: k; A
  2162.   def initialize
    % o* x' H6 D% Q4 M# P3 G
  2163.     sion_mouse_initialize
    5 y7 b9 i: x! G8 g5 Q' T2 |7 l
  2164.     creat_move_sign  ###
    ( Z# n1 P8 }! t- T4 C( |
  2165.     set_constants
    ' w' U4 E; N- ^' A! a0 C
  2166.   end
    2 x% C8 Q  w$ K" S2 ~- o1 i
  2167.   #--------------------------------------------------------------------------
    1 H2 P/ I$ n+ C! D
  2168.   # ● 更新画面: A* w, |& D3 `! @; e
  2169.   #     main  事件解释器更新的标志
    + u% Q) n2 I% D' x9 p; I- e7 f
  2170.   #--------------------------------------------------------------------------
    % v* e% `6 R+ @. \! s# W
  2171.   alias sion_mouse_update update9 U! t/ F& z# v$ ~
  2172.   def update(main = false)
    ) `) p/ `) j( d
  2173.     sion_mouse_update(main)
    4 M+ i% u9 e6 T: X* H. g8 |, i
  2174.     update_move_sign4 S4 X' t5 N3 _6 F
  2175.   end
    7 ^! F: B* P) V( L! u# k6 a' Z' D
  2176.   #--------------------------------------------------------------------------( l* p7 e* \) T) G! U0 g3 \
  2177.   # ● 创建显示路径点的事件
    3 t2 ?( w0 v6 V8 f7 b# S1 P) W, a5 O2 J
  2178.   #--------------------------------------------------------------------------; V. Y' @8 l, ^. V
  2179.   def creat_move_sign# }. t3 R, z2 j/ I7 w# ~; t
  2180.     $mouse_move_sign = Move_Sign.new+ |# g& F0 Q) V/ J" y6 T0 n/ P" w0 R
  2181.   end
    3 ^. E( i+ z1 H7 u" P
  2182.   #--------------------------------------------------------------------------* t* P/ O$ ]/ K. m* n2 h- q
  2183.   # ● 更新显示路径点的事件
      [4 B: |/ K9 y" f8 d  t2 l# h7 C; m
  2184.   #--------------------------------------------------------------------------
    6 D9 ~1 i9 q% ~; i; M: P0 z
  2185.   def set_constants- v  c- N' X" J% l& Z+ H
  2186.     @mouse_pos_setted = true" A' E$ ~5 k" }: K
  2187.     @set_pos_prepared = false
    , _2 d3 X1 G' j3 _' V: {% d
  2188.     @mouse_old_x = 0; U1 O( n  L+ j0 P
  2189.     @mouse_old_y = 0
    " m4 A0 t" b% S( w0 G9 \2 F; m
  2190.   end3 s/ t5 ~  |$ ~  h' l
  2191.   #--------------------------------------------------------------------------* d4 m2 u. d$ s
  2192.   # ● 更新显示路径点的事件
    & _2 C, N' G8 `5 I# u* o( n" n
  2193.   #--------------------------------------------------------------------------
    8 K8 o% U7 G3 p! _
  2194.   def update_move_sign4 _& P. }  K0 R) T
  2195.     $mouse_move_sign.update
    & Z6 L/ _# G* p. x; B
  2196.   end
    9 H6 _0 g' N( e7 a7 o, l5 S
  2197.   #--------------------------------------------------------------------------
    + `' {- b0 U1 M
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    $ v$ d- }5 N8 _7 B3 t3 w
  2199.   #--------------------------------------------------------------------------
    * S8 H. A/ A8 k; ?! R! O" D
  2200.   def get_mouse_map_xy
    - n6 q  U( I7 {  m( }
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y/ n) P0 A- o8 o% |; o1 J
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)! r3 \  _4 A# N; s
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)- {0 |, \. w6 |0 w: L' ~
  2204.   end
    8 b6 r5 J; w- ]. i3 y! Z- m
  2205.   #--------------------------------------------------------------------------
    4 c& E* u9 ~; k0 X+ i! {4 \, |
  2206.   # ● 返回地图画面时重设鼠标坐标: V7 N* J& [) f! m- \3 {
  2207.   #--------------------------------------------------------------------------
    8 N- W3 J. v4 Y" F1 D. _
  2208.   def reset_mouse_pos
    0 l; S0 P( K+ d7 s  Q
  2209.     return if @mouse_pos_setted
    ; b0 p* k3 o* Z5 m5 X
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)' k' H7 @  w, y5 T' J
  2211.     @mouse_pos_setted = true
    / c: A7 a8 m% E6 u/ L& }" n) W! f4 L
  2212.     @set_pos_prepared = false
    8 `% \+ w' U5 u' k) S: J1 _( i$ R3 l
  2213.   end7 ]4 Q: I4 g( @9 K) G/ G: f
  2214.   #--------------------------------------------------------------------------3 k, K' L- H  S# h4 H2 J4 e
  2215.   # ● 重设鼠标的坐标
    : \3 q9 q, n: i% R( |
  2216.   #--------------------------------------------------------------------------
    . x! V7 d" v# U
  2217.   def prepare_reset_mouse_pos
      A& z3 Y' t7 X) R# e7 b! G+ n8 z
  2218.     return if @set_pos_prepared
    * S# l+ J/ M- ^, w: R! j
  2219.     @mouse_pos_setted = false0 o: C, o- g# L6 w# y
  2220.     @mouse_old_x = Mouse.mouse_x
    ) G/ w/ ?+ T* K3 o) V3 Q
  2221.     @mouse_old_y = Mouse.mouse_y
    9 c3 V9 @: {* s
  2222.     @set_pos_prepared = true+ {& ^: M* Q# }, j+ r3 k# \
  2223.   end: M$ e1 Q6 `3 Z- O
  2224. end, ~  g6 ^- c9 Q- U
  2225. . }9 s2 C" _% m( l# e, ]5 P) v
  2226. #==============================================================================
    $ f2 \+ `8 Z7 m( M3 g% j- n
  2227. # ■ Spriteset_Map; T4 k0 l- F9 @; q8 g
  2228. #------------------------------------------------------------------------------, H8 K: A3 H2 O) o
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    ( C& }+ i5 S/ |$ K, h
  2230. #==============================================================================
    ' X: w* K+ O; O/ _7 [% m2 r/ z. @0 P  S3 H
  2231. class Spriteset_Map8 z, f7 `7 P+ ^
  2232.   #--------------------------------------------------------------------------
    : w7 T3 P- d  P6 E6 g# ?. x2 ~, X
  2233.   # ● 生成路径点精灵$ h7 Z/ D, [. F3 j5 g& M* ^
  2234.   #--------------------------------------------------------------------------0 J+ }5 ~4 S# s; w2 X
  2235.   alias sion_mouse_create_characters create_characters9 k/ X& c4 t3 d7 t5 P2 b
  2236.   def create_characters
    % S1 C6 t% L: H6 w8 w% T/ t
  2237.     sion_mouse_create_characters! b, |4 S9 E" U- r: k
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))6 _$ [, T9 d4 ]
  2239.   end
    : R( ?! J& T9 H( B* F# f$ h$ M/ x: ]
  2240. end. e8 R( B: u/ S0 m4 ~3 O

  2241. ) L# j* B3 G4 ?$ V8 B" W
  2242. #==============================================================================
    $ |# j, l5 m! g" W8 h+ Y! G0 c
  2243. # ■ Scene_Map
    / G! @+ Q3 S3 j6 m( @- a3 b; K$ }
  2244. #------------------------------------------------------------------------------
    2 [5 ], D/ K) ^
  2245. #  地图画面
    ! A) r: V2 [1 K5 H5 x; v8 P# ]
  2246. #==============================================================================
    , u2 B: M; u0 c; s
  2247. class Scene_Map  Scene_Base
    " a! H. z0 d( @# E
  2248.   #--------------------------------------------------------------------------
    + U/ s/ B  q3 s( o6 p
  2249.   # ● 画面更新7 M4 d8 h+ i% x' K
  2250.   #--------------------------------------------------------------------------
    # y  {0 Q8 y; }) J
  2251.   alias sion_mouse_update_scene update_scene* K* W! Z* T- X/ e8 d
  2252.   def update_scene
    , z% X8 v- P) \9 r  p! S; i9 R0 A
  2253.     sion_mouse_update_scene# y. |* K; ], M
  2254.     update_mouse_action unless scene_changing+ N  K- l4 x5 \+ [3 m! p$ x8 e
  2255.   end, a  a. N$ t' t' b
  2256.   #--------------------------------------------------------------------------2 l/ j/ W# x$ A8 `2 m$ [4 i) [* m; ?
  2257.   # ● 场所移动前的处理: h2 l1 s- h; y' L1 E5 s
  2258.   #--------------------------------------------------------------------------
    - V/ r6 G$ P7 ~9 K$ M
  2259.   alias sion_mouse_pre_transfer pre_transfer0 \: f- {- C+ O, C
  2260.   def pre_transfer  t2 I' H. c1 _' l8 E9 k' K9 y
  2261.     $game_player.reset_move_path
    4 V' A) R% u/ v* ~8 \1 j" v
  2262.     sion_mouse_pre_transfer
    2 {: ~/ @" o7 W5 B. L
  2263.   end4 X6 P( O% y/ W" `. d! L) H( R
  2264.   #--------------------------------------------------------------------------( J, M( q4 K4 }9 j
  2265.   # ● 监听鼠标左键的按下
    6 F8 E: f0 K1 J& Y) B! D" R
  2266.   #--------------------------------------------------------------------------
    : R9 A7 U& p! r2 S
  2267.   def update_mouse_action
    * B  [# t5 T% h& v6 q; \
  2268.     $game_player.left_button_action if Mouse.press(0x01), R2 ~/ \+ x- }' Z+ t$ u
  2269.   end% {7 `8 `$ l' n0 {! \
  2270. end
    5 Y" j& B( v* e& Z

  2271. # g6 s4 f3 B# s. k- g9 t
  2272. #==============================================================================
    1 G1 _+ o# U3 Z9 S
  2273. # ■ Scene_File* l4 S8 K5 i0 A7 T) _
  2274. #------------------------------------------------------------------------------
    . c, O- B5 ?7 c8 M
  2275. #  存档画面和读档画面共同的父类& i. y. I# q+ d& y" w
  2276. #==============================================================================: J' ]. C2 E9 Q0 k! X' ]8 R  x
  2277. class Scene_File  Scene_MenuBase
    . A4 f7 G& j1 ]+ a4 v
  2278.   #--------------------------------------------------------------------------
    8 \3 S% `2 R( V6 `
  2279.   # ● 开始处理7 @+ B  k7 r: U. E0 E9 f
  2280.   #--------------------------------------------------------------------------& @0 u7 J: `2 y& u5 U3 |  {0 V
  2281.   alias sion_mouse_start start
    " R; h. b& O# `
  2282.   def start4 Q8 J8 [: x7 b7 ^, ^4 C. t
  2283.     sion_mouse_start  n2 ~  r+ U2 S: A" T5 c3 n
  2284.     @move_state = 0
    ; N& w( m/ ]! N8 _, I: `" y  B* A
  2285.     set_mouse_pos
    - [# j4 i( k8 t" C1 E7 c/ o" d# H- t: w
  2286.   end, J- |, |3 i  \% I) m1 h
  2287.   #--------------------------------------------------------------------------
    0 w% v- z, |$ j
  2288.   # ● 更新画面/ T7 U6 o4 R+ x' e7 h( A
  2289.   #--------------------------------------------------------------------------  Q- i- G- Z7 c. M) U# F+ @
  2290.   alias sion_mouse_update update
    , C7 f/ @3 l% q: w
  2291.   def update
    5 n7 M" a" j1 u9 w
  2292.     sion_mouse_update5 _! L3 Y* K& [# s
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    0 i- ~/ b2 z& {% |
  2294.   end
    + `0 S- [6 r0 B
  2295.   #--------------------------------------------------------------------------
    , f+ c6 J! v; @6 ~) B: i( k
  2296.   # ● 更新光标* Y6 \7 q# c7 u& K& L
  2297.   #--------------------------------------------------------------------------' e8 I0 I0 W) i3 V# {) [
  2298.   def set_cursor
      G) ~, k3 L- B6 D
  2299.     @move_state += 1$ I1 |4 V/ G( b8 o7 u
  2300.     last_index = @index
    3 H- K0 W' R: p
  2301.     if mouse_which_window == -2
    : q# o  n- l( n$ }9 r6 R+ h
  2302.       if (@move_state - 1) % 6 == 0' P+ D) d% ?) W
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1& ~; n( B: b$ F
  2304.       end4 s4 W$ N* s7 U- Q& ^& i2 y
  2305.     elsif mouse_which_window == -1; |& }, q" S1 k/ _, a- I2 W; |
  2306.       if (@move_state - 1) % 6 == 0
    7 ]& `+ a1 w: L4 R" J# o; i
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    6 ?3 Y5 p+ a7 [
  2308.       end) Z* E9 X' {& @, o0 f0 z
  2309.     else
    % F( u- _5 L# a- B. K
  2310.       @move_state = 07 T( k1 z& h2 T* U' m
  2311.       @index = top_index + mouse_which_window5 [; H0 r5 P5 ?5 q+ ]3 c
  2312.     end
    0 a! s+ H  R" s3 @$ _# u- U
  2313.     ensure_cursor_visible
    + S) O4 V$ C% d3 f
  2314.     if @index != last_index
    8 B" o% `. o; ^5 W, X
  2315.       @savefile_windows[last_index].selected = false, w6 F. U. P  R9 ^( z2 F5 j
  2316.       @savefile_windows[@index].selected = true
    . x+ r4 l3 ~/ M6 G' a
  2317.     end
    + s; k' V2 s- [- l0 l; O/ Z. h
  2318.   end
    & A& {5 W) d# s
  2319.   #--------------------------------------------------------------------------
    . u( Q" G( }& W3 i
  2320.   # ● 判断鼠标位于哪个窗口$ K, U2 p9 V5 @
  2321.   #--------------------------------------------------------------------------8 b; p! c7 Z8 `5 w- j$ }8 L$ F
  2322.   def mouse_which_window- p+ r3 K2 w+ D; Q- b* K. x! D9 T7 E8 `
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y8 G: [: W  V9 n: ^  w# A# h/ d# k
  2324.     if mouse_y  @help_window.height + 14
    1 I; W3 E1 A: }( @5 \
  2325.       mouse_row = -1
    ) n( O+ F' m! [
  2326.     elsif mouse_y  Graphics.height - 14
    / \; O/ H2 V+ D: t
  2327.       mouse_row = -22 a9 w, T( b( }) S- j
  2328.     else/ N" Q3 c+ `% l7 X: H. s
  2329.       mouse_row = 4  (mouse_y - @help_window.height) - V5 G. R% o7 A2 t, p
  2330.         (Graphics.height - @help_window.height)
    2 o" G0 {0 O9 M5 e
  2331.     end7 v& T" U; v5 b+ ?7 \; O
  2332.     return mouse_row7 k2 P9 m: v0 _+ r0 f0 D- \
  2333.   end) i% P: N* S" q. S0 F4 Q- [
  2334.   #--------------------------------------------------------------------------, u0 f; r5 q: g
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置1 {2 Z+ {# L: z7 z
  2336.   #--------------------------------------------------------------------------% I$ z- L5 |! [0 L
  2337.   def set_mouse_pos
    6 P6 d5 h# N. d9 q3 \
  2338.     new_x = 40
    ' @# f  c1 R+ q( h' Q% B' \7 k5 E
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24; x0 p, y6 m% y6 d
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    # z+ `: `9 b6 r* D6 ~/ n9 g# {4 j
  2341.   end
    4 E. \; s* ^* n% U+ M6 J! O
  2342. end
    ; U+ a, p8 ]: x$ r8 J2 b, Y  {

  2343. 8 K5 |- V3 ~( f7 o$ g: f
  2344. #==============================================================================
    1 K$ Y: e. m1 x5 ~8 F/ R
  2345. # ■ Game_Event
    2 p8 W7 @- _5 L) T& |7 X
  2346. #------------------------------------------------------------------------------' D' M. P' e" C7 x* J
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。* B( Q$ f0 q  t* C9 \3 w0 V
  2348. #   在 Game_Map 类的内部使用。& Y7 {( M) S0 {4 E
  2349. #==============================================================================2 T6 b1 ]9 I( X
  2350. class Game_Event  Game_Character% X# l; X5 q$ n. G- B
  2351.   #--------------------------------------------------------------------------
    3 E0 i" o6 D4 P! z) W/ s3 z
  2352.   # ● 事件启动+ Z" e" Q; \. b
  2353.   #--------------------------------------------------------------------------" w) G- F1 r; ~) [7 {
  2354.   alias sion_mouse_start start
    & q3 x* N& s4 J* ~& u' O3 E) I+ d
  2355.   def start& C- c" W9 X( I. s: B; C
  2356.     return if mouse_start && !Mouse.press(0x01)
    7 q8 c- e, B# m' \' M- @
  2357.     sion_mouse_start/ C5 f: i4 o+ \0 u
  2358.   end
    $ X; S: g. ]& e  l* N) P) Q
  2359.   #--------------------------------------------------------------------------/ G+ ^0 t% c& l1 t4 G0 ]9 z
  2360.   # ● 判断事件是否由鼠标启动1 Z3 x- x% M, p7 _3 ^
  2361.   #--------------------------------------------------------------------------' U/ l+ G9 p& ?2 u) k' B
  2362.   def mouse_start7 a; A8 T7 v# E" L9 E! o$ F  I
  2363.     return false if empty, O6 W5 @) y" A. [
  2364.     @list.each do index
    7 B5 v8 k1 \/ g3 D+ J4 \9 q" c
  2365.       return true if (index.code == 108  index.code == 408) &&
    1 J( z- K: X( v& C9 a+ V! N8 F: H
  2366.         index.parameters[0].include('鼠标启动')3 l$ X' x" I# D0 X* \' F  h$ F
  2367.     end" X& Z6 j& ^4 D: L' @
  2368.     return false
    2 A0 F/ }9 L- s4 h" ~+ B4 B& W
  2369.   end
    & y0 T* @; ~3 S) Q; j: g, \% t
  2370. end
    . ^, |5 m$ A( R' {# I) ?; ^6 `

  2371. 9 Q# i2 [( Z, u' _. Q3 X" {2 I
  2372. ####泥煤的height
    ) x* o9 i% r" V6 K4 W
  2373. # @height = height4 @# b( @% m+ w- }- D

  2374. 8 n/ d0 G% }3 b, O
  2375. class Area_Response% K% f; f& G6 {- _( z2 p( z9 I
  2376.   attr_accessor type4 X5 m. l) r: V) E( s0 E( ^
  2377.   attr_reader ox1 o; N1 I, I/ {# f
  2378.   attr_reader oy
    8 b5 t, k" _( A, b# W: }7 U: n
  2379.   attr_reader width
    % V, w* w6 u+ X, m8 Z" Q+ @) G, N
  2380.   attr_reader height7 T/ S$ f3 m1 \5 ]. y
  2381.   attr_reader switch_id4 k! Y9 _7 A1 t/ z% `3 v+ e
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    5 ]- J! }" Z  }; x8 ^' Z: X; g) Z
  2383.     @type = type
    * a8 }& M' c  y9 ]8 u$ L
  2384.     @ox = ox
    5 N6 y+ Q! o: D1 ]" R: m; b2 a2 N6 |
  2385.     @oy = oy* p! X& i0 I- h9 \% ^
  2386.     @width = width/ j( Q& M3 L+ @: {5 H# o
  2387.     @height = height' M8 ^  C. k* k+ q. n* e9 q- `
  2388.     @switch_id = switch_id! ^! @* W$ Y: e/ [5 C
  2389.   end+ q/ C" o4 ]/ O1 m6 q
  2390. end
    3 p4 L5 S7 g( H" j

  2391. 4 C8 I! N9 S& d1 k) d) k4 Z/ E1 ]6 ]
  2392. $area_responses = []
    ; N& b: v3 R9 |( q  d1 ~' ^
  2393. * {9 U* p5 J. a* Y% L; t, E1 {
  2394. class Scene_Map
    : f" Z7 }  j$ S' Y2 M, S& @- O
  2395.   alias update_mouse_2013421 update_mouse_action* o8 I- b. _7 I$ d1 d/ R
  2396.   def update_mouse_action
    0 }! A& E9 c8 v* L, ?  S
  2397.     update_area_response
    0 h4 q6 C& `& D0 Y: k: f
  2398.     update_mouse_2013421
    ) X/ r  S, K( k8 Q- U
  2399.   end6 Q3 k3 G! _3 Y$ |1 E# s0 J( B
  2400.   def update_area_response
    $ E' `/ [4 \6 Z5 P2 v
  2401.     responses = $area_responses
    9 s' \7 [  x! f' w
  2402.     responses.each {response
    - L" A+ i4 T7 Y; b% v
  2403.       ox = response.ox
    # n! Q' |# o* M( O: o* w. ?
  2404.       oy = response.oy2 E: a) n, V7 k  l# V
  2405.       width = response.width( c3 z* v& o/ l/ X3 l) e0 ?( V: l
  2406.       height = response.height9 `% q0 t9 f& K3 w+ }3 @
  2407.       switch_id = response.switch_id
    2 u4 R) D/ b8 I
  2408.       case response.type* J6 E) t2 M8 p
  2409.       when 0
    ( @6 q5 u4 V. z+ E- l& G
  2410.         if mouse_in_area(ox, oy, width, height)$ h: w. C  d0 S- V* T2 o
  2411.           $game_switches[switch_id] = true
    ( n' @, ^3 Y+ l3 M9 J  B
  2412.           $area_responses.delete(response)0 T& f) Y4 Q" `$ I
  2413.         end- V  x9 J, O3 @1 T; {  N
  2414.       when 1
    1 x* v7 C1 G- ], D7 B% @
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    " n% T* T+ i, e% I  N3 a) X
  2416.           $game_switches[switch_id] = true" z( [; m1 m! f. P
  2417.           $area_responses.delete(response)7 i; o+ l) f0 r( m% H! N$ g& M
  2418.         end
    1 A! a% {( {& v
  2419.       when 2
    + G  N- F1 o# r5 h  W+ D% ~2 Y
  2420.         if mouse_in_area(ox, oy, width, height)
    & H  V' |/ C- B+ V9 W; ]; H
  2421.           $game_switches[switch_id] = true
    4 }4 O5 |  G; Z6 |. O. w& p# N
  2422.         else' ~0 x7 W# W3 ]% ^
  2423.           $game_switches[switch_id] = false, T% `3 v, \6 u# L/ F# _. V
  2424.         end
    4 d" o( w( I# i9 ?) x7 D# t  [/ a+ @
  2425.       when 3
    + ^* l3 ^8 ?! M3 o
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,9 C6 C& x2 |  l4 }* a6 v2 u" h5 S
  2427.             (oy - $game_map.display_y)  32, width, height)" p4 X4 Y' \. X' H3 K
  2428.           $game_map.events_xy(ox, oy).each {event' O* c5 Q2 E9 C5 l* \5 F0 ?  P6 l
  2429.           event.start# z4 Z9 [; f, j
  2430.           $area_responses.delete(response)
    / k5 D8 X! \' q$ F. [" N% @. E
  2431.           return
    - ?3 t+ H* k  m* c& R* m
  2432.           } " v, ]8 O: @  g2 p- K& Q
  2433.         end
    7 N2 f) j0 T" P7 k" }- I
  2434.       when 4
    $ `( j7 j% ~/ C" O2 i
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,8 T% C' F6 N5 P& }5 Y8 p
  2436.             (oy - $game_map.display_y)  32, width, height)4 V+ I1 G8 n* p3 n& ~
  2437.           $game_map.events_xy(ox, oy).each {event# Y; t) |( Q2 ^3 t+ ^
  2438.             event.start! t7 X* }$ \" c8 b! G' t/ q8 ]# s
  2439.             return1 [8 c+ F; J) z) x% x* }: L
  2440.           }
    # _3 @7 s$ x8 v. ]) I& i
  2441.         end0 {6 k" X- T/ q! |$ s
  2442.       end& ?& l/ i5 [. I
  2443.     }2 D- J0 G6 g! u/ d4 @$ S
  2444.   end
    2 l. K8 Y# h1 b, N3 T1 c. w& Z
  2445.   def mouse_in_area(ox, oy, width, height)
    - _8 u. b+ c  Y7 e6 |( w2 d
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&( _$ L: S1 J! l# z" D) A1 W  h, R
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height4 H) Y: m- b) r! w" {
  2448.   end
    % c. n; r0 w9 Y% g6 y5 l7 E
  2449. end/ ], n9 a4 a' \
  2450. class Game_Interpreter0 E% A! c1 b" ?7 ^: D' s  t
  2451.   def area_response(arg)
    . v/ H! v3 R! s) E9 u" B
  2452.     $area_responses.push(Area_Response.new(arg))0 k2 \7 `" y4 N* o# {
  2453.   end7 K* U1 h) F8 U
  2454. end
    ( V' p/ {0 Z0 L/ q/ R4 }
复制代码

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本发帖返回顶部